mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
webui: fix services display (#7993)
* fixed display bug when only one host had services * small cleanup, renamed vars as laf change request * message display wrongly removed, integrated back * missed one changed line by #8030
This commit is contained in:
@@ -100,6 +100,7 @@ require_once 'includes/modal/delete_service.inc.php';
|
||||
unset($sep);
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '<div style="margin:10px 10px 0px 10px;" id="message"></div>';
|
||||
echo '<div class="panel-body">';
|
||||
|
||||
$sql_param = array();
|
||||
@@ -118,9 +119,7 @@ require_once 'includes/modal/delete_service.inc.php';
|
||||
$where .= " AND service_status= ? AND service_disabled='0' AND `service_ignore`='0'";
|
||||
$sql_param[] = $state;
|
||||
}
|
||||
?>
|
||||
<div class="row col-sm-12"><span id="message"></span></div>
|
||||
<?php
|
||||
|
||||
if ($_SESSION['userlevel'] >= '5') {
|
||||
$host_sql = 'SELECT `D`.`device_id`,`D`.`hostname`,`D`.`sysName` FROM devices AS D, services AS S WHERE D.device_id = S.device_id GROUP BY `D`.`hostname`, `D`.`device_id`, `D`.`sysName` ORDER BY D.hostname';
|
||||
$host_par = array();
|
||||
@@ -141,9 +140,14 @@ require_once 'includes/modal/delete_service.inc.php';
|
||||
} else {
|
||||
$sql_param[0] = $device_id;
|
||||
}
|
||||
$head = true;
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM `services` WHERE `device_id` = ? $where ORDER BY service_type", $sql_param) as $service) {
|
||||
$header = true;
|
||||
$footer = false;
|
||||
|
||||
$service_iteration = 0;
|
||||
$services = dbFetchRows("SELECT * FROM `services` WHERE `device_id` = ? $where ORDER BY service_type", $sql_param);
|
||||
$services_count = count($services);
|
||||
foreach ($services as $service) {
|
||||
if ($service['service_status'] == '2') {
|
||||
$label = 'label-danger';
|
||||
$title = 'CRITICAL';
|
||||
@@ -157,52 +161,55 @@ require_once 'includes/modal/delete_service.inc.php';
|
||||
$label = 'label-info';
|
||||
$title = 'UNKNOWN';
|
||||
}
|
||||
if ($head) {
|
||||
echo '
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">' . $devlink . '</h3>
|
||||
' . $device_sysName . '
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<table class="table table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:1%;max-width:1%;"></th>
|
||||
<th style="width:10%;max-width: 10%;">Service</th>
|
||||
<th style="width:15%;max-width: 15%;">Last Changed</th>
|
||||
<th style="width:15%;max-width: 15%;">Description</th>
|
||||
<th >Message</th>
|
||||
<th style="width:5%;max-width:5%;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
';
|
||||
|
||||
$service_iteration++;
|
||||
|
||||
if ($service_iteration < 2 && $header) {
|
||||
echo '<div class="panel panel-default">';
|
||||
echo '<div class="panel-heading"><h3 class="panel-title">' . $devlink . '</h3>' . $device_sysName . '</div>';
|
||||
echo '<div class="panel-body">';
|
||||
echo '<table class="table table-hover table-condensed">';
|
||||
echo '<thead>';
|
||||
echo '<th style="width:1%;max-width:1%;"></th>';
|
||||
echo '<th style="width:10%;max-width: 10%;">Service</th>';
|
||||
echo '<th style="width:15%;max-width: 15%;">Last Changed</th>';
|
||||
echo '<th style="width:15%;max-width: 15%;">Description</th>';
|
||||
echo '<th >Message</th>';
|
||||
echo '<th style="width:5%;max-width:5%;"></th>';
|
||||
echo '</thead>';
|
||||
}
|
||||
$head = false;
|
||||
?>
|
||||
<tr id="row_<?php echo $service['service_id']; ?>">
|
||||
<td><span data-toggle='tooltip' title='<?php echo $title ?>'
|
||||
class='alert-status <?php echo $label ?>'> </span></td>
|
||||
<td><?php echo nl2br(display($service['service_type'])) ?></td>
|
||||
<td><?php echo formatUptime(time() - $service['service_changed']) ?></td>
|
||||
<td><?php echo nl2br(display($service['service_desc'])) ?></td>
|
||||
<td><?php echo nl2br(display($service['service_message'])) ?></td>
|
||||
<?php
|
||||
if (is_admin() === true) {
|
||||
echo "<td>
|
||||
|
||||
$header = false;
|
||||
|
||||
echo '<tr id="row_' . $service['service_id'] . '">';
|
||||
echo '<td><span data-toggle="tooltip" title="' . $title . '" class="alert-status ' . $label . '"></span></td>';
|
||||
echo '<td>' . nl2br(display($service['service_type'])) . '</td>';
|
||||
echo '<td>' . formatUptime(time() - $service['service_changed']) . '</td>';
|
||||
echo '<td>' . nl2br(display($service['service_desc'])) . '</td>';
|
||||
echo '<td>' . nl2br(display($service['service_message'])) . '</td>';
|
||||
|
||||
if (is_admin() === true) {
|
||||
echo "<td>
|
||||
<button type='button' class='btn btn-primary btn-sm' aria-label='Edit' data-toggle='modal' data-target='#create-service' data-service_id='{$service['service_id']}' name='edit-service'><i class='fa fa-pencil' aria-hidden='true'></i></button>
|
||||
<button type='button' class='btn btn-danger btn-sm' aria-label='Delete' data-toggle='modal' data-target='#confirm-delete' data-service_id='{$service['service_id']}' name='delete-service'><i class='fa fa-trash' aria-hidden='true'></i></button>
|
||||
</td>";
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
}//end foreach
|
||||
}
|
||||
echo '</tr>';
|
||||
|
||||
echo "</table></div></div>";
|
||||
unset($samehost);
|
||||
}//end foreach
|
||||
if ($service_iteration >= $services_count) {
|
||||
$footer = true;
|
||||
}
|
||||
|
||||
if ($footer) {
|
||||
echo '</table>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($samehost);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user