From d0997d09d4b3f811ff46b0b787cfce018e42cacf Mon Sep 17 00:00:00 2001 From: Rosiak Date: Tue, 3 Mar 2015 18:48:40 +0100 Subject: [PATCH 1/2] Print alert state and a matching glyphic - Print alert state on default front page and on alert-log page. Prints the state and a matching glyphicon. --- html/includes/print-alerts.inc.php | 23 +++++++++++++++++++++-- html/pages/alert-log.inc.php | 4 ++-- html/pages/front/default.php | 4 ++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/html/includes/print-alerts.inc.php b/html/includes/print-alerts.inc.php index a6a8c98801..e6b6ab4ec3 100644 --- a/html/includes/print-alerts.inc.php +++ b/html/includes/print-alerts.inc.php @@ -1,6 +1,7 @@ @@ -14,8 +15,26 @@ if (!isset($alert_entry['device'])) { "); } -echo("".htmlspecialchars($alert_entry['name']) . " +echo("".htmlspecialchars($alert_entry['name']) . ""); -"); +if ($alert_state!='') { + if ($alert_state=='0') { + echo(" Ok"); + } + elseif ($alert_state=='1') { + echo(" Alert"); + } + elseif ($alert_state=='2') { + echo(" Ack"); + } + elseif ($alert_state=='3') { + echo(" Worse"); + } + elseif ($alert_state=='4') { + echo(" Better"); + } +} + +echo(""); ?> diff --git a/html/pages/alert-log.inc.php b/html/pages/alert-log.inc.php index fc9eacaa02..812097da54 100644 --- a/html/pages/alert-log.inc.php +++ b/html/pages/alert-log.inc.php @@ -60,7 +60,7 @@ if ($_SESSION['userlevel'] >= '5') } $count_query = "SELECT COUNT(time_logged) $query"; $count = dbFetchCell($count_query,$param); -$full_query = "SELECT D.device_id,name,time_logged,DATE_FORMAT(time_logged, '%D %b %Y %T') as humandate $query LIMIT $start,$numresults"; +$full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '%D %b %Y %T') as humandate $query LIMIT $start,$numresults"; echo('
@@ -112,4 +112,4 @@ echo(' $('#page_number').val(page); $('#result_form').submit(); } - \ No newline at end of file + diff --git a/html/pages/front/default.php b/html/pages/front/default.php index 2e6e34c268..12bdc52e90 100644 --- a/html/pages/front/default.php +++ b/html/pages/front/default.php @@ -199,10 +199,10 @@ if ($config['enable_syslog']) if ($_SESSION['userlevel'] >= '10') { $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; - $alertquery = "SELECT devices.device_id,name,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id RIGHT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15"; + $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id RIGHT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15"; } else { $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; - $alertquery = "SELECT devices.device_id,name,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id RIGHT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id'] . " ORDER BY `time_logged` DESC LIMIT 0,15"; + $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id RIGHT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id'] . " ORDER BY `time_logged` DESC LIMIT 0,15"; } $data = mysql_query($query); From dbf0107827c0fe5f9b9d30c9f9038f2542a568b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Rosiak?= Date: Tue, 3 Mar 2015 19:25:20 +0100 Subject: [PATCH 2/2] Update print-alerts.inc.php - Changed using lafwoods suggested changes. --- html/includes/print-alerts.inc.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/html/includes/print-alerts.inc.php b/html/includes/print-alerts.inc.php index e6b6ab4ec3..2a6d71a471 100644 --- a/html/includes/print-alerts.inc.php +++ b/html/includes/print-alerts.inc.php @@ -19,20 +19,31 @@ echo("".htmlspecialchars($alert_entry['name']) . ""); if ($alert_state!='') { if ($alert_state=='0') { - echo(" Ok"); + $glyph_icon = 'ok'; + $glyph_color = 'green'; + $text = 'Ok'; } elseif ($alert_state=='1') { - echo(" Alert"); + $glyph_icon = 'remove'; + $glyph_color = 'red'; + $text = 'Alert'; } elseif ($alert_state=='2') { - echo(" Ack"); + $glyph_icon = 'info-sign'; + $glyph_color = 'lightgrey'; + $text = 'Ack'; } elseif ($alert_state=='3') { - echo(" Worse"); + $glyph_icon = 'arrow-down'; + $glyph_color = 'orange'; + $text = 'Worse'; } elseif ($alert_state=='4') { - echo(" Better"); + $glyph_icon = 'arrow-up'; + $glyph_color = 'khaki'; + $text = 'Better'; } + echo(" $text"); } echo("");