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 [
|
||||
'extra' => $this->getLabel($device),
|
||||
'status' => $device->statusName(),
|
||||
'status' => $this->getStatus($device),
|
||||
'icon' => '<img src="' . asset($device->icon) . '" title="' . pathinfo($device->icon, PATHINFO_FILENAME) . '">',
|
||||
'hostname' => $this->getHostname($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
|
||||
* @param Device $device
|
||||
@@ -139,15 +155,20 @@ class DeviceController extends TableController
|
||||
*/
|
||||
private function getLabel($device)
|
||||
{
|
||||
if ($device->disabled) {
|
||||
if ($device->disabled == 1) {
|
||||
return 'blackbg';
|
||||
} elseif ($device->ignore == 1) {
|
||||
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-default';
|
||||
return 'label-success';
|
||||
}
|
||||
|
||||
return $device->status ? 'label-success' : 'label-danger';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -334,27 +334,6 @@ class Device extends BaseModel
|
||||
$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 ----
|
||||
|
||||
public function getIconAttribute($icon)
|
||||
|
@@ -32,7 +32,7 @@ if (device_permitted($vars['device']) || $permitted_by_port) {
|
||||
$component_count = $component->getComponentCount($device['device_id']);
|
||||
|
||||
$alert_class = '';
|
||||
if ($device['disabled'] == '1' || $device['ignore'] == '1') {
|
||||
if ($device['disabled'] == '1') {
|
||||
$alert_class = 'alert-info';
|
||||
} elseif ($device['status'] == '0') {
|
||||
$alert_class = 'alert-danger';
|
||||
|
@@ -318,12 +318,12 @@ if ($format == "graph") {
|
||||
return "<span>" + row.hostname + "</span>";
|
||||
},
|
||||
"uptime": function (column, row) {
|
||||
if (isNaN(row.uptime.charAt(0))) {
|
||||
return row.uptime;
|
||||
} else if (row.status == 'down') {
|
||||
return "<span class='alert-status-small label-danger'></span><span>" + row.uptime + "</span>";
|
||||
if (row.status == 'down') {
|
||||
return "<span class='red'>" + row.uptime + "</span>"
|
||||
} else if(row.status == 'disabled') {
|
||||
return '';
|
||||
} else {
|
||||
return "<span class='alert-status-small label-success'></span><span>" + row.uptime + "</span>";
|
||||
return row.uptime;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user