From aad9b675c32521cde91b6492fd894c4c06b7662e Mon Sep 17 00:00:00 2001 From: crcro Date: Tue, 6 Sep 2016 02:01:15 +0300 Subject: [PATCH 01/12] more options to amap --- html/css/styles.css | 1 - html/includes/common/availability-map.inc.php | 458 ++++++++---------- html/includes/functions.inc.php | 12 +- html/pages/settings/webui.inc.php | 14 +- sql-schema/133.sql | 3 + 5 files changed, 229 insertions(+), 259 deletions(-) create mode 100644 sql-schema/133.sql diff --git a/html/css/styles.css b/html/css/styles.css index e0b0caef57..7649a3e30a 100644 --- a/html/css/styles.css +++ b/html/css/styles.css @@ -1872,7 +1872,6 @@ label { .device-availability, .service-availability { color:#000000; float:left; - width:163px; height:64px; margin:10px; padding:8px; diff --git a/html/includes/common/availability-map.inc.php b/html/includes/common/availability-map.inc.php index 80cd4b38da..fefb525830 100644 --- a/html/includes/common/availability-map.inc.php +++ b/html/includes/common/availability-map.inc.php @@ -18,34 +18,164 @@ $select_modes = array( '2' => 'devices and services', ); -if (defined('SHOW_SETTINGS')) { - if (isset($widget_settings['mode'])) { - $mode = $widget_settings['mode']; - } else { - $mode = 0; +require_once 'includes/object-cache.inc.php'; + +$sql = dbFetchRow('SELECT `settings` FROM `users_widgets` WHERE `user_id` = ? AND `widget_id` = ?', array($_SESSION["user_id"], '1')); +$widget_mode = json_decode($sql['settings']); + +if (isset($_SESSION["map_view"])) { + $mode = $_SESSION["map_view"]; +} else { + $mode = $widget_mode->{'mode'}; +} + +$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 ($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) + if ($config['webui']['availability_map_use_device_groups'] != 0) { + $device_group = 'SELECT `D`.`device_id` FROM `device_group_device` AS `D` WHERE `device_group_id` = ?'; + $param = array($_SESSION['group_view']); + $devices = dbFetchRows($device_group, $param); + foreach ($devices as $in_dev) { + $in_devices[] = $in_dev['device_id']; + } + $in_devices = implode(',', $in_devices); } - if (isset($widget_settings['tile_width'])) { - $current_width = $widget_settings['tile_width']; + $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( + $_SESSION['user_id'] + ); } else { - $current_width = 10; + $sql .= ' WHERE'; } - $common_output[] = ' -
-
- -
- -
-
-
- -
- '; if ($config['show_services'] == 0) { - $common_output[] = ''; + $temp_header[] = ''; } else { foreach ($select_modes as $mode_select => $option) { if ($mode_select == $mode) { @@ -53,249 +183,71 @@ if (defined('SHOW_SETTINGS')) { } else { $selected = ''; } - $common_output[] = ''; - } - } - $common_output[] =' - -
-
-
-
-
-
'; -} else { - require_once 'includes/object-cache.inc.php'; - - $sql = dbFetchRow('SELECT `settings` FROM `users_widgets` WHERE `user_id` = ? AND `widget_id` = ?', array($_SESSION["user_id"], '1')); - $widget_mode = json_decode($sql['settings']); - - if (isset($_SESSION["map_view"])) { - $mode = $_SESSION["map_view"]; - } else { - $mode = $widget_mode->{'mode'}; - } - - $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 ($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) - if ($config['webui']['availability_map_use_device_groups'] != 0) { - $device_group = 'SELECT `D`.`device_id` FROM `device_group_device` AS `D` WHERE `device_group_id` = ?'; - $param = array($_SESSION['group_view']); - $devices = dbFetchRows($device_group, $param); - foreach ($devices as $in_dev) { - $in_devices[] = $in_dev['device_id']; - } - $in_devices = implode(',', $in_devices); - } - - $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( - $_SESSION['user_id'] - ); - } else { - $sql .= ' WHERE'; - } - - - if ($config['webui']['availability_map_use_device_groups'] != 0 && isset($in_devices)) { - $sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' AND `D`.`device_id` IN (".$in_devices.") ORDER BY `".$deviceOrderBy."`"; - } else { - $sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `".$deviceOrderBy."`"; - } - - $temp_output = array(); - - foreach (dbFetchRows($sql, $param) as $device) { - if ($device['status'] == '1') { - if (($device['uptime'] < $config['uptime_warning']) && ($device['uptime'] != '0')) { - $deviceState = 'warn'; - $deviceLabel = 'label-warning'; - $deviceLabelOld = 'availability-map-oldview-box-warn'; - $host_warn_count++; - } else { - $deviceState = 'up'; - $deviceLabel = 'label-success'; - $deviceLabelOld = 'availability-map-oldview-box-up'; - $host_up_count++; - } - } else { - $deviceState = 'down'; - $deviceLabel = 'label-danger'; - $deviceLabelOld = 'availability-map-oldview-box-down'; - $host_down_count++; - } - - if ($config['webui']['old_availability_map'] == 0) { - if ($directpage == "yes") { - $deviceIcon = getImage($device); - $temp_output[] = ' - -
- '.$deviceState.' - '.$deviceIcon.'
- '.shorthost(ip_to_sysname($device, $device['hostname'])).' -
-
'; - } else { - $temp_output[] = ' - - '.$deviceState.' - '; - } - } else { - $temp_output[] = '
'; - } + $temp_header[] = ''; } } - 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`.`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) { - if ($service['service_status'] == '0') { - $serviceLabel = "label-success"; - $serviceLabelOld = 'availability-map-oldview-box-up'; - $serviceState = "up"; - $service_up_count++; - } elseif ($service['service_status'] == '1') { - $serviceLabel = "label-warning"; - $serviceLabelOld = 'availability-map-oldview-box-warn'; - $serviceState = "warn"; - $service_warn_count++; - } else { - $serviceLabel = "label-danger"; - $serviceLabelOld = 'availability-map-oldview-box-down'; - $serviceState = "down"; - $service_down_count++; - } - - if ($config['webui']['old_availability_map'] == 0) { - if ($directpage == "yes") { - $deviceIcon = getImage($service); - $temp_output[] = ' - -
- '.$service["service_type"].' - '.$serviceState.' - '.$deviceIcon.'
- '.shorthost(ip_to_sysname($service, $service['hostname'])).' -
-
'; - } else { - $temp_output[] = ' - - '.$service['service_type'].' - '.$serviceState.' - '; - } - } else { - $temp_output[] = '
'; - } - } - } else { - $temp_output [] = ''; - } - } - - if ($directpage == "yes") { - $temp_header[] = ' -
- Availability map for - + $temp_header[] = + '
'; - if (($config['webui']['availability_map_use_device_groups'] != 0) && ($mode == 0 || $mode == 2)) { - $sql = 'SELECT `G`.`id`, `G`.`name` FROM `device_groups` AS `G`'; - $dev_groups = dbFetchRows($sql); + if (($config['webui']['availability_map_use_device_groups'] != 0) && ($mode == 0 || $mode == 2)) { + $sql = 'SELECT `G`.`id`, `G`.`name` FROM `device_groups` AS `G`'; + $dev_groups = dbFetchRows($sql); - if ($_SESSION['group_view'] == 0) { + if ($_SESSION['group_view'] == 0) { + $selected = 'selected'; + } else { + $selected = ''; + } + + $temp_header[] = ' + Device group + - '; - - foreach ($dev_groups as $dev_group) { - if ($_SESSION['group_view'] == $dev_group['id']) { - $selected = 'selected'; - } else { - $selected = ''; - } - $temp_header[] = ''; - } - $temp_header[] = ''; + $temp_header[] = ''; } + $temp_header[] = ''; } - - if ($directpage == "yes") { - $deviceClass = 'page-availability-report-host'; - $serviceClass = 'page-availability-report-host'; - } else { - $deviceClass = 'widget-availability-host'; - $serviceClass = 'widget-availability-service'; - } - - if ($mode == 0 || $mode == 2) { - $temp_header[] = ' -
- Total hosts - up: '.$host_up_count.' - warn: '.$host_warn_count.' - down: '.$host_down_count.' -
'; - } - - if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) { - $temp_header[] = ' -
- Total services - up: '.$service_up_count.' - warn: '.$service_warn_count.' - down: '.$service_down_count.' -
'; - } - - $temp_header[] = '
'; - $temp_header[] = '
'; - - $common_output = array_merge($temp_header, $temp_output); } + +if ($directpage == "yes") { + $deviceClass = 'page-availability-report-host'; + $serviceClass = 'page-availability-report-host'; +} else { + $deviceClass = 'widget-availability-host'; + $serviceClass = 'widget-availability-service'; +} + +if ($mode == 0 || $mode == 2) { + $temp_header[] = ' +
+ Total hosts + up: ' . $host_up_count . ' + warn: ' . $host_warn_count . ' + down: ' . $host_down_count . ' +
'; +} + +if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) { + $temp_header[] = ' +
+ Total services + up: ' . $service_up_count . ' + warn: ' . $service_warn_count . ' + down: ' . $service_down_count . ' +
'; +} + +$temp_header[] = ''; +$temp_header[] = '
'; + +$common_output = array_merge($temp_header, $temp_output); diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index dfa560ab59..6a8f07b5fb 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -73,8 +73,11 @@ function nicecase($item) case 'nfs-v3-stats': return 'NFS v3 Stats'; - case 'ntpd': - return 'NTPD (Server)'; + case 'ntp-client': + return 'NTP Client'; + + case 'ntp-server': + return 'NTP Server'; case 'os-updates': return 'OS Updates'; @@ -1213,6 +1216,11 @@ function generate_dynamic_config_panel($title, $config_groups, $items = array(), '; + } elseif ($item['type'] == 'numeric') { + $output .= ' + + + '; } elseif ($item['type'] == 'select') { $output .= ' + + +
+
+ +
+
+ '; } else { - $mode = $widget_mode->{'mode'}; -} + require_once 'includes/object-cache.inc.php'; -$host_up_count = 0; -$host_warn_count = 0; -$host_down_count = 0; -$service_up_count = 0; -$service_warn_count = 0; -$service_down_count = 0; + $sql = dbFetchRow('SELECT `settings` FROM `users_widgets` WHERE `user_id` = ? AND `widget_id` = ?', array($_SESSION["user_id"], '1')); + $widget_mode = json_decode($sql['settings']); -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) - if ($config['webui']['availability_map_use_device_groups'] != 0) { - $device_group = 'SELECT `D`.`device_id` FROM `device_group_device` AS `D` WHERE `device_group_id` = ?'; - $param = array($_SESSION['group_view']); - $devices = dbFetchRows($device_group, $param); - foreach ($devices as $in_dev) { - $in_devices[] = $in_dev['device_id']; - } - $in_devices = implode(',', $in_devices); - } - - $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( - $_SESSION['user_id'] - ); + if (isset($_SESSION["map_view"])) { + $mode = $_SESSION["map_view"]; } else { - $sql .= ' WHERE'; + $mode = $widget_mode->{'mode'}; } + $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 ($config['webui']['availability_map_use_device_groups'] != 0 && isset($in_devices)) { - $sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' AND `D`.`device_id` IN (" . $in_devices . ") ORDER BY `" . $deviceOrderBy . "`"; + if ($config['webui']['availability_map_sort_status'] == 1) { + $deviceOrderBy = 'status'; + $serviceOrderBy = '`S`.`service_status` DESC'; } else { - $sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `" . $deviceOrderBy . "`"; + $deviceOrderBy = 'hostname'; + $serviceOrderBy = '`D`.`hostname`'; } - $temp_output = array(); - - foreach (dbFetchRows($sql, $param) as $device) { - if ($device['status'] == '1') { - if (($device['uptime'] < $config['uptime_warning']) && ($device['uptime'] != '0')) { - $deviceState = 'warn'; - $deviceLabel = 'label-warning'; - $deviceLabelOld = 'availability-map-oldview-box-warn'; - $host_warn_count++; - } else { - $deviceState = 'up'; - $deviceLabel = 'label-success'; - $deviceLabelOld = 'availability-map-oldview-box-up'; - $host_up_count++; + if ($mode == 0 || $mode == 2) { + // Only show devices if mode is 0 or 2 (Only Devices or both) + if ($config['webui']['availability_map_use_device_groups'] != 0) { + $device_group = 'SELECT `D`.`device_id` FROM `device_group_device` AS `D` WHERE `device_group_id` = ?'; + $param = array($_SESSION['group_view']); + $devices = dbFetchRows($device_group, $param); + foreach ($devices as $in_dev) { + $in_devices[] = $in_dev['device_id']; } - } else { - $deviceState = 'down'; - $deviceLabel = 'label-danger'; - $deviceLabelOld = 'availability-map-oldview-box-down'; - $host_down_count++; + $in_devices = implode(',', $in_devices); } - if ($config['webui']['availability_map_old'] == 0) { - if ($directpage == "yes") { - $deviceIcon = getImage($device); - $temp_output[] = ' + $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( + $_SESSION['user_id'] + ); + } else { + $sql .= ' WHERE'; + } + + + if ($config['webui']['availability_map_use_device_groups'] != 0 && isset($in_devices)) { + $sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' AND `D`.`device_id` IN (" . $in_devices . ") ORDER BY `" . $deviceOrderBy . "`"; + } else { + $sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `" . $deviceOrderBy . "`"; + } + + $temp_output = array(); + + foreach (dbFetchRows($sql, $param) as $device) { + if ($device['status'] == '1') { + if (($device['uptime'] < $config['uptime_warning']) && ($device['uptime'] != '0')) { + $deviceState = 'warn'; + $deviceLabel = 'label-warning'; + $deviceLabelOld = 'availability-map-oldview-box-warn'; + $host_warn_count++; + } else { + $deviceState = 'up'; + $deviceLabel = 'label-success'; + $deviceLabelOld = 'availability-map-oldview-box-up'; + $host_up_count++; + } + } else { + $deviceState = 'down'; + $deviceLabel = 'label-danger'; + $deviceLabelOld = 'availability-map-oldview-box-down'; + $host_down_count++; + } + + if ($config['webui']['availability_map_old'] == 0) { + if ($directpage == "yes") { + $deviceIcon = getImage($device); + $temp_output[] = '
' . $deviceState . ' @@ -107,44 +125,44 @@ if ($mode == 0 || $mode == 2) { ' . shorthost(ip_to_sysname($device, $device['hostname'])) . '
'; - } else { - $temp_output[] = ' + } else { + $temp_output[] = ' ' . $deviceState . ' '; + } + } else { + $temp_output[] = '
'; } - } else { - $temp_output[] = '
'; } } -} -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`.`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) { - if ($service['service_status'] == '0') { - $serviceLabel = "label-success"; - $serviceLabelOld = 'availability-map-oldview-box-up'; - $serviceState = "up"; - $service_up_count++; - } elseif ($service['service_status'] == '1') { - $serviceLabel = "label-warning"; - $serviceLabelOld = 'availability-map-oldview-box-warn'; - $serviceState = "warn"; - $service_warn_count++; - } else { - $serviceLabel = "label-danger"; - $serviceLabelOld = 'availability-map-oldview-box-down'; - $serviceState = "down"; - $service_down_count++; - } + 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`.`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) { + if ($service['service_status'] == '0') { + $serviceLabel = "label-success"; + $serviceLabelOld = 'availability-map-oldview-box-up'; + $serviceState = "up"; + $service_up_count++; + } elseif ($service['service_status'] == '1') { + $serviceLabel = "label-warning"; + $serviceLabelOld = 'availability-map-oldview-box-warn'; + $serviceState = "warn"; + $service_warn_count++; + } else { + $serviceLabel = "label-danger"; + $serviceLabelOld = 'availability-map-oldview-box-down'; + $serviceState = "down"; + $service_down_count++; + } - if ($config['webui']['availability_map_old'] == 0) { - if ($directpage == "yes") { - $deviceIcon = getImage($service); - $temp_output[] = ' + if ($config['webui']['availability_map_old'] == 0) { + if ($directpage == "yes") { + $deviceIcon = getImage($service); + $temp_output[] = '
' . $service["service_type"] . ' @@ -153,101 +171,102 @@ if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) { ' . shorthost(ip_to_sysname($service, $service['hostname'])) . '
'; - } else { - $temp_output[] = ' + } else { + $temp_output[] = ' ' . $service['service_type'] . ' - ' . $serviceState . ' '; + } + } else { + $temp_output[] = '
'; } - } else { - $temp_output[] = '
'; } + } else { + $temp_output [] = ''; } - } else { - $temp_output [] = ''; } -} -if ($directpage == "yes") { - $temp_header[] = ' + if ($directpage == "yes") { + $temp_header[] = '
Availability map for +
+
'; + + if (($config['webui']['availability_map_use_device_groups'] != 0) && ($mode == 0 || $mode == 2)) { + $sql = 'SELECT `G`.`id`, `G`.`name` FROM `device_groups` AS `G`'; + $dev_groups = dbFetchRows($sql); + + if ($_SESSION['group_view'] == 0) { $selected = 'selected'; } else { $selected = ''; } - $temp_header[] = ''; - } - } - $temp_header[] = - ' -
-
'; - - if (($config['webui']['availability_map_use_device_groups'] != 0) && ($mode == 0 || $mode == 2)) { - $sql = 'SELECT `G`.`id`, `G`.`name` FROM `device_groups` AS `G`'; - $dev_groups = dbFetchRows($sql); - - if ($_SESSION['group_view'] == 0) { - $selected = 'selected'; - } else { - $selected = ''; - } - - $temp_header[] = ' + $temp_header[] = ' Device group '; } - $temp_header[] = ''; } -} -if ($directpage == "yes") { - $deviceClass = 'page-availability-report-host'; - $serviceClass = 'page-availability-report-host'; -} else { - $deviceClass = 'widget-availability-host'; - $serviceClass = 'widget-availability-service'; -} + if ($directpage == "yes") { + $deviceClass = 'page-availability-report-host'; + $serviceClass = 'page-availability-report-host'; + } else { + $deviceClass = 'widget-availability-host'; + $serviceClass = 'widget-availability-service'; + } -if ($mode == 0 || $mode == 2) { - $temp_header[] = ' + if ($mode == 0 || $mode == 2) { + $temp_header[] = '
Total hosts up: ' . $host_up_count . ' warn: ' . $host_warn_count . ' down: ' . $host_down_count . '
'; -} + } -if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) { - $temp_header[] = ' + if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) { + $temp_header[] = '
Total services up: ' . $service_up_count . ' warn: ' . $service_warn_count . ' down: ' . $service_down_count . '
'; + } + + $temp_header[] = '
'; + $temp_header[] = '
'; + + $common_output = array_merge($temp_header, $temp_output); } - -$temp_header[] = ''; -$temp_header[] = '
'; - -$common_output = array_merge($temp_header, $temp_output); From 23e31bd030a9e3ec437ddc0ec2943ada12965b52 Mon Sep 17 00:00:00 2001 From: crcro Date: Tue, 6 Sep 2016 02:54:13 +0300 Subject: [PATCH 04/12] fix functions.php, sql queries --- html/includes/functions.inc.php | 10 ++-------- sql-schema/133.sql | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 6a8f07b5fb..b4465a5a4f 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -73,14 +73,8 @@ function nicecase($item) case 'nfs-v3-stats': return 'NFS v3 Stats'; - case 'ntp-client': - return 'NTP Client'; - - case 'ntp-server': - return 'NTP Server'; - - case 'os-updates': - return 'OS Updates'; + case 'ntpd': + return 'NTPD (Server)'; case 'powerdns-recursor': return 'PowerDNS Recursor'; diff --git a/sql-schema/133.sql b/sql-schema/133.sql index 6f02164946..b8221686ed 100644 --- a/sql-schema/133.sql +++ b/sql-schema/133.sql @@ -3,4 +3,4 @@ INSERT INTO `config` (`config_name`, `config_value`, `config_default`, `config_d UPDATE `config` SET `config_name` = 'webui.availability_map_old', `config_hidden` = '0' WHERE `config_name` = 'webui.old_availability_map'; UPDATE `config` SET `config_hidden` = '0' WHERE `config_name` = 'webui.availability_map_sort_status'; UPDATE `config` SET `config_descr` = 'Enable usage of device groups filter' WHERE `config_name` = 'webui.availability_map_use_device_groups'; -UPDATE `config` SET `config_descr` = 'Sort devices and services by status` WHERE `config_name` = 'webui.availability_map_sort_status'; +UPDATE `config` SET `config_descr` = 'Sort devices and services by status' WHERE `config_name` = 'webui.availability_map_sort_status'; From d1130818dd4aefeef66306fda7d10258cfd72652 Mon Sep 17 00:00:00 2001 From: crcro Date: Tue, 6 Sep 2016 02:55:29 +0300 Subject: [PATCH 05/12] fix functions.php, sql queries --- html/includes/functions.inc.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index b4465a5a4f..48e933266a 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -76,6 +76,9 @@ function nicecase($item) case 'ntpd': return 'NTPD (Server)'; + case 'os-updates': + return 'OS Updates'; + case 'powerdns-recursor': return 'PowerDNS Recursor'; From 05e0d5cc3ab858966a64ee8bac0f012ee5cedfad Mon Sep 17 00:00:00 2001 From: crcro Date: Wed, 14 Sep 2016 01:31:29 +0300 Subject: [PATCH 06/12] sql reindex --- sql-schema/134.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 sql-schema/134.sql diff --git a/sql-schema/134.sql b/sql-schema/134.sql new file mode 100644 index 0000000000..b8221686ed --- /dev/null +++ b/sql-schema/134.sql @@ -0,0 +1,6 @@ +INSERT INTO `config` (`config_name`, `config_value`, `config_default`, `config_descr`, `config_group`, `config_group_order`, `config_sub_group`, `config_sub_group_order`, `config_hidden`, `config_disabled`) VALUES('webui.availability_map_direct_tile_size', '200', '165', 'Input desired tile width in pixels for direct page mode', 'webui', 0, 'graph', 0, '0', '0'); +INSERT INTO `config` (`config_name`, `config_value`, `config_default`, `config_descr`, `config_group`, `config_group_order`, `config_sub_group`, `config_sub_group_order`, `config_hidden`, `config_disabled`) VALUES('webui.availability_map_old_widget_tile_size', '60', '10', 'Input desired tile width in pixels for widget mode', 'webui', 0, 'graph', 0, '0', '0'); +UPDATE `config` SET `config_name` = 'webui.availability_map_old', `config_hidden` = '0' WHERE `config_name` = 'webui.old_availability_map'; +UPDATE `config` SET `config_hidden` = '0' WHERE `config_name` = 'webui.availability_map_sort_status'; +UPDATE `config` SET `config_descr` = 'Enable usage of device groups filter' WHERE `config_name` = 'webui.availability_map_use_device_groups'; +UPDATE `config` SET `config_descr` = 'Sort devices and services by status' WHERE `config_name` = 'webui.availability_map_sort_status'; From 52693426bceae62dd211f4a825b0b2ec6ad698ca Mon Sep 17 00:00:00 2001 From: crcro Date: Thu, 15 Sep 2016 00:07:03 +0300 Subject: [PATCH 07/12] changed webui and sql from old availability map to compact availability map --- html/pages/settings/webui.inc.php | 16 ++++------------ sql-schema/134.sql | 1 + 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/html/pages/settings/webui.inc.php b/html/pages/settings/webui.inc.php index 3bfc9181b9..e5b39cf1bb 100644 --- a/html/pages/settings/webui.inc.php +++ b/html/pages/settings/webui.inc.php @@ -19,26 +19,18 @@ $graph_conf = array( ); $availability_map_conf = array( - array('name' => 'webui.availability_map_old', - 'descr' => 'Availability map old view', + array('name' => 'webui.availability_map_compact', + 'descr' => 'Availability map compact view', 'type' => 'checkbox', ), array('name' => 'webui.availability_map_sort_status', - 'descr' => 'Device sort by status', + 'descr' => 'Sort devices by status', 'type' => 'checkbox', ), array('name' => 'webui.availability_map_use_device_groups', - 'descr' => 'Device groups filtering', + 'descr' => 'Use device groups filter', 'type' => 'checkbox', ), - array('name' => 'webui.availability_map_direct_tile_size', - 'descr' => 'Direct page tile size', - 'type' => 'numeric', - ), - array('name' => 'webui.availability_map_old_widget_tile_size', - 'descr' => 'Old view widget tile size', - 'type' => 'numeric', - ), ); $dashboard_conf = array( diff --git a/sql-schema/134.sql b/sql-schema/134.sql index b8221686ed..cecdf2a1dd 100644 --- a/sql-schema/134.sql +++ b/sql-schema/134.sql @@ -4,3 +4,4 @@ UPDATE `config` SET `config_name` = 'webui.availability_map_old', `config_hidden UPDATE `config` SET `config_hidden` = '0' WHERE `config_name` = 'webui.availability_map_sort_status'; UPDATE `config` SET `config_descr` = 'Enable usage of device groups filter' WHERE `config_name` = 'webui.availability_map_use_device_groups'; UPDATE `config` SET `config_descr` = 'Sort devices and services by status' WHERE `config_name` = 'webui.availability_map_sort_status'; +UPDATE `config` SET `config_name` = 'webui.availability_map_compact' WHERE `config_name` = 'webui.availability_map_old'; From 79b93ddd33ff33584f63121abf76f4f40d449475 Mon Sep 17 00:00:00 2001 From: crcro Date: Sat, 17 Sep 2016 23:42:08 +0300 Subject: [PATCH 08/12] fix conflict --- sql-schema/{134.sql => 135.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sql-schema/{134.sql => 135.sql} (100%) diff --git a/sql-schema/134.sql b/sql-schema/135.sql similarity index 100% rename from sql-schema/134.sql rename to sql-schema/135.sql From 63f42acda6e8b02b7cd880e3f4d0672c083b8da5 Mon Sep 17 00:00:00 2001 From: crcro Date: Thu, 22 Sep 2016 00:11:16 +0300 Subject: [PATCH 09/12] general updates --- html/css/styles.css | 4 ++ html/includes/common/availability-map.inc.php | 50 +++++++++++++------ html/pages/settings/webui.inc.php | 4 ++ sql-schema/135.sql | 7 --- sql-schema/136.sql | 4 ++ 5 files changed, 46 insertions(+), 23 deletions(-) delete mode 100644 sql-schema/135.sql create mode 100644 sql-schema/136.sql diff --git a/html/css/styles.css b/html/css/styles.css index 7e3fe078e1..a309e9ab10 100644 --- a/html/css/styles.css +++ b/html/css/styles.css @@ -1990,3 +1990,7 @@ label { float:left; background-color: #D9534F; } + +.availability-map-widget-header { + line-height:30px; +} diff --git a/html/includes/common/availability-map.inc.php b/html/includes/common/availability-map.inc.php index 7a3bf215bd..f3c9ae5b69 100644 --- a/html/includes/common/availability-map.inc.php +++ b/html/includes/common/availability-map.inc.php @@ -12,24 +12,51 @@ * the source code distribution for details. */ +$sql = dbFetchRow('SELECT `settings` FROM `users_widgets` WHERE `user_id` = ? AND `widget_id` = ?', array($_SESSION["user_id"], '1')); +$widget_mode = json_decode($sql['settings']); + +if (isset($_SESSION["map_view"]) && is_numeric($_SESSION["map_view"])) { + $mode = $_SESSION["map_view"]; +} else { + $mode = $widget_mode->{'mode'}; +} + $select_modes = array( '0' => 'only devices', '1' => 'only services', '2' => 'devices and services', ); +if ($config['webui']['availability_map_compact'] == 1) { + $compact_tile = $widget_mode->{'tile_width'}; +} + if (defined('SHOW_SETTINGS')) { $common_output[] = '
- +
-
+ '; + + if ($config['webui']['availability_map_compact'] == 1) { + $common_output[] = '
+
+ +
+
+ +
+
'; + } + + $common_output[] = ' +
@@ -37,16 +64,6 @@ if (defined('SHOW_SETTINGS')) { '; } else { require_once 'includes/object-cache.inc.php'; - - $sql = dbFetchRow('SELECT `settings` FROM `users_widgets` WHERE `user_id` = ? AND `widget_id` = ?', array($_SESSION["user_id"], '1')); - $widget_mode = json_decode($sql['settings']); - - if (isset($_SESSION["map_view"])) { - $mode = $_SESSION["map_view"]; - } else { - $mode = $widget_mode->{'mode'}; - } - $host_up_count = 0; $host_warn_count = 0; $host_down_count = 0; @@ -114,7 +131,7 @@ if (defined('SHOW_SETTINGS')) { $host_down_count++; } - if ($config['webui']['availability_map_old'] == 0) { + if ($config['webui']['availability_map_compact'] == 0) { if ($directpage == "yes") { $deviceIcon = getImage($device); $temp_output[] = ' @@ -132,7 +149,7 @@ if (defined('SHOW_SETTINGS')) { '; } } else { - $temp_output[] = '
'; + $temp_output[] = '
'; } } } @@ -159,7 +176,7 @@ if (defined('SHOW_SETTINGS')) { $service_down_count++; } - if ($config['webui']['availability_map_old'] == 0) { + if ($config['webui']['availability_map_compact'] == 0) { if ($directpage == "yes") { $deviceIcon = getImage($service); $temp_output[] = ' @@ -176,9 +193,10 @@ if (defined('SHOW_SETTINGS')) { ' . $service['service_type'] . ' - ' . $serviceState . ' '; + } } else { - $temp_output[] = '
'; + $temp_output[] = '
'; } } } else { diff --git a/html/pages/settings/webui.inc.php b/html/pages/settings/webui.inc.php index e5b39cf1bb..b1ff79a24c 100644 --- a/html/pages/settings/webui.inc.php +++ b/html/pages/settings/webui.inc.php @@ -31,6 +31,10 @@ $availability_map_conf = array( 'descr' => 'Use device groups filter', 'type' => 'checkbox', ), + array('name' => 'webui.availability_map_box_size', + 'descr' => 'Availability box width', + 'type' => 'numeric', + ), ); $dashboard_conf = array( diff --git a/sql-schema/135.sql b/sql-schema/135.sql deleted file mode 100644 index cecdf2a1dd..0000000000 --- a/sql-schema/135.sql +++ /dev/null @@ -1,7 +0,0 @@ -INSERT INTO `config` (`config_name`, `config_value`, `config_default`, `config_descr`, `config_group`, `config_group_order`, `config_sub_group`, `config_sub_group_order`, `config_hidden`, `config_disabled`) VALUES('webui.availability_map_direct_tile_size', '200', '165', 'Input desired tile width in pixels for direct page mode', 'webui', 0, 'graph', 0, '0', '0'); -INSERT INTO `config` (`config_name`, `config_value`, `config_default`, `config_descr`, `config_group`, `config_group_order`, `config_sub_group`, `config_sub_group_order`, `config_hidden`, `config_disabled`) VALUES('webui.availability_map_old_widget_tile_size', '60', '10', 'Input desired tile width in pixels for widget mode', 'webui', 0, 'graph', 0, '0', '0'); -UPDATE `config` SET `config_name` = 'webui.availability_map_old', `config_hidden` = '0' WHERE `config_name` = 'webui.old_availability_map'; -UPDATE `config` SET `config_hidden` = '0' WHERE `config_name` = 'webui.availability_map_sort_status'; -UPDATE `config` SET `config_descr` = 'Enable usage of device groups filter' WHERE `config_name` = 'webui.availability_map_use_device_groups'; -UPDATE `config` SET `config_descr` = 'Sort devices and services by status' WHERE `config_name` = 'webui.availability_map_sort_status'; -UPDATE `config` SET `config_name` = 'webui.availability_map_compact' WHERE `config_name` = 'webui.availability_map_old'; diff --git a/sql-schema/136.sql b/sql-schema/136.sql new file mode 100644 index 0000000000..f5a311d2ab --- /dev/null +++ b/sql-schema/136.sql @@ -0,0 +1,4 @@ +INSERT INTO `config` (`config_name`, `config_value`, `config_default`, `config_descr`, `config_group`, `config_group_order`, `config_sub_group`, `config_sub_group_order`, `config_hidden`, `config_disabled`) VALUES('webui.availability_map_box_size', '165', '165', 'Input desired tile width in pixels for box size in full view', 'webui', 0, 'graph', 0, '0', '0'); +UPDATE `config` SET `config_hidden` = '0', `config_descr` = 'Sort devices and services by status' WHERE `config_name` = 'webui.availability_map_sort_status'; +UPDATE `config` SET `config_descr` = 'Enable usage of device groups filter' WHERE `config_name` = 'webui.availability_map_use_device_groups'; +UPDATE `config` SET `config_name` = 'webui.availability_map_compact', `config_hidden` = '0' WHERE `config_name` = 'webui.old_availability_map'; From f6691ab0a67afe5f8042f5c3b180558a11a87692 Mon Sep 17 00:00:00 2001 From: crcro Date: Thu, 22 Sep 2016 00:12:20 +0300 Subject: [PATCH 10/12] fix renumbering --- sql-schema/{136.sql => 137.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sql-schema/{136.sql => 137.sql} (100%) diff --git a/sql-schema/136.sql b/sql-schema/137.sql similarity index 100% rename from sql-schema/136.sql rename to sql-schema/137.sql From cae9f577061bc84736fe2eebf3f5f15228bd9446 Mon Sep 17 00:00:00 2001 From: crcro Date: Thu, 22 Sep 2016 00:27:12 +0300 Subject: [PATCH 11/12] fix blank line --- html/includes/common/availability-map.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/html/includes/common/availability-map.inc.php b/html/includes/common/availability-map.inc.php index f3c9ae5b69..86317ba481 100644 --- a/html/includes/common/availability-map.inc.php +++ b/html/includes/common/availability-map.inc.php @@ -193,7 +193,6 @@ if (defined('SHOW_SETTINGS')) { ' . $service['service_type'] . ' - ' . $serviceState . ' '; - } } else { $temp_output[] = '
'; From 27235c3ab10fc95413d31184c94f3c54f774c8dc Mon Sep 17 00:00:00 2001 From: crcro Date: Fri, 23 Sep 2016 01:31:11 +0300 Subject: [PATCH 12/12] json_decode as array --- html/includes/common/availability-map.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/includes/common/availability-map.inc.php b/html/includes/common/availability-map.inc.php index 86317ba481..cc00b3dcae 100644 --- a/html/includes/common/availability-map.inc.php +++ b/html/includes/common/availability-map.inc.php @@ -13,7 +13,7 @@ */ $sql = dbFetchRow('SELECT `settings` FROM `users_widgets` WHERE `user_id` = ? AND `widget_id` = ?', array($_SESSION["user_id"], '1')); -$widget_mode = json_decode($sql['settings']); +$widget_mode = json_decode($sql['settings'], true); if (isset($_SESSION["map_view"]) && is_numeric($_SESSION["map_view"])) { $mode = $_SESSION["map_view"];