mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
webui: Updated devices view (#4700)
This commit is contained in:
@@ -2057,3 +2057,75 @@ label {
|
||||
padding-top: 15px !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* devices layout modifications */
|
||||
.devices-font-bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.devices-float-right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.devices-graphs-select {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.devices-search-header {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.devices-input-small {
|
||||
line-height: 14px;
|
||||
}
|
||||
|
||||
.devices-status-box-detail {
|
||||
line-height: 16px;
|
||||
margin-left: 5px;
|
||||
font-size: 14px;
|
||||
width: 80px;
|
||||
display: block;
|
||||
height: 24px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.devices-status-box-basic {
|
||||
margin-left: 5px;
|
||||
width: 70px;
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.devices-headers-table-menu {
|
||||
padding: 0;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.devices-overlib-box {
|
||||
display: block;
|
||||
padding: 1px;
|
||||
margin: 2px;
|
||||
min-height: 170px;
|
||||
max-height: 170px;
|
||||
text-align: center;
|
||||
float: left;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.device-table-header-status {
|
||||
width: 100px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.device-table-header-vendor {
|
||||
width: 100px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.device-table-icon {
|
||||
text-align: center;
|
||||
display: block;
|
||||
width: 70px;
|
||||
}
|
||||
@@ -6,8 +6,8 @@ $param = array();
|
||||
$sql = ' FROM `devices`';
|
||||
|
||||
if (is_admin() === false && is_read() === false) {
|
||||
$sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`';
|
||||
$where .= ' AND `DP`.`user_id`=?';
|
||||
$sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`';
|
||||
$where .= ' AND `DP`.`user_id`=?';
|
||||
$param[] = $_SESSION['user_id'];
|
||||
}
|
||||
|
||||
@@ -18,36 +18,36 @@ if (!empty($_POST['location'])) {
|
||||
$sql .= " WHERE $where ";
|
||||
|
||||
if (!empty($_POST['hostname'])) {
|
||||
$sql .= ' AND hostname LIKE ?';
|
||||
$param[] = '%'.$_POST['hostname'].'%';
|
||||
$sql .= ' AND hostname LIKE ?';
|
||||
$param[] = '%' . $_POST['hostname'] . '%';
|
||||
}
|
||||
|
||||
if (!empty($_POST['os'])) {
|
||||
$sql .= ' AND os = ?';
|
||||
$sql .= ' AND os = ?';
|
||||
$param[] = $_POST['os'];
|
||||
}
|
||||
|
||||
if (!empty($_POST['version'])) {
|
||||
$sql .= ' AND version = ?';
|
||||
$sql .= ' AND version = ?';
|
||||
$param[] = $_POST['version'];
|
||||
}
|
||||
|
||||
if (!empty($_POST['hardware'])) {
|
||||
$sql .= ' AND hardware = ?';
|
||||
$sql .= ' AND hardware = ?';
|
||||
$param[] = $_POST['hardware'];
|
||||
}
|
||||
|
||||
if (!empty($_POST['features'])) {
|
||||
$sql .= ' AND features = ?';
|
||||
$sql .= ' AND features = ?';
|
||||
$param[] = $_POST['features'];
|
||||
}
|
||||
|
||||
if (!empty($_POST['type'])) {
|
||||
if ($_POST['type'] == 'generic') {
|
||||
$sql .= " AND ( type = ? OR type = '')";
|
||||
$sql .= " AND ( type = ? OR type = '')";
|
||||
$param[] = $_POST['type'];
|
||||
} else {
|
||||
$sql .= ' AND type = ?';
|
||||
$sql .= ' AND type = ?';
|
||||
$param[] = $_POST['type'];
|
||||
}
|
||||
}
|
||||
@@ -62,12 +62,12 @@ if (!empty($_POST['state'])) {
|
||||
}
|
||||
|
||||
if (!empty($_POST['disabled'])) {
|
||||
$sql .= ' AND disabled= ?';
|
||||
$sql .= ' AND disabled= ?';
|
||||
$param[] = $_POST['disabled'];
|
||||
}
|
||||
|
||||
if (!empty($_POST['ignore'])) {
|
||||
$sql .= ' AND `ignore`= ?';
|
||||
$sql .= ' AND `ignore`= ?';
|
||||
$param[] = $_POST['ignore'];
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ if (!empty($_POST['location']) && $_POST['location'] == 'Unset') {
|
||||
}
|
||||
|
||||
if (!empty($_POST['location'])) {
|
||||
$sql .= " AND `location` = ?";
|
||||
$sql .= " AND `location` = ?";
|
||||
$param[] = $_POST['location'];
|
||||
}
|
||||
|
||||
@@ -84,11 +84,11 @@ if (!empty($_POST['group'])) {
|
||||
include_once '../includes/device-groups.inc.php';
|
||||
$sql .= ' AND ( ';
|
||||
foreach (GetDevicesFromGroup($_POST['group']) as $dev) {
|
||||
$sql .= '`devices`.`device_id` = ? OR ';
|
||||
$sql .= '`devices`.`device_id` = ? OR ';
|
||||
$param[] = $dev;
|
||||
}
|
||||
|
||||
$sql = substr($sql, 0, (strlen($sql) - 3));
|
||||
$sql = substr($sql, 0, (strlen($sql) - 3));
|
||||
$sql .= ' )';
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ if (!isset($sort) || empty($sort)) {
|
||||
$sql .= " ORDER BY $sort";
|
||||
|
||||
if (isset($current)) {
|
||||
$limit_low = (($current * $rowCount) - ($rowCount));
|
||||
$limit_low = (($current * $rowCount) - ($rowCount));
|
||||
$limit_high = $rowCount;
|
||||
}
|
||||
|
||||
@@ -131,27 +131,28 @@ foreach (dbFetchRows($sql, $param) as $device) {
|
||||
|
||||
if ($device['status'] == '0') {
|
||||
$extra = 'danger';
|
||||
$msg = $device['status_reason'];
|
||||
$msg = $device['status_reason'];
|
||||
} else {
|
||||
$extra = 'success';
|
||||
$msg = 'up';
|
||||
$msg = 'up';
|
||||
}
|
||||
|
||||
if ($device['ignore'] == '1') {
|
||||
$extra = 'default';
|
||||
$msg = 'ignored';
|
||||
$msg = 'ignored';
|
||||
if ($device['status'] == '1') {
|
||||
$extra = 'warning';
|
||||
$msg = 'ignored';
|
||||
$msg = 'ignored';
|
||||
}
|
||||
}
|
||||
|
||||
if ($device['disabled'] == '1') {
|
||||
$extra = 'default';
|
||||
$msg = 'disabled';
|
||||
$msg = 'disabled';
|
||||
}
|
||||
|
||||
$type = strtolower($device['os']);
|
||||
$type = strtolower($device['os']);
|
||||
|
||||
$image = getImage($device);
|
||||
|
||||
if ($device['os'] == 'ios') {
|
||||
@@ -159,78 +160,80 @@ foreach (dbFetchRows($sql, $param) as $device) {
|
||||
}
|
||||
|
||||
$device['os_text'] = $config['os'][$device['os']]['text'];
|
||||
$port_count = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?', array($device['device_id']));
|
||||
$sensor_count = dbFetchCell('SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?', array($device['device_id']));
|
||||
$port_count = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?', array($device['device_id']));
|
||||
$sensor_count = dbFetchCell('SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?', array($device['device_id']));
|
||||
|
||||
$actions = '
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-xs-1"><a href="' . generate_device_url($device) . '"> <img src="images/16/server.png" border="0" align="absmiddle" alt="View device" title="View device"></a></div>
|
||||
<div class="col-xs-1"><a href="' . generate_device_url($device, array('tab' => 'alerts')) . '"> <img src="images/16/bell.png" border="0" align="absmiddle" alt="View alerts" title="View alerts"></a></div>
|
||||
';
|
||||
|
||||
$actions = ('<div class="container-fluid"><div class="row">
|
||||
<div class="col-xs-1">');
|
||||
$actions .= '<a href="'.generate_device_url($device).'"> <img src="images/16/server.png" border="0" align="absmiddle" alt="View device" title="View device" /></a> ';
|
||||
$actions .= ('</div>
|
||||
<div class="col-xs-1">');
|
||||
$actions .= '<a href="'.generate_device_url($device, array('tab' => 'alerts')).'"> <img src="images/16/bell.png" border="0" align="absmiddle" alt="View alerts" title="View alerts" /></a> ';
|
||||
$actions .= '</div>';
|
||||
if ($_SESSION['userlevel'] >= '7') {
|
||||
$actions .= ('<div class="col-xs-1">
|
||||
<a href="'.generate_device_url($device, array('tab' => 'edit')).'"> <img src="images/16/wrench.png" border="0" align="absmiddle" alt="Edit device" title="Edit device" /></a>
|
||||
</div>');
|
||||
$actions .= '<div class="col-xs-1"><a href="' . generate_device_url($device, array('tab' => 'edit')) . '"> <img src="images/16/wrench.png" border="0" align="absmiddle" alt="Edit device" title="Edit device"></a></div>';
|
||||
}
|
||||
|
||||
$actions .= ('</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-1">
|
||||
<a href="telnet://'.$device['hostname'].'"><img src="images/16/telnet.png" alt="telnet" title="Telnet to '.$device['hostname'].'" border="0" width="16" height="16"></a>
|
||||
</div>
|
||||
<div class="col-xs-1">
|
||||
<a href="ssh://'.$device['hostname'].'"><img src="images/16/ssh.png" alt="ssh" title="SSH to '.$device['hostname'].'" border="0" width="16" height="16"></a>
|
||||
</div>
|
||||
<div class="col-xs-1">
|
||||
<a href="https://'.$device['hostname'].'"><img src="images/16/http.png" alt="https" title="Launch browser https://'.$device['hostname'].'" border="0" width="16" height="16" target="_blank"></a>
|
||||
</div>
|
||||
</div></div>');
|
||||
if ($subformat == 'detail') {
|
||||
$actions .= '</div><div class="row">';
|
||||
}
|
||||
|
||||
$actions .= '
|
||||
<div class="col-xs-1"><a href="telnet://' . $device['hostname'] . '"><img src="images/16/telnet.png" alt="telnet" title="Telnet to ' . $device['hostname'] . '" border="0" width="16" height="16"></a></div>
|
||||
<div class="col-xs-1"><a href="ssh://' . $device['hostname'] . '"><img src="images/16/ssh.png" alt="ssh" title="SSH to ' . $device['hostname'] . '" border="0" width="16" height="16"></a></div>
|
||||
<div class="col-xs-1"><a href="https://' . $device['hostname'] . '"><img src="images/16/http.png" alt="https" title="Launch browser https://' . $device['hostname'] . '" border="0" width="16" height="16" target="_blank"></a></div>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
$hostname = generate_device_link($device);
|
||||
$platform = $device['hardware'].'<br />'.$device['features'];
|
||||
$os = $device['os_text'].'<br />'.$device['version'];
|
||||
|
||||
if (extension_loaded('mbstring')) {
|
||||
$location = mb_substr($device['location'], 0, 32, 'utf8');
|
||||
} else {
|
||||
$location = truncate($device['location'], 32, '');
|
||||
}
|
||||
|
||||
$uptime = formatUptime($device['uptime'], 'short').'<br />'.$location;
|
||||
if ($subformat == 'detail') {
|
||||
$hostname .= '<br />'.$device['sysName'];
|
||||
$platform = $device['hardware'] . '<br>' . $device['features'];
|
||||
$os = $device['os_text'] . '<br>' . $device['version'];
|
||||
$uptime = formatUptime($device['uptime'], 'short');
|
||||
$hostname .= '<br>' . $device['sysName'];
|
||||
if (empty($port_count)) {
|
||||
$port_count = 0;
|
||||
$col_port = '';
|
||||
}
|
||||
if ($port_count) {
|
||||
$col_port = ' <img src="images/icons/port.png" align=absmiddle /> '.$port_count.'<br />';
|
||||
$col_port = '<img src="images/icons/port.png" align="absmiddle"> ' . $port_count . '<br>';
|
||||
}
|
||||
|
||||
if ($sensor_count) {
|
||||
$col_port .= ' <img src="images/icons/sensors.png" align=absmiddle /> '.$sensor_count;
|
||||
$col_port .= '<img src="images/icons/sensors.png" align="absmiddle"> ' . $sensor_count;
|
||||
}
|
||||
} else {
|
||||
$platform = $device['hardware'];
|
||||
$os = $device['os_text'] . ' ' . $device['version'];
|
||||
$uptime = formatUptime($device['uptime'], 'short');
|
||||
}
|
||||
|
||||
$response[] = array(
|
||||
'extra' => $extra,
|
||||
'msg' => $msg,
|
||||
'icon' => $image,
|
||||
'extra' => $extra,
|
||||
'msg' => $msg,
|
||||
'list_type' => $subformat,
|
||||
'icon' => $image,
|
||||
'hostname' => $hostname,
|
||||
'ports' => $col_port,
|
||||
'ports' => $col_port,
|
||||
'hardware' => $platform,
|
||||
'os' => $os,
|
||||
'uptime' => $uptime,
|
||||
'actions' => $actions,
|
||||
'os' => $os,
|
||||
'uptime' => $uptime,
|
||||
'location' => $location,
|
||||
'actions' => $actions,
|
||||
);
|
||||
}//end foreach
|
||||
|
||||
$output = array(
|
||||
'current' => $current,
|
||||
'current' => $current,
|
||||
'rowCount' => $rowCount,
|
||||
'rows' => $response,
|
||||
'total' => $total,
|
||||
'rows' => $response,
|
||||
'total' => $total,
|
||||
);
|
||||
echo _json_encode($output);
|
||||
|
||||
@@ -10,96 +10,83 @@ $pagetitle[] = "Devices";
|
||||
|
||||
print_optionbar_start();
|
||||
|
||||
echo('<span style="font-weight: bold;">Lists</span> » ');
|
||||
echo '<span class="devices-font-bold">Lists: </span>';
|
||||
|
||||
$menu_options = array('basic' => 'Basic', 'detail' => 'Detail');
|
||||
|
||||
$sep = "";
|
||||
foreach ($menu_options as $option => $text) {
|
||||
echo($sep);
|
||||
if ($vars['format'] == "list_".$option) {
|
||||
echo("<span class='pagemenu-selected'>");
|
||||
if ($vars['format'] == "list_" . $option) {
|
||||
echo '<span class="pagemenu-selected">';
|
||||
}
|
||||
echo('<a href="' . generate_url($vars, array('format' => "list_".$option)) . '">' . $text . '</a>');
|
||||
if ($vars['format'] == "list_".$option) {
|
||||
echo("</span>");
|
||||
echo '<a href="' . generate_url($vars, array('format' => "list_" . $option)) . '">' . $text . '</a>';
|
||||
if ($vars['format'] == "list_" . $option) {
|
||||
echo '</span>';
|
||||
}
|
||||
$sep = " | ";
|
||||
}
|
||||
|
||||
?>
|
||||
echo ' | <span class="devices-font-bold">Graphs: </span>';
|
||||
|
||||
|
|
||||
|
||||
<span style="font-weight: bold;">Graphs</span> »
|
||||
|
||||
<?php
|
||||
|
||||
$menu_options = array('bits' => 'Bits',
|
||||
'processor' => 'CPU',
|
||||
'ucd_load' => 'Load',
|
||||
'mempool' => 'Memory',
|
||||
'uptime' => 'Uptime',
|
||||
'storage' => 'Storage',
|
||||
'diskio' => 'Disk I/O',
|
||||
$menu_options = array('bits' => 'Bits',
|
||||
'processor' => 'CPU',
|
||||
'ucd_load' => 'Load',
|
||||
'mempool' => 'Memory',
|
||||
'uptime' => 'Uptime',
|
||||
'storage' => 'Storage',
|
||||
'diskio' => 'Disk I/O',
|
||||
'poller_perf' => 'Poller',
|
||||
'ping_perf' => 'Ping',
|
||||
'ping_perf' => 'Ping',
|
||||
'temperature' => 'Temperature'
|
||||
);
|
||||
$sep = "";
|
||||
foreach ($menu_options as $option => $text) {
|
||||
echo($sep);
|
||||
if ($vars['format'] == 'graph_'.$option) {
|
||||
echo("<span class='pagemenu-selected'>");
|
||||
echo $sep;
|
||||
if ($vars['format'] == 'graph_' . $option) {
|
||||
echo '<span class="pagemenu-selected">';
|
||||
}
|
||||
echo('<a href="' . generate_url($vars, array('format' => 'graph_'.$option, 'from' => '-24h', 'to' => 'now')) . '">' . $text . '</a>');
|
||||
if ($vars['format'] == 'graph_'.$option) {
|
||||
echo("</span>");
|
||||
echo '<a href="' . generate_url($vars, array('format' => 'graph_' . $option, 'from' => '-24h', 'to' => 'now')) . '">' . $text . '</a>';
|
||||
if ($vars['format'] == 'graph_' . $option) {
|
||||
echo '</span>';
|
||||
}
|
||||
$sep = " | ";
|
||||
}
|
||||
|
||||
?>
|
||||
echo '<div class="devices-float-right">';
|
||||
|
||||
<div style="float: right;">
|
||||
|
||||
<select name='type' id='type'
|
||||
onchange="window.open(this.options[this.selectedIndex].value,'_top')" >
|
||||
<?php
|
||||
$type = 'device';
|
||||
$graphs_types = '<select name="type" id="type" onchange="window.open(this.options[this.selectedIndex].value,\'_top\')" class="devices-graphs-select">';
|
||||
$type = 'device';
|
||||
foreach (get_graph_subtypes($type) as $avail_type) {
|
||||
echo("<option value='".generate_url($vars, array('format' => 'graph_'.$avail_type))."'");
|
||||
if ('graph_'.$avail_type == $vars['format']) {
|
||||
echo(" selected");
|
||||
}
|
||||
$display_type = is_mib_graph($type, $avail_type) ? $avail_type : nicecase($avail_type);
|
||||
echo(">$display_type</option>");
|
||||
if ('graph_' . $avail_type == $vars['format']) {
|
||||
$is_selected = 'selected';
|
||||
} else {
|
||||
$is_selected = '';
|
||||
}
|
||||
$graphs_types .= '<option value="' . generate_url($vars, array('format' => 'graph_' . $avail_type)) . '" ' . $is_selected . '>' . $display_type . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
$graphs_types .= '</select>';
|
||||
|
||||
<?php
|
||||
echo $graphs_types;
|
||||
|
||||
if (isset($vars['searchbar']) && $vars['searchbar'] == "hide") {
|
||||
echo('<a href="'. generate_url($vars, array('searchbar' => '')).'">Restore Search</a>');
|
||||
echo('<a href="' . generate_url($vars, array('searchbar' => '')) . '">Restore Search</a>');
|
||||
} else {
|
||||
echo('<a href="'. generate_url($vars, array('searchbar' => 'hide')).'">Remove Search</a>');
|
||||
echo('<a href="' . generate_url($vars, array('searchbar' => 'hide')) . '">Remove Search</a>');
|
||||
}
|
||||
|
||||
echo(" | ");
|
||||
|
||||
if (isset($vars['bare']) && $vars['bare'] == "yes") {
|
||||
echo('<a href="'. generate_url($vars, array('bare' => '')).'">Restore Header</a>');
|
||||
echo('<a href="' . generate_url($vars, array('bare' => '')) . '">Restore Header</a>');
|
||||
} else {
|
||||
echo('<a href="'. generate_url($vars, array('bare' => 'yes')).'">Remove Header</a>');
|
||||
echo('<a href="' . generate_url($vars, array('bare' => 'yes')) . '">Remove Header</a>');
|
||||
}
|
||||
|
||||
print_optionbar_end();
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
echo '</div>';
|
||||
|
||||
list($format, $subformat) = explode("_", $vars['format'], 2);
|
||||
|
||||
@@ -141,7 +128,7 @@ if ($format == "graph") {
|
||||
|
||||
if (!empty($vars['hostname'])) {
|
||||
$where .= " AND hostname LIKE ?";
|
||||
$sql_param[] = "%".$vars['hostname']."%";
|
||||
$sql_param[] = "%" . $vars['hostname'] . "%";
|
||||
}
|
||||
if (!empty($vars['os'])) {
|
||||
$where .= " AND os = ?";
|
||||
@@ -196,7 +183,7 @@ if ($format == "graph") {
|
||||
$where .= "device_id = ? OR ";
|
||||
$sql_param[] = $dev;
|
||||
}
|
||||
$where = substr($where, 0, strlen($where)-3);
|
||||
$where = substr($where, 0, strlen($where) - 3);
|
||||
$where .= " )";
|
||||
}
|
||||
|
||||
@@ -210,7 +197,7 @@ if ($format == "graph") {
|
||||
|
||||
$row = 1;
|
||||
foreach (dbFetchRows($query, $sql_param) as $device) {
|
||||
if (is_integer($row/2)) {
|
||||
if (is_integer($row / 2)) {
|
||||
$row_colour = $list_colour_a;
|
||||
} else {
|
||||
$row_colour = $list_colour_b;
|
||||
@@ -218,31 +205,32 @@ if ($format == "graph") {
|
||||
|
||||
if (device_permitted($device['device_id'])) {
|
||||
if (!$location_filter || $device['location'] == $location_filter) {
|
||||
$graph_type = "device_".$subformat;
|
||||
$graph_type = "device_" . $subformat;
|
||||
|
||||
if ($_SESSION['widescreen']) {
|
||||
$width=270;
|
||||
$width = 270;
|
||||
} else {
|
||||
$width=315;
|
||||
$width = 315;
|
||||
}
|
||||
|
||||
$graph_array_new = array();
|
||||
$graph_array_new['type'] = $graph_type;
|
||||
$graph_array_new['device'] = $device['device_id'];
|
||||
$graph_array_new['height'] = '110';
|
||||
$graph_array_new['width'] = $width;
|
||||
$graph_array_new['legend'] = 'no';
|
||||
$graph_array_new['title'] = 'yes';
|
||||
$graph_array_new['from'] = $graph_array['from'];
|
||||
$graph_array_new['to'] = $graph_array['to'];
|
||||
$graph_array_new = array();
|
||||
$graph_array_new['type'] = $graph_type;
|
||||
$graph_array_new['device'] = $device['device_id'];
|
||||
$graph_array_new['height'] = '110';
|
||||
$graph_array_new['width'] = $width;
|
||||
$graph_array_new['legend'] = 'no';
|
||||
$graph_array_new['title'] = 'yes';
|
||||
$graph_array_new['from'] = $graph_array['from'];
|
||||
$graph_array_new['to'] = $graph_array['to'];
|
||||
|
||||
$graph_array_zoom = $graph_array_new;
|
||||
$graph_array_zoom = $graph_array_new;
|
||||
$graph_array_zoom['height'] = '150';
|
||||
$graph_array_zoom['width'] = '400';
|
||||
$graph_array_zoom['width'] = '400';
|
||||
$graph_array_zoom['legend'] = 'yes';
|
||||
|
||||
$overlib_link = "device/device=".$device['device_id']."/";
|
||||
echo "<div style='display: block; padding: 1px; margin: 2px; min-width: ".($width+90)."px; max-width:".($width+90)."px; min-height:170px; max-height:170px; text-align: center; float: left; background-color: #f5f5f5;'>";
|
||||
$overlib_link = "device/device=" . $device['device_id'] . "/";
|
||||
|
||||
echo '<div class="devices-overlib-box" style="min-width:' . ($width + 90) . '; max-width: ' . ($width + 90) . '">';
|
||||
echo '<div class="panel panel-default">';
|
||||
echo overlib_link($overlib_link, generate_lazy_graph_tag($graph_array_new), generate_graph_tag($graph_array_zoom), null);
|
||||
echo "</div></div>\n\n";
|
||||
@@ -250,224 +238,213 @@ if ($format == "graph") {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$os = "SELECT `os` FROM `devices` AS D WHERE 1 GROUP BY `os` ORDER BY `os`";
|
||||
$ver = "SELECT `version` FROM `devices` AS D WHERE 1 GROUP BY `version` ORDER BY `version`";
|
||||
$platform = "SELECT `hardware` FROM `devices` AS D WHERE 1 GROUP BY `hardware` ORDER BY `hardware`";
|
||||
$features = "SELECT `features` FROM `devices` AS D WHERE 1 GROUP BY `features` ORDER BY `features`";
|
||||
$types = "SELECT `type` FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`";
|
||||
} else {
|
||||
$os = "SELECT `os` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `os` ORDER BY `os`";
|
||||
$ver = "SELECT `version` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `version` ORDER BY `version`";
|
||||
$platform = "SELECT `hardware` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hardware` ORDER BY `hardware`";
|
||||
$features = "SELECT `features` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `features` ORDER BY `features`";
|
||||
$types = "SELECT `type` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `type` ORDER BY `type`";
|
||||
$param[] = $_SESSION['user_id'];
|
||||
}
|
||||
|
||||
<div class="panel panel-default panel-condensed">
|
||||
|
||||
$os_options = '<select name="os" id="os" class="form-control input-sm">';
|
||||
$os_options .= '<option value="">All OSes</option>';
|
||||
foreach (dbFetch($os, $param) as $data) {
|
||||
if ($data['os']) {
|
||||
$tmp_os = clean_bootgrid($data['os']);
|
||||
if ($tmp_os == $vars['os']) {
|
||||
$os_selected = 'selected';
|
||||
} else {
|
||||
$os_selected = '';
|
||||
}
|
||||
$os_options .= '<option value="' . $tmp_os . '" ' . $os_selected . '>' . $config['os'][$tmp_os]['text'] . '</option>';
|
||||
}
|
||||
}
|
||||
$os_options .= '<select>';
|
||||
|
||||
$ver_options = '<select name="version" id="version" class="form-control input-sm">';
|
||||
$ver_options .= '<option value="">All Versions</option>';
|
||||
foreach (dbFetch($ver, $param) as $data) {
|
||||
if ($data['version']) {
|
||||
$tmp_version = clean_bootgrid($data['version']);
|
||||
if ($tmp_version == $vars['version']) {
|
||||
$ver_selected = 'selected';
|
||||
} else {
|
||||
$ver_selected = '';
|
||||
}
|
||||
$ver_options .= '<option value="' . $tmp_version . '" ' . $ver_selected . '> ' . $tmp_version . '</option>';
|
||||
}
|
||||
}
|
||||
$ver_options .= '</select>';
|
||||
|
||||
$platform_options = '<select name="hardware" id="hardware" class="form-control input-sm">';
|
||||
$platform_options .= '<option value="">All Platforms</option>';
|
||||
foreach (dbFetch($platform, $param) as $data) {
|
||||
if ($data['hardware']) {
|
||||
$tmp_hardware = clean_bootgrid($data['hardware']);
|
||||
if ($tmp_hardware == $vars['hardware']) {
|
||||
$platform_selected = 'selected';
|
||||
} else {
|
||||
$platform_selected = '';
|
||||
}
|
||||
$platform_options .= '<option value="' . $tmp_hardware . '" ' . $platform_selected . '>' . $tmp_hardware . '</option>';
|
||||
}
|
||||
}
|
||||
$platform_options .= '</select>';
|
||||
|
||||
|
||||
$features_options = '<select name="features" id="features" class="form-control input-sm">';
|
||||
$features_options .= '<option value="">All Featuresets</option>';
|
||||
foreach (dbFetch($features, $param) as $data) {
|
||||
if ($data['features']) {
|
||||
$tmp_features = clean_bootgrid($data['features']);
|
||||
if ($tmp_features == $vars['features']) {
|
||||
$feature_selected = 'selected';
|
||||
} else {
|
||||
$feature_selected = '';
|
||||
}
|
||||
$features_options .= '<option value="' . $tmp_features . '" ' . $feature_selected . '>' . $tmp_features . '</option>';
|
||||
}
|
||||
}
|
||||
$features_options .= '</select>';
|
||||
|
||||
$locations_options = '<select name="location" id="location" class="form-control input-sm">';
|
||||
$locations_options .= '<option value="">All Locations</option>';
|
||||
foreach (getlocations() as $location) {
|
||||
if ($location) {
|
||||
$location = clean_bootgrid($location);
|
||||
if ($location == $vars['location']) {
|
||||
$location_selected = 'selected';
|
||||
} else {
|
||||
$location_selected = '';
|
||||
}
|
||||
$locations_options .= '<option value="' . $location . '" ' . $location_selected . '>' . $location . '</option>';
|
||||
}
|
||||
}
|
||||
$locations_options .= '</select>';
|
||||
|
||||
$types_options = '<select name="type" id="type" class="form-control input-sm">';
|
||||
$types_options .= '<option value="">All Device Types</option>';
|
||||
foreach (dbFetch($types, $param) as $data) {
|
||||
if ($data['type']) {
|
||||
if ($data['type'] == $vars['type']) {
|
||||
$type_selected = 'selected';
|
||||
} else {
|
||||
$type_selected = '';
|
||||
}
|
||||
$types_options .= '<option value="' . $data['type'] . '" ' . $type_selected . '> ' . ucfirst($data['type']) . '</option>';
|
||||
}
|
||||
}
|
||||
$types_options .= '</select>';
|
||||
|
||||
if (isset($vars['searchbar']) && $vars['searchbar'] == "hide") {
|
||||
$searchbar = '';
|
||||
} else {
|
||||
$searchbar = '
|
||||
<div class="panel panel-default panel-condensed">
|
||||
<form method="post" action="" class="form-inline devices-search-header" role="form">
|
||||
<div class="form-group">
|
||||
<input type="text" name="hostname" id="hostname" value="' . $vars['hostname'] . '" class="form-control input-sm" placeholder="Hostname">
|
||||
</div>
|
||||
<div class="form-group">' . $os_options . '</div>
|
||||
<div class="form-group">' . $ver_options . '</div>
|
||||
<div class="form-group">' . $platform_options . '</div>
|
||||
<div class="form-group">' . $features_options . '</div>
|
||||
<div class="form-group">' . $locations_options . '</div>
|
||||
<div class="form-group">' . $types_options . '</div>
|
||||
<input type="submit" class="btn btn-default input-sm devices-input-small" value="Search">
|
||||
<a href="' . generate_url($vars) . '" title="Update the browser URL to reflect the search criteria." class="btn btn-default input-sm devices-input-small">Update URL</a>
|
||||
<a href="' . generate_url(array('page' => 'devices', 'section' => $vars['section'], 'bare' => $vars['bare'])) . '" title="Reset critera to default." class="btn btn-default input-sm devices-input-small">Reset</a>
|
||||
</form>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
|
||||
echo $searchbar;
|
||||
|
||||
echo '
|
||||
<div class="table-responsive">
|
||||
<table id="devices" class="table table-condensed table-hover">
|
||||
<table id="devices" class="table table-condensed table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="status" data-searchable="false" data-formatter="status">Status</th>
|
||||
<th data-column-id="icon" data-sortable="false" data-searchable="false">Vendor</th>
|
||||
<th data-column-id="hostname" data-order="asc">Device</th>
|
||||
<th data-column-id="ports" data-sortable="false" data-searchable="false"></th>
|
||||
<th data-column-id="status" data-searchable="false" data-formatter="status" data-header-css-class="device-table-header-status">Status</th>
|
||||
';
|
||||
|
||||
if ($subformat == "detail") {
|
||||
echo '<th data-column-id="icon" data-sortable="false" data-searchable="false" data-formatter="icon" data-header-css-class="device-table-header-vendor">Vendor</th>';
|
||||
}
|
||||
|
||||
echo '<th data-column-id="hostname" data-order="asc">Device</th>';
|
||||
|
||||
if ($subformat == "detail") {
|
||||
echo '<th data-column-id="ports" data-sortable="false" data-searchable="false">Metrics</th>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<th data-column-id="hardware">Platform</th>
|
||||
<th data-column-id="os">Operating System</th>
|
||||
<th data-column-id="uptime">Uptime/Location</th>
|
||||
<th data-column-id="uptime">Uptime</th>
|
||||
';
|
||||
|
||||
if ($subformat == "detail") {
|
||||
echo '<th data-column-id="location">Location</th>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<th data-column-id="actions" data-sortable="false" data-searchable="false">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
';
|
||||
|
||||
searchbar = "<div id=\"{{ctx.id}}\" class=\"{{css.header}}\"><div class=\"row\">"+
|
||||
"<div class=\"col-sm-9 actionBar\"><span class=\"pull-left\"><form method=\"post\" action=\"\" class=\"form-inline\" role=\"form\">"+
|
||||
"<span class=\"pull-left\"><div class=\"form-group\">"+
|
||||
"<input type=\"text\" name=\"hostname\" id=\"hostname\" value=\"<?php echo($vars['hostname']); ?>\" class=\"form-control input-sm\" placeholder=\"Hostname\"/>"+
|
||||
"</div>"+
|
||||
"<div class=\"form-group\">"+
|
||||
"<select name='os' id='os' class=\"form-control input-sm\">"+
|
||||
"<option value=''>All OSes</option>"+
|
||||
<?php
|
||||
?>
|
||||
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$sql = "SELECT `os` FROM `devices` AS D WHERE 1 GROUP BY `os` ORDER BY `os`";
|
||||
} else {
|
||||
$sql = "SELECT `os` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `os` ORDER BY `os`";
|
||||
$param[] = $_SESSION['user_id'];
|
||||
}
|
||||
foreach (dbFetch($sql, $param) as $data) {
|
||||
if ($data['os']) {
|
||||
$tmp_os = clean_bootgrid($data['os']);
|
||||
echo('"<option value=\"'.$tmp_os.'\""+');
|
||||
if ($tmp_os == $vars['os']) {
|
||||
echo('" selected "+');
|
||||
}
|
||||
echo('">'.$config['os'][$tmp_os]['text'].'</option>"+');
|
||||
}
|
||||
}
|
||||
?>
|
||||
"</select>"+
|
||||
"</div>"+
|
||||
"<div class=\"form-group\">"+
|
||||
"<select name='version' id='version' class=\"form-control input-sm\">"+
|
||||
"<option value=''>All Versions</option>"+
|
||||
<?php
|
||||
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$sql = "SELECT `version` FROM `devices` AS D WHERE 1 GROUP BY `version` ORDER BY `version`";
|
||||
} else {
|
||||
$sql = "SELECT `version` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `version` ORDER BY `version`";
|
||||
$param[] = $_SESSION['user_id'];
|
||||
}
|
||||
foreach (dbFetch($sql, $param) as $data) {
|
||||
if ($data['version']) {
|
||||
$tmp_version = clean_bootgrid($data['version']);
|
||||
echo('"<option value=\"'.$tmp_version.'\""+');
|
||||
if ($tmp_version == $vars['version']) {
|
||||
echo('" selected "+');
|
||||
}
|
||||
echo('">'.$tmp_version.'</option>"+');
|
||||
}
|
||||
}
|
||||
?>
|
||||
"</select>"+
|
||||
"</div>"+
|
||||
"<div class=\"form-group\">"+
|
||||
"<select name=\"hardware\" id=\"hardware\" class=\"form-control input-sm\">"+
|
||||
"<option value=\"\">All Platforms</option>"+
|
||||
<?php
|
||||
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$sql = "SELECT `hardware` FROM `devices` AS D WHERE 1 GROUP BY `hardware` ORDER BY `hardware`";
|
||||
} else {
|
||||
$sql = "SELECT `hardware` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hardware` ORDER BY `hardware`";
|
||||
$param[] = $_SESSION['user_id'];
|
||||
}
|
||||
foreach (dbFetch($sql, $param) as $data) {
|
||||
if ($data['hardware']) {
|
||||
$tmp_hardware = clean_bootgrid($data['hardware']);
|
||||
echo('"<option value=\"'.$tmp_hardware.'\""+');
|
||||
if ($tmp_hardware == $vars['hardware']) {
|
||||
echo('" selected"+');
|
||||
}
|
||||
echo('">'.$tmp_hardware.'</option>"+');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
"</select>"+
|
||||
"</div>"+
|
||||
"<div class=\"form-group\">"+
|
||||
"<select name=\"features\" id=\"features\" class=\"form-control input-sm\">"+
|
||||
"<option value=\"\">All Featuresets</option>"+
|
||||
<?php
|
||||
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$sql = "SELECT `features` FROM `devices` AS D WHERE 1 GROUP BY `features` ORDER BY `features`";
|
||||
} else {
|
||||
$sql = "SELECT `features` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `features` ORDER BY `features`";
|
||||
$param[] = $_SESSION['user_id'];
|
||||
}
|
||||
|
||||
foreach (dbFetch($sql, $param) as $data) {
|
||||
if ($data['features']) {
|
||||
$tmp_features = clean_bootgrid($data['features']);
|
||||
echo('"<option value=\"'.$tmp_features.'\""+');
|
||||
if ($tmp_features == $vars['features']) {
|
||||
echo('" selected"+');
|
||||
}
|
||||
echo('">'.$tmp_features.'</option>"+');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
"</select>"+
|
||||
"</div></span><span class=\"pull-left\">"+
|
||||
"<div class=\"form-group\">"+
|
||||
"<select name=\"location\" id=\"location\" class=\"form-control input-sm\">"+
|
||||
"<option value=\"\">All Locations</option>"+
|
||||
|
||||
<?php
|
||||
// fix me function?
|
||||
|
||||
foreach (getlocations() as $location) {
|
||||
if ($location) {
|
||||
$location = clean_bootgrid($location);
|
||||
echo('"<option value=\"'.$location.'\""+');
|
||||
if ($location == $vars['location']) {
|
||||
echo('" selected"+');
|
||||
}
|
||||
echo('">'.$location.'</option>"+');
|
||||
}
|
||||
}
|
||||
?>
|
||||
"</select>"+
|
||||
"</div>"+
|
||||
"<div class=\"form-group\">"+
|
||||
"<select name=\"type\" id=\"type\" class=\"form-control input-sm\">"+
|
||||
"<option value=\"\">All Device Types</option>"+
|
||||
<?php
|
||||
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$sql = "SELECT `type` FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`";
|
||||
} else {
|
||||
$sql = "SELECT `type` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `type` ORDER BY `type`";
|
||||
$param[] = $_SESSION['user_id'];
|
||||
}
|
||||
foreach (dbFetch($sql, $param) as $data) {
|
||||
if ($data['type']) {
|
||||
echo('"<option value=\"'.$data['type'].'\""+');
|
||||
if ($data['type'] == $vars['type']) {
|
||||
echo('" selected"+');
|
||||
}
|
||||
echo('">'.ucfirst($data['type']).'</option>"+');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
"</select>"+
|
||||
"</div>"+
|
||||
"<button type=\"submit\" class=\"btn btn-default input-sm\">Search</button>"+
|
||||
"<div class=\"form-group\">"+
|
||||
"<a href=\"<?php echo(generate_url($vars)); ?>\" title=\"Update the browser URL to reflect the search criteria.\" > Update URL</a> |"+
|
||||
"<a href=\"<?php echo(generate_url(array('page' => 'devices', 'section' => $vars['section'], 'bare' => $vars['bare']))); ?>\" title=\"Reset critera to default.\" > Reset</a>"+
|
||||
"</div>"+
|
||||
"</form></span></div>"+
|
||||
"<div class=\"col-sm-3 actionBar\"><p class=\"{{css.actions}}\"></p></div></div></div>"
|
||||
|
||||
<?php
|
||||
if (isset($vars['searchbar']) && $vars['searchbar'] == "hide") {
|
||||
echo "searchbar = ''";
|
||||
}
|
||||
?>
|
||||
|
||||
var grid = $("#devices").bootgrid({
|
||||
ajax: true,
|
||||
rowCount: [50,100,250,-1],
|
||||
columnSelection: false,
|
||||
formatters: {
|
||||
"status": function(column,row) {
|
||||
return "<h4><span class='label label-"+row.extra+" threeqtr-width'>" + row.msg + "</span></h4>";
|
||||
}
|
||||
},
|
||||
templates: {
|
||||
header: searchbar
|
||||
},
|
||||
post: function ()
|
||||
{
|
||||
return {
|
||||
id: "devices",
|
||||
format: '<?php echo mres($vars['format']); ?>',
|
||||
hostname: '<?php echo htmlspecialchars($vars['hostname']); ?>',
|
||||
os: '<?php echo mres($vars['os']); ?>',
|
||||
version: '<?php echo mres($vars['version']); ?>',
|
||||
hardware: '<?php echo mres($vars['hardware']); ?>',
|
||||
features: '<?php echo mres($vars['features']); ?>',
|
||||
location: '<?php echo mres($vars['location']); ?>',
|
||||
type: '<?php echo mres($vars['type']); ?>',
|
||||
state: '<?php echo mres($vars['state']); ?>',
|
||||
disabled: '<?php echo mres($vars['disabled']); ?>',
|
||||
ignore: '<?php echo mres($vars['ignore']); ?>',
|
||||
group: '<?php echo mres($vars['group']); ?>',
|
||||
};
|
||||
},
|
||||
url: "ajax_table.php"
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
<script>
|
||||
var grid = $("#devices").bootgrid({
|
||||
ajax: true,
|
||||
rowCount: [50, 100, 250, -1],
|
||||
columnSelection: true,
|
||||
formatters: {
|
||||
"status": function (column, row) {
|
||||
return "<span class=\"label label-" + row.extra + " devices-status-box-" + row.list_type + "\">" + row.msg + "</span>";
|
||||
},
|
||||
"icon": function (column, row) {
|
||||
return "<span class=\"device-table-icon\">" + row.icon + "</span>";
|
||||
}
|
||||
},
|
||||
templates: {
|
||||
header: "<div class=\"devices-headers-table-menu\"><p class=\"{{css.actions}}\"></p></div><div class=\"row\"></div>"
|
||||
|
||||
},
|
||||
post: function () {
|
||||
return {
|
||||
id: "devices",
|
||||
format: ' <?php echo mres($vars['format']); ?>',
|
||||
hostname: '<?php echo htmlspecialchars($vars['hostname']); ?>',
|
||||
os: '<?php echo mres($vars['os']); ?>',
|
||||
version: '<?php echo mres($vars['version']); ?>',
|
||||
hardware: '<?php echo mres($vars['hardware']); ?>',
|
||||
features: '<?php echo mres($vars['features']); ?>',
|
||||
location: '<?php echo mres($vars['location']); ?>',
|
||||
type: '<?php echo mres($vars['type']); ?>',
|
||||
state: '<?php echo mres($vars['state']); ?>',
|
||||
disabled: '<?php echo mres($vars['disabled']); ?>',
|
||||
ignore: '<?php echo mres($vars['ignore']); ?>',
|
||||
group: '<?php echo mres($vars['group']); ?>',
|
||||
};
|
||||
},
|
||||
url: "ajax_table.php"
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user