aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorVincent Brillault2013-12-16 22:28:33 +0100
committerPim van den Berg2014-01-12 14:35:02 +0100
commit775da40f8c247a97a01c3affd75511b4cbdb95b7 (patch)
tree1bf6a5fcaff9b6fec8268c6161a2fbf4fb7e79cb
parentjsrrdgraph: CGP.js: split draw(id) into prepare_draw(id) and draw(id) (diff)
downloadapt-panopticon_cgp-775da40f8c247a97a01c3affd75511b4cbdb95b7.zip
apt-panopticon_cgp-775da40f8c247a97a01c3affd75511b4cbdb95b7.tar.gz
apt-panopticon_cgp-775da40f8c247a97a01c3affd75511b4cbdb95b7.tar.bz2
apt-panopticon_cgp-775da40f8c247a97a01c3affd75511b4cbdb95b7.tar.xz
Add a configuration option for sync/async choice for the canvas graphs
-rw-r--r--conf/config.php3
-rw-r--r--inc/html.inc.php11
-rw-r--r--js/CGP-async.js21
-rw-r--r--js/CGP-sync.js21
-rw-r--r--js/CGP.js22
5 files changed, 56 insertions, 22 deletions
diff --git a/conf/config.php b/conf/config.php
index 26172b1..b808a70 100644
--- a/conf/config.php
+++ b/conf/config.php
@@ -45,6 +45,9 @@ $CONFIG['network_datasize'] = 'bytes';
45# png or canvas graphs 45# png or canvas graphs
46$CONFIG['graph_type'] = 'png'; 46$CONFIG['graph_type'] = 'png';
47 47
48# For canvas graphs, use 'async' or 'sync' fetch method
49$CONFIG['rrd_fetch_method'] = 'sync';
50
48# use the negative X-axis in I/O graphs 51# use the negative X-axis in I/O graphs
49$CONFIG['negative_io'] = false; 52$CONFIG['negative_io'] = false;
50 53
diff --git a/inc/html.inc.php b/inc/html.inc.php
index 478045c..b07be8a 100644
--- a/inc/html.inc.php
+++ b/inc/html.inc.php
@@ -87,6 +87,17 @@ EOT;
87<script type="text/javascript" src="{$CONFIG['weburl']}js/CGP.js"></script> 87<script type="text/javascript" src="{$CONFIG['weburl']}js/CGP.js"></script>
88 88
89EOT; 89EOT;
90 if ($CONFIG['rrd_fetch_method'] == 'async') {
91 echo <<<EOT
92<script type="text/javascript" src="{$CONFIG['weburl']}js/CGP-async.js"></script>
93
94EOT;
95 } else {
96 echo <<<EOT
97<script type="text/javascript" src="{$CONFIG['weburl']}js/CGP-sync.js"></script>
98
99EOT;
100 }
90 } 101 }
91 102
92echo <<<EOT 103echo <<<EOT
diff --git a/js/CGP-async.js b/js/CGP-async.js
new file mode 100644
index 0000000..4976509
--- /dev/null
+++ b/js/CGP-async.js
@@ -0,0 +1,21 @@
1function draw(id) {
2 var rrdgraph = prepare_draw(id);
3
4 try {
5 rrdgraph.graph_paint_async();
6 } catch (e) {
7 alert(e+"\n"+e.stack);
8 }
9}
10
11function drawAll()
12{
13 var list=[];
14 var a=document.getElementsByClassName('rrd');
15 for (var i=0,l=a.length;i<l;i++)
16 {
17 draw(a[i].getAttribute('id'))
18 }
19}
20
21window.onload = drawAll()
diff --git a/js/CGP-sync.js b/js/CGP-sync.js
new file mode 100644
index 0000000..01f6b19
--- /dev/null
+++ b/js/CGP-sync.js
@@ -0,0 +1,21 @@
1function draw(id) {
2 var rrdgraph = prepare_draw(id);
3
4 try {
5 rrdgraph.graph_paint();
6 } catch (e) {
7 alert(e+"\n"+e.stack);
8 }
9}
10
11function drawAll()
12{
13 var list=[];
14 var a=document.getElementsByClassName('rrd');
15 for (var i=0,l=a.length;i<l;i++)
16 {
17 draw(a[i].getAttribute('id'))
18 }
19}
20
21window.onload = drawAll()
diff --git a/js/CGP.js b/js/CGP.js
index add1a20..bbfd1b5 100644
--- a/js/CGP.js
+++ b/js/CGP.js
@@ -106,25 +106,3 @@ function prepare_draw(id) {
106 106
107 return rrdgraph; 107 return rrdgraph;
108} 108}
109
110function draw(id) {
111 var rrdgraph = prepare_draw(id);
112
113 try {
114 rrdgraph.graph_paint();
115 } catch (e) {
116 alert(e+"\n"+e.stack);
117 }
118}
119
120function drawAll()
121{
122 var list=[];
123 var a=document.getElementsByClassName('rrd');
124 for (var i=0,l=a.length;i<l;i++)
125 {
126 draw(a[i].getAttribute('id'))
127 }
128}
129
130window.onload = drawAll()