mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #761 from laf/bootgrid-devices
Updated the devices page to use bootgrid
This commit is contained in:
@@ -1605,3 +1605,8 @@ tr.search:nth-child(odd) {
|
||||
width: 90%;
|
||||
height: 600px;
|
||||
}
|
||||
|
||||
.75pc-width {
|
||||
display:block;
|
||||
width: 75%;
|
||||
}
|
||||
|
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
if ($bg == $list_colour_b) { $bg = $list_colour_a; } else { $bg = $list_colour_b; }
|
||||
|
||||
if ($device['status'] == '0')
|
||||
{
|
||||
$class = "bg-danger";
|
||||
} else {
|
||||
$class = "bg-primary";
|
||||
}
|
||||
if ($device['ignore'] == '1')
|
||||
{
|
||||
$class = "bg-warning";
|
||||
if ($device['status'] == '1')
|
||||
{
|
||||
$class = "bg-success";
|
||||
}
|
||||
}
|
||||
if ($device['disabled'] == '1')
|
||||
{
|
||||
$class = "bg-info";
|
||||
}
|
||||
|
||||
$type = strtolower($device['os']);
|
||||
|
||||
if ($device['os'] == "ios") { formatCiscoHardware($device, true); }
|
||||
$device['os_text'] = $config['os'][$device['os']]['text'];
|
||||
$image = getImage($device);
|
||||
|
||||
echo(' <tr>
|
||||
<td class="'. $class .' " '. $cell_click .'></td>
|
||||
<td '. $cell_click .'>' . $image . '</td>
|
||||
<td '. $cell_click .'><span style="font-size: 15px;">' . generate_device_link($device) . '</span></td>'
|
||||
);
|
||||
|
||||
echo('<td '. $cell_click .'>');
|
||||
if ($port_count) { echo(' <img src="images/icons/port.png" align=absmiddle /> '.$port_count); }
|
||||
echo('<br />');
|
||||
if ($sensor_count) { echo(' <img src="images/icons/sensors.png" align=absmiddle /> '.$sensor_count); }
|
||||
echo('</td>');
|
||||
echo(' <td '. $cell_click .'>' . $device['hardware'] . ' ' . $device['features'] . '</td>');
|
||||
echo(' <td '. $cell_click .'>' . $device['os_text'] . ' ' . $device['version'] . '</td>');
|
||||
echo(' <td '. $cell_click .'>' . formatUptime($device['uptime'], 'short') . ' <br />');
|
||||
|
||||
if (get_dev_attrib($device,'override_sysLocation_bool')) { $device['location'] = get_dev_attrib($device,'override_sysLocation_string'); }
|
||||
echo(' ' . truncate($device['location'],32, '') . '</td>');
|
||||
require 'hostbox-menu.inc.php';
|
||||
|
||||
echo(' </tr>');
|
||||
|
||||
?>
|
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (isset($bg) && $bg == $list_colour_b) { $bg = $list_colour_a; } else { $bg = $list_colour_b; }
|
||||
|
||||
if ($device['status'] == '0')
|
||||
{
|
||||
$class = "list-device-down";
|
||||
$table_tab_colour = "bg-danger";
|
||||
} else {
|
||||
$class = "list-device";
|
||||
$table_tab_colour = "bg-primary";
|
||||
}
|
||||
if ($device['ignore'] == '1')
|
||||
{
|
||||
$class = "list-device-ignored";
|
||||
$table_tab_colour = "bg-warning";
|
||||
if ($device['status'] == '1')
|
||||
{
|
||||
$class = "list-device-ignored-up";
|
||||
$table_tab_colour = "bg-success";
|
||||
}
|
||||
}
|
||||
if ($device['disabled'] == '1')
|
||||
{
|
||||
$class = "list-device-disabled";
|
||||
$table_tab_colour = "bg-info";
|
||||
}
|
||||
|
||||
$type = strtolower($device['os']);
|
||||
|
||||
$image = getImage($device);
|
||||
if ($device['os'] == "ios") { formatCiscoHardware($device, true); }
|
||||
$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']));
|
||||
|
||||
echo(' <tr>
|
||||
<td class="'. $table_tab_colour .' '. $cell_click .'"></td>
|
||||
<td '. $cell_click .'>' . $image . '</td>
|
||||
<td '. $cell_click .'><span style="font-size: 15px;">' . generate_device_link($device) . '</span>
|
||||
<br />' . $device['sysName'] . '</td>'
|
||||
);
|
||||
|
||||
echo('<td '. $cell_click .'>');
|
||||
if ($port_count) { echo(' <img src="images/icons/port.png" align=absmiddle /> '.$port_count); }
|
||||
echo('<br />');
|
||||
if ($sensor_count) { echo(' <img src="images/icons/sensors.png" align=absmiddle /> '.$sensor_count); }
|
||||
echo('</td>');
|
||||
echo(' <td '. $cell_click .'>' . $device['hardware'] . '<br />' . $device['features'] . '</td>');
|
||||
echo(' <td '. $cell_click .'>' . $device['os_text'] . '<br />' . $device['version'] . '</td>');
|
||||
echo(' <td '. $cell_click .'>' . formatUptime($device['uptime'], 'short') . ' <br />');
|
||||
|
||||
if (get_dev_attrib($device,'override_sysLocation_bool')) { $device['location'] = get_dev_attrib($device,'override_sysLocation_string'); }
|
||||
echo(' ' . truncate($device['location'],32, '') . '</td>');
|
||||
require 'hostbox-menu.inc.php';
|
||||
|
||||
echo(' </tr>');
|
||||
|
||||
?>
|
157
html/includes/table/devices.inc.php
Normal file
157
html/includes/table/devices.inc.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
$where = 1;
|
||||
$param = array();
|
||||
|
||||
$sql = " FROM `devices` WHERE $where ";
|
||||
|
||||
if (!empty($_POST['hostname'])) { $sql .= " AND hostname LIKE ?"; $param[] = "%".$_POST['hostname']."%"; }
|
||||
if (!empty($_POST['os'])) { $sql .= " AND os = ?"; $param[] = $_POST['os']; }
|
||||
if (!empty($_POST['version'])) { $sql .= " AND version = ?"; $param[] = $_POST['version']; }
|
||||
if (!empty($_POST['hardware'])) { $sql .= " AND hardware = ?"; $param[] = $_POST['hardware']; }
|
||||
if (!empty($_POST['features'])) { $sql .= " AND features = ?"; $param[] = $_POST['features']; }
|
||||
if (!empty($_POST['type'])) {
|
||||
if ($_POST['type'] == 'generic') {
|
||||
$sql .= " AND ( type = ? OR type = '')"; $param[] = $_POST['type'];
|
||||
} else {
|
||||
$sql .= " AND type = ?"; $param[] = $_POST['type'];
|
||||
}
|
||||
}
|
||||
if (!empty($_POST['state'])) {
|
||||
$sql .= " AND status= ?"; $param[] = $state;
|
||||
$sql .= " AND disabled='0' AND `ignore`='0'"; $param[] = '';
|
||||
}
|
||||
if (!empty($_POST['disabled'])) { $sql .= " AND disabled= ?"; $param[] = $_POST['disabled']; }
|
||||
if (!empty($_POST['ignore'])) { $sql .= " AND `ignore`= ?"; $param[] = $_POST['ignore']; }
|
||||
if (!empty($_POST['location']) && $_POST['location'] == "Unset") { $location_filter = ''; }
|
||||
if (!empty($_POST['location'])) { $location_filter = $_POST['location']; }
|
||||
if( !empty($_POST['group']) ) {
|
||||
require_once('../includes/device-groups.inc.php');
|
||||
$sql .= " AND ( ";
|
||||
foreach( GetDevicesFromGroup($_POST['group']) as $dev ) {
|
||||
$sql .= "device_id = ? OR ";
|
||||
$param[] = $dev['device_id'];
|
||||
}
|
||||
$sql = substr($sql, 0, strlen($sql)-3);
|
||||
$sql .= " )";
|
||||
}
|
||||
|
||||
$count_sql = "SELECT COUNT(`device_id`) $sql";
|
||||
|
||||
$total = dbFetchCell($count_sql,$param);
|
||||
|
||||
if (!isset($sort) || empty($sort)) {
|
||||
$sort = '`hostname` DESC';
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY $sort";
|
||||
|
||||
if (isset($current)) {
|
||||
$limit_low = ($current * $rowCount) - ($rowCount);
|
||||
$limit_high = $rowCount;
|
||||
}
|
||||
|
||||
if ($rowCount != -1) {
|
||||
$sql .= " LIMIT $limit_low,$limit_high";
|
||||
}
|
||||
|
||||
$sql = "SELECT * $sql";
|
||||
|
||||
if (!isset($_POST['format'])) {
|
||||
$_POST['format'] = "list_detail";
|
||||
}
|
||||
list($format, $subformat) = explode("_", $_POST['format']);
|
||||
|
||||
foreach (dbFetchRows($sql, $param) as $device) {
|
||||
if (device_permitted($device['device_id'])) {
|
||||
if (!isset($location_filter) || ((get_dev_attrib($device,'override_sysLocation_bool') &&
|
||||
get_dev_attrib($device,'override_sysLocation_string') == $location_filter) || $device['location'] == $location_filter)) {
|
||||
|
||||
if (isset($bg) && $bg == $list_colour_b) {
|
||||
$bg = $list_colour_a;
|
||||
} else {
|
||||
$bg = $list_colour_b;
|
||||
}
|
||||
|
||||
if ($device['status'] == '0') {
|
||||
$extra = "danger";
|
||||
$msg = "down";
|
||||
} else {
|
||||
$extra = "success";
|
||||
$msg = "up";
|
||||
}
|
||||
if ($device['ignore'] == '1') {
|
||||
$extra = "default";
|
||||
$msg = "ignored";
|
||||
if ($device['status'] == '1') {
|
||||
$extra = "warning";
|
||||
$msg = "ignored";
|
||||
}
|
||||
}
|
||||
if ($device['disabled'] == '1') {
|
||||
$extra = "default";
|
||||
$msg = "disabled";
|
||||
}
|
||||
|
||||
$type = strtolower($device['os']);
|
||||
$image = getImage($device);
|
||||
|
||||
if ($device['os'] == "ios") {
|
||||
formatCiscoHardware($device, true);
|
||||
}
|
||||
|
||||
$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']));
|
||||
|
||||
if (get_dev_attrib($device,'override_sysLocation_bool')) {
|
||||
$device['location'] = get_dev_attrib($device,'override_sysLocation_string');
|
||||
}
|
||||
|
||||
$actions = ('<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>
|
||||
<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>');
|
||||
|
||||
$hostname = generate_device_link($device);
|
||||
$platform = $device['hardware'] . '<br />' . $device['features'];
|
||||
$os = $device['os_text'] . '<br />' . $device['version'];
|
||||
$uptime = formatUptime($device['uptime'], 'short') . '<br />' . truncate($device['location'],32, '');
|
||||
if ($subformat == "detail") {
|
||||
$hostname .= '<br />' . $device['sysName'];
|
||||
if ($port_count) {
|
||||
$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;
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
$response[] = array('extra'=>$extra,'msg'=>$msg,'icon'=>$image,'hostname'=>$hostname,'ports'=>$col_port,'hardware'=>$platform,'os'=>$os,'uptime'=>$uptime,'actions'=>$actions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total);
|
||||
echo _json_encode($output);
|
@@ -4,50 +4,6 @@
|
||||
|
||||
if(!isset($vars['format'])) { $vars['format'] = "list_detail"; }
|
||||
|
||||
$sql_param = array();
|
||||
if(isset($vars['state']))
|
||||
{
|
||||
if($vars['state'] == 'up')
|
||||
{
|
||||
$state = '1';
|
||||
}
|
||||
elseif($vars['state'] == 'down')
|
||||
{
|
||||
$state = '0';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($vars['hostname'])) { $where .= " AND hostname LIKE ?"; $sql_param[] = "%".$vars['hostname']."%"; }
|
||||
if (!empty($vars['os'])) { $where .= " AND os = ?"; $sql_param[] = $vars['os']; }
|
||||
if (!empty($vars['version'])) { $where .= " AND version = ?"; $sql_param[] = $vars['version']; }
|
||||
if (!empty($vars['hardware'])) { $where .= " AND hardware = ?"; $sql_param[] = $vars['hardware']; }
|
||||
if (!empty($vars['features'])) { $where .= " AND features = ?"; $sql_param[] = $vars['features']; }
|
||||
if (!empty($vars['type'])) {
|
||||
if ($vars['type'] == 'generic') {
|
||||
$where .= " AND ( type = ? OR type = '')"; $sql_param[] = $vars['type'];
|
||||
} else {
|
||||
$where .= " AND type = ?"; $sql_param[] = $vars['type'];
|
||||
}
|
||||
}
|
||||
if (!empty($vars['state'])) {
|
||||
$where .= " AND status= ?"; $sql_param[] = $state;
|
||||
$where .= " AND disabled='0' AND `ignore`='0'"; $sql_param[] = '';
|
||||
}
|
||||
if (!empty($vars['disabled'])) { $where .= " AND disabled= ?"; $sql_param[] = $vars['disabled']; }
|
||||
if (!empty($vars['ignore'])) { $where .= " AND `ignore`= ?"; $sql_param[] = $vars['ignore']; }
|
||||
if (!empty($vars['location']) && $vars['location'] == "Unset") { $location_filter = ''; }
|
||||
if (!empty($vars['location'])) { $location_filter = $vars['location']; }
|
||||
if( !empty($vars['group']) ) {
|
||||
require_once('../includes/device-groups.inc.php');
|
||||
$where .= " AND ( ";
|
||||
foreach( GetDevicesFromGroup($vars['group']) as $dev ) {
|
||||
$where .= "device_id = ? OR ";
|
||||
$sql_param[] = $dev['device_id'];
|
||||
}
|
||||
$where = substr($where, 0, strlen($where)-3);
|
||||
$where .= " )";
|
||||
}
|
||||
|
||||
$pagetitle[] = "Devices";
|
||||
|
||||
print_optionbar_start();
|
||||
@@ -125,140 +81,14 @@ foreach ($menu_options as $option => $text)
|
||||
} else {
|
||||
echo('<a href="'. generate_url($vars, array('bare' => 'yes')).'">Remove Header</a>');
|
||||
}
|
||||
|
||||
print_optionbar_end();
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
print_optionbar_end();
|
||||
print_optionbar_start();
|
||||
|
||||
if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars['searchbar']))
|
||||
{
|
||||
|
||||
?>
|
||||
<form method="post" action="" class="form-inline" role="form">
|
||||
<div class="form-group">
|
||||
<input type="text" name="hostname" id="hostname" size="38" 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
|
||||
|
||||
foreach (dbFetch('SELECT `os` FROM `devices` AS D WHERE 1 GROUP BY `os` ORDER BY `os`') as $data)
|
||||
{
|
||||
if ($data['os'])
|
||||
{
|
||||
echo("<option value='".$data['os']."'");
|
||||
if ($data['os'] == $vars['os']) { echo(" selected"); }
|
||||
echo(">".$config['os'][$data['os']]['text']."</option>");
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<select name='version' id='version' class="form-control input-sm">
|
||||
<option value=''>All Versions</option>
|
||||
<?php
|
||||
|
||||
foreach (dbFetch('SELECT `version` FROM `devices` AS D WHERE 1 GROUP BY `version` ORDER BY `version`') as $data)
|
||||
{
|
||||
if ($data['version'])
|
||||
{
|
||||
echo("<option value='".$data['version']."'");
|
||||
if ($data['version'] == $vars['version']) { echo(" selected"); }
|
||||
echo(">".$data['version']."</option>");
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<select name="hardware" id="hardware" class="form-control input-sm">
|
||||
<option value="">All Platforms</option>
|
||||
<?php
|
||||
foreach (dbFetch('SELECT `hardware` FROM `devices` AS D WHERE 1 GROUP BY `hardware` ORDER BY `hardware`') as $data)
|
||||
{
|
||||
if ($data['hardware'])
|
||||
{
|
||||
echo('<option value="'.$data['hardware'].'"');
|
||||
if ($data['hardware'] == $vars['hardware']) { echo(" selected"); }
|
||||
echo(">".$data['hardware']."</option>");
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<select name="features" id="features" class="form-control input-sm">
|
||||
<option value="">All Featuresets</option>
|
||||
<?php
|
||||
|
||||
foreach (dbFetch('SELECT `features` FROM `devices` AS D WHERE 1 GROUP BY `features` ORDER BY `features`') as $data)
|
||||
{
|
||||
if ($data['features'])
|
||||
{
|
||||
echo('<option value="'.$data['features'].'"');
|
||||
if ($data['features'] == $vars['features']) { echo(" selected"); }
|
||||
echo(">".$data['features']."</option>");
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<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) // FIXME function name sucks maybe get_locations ?
|
||||
{
|
||||
if ($location)
|
||||
{
|
||||
echo('<option value="'.$location.'"');
|
||||
if ($location == $vars['location']) { echo(" selected"); }
|
||||
echo(">".$location."</option>");
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<select name="type" id="type" class="form-control input-sm">
|
||||
<option value="">All Device Types</option>
|
||||
<?php
|
||||
|
||||
foreach (dbFetch('SELECT `type` FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`') as $data)
|
||||
{
|
||||
if ($data['type'])
|
||||
{
|
||||
echo("<option value='".$data['type']."'");
|
||||
if ($data['type'] == $vars['type']) { echo(" selected"); }
|
||||
echo(">".ucfirst($data['type'])."</option>");
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<button type="submit" class="btn btn-default input-sm">Search</button>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
print_optionbar_end();
|
||||
|
||||
$query = "SELECT * FROM `devices` WHERE 1 ";
|
||||
|
||||
if (isset($where)) {
|
||||
$query .= $where;
|
||||
}
|
||||
|
||||
$query .= " ORDER BY hostname";
|
||||
|
||||
list($format, $subformat) = explode("_", $vars['format']);
|
||||
|
||||
if($format == "graph")
|
||||
@@ -291,44 +121,185 @@ if($format == "graph")
|
||||
|
||||
} else {
|
||||
|
||||
echo('<div class="panel panel-default panel-condensed">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-condensed">');
|
||||
|
||||
if ($subformat == "detail" || $subformat == "basic")
|
||||
{
|
||||
echo('<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th>Device</th>
|
||||
<th></th>
|
||||
<th>Platform</th>
|
||||
<th>Operating System</th>
|
||||
<th>Uptime/Location</th>
|
||||
<th>Actions</th>
|
||||
</tr>');
|
||||
}
|
||||
?>
|
||||
|
||||
foreach (dbFetchRows($query, $sql_param) as $device)
|
||||
{
|
||||
if (device_permitted($device['device_id']))
|
||||
{
|
||||
if (!isset($location_filter) || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter)
|
||||
|| $device['location'] == $location_filter))
|
||||
{
|
||||
$cell_click = 'onclick="location.href=\'device/device='.$device['device_id'].'/\'" style="cursor: pointer;"';
|
||||
if ($subformat == "detail")
|
||||
{
|
||||
include("includes/hostbox.inc.php");
|
||||
} else {
|
||||
include("includes/hostbox-basic.inc.php");
|
||||
<div class="panel panel-default panel-condensed">
|
||||
<div class="table-responsive">
|
||||
<table id="devices" class="table table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="status" data-sortable="false" data-searchable="false" data-formatter="status"></th>
|
||||
<th data-column-id="icon" data-sortable="false" data-searchable="false"></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="hardware">Platform</th>
|
||||
<th data-column-id="os">Operating System</th>
|
||||
<th data-column-id="uptime">Uptime/Location</th>
|
||||
<th data-column-id="actions" data-sortable="false" data-searchable="false">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
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+" 75pc-width'>" + row.msg + "</span></h4>";
|
||||
}
|
||||
}
|
||||
},
|
||||
templates: {
|
||||
header: "<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
|
||||
|
||||
foreach (dbFetch('SELECT `os` FROM `devices` AS D WHERE 1 GROUP BY `os` ORDER BY `os`') as $data) {
|
||||
if ($data['os']) {
|
||||
echo('"<option value=\"'.$data['os'].'\""+');
|
||||
if ($data['os'] == $vars['os']) {
|
||||
echo('" selected "+');
|
||||
}
|
||||
echo('">'.$config['os'][$data['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
|
||||
|
||||
foreach (dbFetch('SELECT `version` FROM `devices` AS D WHERE 1 GROUP BY `version` ORDER BY `version`') as $data) {
|
||||
if ($data['version']) {
|
||||
echo('"<option value=\"'.$data['version'].'\""+');
|
||||
if ($data['version'] == $vars['version']) {
|
||||
echo('" selected "+');
|
||||
}
|
||||
echo('">'.$data['version'].'</option>"+');
|
||||
}
|
||||
echo("</table>");
|
||||
echo('</div>');
|
||||
echo('</div>');
|
||||
}
|
||||
?>
|
||||
"</select>"+
|
||||
"</div>"+
|
||||
"<div class=\"form-group\">"+
|
||||
"<select name=\"hardware\" id=\"hardware\" class=\"form-control input-sm\">"+
|
||||
"<option value=\"\">All Platforms</option>"+
|
||||
<?php
|
||||
|
||||
foreach (dbFetch('SELECT `hardware` FROM `devices` AS D WHERE 1 GROUP BY `hardware` ORDER BY `hardware`') as $data) {
|
||||
if ($data['hardware']) {
|
||||
echo('"<option value=\"'.$data['hardware'].'\""+');
|
||||
if ($data['hardware'] == $vars['hardware']) {
|
||||
echo('" selected"+');
|
||||
}
|
||||
echo('">'.$data['hardware'].'</option>"+');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
"</select>"+
|
||||
"</div>"+
|
||||
"<div class=\"form-group\">"+
|
||||
"<select name=\"features\" id=\"features\" class=\"form-control input-sm\">"+
|
||||
"<option value=\"\">All Featuresets</option>"+
|
||||
<?php
|
||||
|
||||
foreach (dbFetch('SELECT `features` FROM `devices` AS D WHERE 1 GROUP BY `features` ORDER BY `features`') as $data)
|
||||
{
|
||||
if ($data['features'])
|
||||
{
|
||||
echo('"<option value=\"'.$data['features'].'\""+');
|
||||
if ($data['features'] == $vars['features']) {
|
||||
echo('" selected"+');
|
||||
}
|
||||
echo('">'.$data['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) {
|
||||
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
|
||||
|
||||
foreach (dbFetch('SELECT `type` FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`') 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>"
|
||||
},
|
||||
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