diff --git a/html/ajax_mapview.php b/html/ajax_mapview.php new file mode 100644 index 0000000000..bfc2d19e0b --- /dev/null +++ b/html/ajax_mapview.php @@ -0,0 +1,7 @@ + * Copyright (c) 2016 Jens Langhammer + * Copyright (c) 2016 Cercel Valentin * 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. Please see LICENSE.txt at the top level of * the source code distribution for details. */ - if (defined('show_settings')) { $current_mode = isset($widget_settings['mode']) ? $widget_settings['mode'] : 0; $current_width = isset($widget_settings['tile_width']) ? $widget_settings['tile_width'] : 10; - $common_output[] = ' -
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
-
- '; -} -else { + + $common_output[] = '
'; + $common_output[] = '
'; + $common_output[] = ''; + $common_output[] = '
'; + $common_output[] = ''; + $common_output[] = '
'; + $common_output[] = '
'; + $common_output[] = '
'; + $common_output[] = ''; + $common_output[] = '
'; + $common_output[] = ''; + $common_output[] = '
'; + $common_output[] = '
'; + $common_output[] = '
'; + $common_output[] = '
'; + $common_output[] = ''; + $common_output[] = '
'; + $common_output[] = '
'; + $common_output[] = '
'; + +} else { require_once 'includes/object-cache.inc.php'; - $mode = isset($widget_settings['mode']) ? $widget_settings['mode'] : 0; + $mode = isset($_SESSION["mapView"]) ? $_SESSION["mapView"] : 0; + + $widget_mode = isset($widget_settings['mode']) ? $widget_settings['mode'] : 0; $tile_width = isset($widget_settings['tile_width']) ? $widget_settings['tile_width'] : 10; - $up_count = 0; - $warn_count = 0; - $down_count = 0; + $host_up_count = 0; + $host_warn_count = 0; + $host_down_count = 0; + $service_up_count = 0; + $service_down_count = 0; if ($mode == 0 || $mode == 2) { // Only show devices if mode is 0 or 2 (Only Devices or both) - $sql = 'SELECT `D`.`hostname`,`D`.`device_id`,`D`.`status`,`D`.`uptime` FROM `devices` AS `D`'; + $sql = 'SELECT `D`.`hostname`,`D`.`device_id`,`D`.`status`,`D`.`uptime`, `D`.`os` FROM `devices` AS `D`'; if (is_normal_user() === true) { $sql .= ' , `devices_perms` AS P WHERE D.`device_id` = P.`device_id` AND P.`user_id` = ? AND'; $param = array( $_SESSION['user_id'] - ); - } - else { + ); + } else { $sql .= ' WHERE'; } $sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `hostname`"; @@ -67,49 +69,135 @@ else { foreach (dbFetchRows($sql, $param) as $device) { if ($device['status'] == '1') { if (($device['uptime'] < $config['uptime_warning']) && ($device['uptime'] != '0')) { - $btn_type = 'btn-warning'; - $warn_count++; + $deviceState = 'warning'; + $deviceLabel = 'label-warning'; + $host_warn_count++; + } else { + $deviceState = 'up'; + $deviceLabel = 'label-success'; + $host_up_count++; } - else { - $btn_type = 'btn-success'; - $up_count ++; - } - } - else { - $btn_type = 'btn-danger'; - $down_count++; + } else { + $deviceState = 'down'; + $deviceLabel = 'label-danger'; + $host_down_count++; + } + + if($directpage == "yes") + { + $deviceIcon = getImage($device); + $temp_output[] = ''; + $temp_output[] = '
'; + $temp_output[] = ''; + $temp_output[] = '' . $deviceIcon . '
'; + $temp_output[] = '' . $device["hostname"] . ''; + $temp_output[] = '
'; + } else { + $temp_output[] = ''; + $temp_output[] = ''; + $temp_output[] = ''; } - $temp_output[] = ''; } } if ($mode == 1 || $mode == 2) { - $service_query = 'select `S`.`service_type`, `S`.`service_id`, `S`.`service_desc`, `S`.`service_status`, `D`.`hostname`, `D`.`device_id` from services S, devices D where `S`.`device_id` = `D`.`device_id`;'; + $service_query = 'select `S`.`service_type`, `S`.`service_id`, `S`.`service_desc`, `S`.`service_status`, `D`.`hostname`, `D`.`device_id`, `D`.`os` from services S, devices D where `S`.`device_id` = `D`.`device_id`;'; foreach (dbFetchRows($service_query) as $service) { if ($service['service_status'] == '0') { - $btn_type = 'btn-success'; - $up_count ++; - } - else { - $btn_type = 'btn-danger'; - $down_count += 1; + $serviceLabel = "label-success"; + $serviceState = "up"; + $service_up_count++; + } else { + $serviceLabel = "label-danger"; + $serviceState = "down"; + $service_down_count += 1; } - $temp_output[] = ''; + if($directpage == "yes") + { + $deviceIcon = getImage($service); + $temp_output[] = ''; + $temp_output[] = '
'; + $temp_output[] = ''; + $temp_output[] = ''; + $temp_output[] = '' . $deviceIcon . '
'; + $temp_output[] = '' . $service["hostname"] . ''; + $temp_output[] = '
'; + } else { + $temp_output[] = ''; + $temp_output[] = ''; + $temp_output[] = ''; + } } } - $temp_output[] = ''; - $temp_header = array( - '
'.$up_count.' '.$warn_count.' '.$down_count.'

' - ); + if($directpage == "yes") + { + $temp_header[] = '
'; + $temp_header[] = 'Availability map for'; + $temp_header[] = '
'; + $temp_header[] = '
'; + + } + + + if ($mode == 0 || $mode == 2) + { + if($directpage == "yes") + { + $temp_header[] = '
'; + $temp_header[] = 'Hosts report:'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
' . $host_up_count . '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
' . $host_warn_count . '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
' . $host_down_count . '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + } else { + $temp_header[] = '
Total hosts '.$host_up_count.' '.$host_warn_count.' '.$host_down_count.'
'; + } + + } + + if ($mode == 1 || $mode == 2) + { + if($directpage == "yes") + { + + $temp_header[] = '
'; + $temp_header[] = 'Services report:'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
' . $service_up_count . '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
' . $service_down_count . '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + } else { + $temp_header[] = '
Total services '.$service_up_count.' '.$service_down_count.'
'; + } + } + + $temp_header[] = '
'; + $temp_header[] = '
'; + $common_output = array_merge($temp_header, $temp_output); -} +} \ No newline at end of file diff --git a/html/js/librenms.js b/html/js/librenms.js index f103ea29b0..84cc1b6694 100644 --- a/html/js/librenms.js +++ b/html/js/librenms.js @@ -225,6 +225,17 @@ $(document).on("click", '.collapse-neighbors', function(event) }); +$(document).on("change", '#mode', function() { + $.post('ajax_mapview.php', + { + mapView: $(this).val() + }, + function(data) { + location.reload(); + },'json' + ); +}); + $(document).ready(function() { var lines = 'on'; $("#linenumbers").button().click(function() { @@ -243,4 +254,4 @@ $(document).ready(function() { }); } }); -}); +}); \ No newline at end of file diff --git a/html/pages/availability-map.inc.php b/html/pages/availability-map.inc.php index b5ede4e144..2b86db8361 100644 --- a/html/pages/availability-map.inc.php +++ b/html/pages/availability-map.inc.php @@ -1,6 +1,5 @@ -

Availability Map

-