+
Tile width
+
+
-
+
+
+ ';
+} 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_warn_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`, `D`.`icon` 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 +68,122 @@ 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 = 'warn';
+ $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[] = '
+
+
+ '.$deviceState.'
+ '.$deviceIcon.'
+ '.$device["hostname"].'
+
+ ';
+ } else {
+ $temp_output[] = '
+
+ '.$deviceState.'
+ ';
}
- $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`, `D`.`icon` 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++;
+ } elseif ($service['service_status'] == '1') {
+ $serviceLabel = "label-warning";
+ $serviceState = "warn";
+ $service_warn_count++;
+ } else {
+ $serviceLabel = "label-danger";
+ $serviceState = "down";
+ $service_down_count++;
}
- $temp_output[] = '
';
+ if ($directpage == "yes") {
+ $deviceIcon = getImage($service);
+ $temp_output[] = '
+
+
+ '.$service["service_type"].'
+ '.$serviceState.'
+ '.$deviceIcon.'
+ '.$service["hostname"].'
+
+ ';
+ } else {
+ $temp_output[] = '
+
+ '.$service['service_type'].' - '.$serviceState.'
+ ';
+ }
}
}
- $temp_output[] = '
'.$up_count.' '.$warn_count.' '.$down_count.' '
- );
+ if ($directpage == "yes") {
+ $temp_header[] = '
+
+ Availability map for
+
+ devices
+ services
+ devices and services
+
+
+
';
+ }
+
+ if ($mode == 0 || $mode == 2) {
+ if ($directpage == "yes") {
+ $headerClass = 'page-availability-report-host';
+ } else {
+ $headerClass = 'widget-availability-host';
+ }
+ $temp_header[] = '
+ ';
+ }
+
+ if ($mode == 1 || $mode == 2) {
+ if ($directpage == "yes") {
+ $headerClass = 'page-availability-report-service';
+ } else {
+ $headerClass = 'widget-availability-service';
+ }
+ $temp_header[] = '
+ ';
+ }
+
+ $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..8bed8ff000 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() {
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
-