diff options
| author | Pim van den Berg | 2014-11-11 23:01:15 +0100 |
|---|---|---|
| committer | Pim van den Berg | 2014-11-11 23:01:15 +0100 |
| commit | 82d88098f4203cf7402d4faf5ad100cada70efaf (patch) | |
| tree | 0c7e63a0e91493837dad20a802529b3051bd670a | |
| parent | type/base: allow rrdtool graph -l (lower-limit) to be configured via config o... (diff) | |
| download | apt-panopticon_cgp-82d88098f4203cf7402d4faf5ad100cada70efaf.zip apt-panopticon_cgp-82d88098f4203cf7402d4faf5ad100cada70efaf.tar.gz apt-panopticon_cgp-82d88098f4203cf7402d4faf5ad100cada70efaf.tar.bz2 apt-panopticon_cgp-82d88098f4203cf7402d4faf5ad100cada70efaf.tar.xz | |
make detail page accessible when using "canvas" graph_type
Closes #106
| -rw-r--r-- | detail.php | 2 | ||||
| -rw-r--r-- | inc/functions.inc.php | 10 | ||||
| -rw-r--r-- | inc/html.inc.php | 8 | ||||
| -rw-r--r-- | js/CGP.js | 6 | ||||
| -rw-r--r-- | type/Base.class.php | 2 |
5 files changed, 26 insertions, 2 deletions
| @@ -55,7 +55,9 @@ print "</ul>\n"; | |||
| 55 | 55 | ||
| 56 | if ($CONFIG['graph_type'] == 'canvas') { | 56 | if ($CONFIG['graph_type'] == 'canvas') { |
| 57 | chdir($CONFIG['webdir']); | 57 | chdir($CONFIG['webdir']); |
| 58 | printf('<canvas id="%s" class="rrd">', generate_uuid()); | ||
| 58 | include $CONFIG['webdir'].'/graph.php'; | 59 | include $CONFIG['webdir'].'/graph.php'; |
| 60 | print '</canvas>'; | ||
| 59 | } else { | 61 | } else { |
| 60 | printf("<img src=\"%s%s\">\n", | 62 | printf("<img src=\"%s%s\">\n", |
| 61 | htmlentities($CONFIG['weburl']), | 63 | htmlentities($CONFIG['weburl']), |
diff --git a/inc/functions.inc.php b/inc/functions.inc.php index abe0763..df02d20 100644 --- a/inc/functions.inc.php +++ b/inc/functions.inc.php | |||
| @@ -59,3 +59,13 @@ function error_image() { | |||
| 59 | readfile('layout/error.png'); | 59 | readfile('layout/error.png'); |
| 60 | exit; | 60 | exit; |
| 61 | } | 61 | } |
| 62 | |||
| 63 | function generate_uuid() { | ||
| 64 | return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', | ||
| 65 | mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), | ||
| 66 | mt_rand( 0, 0xffff ), | ||
| 67 | mt_rand( 0, 0x0fff ) | 0x4000, | ||
| 68 | mt_rand( 0, 0x3fff ) | 0x8000, | ||
| 69 | mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) | ||
| 70 | ); | ||
| 71 | } | ||
diff --git a/inc/html.inc.php b/inc/html.inc.php index 161af73..bc22ba3 100644 --- a/inc/html.inc.php +++ b/inc/html.inc.php | |||
| @@ -338,7 +338,15 @@ function graphs_from_plugin($host, $plugin, $overview=false) { | |||
| 338 | isset($items['t']) ? $_GET['t'] = $items['t'] : $_GET['t'] = ''; | 338 | isset($items['t']) ? $_GET['t'] = $items['t'] : $_GET['t'] = ''; |
| 339 | isset($items['ti']) ? $_GET['ti'] = $items['ti'] : $_GET['ti'] = ''; | 339 | isset($items['ti']) ? $_GET['ti'] = $items['ti'] : $_GET['ti'] = ''; |
| 340 | $_GET['s'] = $time; | 340 | $_GET['s'] = $time; |
| 341 | $uuid = generate_uuid(); | ||
| 342 | printf('<canvas id="%s" class="rrd">', $uuid); | ||
| 341 | include $CONFIG['webdir'].'/graph.php'; | 343 | include $CONFIG['webdir'].'/graph.php'; |
| 344 | print '</canvas>'; | ||
| 345 | printf('<a href="%s%s"><img id="%s-img" alt="graph"></a>'."\n", | ||
| 346 | htmlentities($CONFIG['weburl']), | ||
| 347 | htmlentities(build_url('detail.php', $items, $time)), | ||
| 348 | $uuid | ||
| 349 | ); | ||
| 342 | } else { | 350 | } else { |
| 343 | printf('<a href="%1$s%2$s"><img src="%1$s%3$s"></a>'."\n", | 351 | printf('<a href="%1$s%2$s"><img src="%1$s%3$s"></a>'."\n", |
| 344 | htmlentities($CONFIG['weburl']), | 352 | htmlentities($CONFIG['weburl']), |
| @@ -130,6 +130,12 @@ var CGP = (function() { | |||
| 130 | var canvases = document.getElementsByClassName('rrd'); | 130 | var canvases = document.getElementsByClassName('rrd'); |
| 131 | for (var i = 0; i < canvases.length; i++) { | 131 | for (var i = 0; i < canvases.length; i++) { |
| 132 | draw(canvases[i].id, async); | 132 | draw(canvases[i].id, async); |
| 133 | |||
| 134 | if (document.getElementById(canvases[i].id + '-img')) { | ||
| 135 | document.getElementById(canvases[i].id).style.display = 'none'; | ||
| 136 | var dataURL = canvases[i].toDataURL(); | ||
| 137 | document.getElementById(canvases[i].id + '-img').src = dataURL; | ||
| 138 | } | ||
| 133 | } | 139 | } |
| 134 | } | 140 | } |
| 135 | 141 | ||
diff --git a/type/Base.class.php b/type/Base.class.php index 8d51121..ee5050b 100644 --- a/type/Base.class.php +++ b/type/Base.class.php | |||
| @@ -225,11 +225,9 @@ class Type_Base { | |||
| 225 | print '</pre>'; | 225 | print '</pre>'; |
| 226 | break; | 226 | break; |
| 227 | case 'canvas': | 227 | case 'canvas': |
| 228 | printf('<canvas id="%s" class="rrd">', sha1(serialize($graphoptions))); | ||
| 229 | foreach ($graphoptions as $d) { | 228 | foreach ($graphoptions as $d) { |
| 230 | printf("\"%s\"\n", htmlentities($d)); | 229 | printf("\"%s\"\n", htmlentities($d)); |
| 231 | } | 230 | } |
| 232 | print '</canvas>'; | ||
| 233 | break; | 231 | break; |
| 234 | case 'debug': | 232 | case 'debug': |
| 235 | case 1: | 233 | case 1: |
