mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #1962 from laf/availability-map-settings
Added ability to edit the size of the boxes
This commit is contained in:
@ -9,45 +9,69 @@
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
require_once 'includes/object-cache.inc.php';
|
||||
|
||||
$sql = 'SELECT `D`.`hostname`,`D`.`device_id`,`D`.`status`,`D`.`uptime` FROM `devices` AS `D`';
|
||||
if (defined('show_settings')) {
|
||||
|
||||
$common_output[] = '
|
||||
<form class="form-horizontal" onsubmit="widget_settings(this); return false;">
|
||||
<div class="form-group">
|
||||
<label for="tile_width" class="col-sm-4 control-label">Tile width</label>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" name="tile_width" id="input_tile_width_'.$unique_id.'" placeholder="I.e 10" value="'.$widget_settings['tile_width'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-6 col-sm-4">
|
||||
<button type="submit" class="btn btn-primary">Set</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
';
|
||||
|
||||
if (is_normal_user() === true) {
|
||||
$sql.= ' , `devices_perms` AS P WHERE D.`device_id` = P.`device_id` AND P.`user_id` = ? AND';
|
||||
$param = array(
|
||||
$_SESSION['user_id']
|
||||
);
|
||||
}
|
||||
else {
|
||||
$sql.= ' WHERE';
|
||||
}
|
||||
|
||||
$sql.= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `hostname`";
|
||||
$temp_output = array();
|
||||
$c = '0';
|
||||
require_once 'includes/object-cache.inc.php';
|
||||
$tile_width = $widget_settings['tile_width'];
|
||||
|
||||
foreach(dbFetchRows($sql, $param) as $device) {
|
||||
if ($device['status'] == '1') {
|
||||
$btn_type = 'btn-success';
|
||||
if ($device['uptime'] < $config['uptime_warning']) {
|
||||
$btn_type = 'btn-warning';
|
||||
$c++;
|
||||
}
|
||||
$sql = 'SELECT `D`.`hostname`,`D`.`device_id`,`D`.`status`,`D`.`uptime` 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(
|
||||
$_SESSION['user_id']
|
||||
);
|
||||
}
|
||||
else {
|
||||
$btn_type = 'btn-danger';
|
||||
$sql.= ' WHERE';
|
||||
}
|
||||
|
||||
$temp_output[] = '<a href="' . generate_url(array(
|
||||
'page' => 'device',
|
||||
'device' => $device['device_id']
|
||||
)) . '" role="button" class="btn ' . $btn_type . ' btn-xs" title="' . $device['hostname'] . " - " . formatUptime($device['uptime']) . '" style="min-height:25px; min-width:25px; border-radius:0px; margin:0; padding:0;"></a>';
|
||||
}
|
||||
$sql.= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `hostname`";
|
||||
$temp_output = array();
|
||||
$c = '0';
|
||||
|
||||
$temp_rows = count($temp_output);
|
||||
$temp_output[] = '</div>';
|
||||
$temp_header = array(
|
||||
'<div style="margin-left:auto; margin-right:auto;"><center><h5><i class="fa fa-check" style="color:green">' . $devices['up'] . ' </i> <i class="fa fa-exclamation-triangle" style="color:orange"> '. $c .'</i> <i class="fa fa-exclamation-circle" style="color:red"> ' . $devices['down'] . '</i></h5></center><br />'
|
||||
);
|
||||
$common_output = array_merge($temp_header, $temp_output);
|
||||
foreach(dbFetchRows($sql, $param) as $device) {
|
||||
if ($device['status'] == '1') {
|
||||
$btn_type = 'btn-success';
|
||||
if ($device['uptime'] < $config['uptime_warning']) {
|
||||
$btn_type = 'btn-warning';
|
||||
$c++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$btn_type = 'btn-danger';
|
||||
}
|
||||
|
||||
$temp_output[] = '<a href="' . generate_url(array(
|
||||
'page' => 'device',
|
||||
'device' => $device['device_id']
|
||||
)) . '" role="button" class="btn ' . $btn_type . ' btn-xs" title="' . $device['hostname'] . " - " . formatUptime($device['uptime']) . '" style="min-height:' . $tile_width . 'px; min-width: ' . $tile_width . 'px; border-radius:0px; margin:0; padding:0;"></a>';
|
||||
}
|
||||
|
||||
$temp_rows = count($temp_output);
|
||||
$temp_output[] = '</div>';
|
||||
$temp_header = array(
|
||||
'<div style="margin-left:auto; margin-right:auto;"><center><h5><i class="fa fa-check" style="color:green">' . $devices['up'] . ' </i> <i class="fa fa-exclamation-triangle" style="color:orange"> '. $c .'</i> <i class="fa fa-exclamation-circle" style="color:red"> ' . $devices['down'] . '</i></h5></center><br />'
|
||||
);
|
||||
$common_output = array_merge($temp_header, $temp_output);
|
||||
}
|
||||
|
Reference in New Issue
Block a user