mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #4429 from crcro/availability-map-update-5
webui: More updates for availability map
This commit is contained in:
@@ -1872,7 +1872,6 @@ label {
|
||||
.device-availability, .service-availability {
|
||||
color:#000000;
|
||||
float:left;
|
||||
width:163px;
|
||||
height:64px;
|
||||
margin:10px;
|
||||
padding:8px;
|
||||
@@ -1991,3 +1990,7 @@ label {
|
||||
float:left;
|
||||
background-color: #D9534F;
|
||||
}
|
||||
|
||||
.availability-map-widget-header {
|
||||
line-height:30px;
|
||||
}
|
||||
|
@@ -12,70 +12,58 @@
|
||||
* 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'], true);
|
||||
|
||||
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 (defined('SHOW_SETTINGS')) {
|
||||
if (isset($widget_settings['mode'])) {
|
||||
$mode = $widget_settings['mode'];
|
||||
} else {
|
||||
$mode = 0;
|
||||
}
|
||||
if ($config['webui']['availability_map_compact'] == 1) {
|
||||
$compact_tile = $widget_mode->{'tile_width'};
|
||||
}
|
||||
|
||||
if (isset($widget_settings['tile_width'])) {
|
||||
$current_width = $widget_settings['tile_width'];
|
||||
} else {
|
||||
$current_width = 10;
|
||||
if (defined('SHOW_SETTINGS')) {
|
||||
$common_output[] = '
|
||||
<form class="form" onsubmit="widget_settings(this); return false;">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2">
|
||||
<label for="title" class="control-label availability-map-widget-header">Widget title: </label>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="title" placeholder="Custom title for widget" value="'.htmlspecialchars($widget_settings['title']).'">
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
if ($config['webui']['availability_map_compact'] == 1) {
|
||||
$common_output[] = '
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2">
|
||||
<label for="tile_width" class="control-label availability-map-widget-header">Tile width:</label>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="tile_width" placeholder="Tile " value="'.$compact_tile.'">
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
$common_output[] = '
|
||||
<form class="form-horizontal" onsubmit="return widget_settings(this)">
|
||||
<div class="form-group">
|
||||
<label for="tile_width" class="col-sm-4 control-label">Tile width</label>
|
||||
<div class="col-sm-6">
|
||||
<input class="form-control" name="tile_width" placeholder="I.e 10" value="'.$current_width.'">
|
||||
<div class="col-sm-2">
|
||||
<button type="submit" class="btn btn-default">Set</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="show_services" class="col-sm-4 control-label">Show</label>
|
||||
<div class="col-sm-6">
|
||||
<select class="form-control" name="mode">';
|
||||
|
||||
if ($config['show_services'] == 0) {
|
||||
$common_output[] = '<option value="0" selected="selected">only devices</option>';
|
||||
} else {
|
||||
foreach ($select_modes as $mode_select => $option) {
|
||||
if ($mode_select == $mode) {
|
||||
$selected = 'selected';
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
$common_output[] = '<option value="'.$mode_select.'" '.$selected.'>'.$option.'</option>';
|
||||
}
|
||||
}
|
||||
$common_output[] ='
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-6 col-sm-4"><button type="submit" class="btn btn-primary">Set</button></div>
|
||||
</div>
|
||||
</form>';
|
||||
} 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;
|
||||
@@ -116,9 +104,9 @@ if (defined('SHOW_SETTINGS')) {
|
||||
|
||||
|
||||
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."`";
|
||||
$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."`";
|
||||
$sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `" . $deviceOrderBy . "`";
|
||||
}
|
||||
|
||||
$temp_output = array();
|
||||
@@ -143,31 +131,31 @@ if (defined('SHOW_SETTINGS')) {
|
||||
$host_down_count++;
|
||||
}
|
||||
|
||||
if ($config['webui']['old_availability_map'] == 0) {
|
||||
if ($config['webui']['availability_map_compact'] == 0) {
|
||||
if ($directpage == "yes") {
|
||||
$deviceIcon = getImage($device);
|
||||
$temp_output[] = '
|
||||
<a href="'.generate_url(array('page' => 'device', 'device' => $device['device_id'])).'" title="'.$device['hostname']." - ".formatUptime($device['uptime']).'">
|
||||
<div class="device-availability '.$deviceState.'">
|
||||
<span class="availability-label label '.$deviceLabel.' label-font-border">'.$deviceState.'</span>
|
||||
<span class="device-icon">'.$deviceIcon.'</span><br>
|
||||
<span class="small">'.shorthost(ip_to_sysname($device, $device['hostname'])).'</span>
|
||||
<a href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'])) . '" title="' . $device['hostname'] . " - " . formatUptime($device['uptime']) . '">
|
||||
<div class="device-availability ' . $deviceState . '" style="width:' . $config['webui']['availability_map_direct_tile_size'] . 'px;">
|
||||
<span class="availability-label label ' . $deviceLabel . ' label-font-border">' . $deviceState . '</span>
|
||||
<span class="device-icon">' . $deviceIcon . '</span><br>
|
||||
<span class="small">' . shorthost(ip_to_sysname($device, $device['hostname'])) . '</span>
|
||||
</div>
|
||||
</a>';
|
||||
} else {
|
||||
$temp_output[] = '
|
||||
<a href="'.generate_url(array('page' => 'device', 'device' => $device['device_id'])).'" title="'.$device['hostname']." - ".formatUptime($device['uptime']).'">
|
||||
<span class="label '.$deviceLabel.' widget-availability label-font-border">'.$deviceState.'</span>
|
||||
<a href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'])) . '" title="' . $device['hostname'] . " - " . formatUptime($device['uptime']) . '">
|
||||
<span class="label ' . $deviceLabel . ' widget-availability label-font-border">' . $deviceState . '</span>
|
||||
</a>';
|
||||
}
|
||||
} else {
|
||||
$temp_output[] = '<a href="'.generate_url(array('page' => 'device', 'device' => $device['device_id'])).'" title="'.$device['hostname']." - ".formatUptime($device['uptime']).'"><div class="'.$deviceLabelOld.'"></div></a>';
|
||||
$temp_output[] = '<a href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'])) . '" title="' . $device['hostname'] . " - " . formatUptime($device['uptime']) . '"><div class="' . $deviceLabelOld . '" style="width:' . $compact_tile . 'px;"></div></a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.';';
|
||||
$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) {
|
||||
@@ -188,26 +176,26 @@ if (defined('SHOW_SETTINGS')) {
|
||||
$service_down_count++;
|
||||
}
|
||||
|
||||
if ($config['webui']['old_availability_map'] == 0) {
|
||||
if ($config['webui']['availability_map_compact'] == 0) {
|
||||
if ($directpage == "yes") {
|
||||
$deviceIcon = getImage($service);
|
||||
$temp_output[] = '
|
||||
<a href="'.generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])).'" title="'.$service['hostname']." - ".$service['service_type']." - ".$service['service_desc'].'">
|
||||
<div class="service-availability '.$serviceState.'">
|
||||
<span class="service-name-label label '.$serviceLabel.' label-font-border">'.$service["service_type"].'</span>
|
||||
<span class="availability-label label '.$serviceLabel.' label-font-border">'.$serviceState.'</span>
|
||||
<span class="device-icon">'.$deviceIcon.'</span><br>
|
||||
<span class="small">'.shorthost(ip_to_sysname($service, $service['hostname'])).'</span>
|
||||
<a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '">
|
||||
<div class="service-availability ' . $serviceState . '" style="width:' . $config['webui']['availability_map_direct_tile_size'] . 'px;">
|
||||
<span class="service-name-label label ' . $serviceLabel . ' label-font-border">' . $service["service_type"] . '</span>
|
||||
<span class="availability-label label ' . $serviceLabel . ' label-font-border">' . $serviceState . '</span>
|
||||
<span class="device-icon">' . $deviceIcon . '</span><br>
|
||||
<span class="small">' . shorthost(ip_to_sysname($service, $service['hostname'])) . '</span>
|
||||
</div>
|
||||
</a>';
|
||||
} else {
|
||||
$temp_output[] = '
|
||||
<a href="'.generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])).'" title="'.$service['hostname']." - ".$service['service_type']." - ".$service['service_desc'].'">
|
||||
<span class="label '.$serviceLabel.' widget-availability label-font-border">'.$service['service_type'].' - '.$serviceState.'</span>
|
||||
<a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '">
|
||||
<span class="label ' . $serviceLabel . ' widget-availability label-font-border">' . $service['service_type'] . ' - ' . $serviceState . '</span>
|
||||
</a>';
|
||||
}
|
||||
} else {
|
||||
$temp_output[] = '<a href="'.generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])).'" title="'.$service['hostname']." - ".$service['service_type']." - ".$service['service_desc'].'"><div class="'.$serviceLabelOld.'"></div></a>';
|
||||
$temp_output[] = '<a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '"><div class="' . $serviceLabelOld . '" style="width:'.$compact_tile.'px;"></div></a>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -230,7 +218,7 @@ if (defined('SHOW_SETTINGS')) {
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
$temp_header[] = '<option value="'.$mode_select.'" '.$selected.'>'.$option.'</option>';
|
||||
$temp_header[] = '<option value="' . $mode_select . '" ' . $selected . '>' . $option . '</option>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +240,7 @@ if (defined('SHOW_SETTINGS')) {
|
||||
$temp_header[] = '
|
||||
<span class="page-availability-title">Device group</span>
|
||||
<select id="group" class="page-availability-report-select" name="group">
|
||||
<option value="0" '.$selected.'>show all devices</option>';
|
||||
<option value="0" ' . $selected . '>show all devices</option>';
|
||||
|
||||
foreach ($dev_groups as $dev_group) {
|
||||
if ($_SESSION['group_view'] == $dev_group['id']) {
|
||||
@@ -260,7 +248,7 @@ if (defined('SHOW_SETTINGS')) {
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
$temp_header[] = '<option value="'.$dev_group['id'].'" '.$selected.'>'.$dev_group['name'].'</option>';
|
||||
$temp_header[] = '<option value="' . $dev_group['id'] . '" ' . $selected . '>' . $dev_group['name'] . '</option>';
|
||||
}
|
||||
$temp_header[] = '</select>';
|
||||
}
|
||||
@@ -276,21 +264,21 @@ if (defined('SHOW_SETTINGS')) {
|
||||
|
||||
if ($mode == 0 || $mode == 2) {
|
||||
$temp_header[] = '
|
||||
<div class="'.$deviceClass.'">
|
||||
<div class="' . $deviceClass . '">
|
||||
<span>Total hosts</span>
|
||||
<span class="label label-success label-font-border label-border">up: '.$host_up_count.'</span>
|
||||
<span class="label label-warning label-font-border label-border">warn: '.$host_warn_count.'</span>
|
||||
<span class="label label-danger label-font-border label-border">down: '.$host_down_count.'</span>
|
||||
<span class="label label-success label-font-border label-border">up: ' . $host_up_count . '</span>
|
||||
<span class="label label-warning label-font-border label-border">warn: ' . $host_warn_count . '</span>
|
||||
<span class="label label-danger label-font-border label-border">down: ' . $host_down_count . '</span>
|
||||
</div>';
|
||||
}
|
||||
|
||||
if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) {
|
||||
$temp_header[] = '
|
||||
<div class="'.$serviceClass.'">
|
||||
<div class="' . $serviceClass . '">
|
||||
<span>Total services</span>
|
||||
<span class="label label-success label-font-border label-border">up: '.$service_up_count.'</span>
|
||||
<span class="label label-warning label-font-border label-border">warn: '.$service_warn_count.'</span>
|
||||
<span class="label label-danger label-font-border label-border">down: '.$service_down_count.'</span>
|
||||
<span class="label label-success label-font-border label-border">up: ' . $service_up_count . '</span>
|
||||
<span class="label label-warning label-font-border label-border">warn: ' . $service_warn_count . '</span>
|
||||
<span class="label label-danger label-font-border label-border">down: ' . $service_down_count . '</span>
|
||||
</div>';
|
||||
}
|
||||
|
||||
|
@@ -1219,6 +1219,11 @@ function generate_dynamic_config_panel($title, $config_groups, $items = array(),
|
||||
<input id="'.$item['name'].'" class="form-control" type="text" name="global-config-input" value="'.$config_groups[$item['name']]['config_value'].'" data-config_id="'.$config_groups[$item['name']]['config_id'].'">
|
||||
<span class="form-control-feedback"><i class="fa" aria-hidden="true"></i></span>
|
||||
';
|
||||
} elseif ($item['type'] == 'numeric') {
|
||||
$output .= '
|
||||
<input id="'.$item['name'].'" class="form-control" onkeypress="return (event.charCode == 8 || event.charCode == 0) ? null : event.charCode >= 48 && event.charCode <= 57" type="text" name="global-config-input" value="'.$config_groups[$item['name']]['config_value'].'" data-config_id="'.$config_groups[$item['name']]['config_id'].'">
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
';
|
||||
} elseif ($item['type'] == 'select') {
|
||||
$output .= '
|
||||
<select id="'.$config_groups[$item['name']]['name'].'" class="form-control" name="global-config-select" data-config_id="'.$config_groups[$item['name']]['config_id'].'">
|
||||
|
@@ -19,8 +19,8 @@ $graph_conf = array(
|
||||
);
|
||||
|
||||
$availability_map_conf = array(
|
||||
array('name' => 'webui.old_availability_map',
|
||||
'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',
|
||||
@@ -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(
|
||||
|
Reference in New Issue
Block a user