From e67ccd9463f08394f41678c8d70b448edd41ccdd Mon Sep 17 00:00:00 2001 From: Daniel Preussker Date: Mon, 7 Sep 2015 19:30:37 +0100 Subject: [PATCH] Added multiple graph type support for the graph widget --- html/includes/common/generic-graph.inc.php | 288 ++++++++++++++++++--- 1 file changed, 246 insertions(+), 42 deletions(-) diff --git a/html/includes/common/generic-graph.inc.php b/html/includes/common/generic-graph.inc.php index 3ac02ab69..4e75b16ca 100644 --- a/html/includes/common/generic-graph.inc.php +++ b/html/includes/common/generic-graph.inc.php @@ -26,35 +26,107 @@ if( defined('show_settings') || empty($widget_settings) ) { $common_output[] = '
- -
- +
+
-
-
-
-
-
- +
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
-'; } else { - $widget_settings['device_id'] = dbFetchCell('select device_id from devices where hostname = ?',array($widget_settings['graph_device'])); - $widget_settings['title'] = $widget_settings['graph_device']." / ".$widget_settings['graph_type']; - $common_output[] = generate_minigraph_image( - array('device_id'=>(int) $widget_settings['device_id']), - $config['time']['day'], - $config['time']['now'], - $widget_settings['graph_type'], - $widget_settings['graph_legend'] == 1 ? 'yes' : 'no', - $widget_dimensions['x'], - $widget_dimensions['y'], - '&', - 'minigraph-image', - 1 - ); + $widget_settings['title'] = ""; + $type = array_shift(explode('_',$widget_settings['graph_type'],2)); + $widget_settings['graph_'.$type] = json_decode($widget_settings['graph_'.$type],true); + if ($type == 'device') { + $widget_settings['title'] = $widget_settings['graph_device']['name']." / ".$widget_settings['graph_type']; + $param = 'device='.$widget_settings['graph_device']['device_id']; + } + elseif ($type == 'application') { + $param = 'id='.$widget_settings['graph_'.$type]['app_id']; + } + elseif ($type == 'munin') { + $param = 'device='.$widget_settings['graph_'.$type]['device_id'].'&plugin='.$widget_settings['graph_'.$type]['name']; + } + else { + $param = 'id='.$widget_settings['graph_'.$type][$type.'_id']; + } + if (empty($widget_settings['title'])) { + $widget_settings['title'] = $widget_settings['graph_'.$type]['hostname']." / ".$widget_settings['graph_'.$type]['name']." / ".$widget_settings['graph_type']; + } + $common_output[] = ''; } -