mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Replaced color indicator near uptime counter with colored text and change color of status indicator to black on disabled devices instead of gray(#10372)
(matches availablity map with show ignored/disabled enabled)
This commit is contained in:
@@ -120,7 +120,7 @@ class DeviceController extends TableController
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'extra' => $this->getLabel($device),
|
'extra' => $this->getLabel($device),
|
||||||
'status' => $device->statusName(),
|
'status' => $this->getStatus($device),
|
||||||
'icon' => '<img src="' . asset($device->icon) . '" title="' . pathinfo($device->icon, PATHINFO_FILENAME) . '">',
|
'icon' => '<img src="' . asset($device->icon) . '" title="' . pathinfo($device->icon, PATHINFO_FILENAME) . '">',
|
||||||
'hostname' => $this->getHostname($device),
|
'hostname' => $this->getHostname($device),
|
||||||
'metrics' => $this->getMetrics($device),
|
'metrics' => $this->getMetrics($device),
|
||||||
@@ -132,6 +132,22 @@ class DeviceController extends TableController
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the device up/down status
|
||||||
|
* @param Device $device
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getStatus($device)
|
||||||
|
{
|
||||||
|
if ($device->disabled == 1) {
|
||||||
|
return 'disabled';
|
||||||
|
} elseif ($device->status == 0) {
|
||||||
|
return 'down';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'up';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the status label class
|
* Get the status label class
|
||||||
* @param Device $device
|
* @param Device $device
|
||||||
@@ -139,15 +155,20 @@ class DeviceController extends TableController
|
|||||||
*/
|
*/
|
||||||
private function getLabel($device)
|
private function getLabel($device)
|
||||||
{
|
{
|
||||||
if ($device->disabled) {
|
if ($device->disabled == 1) {
|
||||||
|
return 'blackbg';
|
||||||
|
} elseif ($device->ignore == 1) {
|
||||||
return 'label-default';
|
return 'label-default';
|
||||||
}
|
} elseif ($device->status == 0) {
|
||||||
|
return 'label-danger';
|
||||||
|
} else {
|
||||||
|
$warning_time = \LibreNMS\Config::get('uptime_warning', 84600);
|
||||||
|
if ($device->uptime < $warning_time && $device->uptime != 0) {
|
||||||
|
return 'label-warning';
|
||||||
|
}
|
||||||
|
|
||||||
if ($device->ignore) {
|
return 'label-success';
|
||||||
return 'label-default';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $device->status ? 'label-success' : 'label-danger';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -334,27 +334,6 @@ class Device extends BaseModel
|
|||||||
$this->save();
|
$this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function statusName()
|
|
||||||
{
|
|
||||||
if ($this->disabled == 1) {
|
|
||||||
return 'disabled';
|
|
||||||
} elseif ($this->ignore == 1) {
|
|
||||||
return 'ignore';
|
|
||||||
} elseif ($this->status == 0) {
|
|
||||||
return 'down';
|
|
||||||
} else {
|
|
||||||
$warning_time = \LibreNMS\Config::get('uptime_warning', 84600);
|
|
||||||
if ($this->uptime < $warning_time && $this->uptime != 0) {
|
|
||||||
return 'warn';
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'up';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---- Accessors/Mutators ----
|
// ---- Accessors/Mutators ----
|
||||||
|
|
||||||
public function getIconAttribute($icon)
|
public function getIconAttribute($icon)
|
||||||
|
@@ -32,7 +32,7 @@ if (device_permitted($vars['device']) || $permitted_by_port) {
|
|||||||
$component_count = $component->getComponentCount($device['device_id']);
|
$component_count = $component->getComponentCount($device['device_id']);
|
||||||
|
|
||||||
$alert_class = '';
|
$alert_class = '';
|
||||||
if ($device['disabled'] == '1' || $device['ignore'] == '1') {
|
if ($device['disabled'] == '1') {
|
||||||
$alert_class = 'alert-info';
|
$alert_class = 'alert-info';
|
||||||
} elseif ($device['status'] == '0') {
|
} elseif ($device['status'] == '0') {
|
||||||
$alert_class = 'alert-danger';
|
$alert_class = 'alert-danger';
|
||||||
|
@@ -285,7 +285,7 @@ if ($format == "graph") {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table id="devices" class="table table-hover table-condensed table-striped">
|
<table id="devices" class="table table-hover table-condensed table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th data-column-id="status" data-formatter="status" data-width="7px" data-searchable="false"> </th>
|
<th data-column-id="status" data-formatter="status" data-width="7px" data-searchable="false"> </th>
|
||||||
@@ -318,12 +318,12 @@ if ($format == "graph") {
|
|||||||
return "<span>" + row.hostname + "</span>";
|
return "<span>" + row.hostname + "</span>";
|
||||||
},
|
},
|
||||||
"uptime": function (column, row) {
|
"uptime": function (column, row) {
|
||||||
if (isNaN(row.uptime.charAt(0))) {
|
if (row.status == 'down') {
|
||||||
return row.uptime;
|
return "<span class='red'>" + row.uptime + "</span>"
|
||||||
} else if (row.status == 'down') {
|
} else if(row.status == 'disabled') {
|
||||||
return "<span class='alert-status-small label-danger'></span><span>" + row.uptime + "</span>";
|
return '';
|
||||||
} else {
|
} else {
|
||||||
return "<span class='alert-status-small label-success'></span><span>" + row.uptime + "</span>";
|
return row.uptime;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user