mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix service overview (#10709)
* Fix services device overview widget display * Add order by
This commit is contained in:
@@ -3,26 +3,18 @@
|
||||
use LibreNMS\Util\ObjectCache;
|
||||
|
||||
if (ObjectCache::serviceCounts(['total'], $device['device_id'])['total'] > 0) {
|
||||
// Build the string.
|
||||
$break = '';
|
||||
$output = '';
|
||||
foreach (service_get($device['device_id']) as $data) {
|
||||
if ($data['service_status'] == '0') {
|
||||
// Ok
|
||||
$status = 'green';
|
||||
} elseif ($data['service_status'] == '1') {
|
||||
// Warning
|
||||
$status = 'red';
|
||||
} elseif ($data['service_status'] == '2') {
|
||||
// Critical
|
||||
$status = 'red';
|
||||
} else {
|
||||
// Unknown
|
||||
$status = 'grey';
|
||||
}
|
||||
$output .= $break . '<div title=' . str_replace(' ', ' ', $data['service_message']) . '><a class=' . $status . '>' . strtolower($data['service_type']) . '</a></div>';
|
||||
$break = ', ';
|
||||
}
|
||||
$colors = collect(['green', 'yellow', 'red']);
|
||||
$output = \App\Models\Service::query()
|
||||
->where('device_id', $device['device_id'])
|
||||
->orderBy('service_type')
|
||||
->get(['service_type', 'service_status', 'service_message'])
|
||||
->map(function ($service) use ($colors) {
|
||||
$message = str_replace(' ', ' ', $service->service_message);
|
||||
$color = $colors->get($service->service_status, 'grey');
|
||||
$type = strtolower($service->service_type);
|
||||
|
||||
return "<span title='$message' class='$color'>$type</span>";
|
||||
})->implode(', ');
|
||||
|
||||
$services = ObjectCache::serviceCounts(['total', 'ok', 'warning', 'critical'], $device['device_id']);
|
||||
?>
|
||||
@@ -34,7 +26,7 @@ if (ObjectCache::serviceCounts(['total'], $device['device_id'])['total'] > 0) {
|
||||
</div>
|
||||
<table class="table table-hover table-condensed table-striped">
|
||||
<tr>
|
||||
<td title="Total"><i class="fa fa-cog" style="color:#0080FF" aria-hidden="true"></i> <?php echo $services['total']?></td>
|
||||
<td title="Total"><i class="fa fa-cog" aria-hidden="true"></i> <?php echo $services['total']?></td>
|
||||
<td title="Status - Ok"><i class="fa fa-cog" style="color:green" aria-hidden="true"></i> <?php echo $services['ok']?></td>
|
||||
<td title="Status - Warning"><i class="fa fa-cog" style="color:orange" aria-hidden="true"></i> <?php echo $services['warning']?></td>
|
||||
<td title="Status - Critical"><i class="fa fa-cog" style="color:red" aria-hidden="true"></i> <?php echo $services['critical']?></td>
|
||||
|
Reference in New Issue
Block a user