From 63ed6e25aab2176ff1602355401fefe129ee49b9 Mon Sep 17 00:00:00 2001 From: Daniel Preussker Date: Sat, 5 Sep 2015 16:15:56 +0100 Subject: [PATCH] Added generic graph widget (non-responsive sizing) --- html/includes/common/generic-graph.inc.php | 114 +++++++++++++++++++++ sql-schema/068.sql | 1 + 2 files changed, 115 insertions(+) create mode 100644 html/includes/common/generic-graph.inc.php diff --git a/html/includes/common/generic-graph.inc.php b/html/includes/common/generic-graph.inc.php new file mode 100644 index 0000000000..b6e5773eee --- /dev/null +++ b/html/includes/common/generic-graph.inc.php @@ -0,0 +1,114 @@ + + * 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 Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + +/** + * Generic Graph Widget + * @author Daniel Preussker + * @copyright 2015 Daniel Preussker, QuxLabs UG + * @license GPL + * @package LibreNMS + * @subpackage Widgets + */ + +if( empty($widget_settings) ) { + $common_output[] = ' +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+'; +} +else { + $widget_settings['device_id'] = dbFetchCell('select device_id from devices where hostname = ?',array($widget_settings['graph_device'])); + $common_output[] = "
".$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_settings['graph_width'], $widget_settings['graph_height'], '&', $widget_settings['graph_type']); +} +?> + diff --git a/sql-schema/068.sql b/sql-schema/068.sql index 39784b4188..d0bbda576d 100644 --- a/sql-schema/068.sql +++ b/sql-schema/068.sql @@ -1 +1,2 @@ alter table users_widgets add column `settings` text not null; +insert into widgets values(null,'Graph','generic-graph','6,2');