2011-03-17 00:09:20 +00:00
<? php
2017-12-24 21:58:32 +02:00
/*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*
* @package LibreNMS
* @subpackage webui
* @link http://librenms.org
* @copyright 2017 LibreNMS
* @author LibreNMS Contributors
*/
2010-07-26 17:28:51 +00:00
2017-12-24 21:58:32 +02:00
$pagetitle [] = "Devices" ;
2011-09-12 04:57:56 +00:00
2016-08-18 20:28:22 -05:00
if ( ! isset ( $vars [ 'format' ])) {
2015-07-13 20:10:26 +02:00
$vars [ 'format' ] = "list_detail" ;
}
2011-09-12 04:57:56 +00:00
2017-12-24 21:58:32 +02:00
$listoptions = '<span class="devices-font-bold">Lists: </span>' ;
2014-01-13 10:05:19 +00:00
2015-07-13 20:10:26 +02:00
$menu_options = array ( 'basic' => 'Basic' , 'detail' => 'Detail' );
2014-01-13 10:05:19 +00:00
$sep = "" ;
2015-07-13 20:10:26 +02:00
foreach ( $menu_options as $option => $text ) {
2017-12-24 21:58:32 +02:00
$listoptions .= $sep ;
2016-10-16 17:58:48 +03:00
if ( $vars [ 'format' ] == "list_" . $option ) {
2017-12-24 21:58:32 +02:00
$listoptions .= '<span class="pagemenu-selected">' ;
2015-07-13 20:10:26 +02:00
}
2017-12-24 21:58:32 +02:00
$listoptions .= '<a href="' . generate_url ( $vars , array ( 'format' => "list_" . $option )) . '">' . $text . '</a>' ;
2016-10-16 17:58:48 +03:00
if ( $vars [ 'format' ] == "list_" . $option ) {
2017-12-24 21:58:32 +02:00
$listoptions .= '</span>' ;
2015-07-13 20:10:26 +02:00
}
$sep = " | " ;
2014-01-13 10:05:19 +00:00
}
2017-12-24 21:58:32 +02:00
$listoptions .= ' <span class="devices-font-bold">Graphs: </span>' ;
2014-01-13 10:05:19 +00:00
2016-10-16 17:58:48 +03:00
$menu_options = array ( 'bits' => 'Bits' ,
'processor' => 'CPU' ,
'ucd_load' => 'Load' ,
'mempool' => 'Memory' ,
'uptime' => 'Uptime' ,
'storage' => 'Storage' ,
'diskio' => 'Disk I/O' ,
2015-07-13 20:10:26 +02:00
'poller_perf' => 'Poller' ,
2016-10-16 17:58:48 +03:00
'ping_perf' => 'Ping' ,
2016-07-07 21:23:50 -05:00
'temperature' => 'Temperature'
2015-07-13 20:10:26 +02:00
);
2014-01-13 10:05:19 +00:00
$sep = "" ;
2015-07-13 20:10:26 +02:00
foreach ( $menu_options as $option => $text ) {
2017-12-24 21:58:32 +02:00
$listoptions .= $sep ;
2016-10-16 17:58:48 +03:00
if ( $vars [ 'format' ] == 'graph_' . $option ) {
2017-12-24 21:58:32 +02:00
$listoptions .= '<span class="pagemenu-selected">' ;
2015-07-13 20:10:26 +02:00
}
2017-12-24 21:58:32 +02:00
$listoptions .= '<a href="' . generate_url ( $vars , array ( 'format' => 'graph_' . $option , 'from' => '-24h' , 'to' => 'now' )) . '">' . $text . '</a>' ;
2016-10-16 17:58:48 +03:00
if ( $vars [ 'format' ] == 'graph_' . $option ) {
2017-12-24 21:58:32 +02:00
$listoptions .= '</span>' ;
2015-07-13 20:10:26 +02:00
}
$sep = " | " ;
2014-01-13 10:05:19 +00:00
}
2017-12-24 21:58:32 +02:00
$headeroptions = '<select name="type" id="type" onchange="window.open(this.options[this.selectedIndex].value,\'_top\')" class="devices-graphs-select">' ;
2016-10-16 17:58:48 +03:00
$type = 'device' ;
2016-08-18 20:28:22 -05:00
foreach ( get_graph_subtypes ( $type ) as $avail_type ) {
$display_type = is_mib_graph ( $type , $avail_type ) ? $avail_type : nicecase ( $avail_type );
2016-10-16 17:58:48 +03:00
if ( 'graph_' . $avail_type == $vars [ 'format' ]) {
$is_selected = 'selected' ;
} else {
$is_selected = '' ;
}
2017-12-24 21:58:32 +02:00
$headeroptions .= '<option value="' . generate_url ( $vars , array ( 'format' => 'graph_' . $avail_type , 'from' => $vars [ 'from' ] ?: $config [ 'time' ][ 'day' ], 'to' => $vars [ 'to' ] ?: $config [ 'time' ][ 'now' ])) . '" ' . $is_selected . '>' . $display_type . '</option>' ;
2016-08-18 20:28:22 -05:00
}
2017-12-24 21:58:32 +02:00
$headeroptions .= '</select>' ;
2014-01-13 10:05:19 +00:00
2015-07-13 20:10:26 +02:00
if ( isset ( $vars [ 'searchbar' ]) && $vars [ 'searchbar' ] == "hide" ) {
2017-12-24 21:58:32 +02:00
$headeroptions .= '<a href="' . generate_url ( $vars , array ( 'searchbar' => '' )) . '">Restore Search</a>' ;
2016-08-18 20:28:22 -05:00
} else {
2017-12-24 21:58:32 +02:00
$headeroptions .= '<a href="' . generate_url ( $vars , array ( 'searchbar' => 'hide' )) . '">Remove Search</a>' ;
2015-07-13 20:10:26 +02:00
}
2014-01-13 10:05:19 +00:00
2017-12-24 21:58:32 +02:00
$headeroptions .= ' | ' ;
2014-01-13 10:05:19 +00:00
2015-07-13 20:10:26 +02:00
if ( isset ( $vars [ 'bare' ]) && $vars [ 'bare' ] == "yes" ) {
2017-12-24 21:58:32 +02:00
$headeroptions .= '<a href="' . generate_url ( $vars , array ( 'bare' => '' )) . '">Restore Header</a>' ;
2016-08-18 20:28:22 -05:00
} else {
2017-12-24 21:58:32 +02:00
$headeroptions .= '<a href="' . generate_url ( $vars , array ( 'bare' => 'yes' )) . '">Remove Header</a>' ;
2015-07-13 20:10:26 +02:00
}
2014-01-13 10:05:19 +00:00
2015-06-10 00:47:26 +02:00
list ( $format , $subformat ) = explode ( "_" , $vars [ 'format' ], 2 );
2011-09-14 13:38:01 +00:00
2016-08-18 20:28:22 -05:00
if ( $format == "graph" ) {
2015-10-26 20:43:14 +00:00
if ( empty ( $vars [ 'from' ])) {
2015-10-20 21:35:08 +00:00
$graph_array [ 'from' ] = $config [ 'time' ][ 'day' ];
2016-08-18 20:28:22 -05:00
} else {
2015-10-20 21:35:08 +00:00
$graph_array [ 'from' ] = $vars [ 'from' ];
}
2015-10-26 20:43:14 +00:00
if ( empty ( $vars [ 'to' ])) {
2015-10-20 21:35:08 +00:00
$graph_array [ 'to' ] = $config [ 'time' ][ 'now' ];
2016-08-18 20:28:22 -05:00
} else {
2015-10-20 21:35:08 +00:00
$graph_array [ 'to' ] = $vars [ 'to' ];
}
2017-12-29 22:10:36 +02:00
echo '<div class="panel panel-default panel-condensed">' ;
echo '<div class="panel-heading">' ;
echo '<div class="row" style="padding: 0px 10px 0px 10px;">' ;
echo '<div class="pull-left">' . $listoptions . '</div>' ;
echo '<div class="pull-right">' . $headeroptions . '</div>' ;
echo '<div class="col-md-12" style="padding: 10px 0px 0px 0px;">' ;
2015-10-20 21:35:08 +00:00
include_once 'includes/print-date-selector.inc.php' ;
2017-12-29 22:10:36 +02:00
echo '</div>' ;
echo '</div>' ;
echo '</div>' ;
echo '<div class="panel-body">' ;
2015-10-20 21:35:08 +00:00
2015-07-13 20:10:26 +02:00
$sql_param = array ();
2015-04-13 13:21:30 +00:00
2016-08-18 20:28:22 -05:00
if ( isset ( $vars [ 'state' ])) {
if ( $vars [ 'state' ] == 'up' ) {
2015-07-13 20:10:26 +02:00
$state = '1' ;
2016-08-18 20:28:22 -05:00
} elseif ( $vars [ 'state' ] == 'down' ) {
2015-07-13 20:10:26 +02:00
$state = '0' ;
}
}
2015-04-13 13:21:30 +00:00
2015-07-13 20:10:26 +02:00
if ( ! empty ( $vars [ 'hostname' ])) {
$where .= " AND hostname LIKE ?" ;
2016-10-16 17:58:48 +03:00
$sql_param [] = "%" . $vars [ 'hostname' ] . "%" ;
2015-07-13 20:10:26 +02:00
}
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' ];
}
2015-04-13 13:21:30 +00:00
2015-07-13 20:10:26 +02:00
if ( ! empty ( $vars [ 'type' ])) {
if ( $vars [ 'type' ] == 'generic' ) {
$where .= " AND ( type = ? OR type = '')" ;
$sql_param [] = $vars [ 'type' ];
2016-08-18 20:28:22 -05:00
} else {
2015-07-13 20:10:26 +02:00
$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' ];
}
2016-08-18 20:28:22 -05:00
if ( ! empty ( $vars [ 'ignore' ])) {
2015-07-13 20:10:26 +02:00
$where .= " AND `ignore`= ?" ;
$sql_param [] = $vars [ 'ignore' ];
}
if ( ! empty ( $vars [ 'location' ]) && $vars [ 'location' ] == "Unset" ) {
$location_filter = '' ;
}
if ( ! empty ( $vars [ 'location' ])) {
$location_filter = $vars [ 'location' ];
}
2016-08-18 20:28:22 -05:00
if ( ! empty ( $vars [ 'group' ])) {
2015-07-13 20:10:26 +02:00
require_once ( '../includes/device-groups.inc.php' );
$where .= " AND ( " ;
2016-08-18 20:28:22 -05:00
foreach ( GetDevicesFromGroup ( $vars [ 'group' ]) as $dev ) {
2015-07-13 20:10:26 +02:00
$where .= "device_id = ? OR " ;
2016-06-02 12:37:03 -05:00
$sql_param [] = $dev ;
2015-07-13 20:10:26 +02:00
}
2016-10-16 17:58:48 +03:00
$where = substr ( $where , 0 , strlen ( $where ) - 3 );
2015-07-13 20:10:26 +02:00
$where .= " )" ;
}
2015-04-13 13:21:30 +00:00
2015-07-13 20:10:26 +02:00
$query = "SELECT * FROM `devices` WHERE 1 " ;
2015-04-13 13:21:30 +00:00
2015-07-13 20:10:26 +02:00
if ( isset ( $where )) {
$query .= $where ;
}
2011-09-14 13:38:01 +00:00
2015-07-13 20:10:26 +02:00
$query .= " ORDER BY hostname" ;
2011-09-14 13:38:01 +00:00
2015-07-13 20:10:26 +02:00
$row = 1 ;
foreach ( dbFetchRows ( $query , $sql_param ) as $device ) {
2016-10-16 17:58:48 +03:00
if ( is_integer ( $row / 2 )) {
2015-07-13 20:10:26 +02:00
$row_colour = $list_colour_a ;
2016-08-18 20:28:22 -05:00
} else {
2015-07-13 20:10:26 +02:00
$row_colour = $list_colour_b ;
}
if ( device_permitted ( $device [ 'device_id' ])) {
2015-07-20 16:52:33 +01:00
if ( ! $location_filter || $device [ 'location' ] == $location_filter ) {
2016-10-16 17:58:48 +03:00
$graph_type = "device_" . $subformat ;
2011-09-21 13:22:27 +00:00
2015-07-13 20:10:26 +02:00
if ( $_SESSION [ 'widescreen' ]) {
2016-10-16 17:58:48 +03:00
$width = 270 ;
2016-08-18 20:28:22 -05:00
} else {
2016-10-16 17:58:48 +03:00
$width = 315 ;
2015-07-13 20:10:26 +02:00
}
2016-10-16 17:58:48 +03:00
$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 ;
2015-08-05 07:13:19 +10:00
$graph_array_zoom [ 'height' ] = '150' ;
2016-10-16 17:58:48 +03:00
$graph_array_zoom [ 'width' ] = '400' ;
2015-08-05 07:13:19 +10:00
$graph_array_zoom [ 'legend' ] = 'yes' ;
2017-12-24 21:58:32 +02:00
$link_array = $graph_array ;
2016-11-16 03:32:43 +00:00
$link_array [ 'page' ] = 'graphs' ;
$link_array [ 'type' ] = $graph_type ;
$link_array [ 'device' ] = $device [ 'device_id' ];
unset ( $link_array [ 'height' ], $link_array [ 'width' ]);
$overlib_link = generate_url ( $link_array );
2016-10-16 17:58:48 +03:00
echo '<div class="devices-overlib-box" style="min-width:' . ( $width + 90 ) . '; max-width: ' . ( $width + 90 ) . '">' ;
2015-09-23 15:41:48 +05:30
echo '<div class="panel panel-default">' ;
2016-08-18 20:28:22 -05:00
echo overlib_link ( $overlib_link , generate_lazy_graph_tag ( $graph_array_new ), generate_graph_tag ( $graph_array_zoom ), null );
2015-09-23 15:41:48 +05:30
echo "</div></div> \n\n " ;
2015-07-13 20:10:26 +02:00
}
}
2011-09-14 13:38:01 +00:00
}
2017-12-29 22:10:36 +02:00
echo '</div>' ;
2016-08-18 20:28:22 -05:00
} else {
2016-10-16 17:58:48 +03:00
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' ];
}
2015-04-08 21:17:48 +01:00
2017-12-24 21:58:32 +02:00
$os_options = "<select name='os' id='os' class='form-control input-sm'>" ;
$os_options .= "<option value=''>All OSes</option>" ;
2016-10-16 17:58:48 +03:00
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 = '' ;
}
2017-12-24 21:58:32 +02:00
$os_options .= "<option value='" . $tmp_os . "' " . $os_selected . ">" . $config [ 'os' ][ $tmp_os ][ 'text' ] . "</option>" ;
2015-04-08 21:17:48 +01:00
}
}
2017-12-24 21:58:32 +02:00
$os_options .= "<select>" ;
2016-10-16 17:58:48 +03:00
2017-12-24 21:58:32 +02:00
$ver_options = "<select name='version' id='version' class='form-control input-sm'>" ;
$ver_options .= "<option value=''>All Versions</option>" ;
2016-10-16 17:58:48 +03:00
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 = '' ;
}
2017-12-24 21:58:32 +02:00
$ui_version = strlen ( $tmp_version ) > 15 ? substr ( $tmp_version , 0 , 15 ) . "..." : $tmp_version ;
$ver_options .= "<option value='" . $tmp_version . "' " . $ver_selected . ">" . $ui_version . "</option>" ;
2015-04-08 21:17:48 +01:00
}
2015-07-13 20:10:26 +02:00
}
2017-12-24 21:58:32 +02:00
$ver_options .= "</select>" ;
2016-10-16 17:58:48 +03:00
2017-12-24 21:58:32 +02:00
$platform_options = "<select name='hardware' id='hardware' class='form-control input-sm'>" ;
$platform_options .= "<option value=''>All Platforms</option>" ;
2016-10-16 17:58:48 +03:00
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 = '' ;
}
2017-12-24 21:58:32 +02:00
$platform_options .= "<option value='" . $tmp_hardware . "' " . $platform_selected . ">" . $tmp_hardware . "</option>" ;
2015-04-08 21:17:48 +01:00
}
}
2017-12-24 21:58:32 +02:00
$platform_options .= "</select>" ;
2016-10-16 17:58:48 +03:00
2017-12-24 21:58:32 +02:00
$features_options = "<select name='features' id='features' class='form-control input-sm'>" ;
$features_options .= "<option value=''>All Featuresets</option>" ;
2016-10-16 17:58:48 +03:00
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 = '' ;
}
2017-12-24 21:58:32 +02:00
$features_options .= "<option value='" . $tmp_features . "' " . $feature_selected . ">" . $tmp_features . "</option>" ;
2016-10-16 17:58:48 +03:00
}
}
2017-12-24 21:58:32 +02:00
$features_options .= "</select>" ;
2016-10-16 17:58:48 +03:00
2017-12-24 21:58:32 +02:00
$locations_options = "<select name='location' id='location' class='form-control input-sm'>" ;
$locations_options .= "<option value=''>All Locations</option>" ;
2016-10-16 17:58:48 +03:00
foreach ( getlocations () as $location ) {
if ( $location ) {
$location = clean_bootgrid ( $location );
if ( $location == $vars [ 'location' ]) {
$location_selected = 'selected' ;
} else {
$location_selected = '' ;
}
2017-12-24 21:58:32 +02:00
$ui_location = strlen ( $location ) > 15 ? substr ( $location , 0 , 15 ) . "..." : $location ;
$locations_options .= "<option value='" . $location . "' " . $location_selected . ">" . $ui_location . "</option>" ;
2016-10-16 17:58:48 +03:00
}
}
2017-12-24 21:58:32 +02:00
$locations_options .= "</select>" ;
2016-10-16 17:58:48 +03:00
2017-12-24 21:58:32 +02:00
$types_options = "<select name='type' id='type' class='form-control input-sm'>" ;
$types_options .= "<option value=''>All Device Types</option>" ;
2016-10-16 17:58:48 +03:00
foreach ( dbFetch ( $types , $param ) as $data ) {
if ( $data [ 'type' ]) {
if ( $data [ 'type' ] == $vars [ 'type' ]) {
$type_selected = 'selected' ;
} else {
$type_selected = '' ;
}
2017-12-24 21:58:32 +02:00
$types_options .= "<option value='" . $data [ 'type' ] . "' " . $type_selected . ">" . ucfirst ( $data [ 'type' ]) . "</option>" ;
2016-10-16 17:58:48 +03:00
}
}
2017-12-24 21:58:32 +02:00
$types_options .= "</select>" ;
2015-07-13 20:10:26 +02:00
2016-10-16 17:58:48 +03:00
echo '
2017-12-24 21:58:32 +02:00
<div class="panel panel-default panel-condensed">
<div class="panel-heading">
<div class="row" style="padding: 0px 10px 0px 10px;">
<div class="pull-left">
' . $listoptions . '
</div>
<div class="pull-right">
' . $headeroptions . '
</div>
</div>
</div>
2016-10-16 17:58:48 +03:00
<div class="table-responsive">
2017-12-24 21:58:32 +02:00
<table id="devices" class="table table-hover table-condensed table-striped">
2016-10-16 17:58:48 +03:00
<thead>
<tr>
2017-12-24 21:58:32 +02:00
<th data-column-id="status" data-searchable="false" data-formatter="status"></th>
2016-10-16 17:58:48 +03:00
' ;
if ( $subformat == "detail" ) {
2017-05-01 23:49:11 -05:00
echo '<th data-column-id="icon" data-width="80px" data-sortable="false" data-searchable="false" data-formatter="icon">Vendor</th>' ;
2015-04-08 21:17:48 +01:00
}
2016-10-16 17:58:48 +03:00
echo '<th data-column-id="hostname" data-order="asc">Device</th>' ;
2015-04-08 21:17:48 +01:00
2016-10-16 17:58:48 +03:00
if ( $subformat == "detail" ) {
2017-05-01 23:49:11 -05:00
echo '<th data-column-id="ports" data-width="100px" data-sortable="false" data-searchable="false">Metrics</th>' ;
2011-03-31 17:19:54 +00:00
}
2015-04-08 21:17:48 +01:00
2016-10-16 17:58:48 +03:00
echo '
<th data-column-id="hardware">Platform</th>
<th data-column-id="os">Operating System</th>
<th data-column-id="uptime">Uptime</th>
' ;
2015-04-08 21:17:48 +01:00
2016-10-16 17:58:48 +03:00
if ( $subformat == "detail" ) {
echo '<th data-column-id="location">Location</th>' ;
}
2015-07-08 00:22:36 +01:00
2016-10-16 17:58:48 +03:00
echo '
2017-05-01 23:49:11 -05:00
<th data-column-id="actions" data-width="90px" data-sortable="false" data-searchable="false" data-header-css-class="device-table-header-actions">Actions</th>
2016-10-16 17:58:48 +03:00
</tr>
</thead>
</table>
</div>
2017-12-24 21:58:32 +02:00
</div>
2016-10-16 17:58:48 +03:00
' ;
2015-04-08 21:17:48 +01:00
2016-10-16 17:58:48 +03:00
?>
<script>
var grid = $("#devices").bootgrid({
ajax: true,
rowCount: [50, 100, 250, -1],
columnSelection: true,
formatters: {
"status": function (column, row) {
2017-12-24 21:58:32 +02:00
return "<span class=\"alert-status " + row.extra + "\"></span>";
},
"msg": function (column, row) {
return "<span class=\"alert-status\">" + row.msg + "</span>";
2016-10-16 17:58:48 +03:00
},
"icon": function (column, row) {
return "<span class=\"device-table-icon\">" + row.icon + "</span>";
}
},
templates: {
2017-12-24 21:58:32 +02:00
header: "<div class=\"devices-headers-table-menu\" style=\"padding:6px 6px 0px 0px;\"><p class=\"{{css.actions}}\"></p></div><div class=\"row\"></div>"
2016-10-16 17:58:48 +03:00
},
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"
});
2017-12-24 21:58:32 +02:00
<?php
if (!isset($vars['searchbar']) && $vars['searchbar'] != "hide") {
?>
$(".devices-headers-table-menu").append(
"<div class='pull-left'>" +
"<form method='post' action='' class='form-inline devices-search-header' role='form'>" +
"<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'><?php echo $os_options; ?></div>" +
"<div class='form-group'><?php echo $ver_options; ?></div>" +
"<div class='form-group'><?php echo $platform_options; ?></div>" +
"<div class='form-group'><?php echo $features_options; ?></div>" +
"<div class='form-group'><?php echo $locations_options; ?></div>" +
"<div class='form-group'><?php echo $types_options; ?></div>" +
"<input type='submit' class='btn btn-default input-sm devices-input-small' value='Search'>" +
2017-12-27 13:41:59 -06:00
"<a href='<?php echo 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='<?php echo generate_url(array('page' => 'devices', 'section' => $vars['section'], 'bare' => $vars['bare'])) ?>' title='Reset criteria to default.' class='btn btn-default input-sm devices-input-small'>Reset</a>" +
2017-12-24 21:58:32 +02:00
"</form>" +
"</div>"
);
<?php
}
?>
2016-10-16 17:58:48 +03:00
</script>
<?php
2007-04-03 14:10:23 +00:00
}