mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
webui: availability map update (#4300)
* a-map update 3 * pre-commit.php fixes * moved group query inside if
This commit is contained in:
@@ -1,7 +1,17 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (isset($_REQUEST['mapView'])) {
|
||||
$_SESSION['mapView'] = $_REQUEST['mapView'];
|
||||
//availability-map mode view
|
||||
if (isset($_REQUEST['map_view'])) {
|
||||
$_SESSION['map_view'] = $_REQUEST['map_view'];
|
||||
$map_view = array('map_view' => $_SESSION['map_view']);
|
||||
header('Content-type: text/plain');
|
||||
echo json_encode($map_view);
|
||||
}
|
||||
|
||||
//availability-map device group view
|
||||
if (isset($_REQUEST['group_view'])) {
|
||||
$_SESSION['group_view'] = $_REQUEST['group_view'];
|
||||
$group_view = array('group_view' => $_SESSION['group_view']);
|
||||
header('Content-type: text/plain');
|
||||
echo json_encode($group_view);
|
||||
}
|
||||
header('Content-type: text/plain');
|
||||
echo $_SESSION['mapView'];
|
||||
|
@@ -480,18 +480,15 @@ a.list-device-disabled, a.list-device-disabled:visited {
|
||||
border-radius: 2pt 2pt 2pt 2pt;
|
||||
}
|
||||
|
||||
.status-boxes {
|
||||
}
|
||||
|
||||
.boxes {
|
||||
vertical-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.box {
|
||||
width: 500px;
|
||||
height: 300px;
|
||||
padding: 0px;
|
||||
vertical-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.top10 {
|
||||
@@ -1084,10 +1081,10 @@ a.interface-upup:hover, a.interface-updown:hover, a.interface-admindown:hover {
|
||||
|
||||
/* Gradient background */
|
||||
background:#EEF7F7;
|
||||
# background: -moz-linear-gradient(top, #FFF, #DEEFEF);
|
||||
# background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FBFBFB), to(#DEEFEF));
|
||||
# background: -ms-linear-gradient(top, #FBFBFB, #DEEFEF);
|
||||
# background: -webkit-linear-gradient(top, #FBFBFB, #DEEFEF);
|
||||
/* background: -moz-linear-gradient(top, #FFF, #DEEFEF);
|
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FBFBFB), to(#DEEFEF));
|
||||
background: -ms-linear-gradient(top, #FBFBFB, #DEEFEF);
|
||||
background: -webkit-linear-gradient(top, #FBFBFB, #DEEFEF); */
|
||||
|
||||
/* Rounded Corners */
|
||||
-moz-border-radius: 0px 4px 4px 4px;
|
||||
@@ -1417,7 +1414,7 @@ a.interface-upup:hover, a.interface-updown:hover, a.interface-admindown:hover {
|
||||
}
|
||||
|
||||
.tabBox .tabcontent {
|
||||
margin-top -2px;
|
||||
margin-top: -2px;
|
||||
min-height: 600px;
|
||||
clear: left;
|
||||
position: relative;
|
||||
@@ -1682,7 +1679,7 @@ tr.search:nth-child(odd) {
|
||||
.gridster .gs-w {
|
||||
background: #ffffff;
|
||||
box-shadow: inset 0 0 2px #000;
|
||||
color: 000000
|
||||
color: #000000;
|
||||
cursor: pointer;
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
@@ -1836,7 +1833,7 @@ label {
|
||||
}
|
||||
|
||||
.redCluster {
|
||||
background-color: rgba(255,0,0);
|
||||
background-color: rgba(255,0,0, 0);
|
||||
background-color: rgba(255,0,0,0.7);
|
||||
text-align: center;
|
||||
width: 25px !important;
|
||||
@@ -1846,7 +1843,7 @@ label {
|
||||
}
|
||||
|
||||
.greenCluster {
|
||||
background-color: rgba(0,255,0);
|
||||
background-color: rgba(0,255,0, 0);
|
||||
background-color: rgba(110, 204, 57, 0.6);
|
||||
text-align: center;
|
||||
width: 25px !important;
|
||||
@@ -1875,7 +1872,7 @@ label {
|
||||
.device-availability, .service-availability {
|
||||
color:#000000;
|
||||
float:left;
|
||||
width:166px;
|
||||
width:125px;
|
||||
height:64px;
|
||||
margin:10px;
|
||||
padding:8px;
|
||||
|
@@ -70,8 +70,8 @@ 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']);
|
||||
|
||||
if (isset($_SESSION["mapView"])) {
|
||||
$mode = $_SESSION["mapView"];
|
||||
if (isset($_SESSION["map_view"])) {
|
||||
$mode = $_SESSION["map_view"];
|
||||
} else {
|
||||
$mode = $widget_mode->{'mode'};
|
||||
}
|
||||
@@ -93,7 +93,16 @@ if (defined('SHOW_SETTINGS')) {
|
||||
|
||||
if ($mode == 0 || $mode == 2) {
|
||||
// Only show devices if mode is 0 or 2 (Only Devices or both)
|
||||
$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(
|
||||
@@ -102,7 +111,13 @@ if (defined('SHOW_SETTINGS')) {
|
||||
} else {
|
||||
$sql .= ' WHERE';
|
||||
}
|
||||
$sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `".$deviceOrderBy."`";
|
||||
|
||||
if ($config['webui']['availability_map_use_device_groups'] != 0) {
|
||||
$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) {
|
||||
@@ -220,6 +235,32 @@ if (defined('SHOW_SETTINGS')) {
|
||||
'</select>
|
||||
</div>
|
||||
<div class="page-availability-title-right">';
|
||||
|
||||
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[] = '
|
||||
<span class="page-availability-title">Device group</span>
|
||||
<select id="group" class="page-availability-report-select" name="group">
|
||||
<option value="0" '.$selected.'>select device group</option>';
|
||||
|
||||
foreach ($dev_groups as $dev_group) {
|
||||
if ($_SESSION['group_view'] == $dev_group['id']) {
|
||||
$selected = 'selected';
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
$temp_header[] = '<option value="'.$dev_group['id'].'" '.$selected.'>'.$dev_group['name'].'</option>';
|
||||
}
|
||||
$temp_header[] = '</select>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($directpage == "yes") {
|
||||
|
@@ -224,11 +224,11 @@ $(document).on("click", '.collapse-neighbors', function(event)
|
||||
continued.toggle();
|
||||
});
|
||||
|
||||
|
||||
//availability-map mode change
|
||||
$(document).on("change", '#mode', function() {
|
||||
$.post('ajax_mapview.php',
|
||||
{
|
||||
mapView: $(this).val()
|
||||
map_view: $(this).val()
|
||||
},
|
||||
function(data) {
|
||||
location.reload();
|
||||
@@ -236,6 +236,18 @@ $(document).on("change", '#mode', function() {
|
||||
);
|
||||
});
|
||||
|
||||
//availability-map device group
|
||||
$(document).on("change", '#group', function() {
|
||||
$.post('ajax_mapview.php',
|
||||
{
|
||||
group_view: $(this).val()
|
||||
},
|
||||
function(data){
|
||||
location.reload();
|
||||
},'json'
|
||||
);
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
var lines = 'on';
|
||||
$("#linenumbers").button().click(function() {
|
||||
|
@@ -24,8 +24,12 @@ $availability_map_conf = array(
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array('name' => 'webui.availability_map_sort_status',
|
||||
'descr' => 'Sort devices by status',
|
||||
'type' => 'checkbox',
|
||||
'descr' => 'Sort devices by status',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array('name' => 'webui.availability_map_use_device_groups',
|
||||
'descr' => 'Use device groups filter',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
);
|
||||
|
||||
|
1
sql-schema/132.sql
Normal file
1
sql-schema/132.sql
Normal file
@@ -0,0 +1 @@
|
||||
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_use_device_groups', 'false', 'false', 'Use device groups filter', 'webui', 0, 'graph', 0, '0', '0');
|
Reference in New Issue
Block a user