diff --git a/html/css/styles.css b/html/css/styles.css index a5fc4f9057..de0ae68592 100644 --- a/html/css/styles.css +++ b/html/css/styles.css @@ -1881,6 +1881,7 @@ label { padding:8px; border-radius:5px; text-align:center; + white-space: nowrap; } .device-availability.up, .service-availability.up { diff --git a/html/includes/common/availability-map.inc.php b/html/includes/common/availability-map.inc.php index 4fd15f5bf9..d2a5e6b50e 100644 --- a/html/includes/common/availability-map.inc.php +++ b/html/includes/common/availability-map.inc.php @@ -12,9 +12,25 @@ * the source code distribution for details. */ +$select_modes = array( + '0' => 'only devices', + '1' => 'only services', + '2' => 'devices and services', +); + 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; + if (isset($widget_settings['mode'])) { + $mode = $widget_settings['mode']; + } else { + $mode = 0; + } + + if (isset($widget_settings['tile_width'])) { + $current_width = $widget_settings['tile_width']; + } else { + $current_width = 10; + } + $common_output[] = '
@@ -31,12 +47,15 @@ if (defined('SHOW_SETTINGS')) { if ($config['show_services'] == 0) { $common_output[] = ''; } else { - $common_output[] = ' - - - '; + foreach ($select_modes as $mode_select => $option) { + if ($mode_select == $mode) { + $selected = 'selected'; + } else { + $selected = ''; + } + $common_output[] = ''; + } } - $common_output[] ='
@@ -50,7 +69,12 @@ if (defined('SHOW_SETTINGS')) { $sql = dbFetchRow('SELECT `settings` FROM `users_widgets` WHERE `user_id` = ? AND `widget_id` = ?', array($_SESSION["user_id"], '1')); $widget_mode = json_decode($sql['settings']); - $mode = isset($_SESSION["mapView"]) ? $_SESSION["mapView"] : $widget_mode->{'mode'}; + + if (isset($_SESSION["mapView"])) { + $mode = $_SESSION["mapView"]; + } else { + $mode = $widget_mode->{'mode'}; + } $host_up_count = 0; $host_warn_count = 0; @@ -59,9 +83,17 @@ if (defined('SHOW_SETTINGS')) { $service_warn_count = 0; $service_down_count = 0; + if ($config['webui']['availability_map_sort_status'] == 1) { + $deviceOrderBy = 'status'; + $serviceOrderBy = '`S`.`service_status` DESC'; + } else { + $deviceOrderBy = 'hostname'; + $serviceOrderBy = '`D`.`hostname`'; + } + 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`, `D`.`os`, `D`.`icon` FROM `devices` AS `D`'; + $sql = 'SELECT `D`.`hostname`, `D`.`sysName`, `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( @@ -70,7 +102,7 @@ if (defined('SHOW_SETTINGS')) { } else { $sql .= ' WHERE'; } - $sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `hostname`"; + $sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `".$deviceOrderBy."`"; $temp_output = array(); foreach (dbFetchRows($sql, $param) as $device) { @@ -101,7 +133,7 @@ if (defined('SHOW_SETTINGS')) {
'.$deviceState.' '.$deviceIcon.'
- '.$device["hostname"].' + '.shorthost(ip_to_sysname($device, $device['hostname'])).'
'; } else { @@ -117,7 +149,7 @@ if (defined('SHOW_SETTINGS')) { } if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) { - $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`;'; + $service_query = 'select `S`.`service_type`, `S`.`service_id`, `S`.`service_desc`, `S`.`service_status`, `D`.`hostname`, `D`.`sysName`, `D`.`device_id`, `D`.`os`, `D`.`icon` from services S, devices D where `S`.`device_id` = `D`.`device_id` ORDER BY '.$serviceOrderBy.';'; $services = dbFetchRows($service_query); if (count($services) > 0) { foreach ($services as $service) { @@ -142,22 +174,22 @@ if (defined('SHOW_SETTINGS')) { if ($directpage == "yes") { $deviceIcon = getImage($service); $temp_output[] = ' - -
- ' . $service["service_type"] . ' - ' . $serviceState . ' - ' . $deviceIcon . '
- ' . $service["hostname"] . ' +
+
+ '.$service["service_type"].' + '.$serviceState.' + '.$deviceIcon.'
+ '.shorthost(ip_to_sysname($service, $service['hostname'])).'
'; } else { $temp_output[] = ' - - ' . $service['service_type'] . ' - ' . $serviceState . ' + + '.$service['service_type'].' - '.$serviceState.' '; } } else { - $temp_output[] = '
'; + $temp_output[] = '
'; } } } else { @@ -165,8 +197,6 @@ if (defined('SHOW_SETTINGS')) { } } - - if ($directpage == "yes") { $temp_header[] = '
@@ -174,12 +204,16 @@ if (defined('SHOW_SETTINGS')) {