|
From: <net...@us...> - 2010-12-10 21:33:42
|
Revision: 192
http://openautomation.svn.sourceforge.net/openautomation/?rev=192&view=rev
Author: netzkind
Date: 2010-12-10 21:33:36 +0000 (Fri, 10 Dec 2010)
Log Message:
-----------
fixed https://sourceforge.net/tracker/?func=detail&aid=3128530&group_id=296426&atid=1251141
"Refresh in diagram doesn't work"
Modified Paths:
--------------
CometVisu/trunk/visu/plugins/diagram/structure_plugin.js
Modified: CometVisu/trunk/visu/plugins/diagram/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/diagram/structure_plugin.js 2010-12-10 21:21:48 UTC (rev 191)
+++ CometVisu/trunk/visu/plugins/diagram/structure_plugin.js 2010-12-10 21:33:36 UTC (rev 192)
@@ -1,4 +1,4 @@
-/* structure_plugin.js (c) 2010 by Christian Mayer [CometVisu at ChristianMayer dot de]
+/* structure_plugin.js (c) 2010 by Julian Hartmann [julian dot hartmann at gmail dot com]
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -16,9 +16,8 @@
*/
/**
- * This is a custom function that extends the available widgets.
- * It's purpose is to change the design of the visu during runtime
- * to demonstrate all available
+ * This plugins integrates flot (diagrams in javascript) into the visualization.
+ * server-side data-storage is rrd
*/
$("body").append("<script type=\"text/javascript\" src=\"plugins/diagram/flot/jquery.flot.js\"></script>");
@@ -59,14 +58,8 @@
diagram.data("unit", $p.attr("unit") || "");
diagram.data("series", $p.attr("series") || "day");
diagram.data("label", page.textContent);
+ diagram.data("refresh", $p.attr("refresh"));
- if ($(page).attr("refresh")) {
- // reload regularly
- window.setInterval(function(actor) {
- $(diagram).triggerHandler("refresh.widget");
- }, $p.attr("refresh") * 1000, actor);
- }
-
refreshDiagram(diagram, {});
return ret_val;
@@ -117,14 +110,8 @@
diagram.data("unit", $p.attr("unit") || "");
diagram.data("series", $p.attr("series") || "day");
diagram.data("label", page.textContent);
+ diagram.data("refresh", $p.attr("refresh"));
- if ($(page).attr("refresh")) {
- // reload regularly
- window.setInterval(function(actor) {
- $(actor).triggerHandler("refresh.widget");
- }, $p.attr("refresh") * 1000, actor);
- }
-
var bDiagram = $("<div class=\"diagram\" id=\"" + id + "_big\"/>");
diagram.addClass("clickable");
@@ -154,11 +141,12 @@
function refreshDiagram(diagram, flotoptions, data) {
var diagram = $(diagram);
- var c = jQuery.extend(true, {series: diagram.data("series")}, data || {});
+ var config = jQuery.extend(true, {series: diagram.data("series")}, data || {});
var unit = diagram.data("unit");
var rrd = diagram.data("rrd");
var label = diagram.data("label");
+ var refresh = diagram.data("refresh");
var series = {
day: {label: "day", res: "300", start: "-1day", end: "now"},
@@ -194,18 +182,30 @@
},
flotoptions);
- var s = series[c.series];
+ var s = series[config.series];
- // init
- $.ajax({
- url: "/cgi-bin/rrdfetch?rrd=" + rrd + ".rrd&ds=AVERAGE&start=end" + s.start + "&end=" + s.end + "&res=" + s.res,
- dataType: "json",
- type: "GET",
- success: function(data) {
- $.plot(diagram, [{data: data}], options);
+ if (s) {
+ // init
+ $.ajax({
+ url: "/cgi-bin/rrdfetch?rrd=" + rrd + ".rrd&ds=AVERAGE&start=end" + s.start + "&end=" + s.end + "&res=" + s.res,
+ dataType: "json",
+ type: "GET",
+ success: function(data) {
+ $.plot(diagram, [{data: data}], options);
+ }
+ });
+
+ if (typeof (refresh) != "undefined" && refresh) {
+ // reload regularly
+ window.setTimeout(function(diagram, flotoptions, data) {
+ refreshDiagram(diagram, flotoptions, data)
+ }, refresh * 1000, diagram, flotoptions, data);
}
- });
+ }
+
+
+
return false;
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|