diff --git a/includes/html/functions.inc.php b/includes/html/functions.inc.php index 8f7c300f20..037a0fc1df 100644 --- a/includes/html/functions.inc.php +++ b/includes/html/functions.inc.php @@ -331,6 +331,33 @@ function print_graph_tag($args) echo generate_graph_tag($args); }//end print_graph_tag() +function alert_layout($severity) +{ + switch ($severity) { + case 'critical': + $icon = 'exclamation'; + $color = 'danger'; + $background = 'danger'; + break; + case 'warning': + $icon = 'warning'; + $color = 'warning'; + $background = 'warning'; + break; + case 'ok': + $icon = 'check'; + $color = 'success'; + $background = 'success'; + break; + default: + $icon = 'info'; + $color = 'info'; + $background = 'info'; + } + return ['icon' => $icon, + 'icon_color' => $color, + 'background_color' => $background]; +} function generate_graph_tag($args) { diff --git a/includes/html/print-alert-rules.php b/includes/html/print-alert-rules.php index 730eccd384..9c1cf24a58 100644 --- a/includes/html/print-alert-rules.php +++ b/includes/html/print-alert-rules.php @@ -188,6 +188,7 @@ foreach ($rule_list as $rule) { } $sub = dbFetchRows('SELECT * FROM alerts WHERE rule_id = ? ORDER BY `state` DESC, `id` DESC LIMIT 1', array($rule['id'])); + $severity = dbFetchCell('SELECT severity FROM alert_rules where id = ?', array($rule['id'])); $ico = 'check'; $col = 'success'; $extra = ''; @@ -200,9 +201,10 @@ foreach ($rule_list as $rule) { $status_msg = "All devices matching " . $rule['name'] . " are OK"; } if ((int) $sub['state'] === 1 || (int) $sub['state'] === 2) { - $ico = 'exclamation'; - $col = 'danger'; - $extra = 'danger'; + $alert_style = alert_layout($severity); + $ico = $alert_style['icon']; + $col = $alert_style['icon_color']; + $extra = $alert_style['background_color']; $status_msg = "Some devices matching " . $rule['name'] . " are currently alerting"; } } diff --git a/includes/html/table/alerts.inc.php b/includes/html/table/alerts.inc.php index 6124577d7d..da337bea8a 100644 --- a/includes/html/table/alerts.inc.php +++ b/includes/html/table/alerts.inc.php @@ -132,20 +132,7 @@ foreach (dbFetchRows($sql, $param) as $alert) { $hostname = '
' . generate_device_link($alert, format_hostname($alert, shorthost($alert['hostname']))) . '
' . $fault_detail . '
'; $severity = $alert['severity']; - switch ($severity) { - case 'critical': - $severity_ico = ' '; - break; - case 'warning': - $severity_ico = ' '; - break; - case 'ok': - $severity_ico = ' '; - break; - default: - $severity_ico = ' '; - break; - } + $severity_ico = ' '; if ($alert['state'] == 3) { $severity .= ' +';