webui: Small eventlog cleanup (#8056)

* include status badge in first datetime col

* code formatting
This commit is contained in:
crcro 2018-01-09 22:36:28 +02:00 committed by Neil Lathwood
parent 6e134ac4e2
commit d85a228d5b
3 changed files with 24 additions and 21 deletions

View File

@ -2179,3 +2179,8 @@ label {
border-color: red;
}
.eventlog-status {
display: inline-block;
margin-right: 8px;
float: left;
}

View File

@ -18,7 +18,6 @@ $common_output[] = '
<table id="eventlog" class="table table-hover table-condensed table-striped">
<thead>
<tr>
<th data-column-id="eventicon"></th>
<th data-column-id="datetime" data-order="desc">Timestamp</th>
<th data-column-id="type">Type</th>
<th data-column-id="hostname">Hostname</th>
@ -37,8 +36,8 @@ var eventlog_grid = $("#eventlog").bootgrid({
{
return {
id: "eventlog",
device: "' .mres($vars['device']) .'",
eventtype: "' .mres($vars['eventtype']) .'",
device: "' . mres($vars['device']) . '",
eventtype: "' . mres($vars['eventtype']) . '",
};
},
url: "ajax_table.php"

View File

@ -16,7 +16,7 @@
$where = '1';
if (is_numeric($_POST['device'])) {
$where .= ' AND E.host = ?';
$where .= ' AND E.host = ?';
$param[] = $_POST['device'];
}
@ -26,14 +26,14 @@ if (!empty($_POST['eventtype'])) {
}
if ($_POST['string']) {
$where .= ' AND E.message LIKE ?';
$param[] = '%'.$_POST['string'].'%';
$where .= ' AND E.message LIKE ?';
$param[] = '%' . $_POST['string'] . '%';
}
if ($_SESSION['userlevel'] >= '5') {
$sql = " FROM `eventlog` AS E LEFT JOIN `devices` AS `D` ON `E`.`host`=`D`.`device_id` WHERE $where";
} else {
$sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?";
$sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?";
$param[] = $_SESSION['user_id'];
}
@ -42,7 +42,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) {
}
$count_sql = "SELECT COUNT(event_id) $sql";
$total = dbFetchCell($count_sql, $param);
$total = dbFetchCell($count_sql, $param);
if (empty($total)) {
$total = 0;
}
@ -54,7 +54,7 @@ if (!isset($sort) || empty($sort)) {
$sql .= " ORDER BY $sort";
if (isset($current)) {
$limit_low = (($current * $rowCount) - ($rowCount));
$limit_low = (($current * $rowCount) - ($rowCount));
$limit_high = $rowCount;
}
@ -62,36 +62,35 @@ if ($rowCount != -1) {
$sql .= " LIMIT $limit_low,$limit_high";
}
$sql = "SELECT `E`.*,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate,severity $sql";
$sql = "SELECT `E`.*,DATE_FORMAT(datetime, '" . $config['dateformat']['mysql']['compact'] . "') as humandate,severity $sql";
foreach (dbFetchRows($sql, $param) as $eventlog) {
$dev = device_by_id_cache($eventlog['host']);
if ($eventlog['type'] == 'interface') {
$this_if = cleanPort(getifbyid($eventlog['reference']));
$type = '<b>'.generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).'</b>';
$type = '<b>' . generate_port_link($this_if, makeshortif(strtolower($this_if['label']))) . '</b>';
} else {
$type = $eventlog['type'];
}
$severity_colour = $eventlog['severity'];
if ($eventlog['username'] == '') {
$eventlog['username'] = 'System';
$eventlog['username'] = 'System';
}
$response[] = array(
'eventicon' => "<span class='alert-status ".eventlog_severity($severity_colour)."'>&nbsp;</span>",
'datetime' => $eventlog['humandate'],
'hostname' => generate_device_link($dev, shorthost($dev['hostname'])),
'type' => $type,
'message' => htmlspecialchars($eventlog['message']),
'username' => $eventlog['username'],
'datetime' => "<span class='alert-status " . eventlog_severity($severity_colour) . " eventlog-status'></span><span style='display:inline;'>" . $eventlog['humandate'] . "</span>",
'hostname' => generate_device_link($dev, shorthost($dev['hostname'])),
'type' => $type,
'message' => htmlspecialchars($eventlog['message']),
'username' => $eventlog['username'],
);
}
$output = array(
'current' => $current,
'current' => $current,
'rowCount' => $rowCount,
'rows' => $response,
'total' => $total,
'rows' => $response,
'total' => $total,
);
echo _json_encode($output);