mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Corrected active_count for Alert icon color (#9933)
* Corrected active_count for Alert icon color * Corrected active_count for Alert icon color * Corrected active_count for Alert icon color * Laravel version * Laravel version check status worse and better for isActive * cleanup
This commit is contained in:
@@ -222,6 +222,9 @@ class MenuComposer
|
||||
$alert_status = AlertRule::select('severity')
|
||||
->isActive()
|
||||
->hasAccess($user)
|
||||
->leftJoin('devices', 'alerts.device_id', '=', 'devices.device_id')
|
||||
->where('devices.disabled', '=', '0')
|
||||
->where('devices.ignore', '=', '0')
|
||||
->groupBy('severity')
|
||||
->pluck('severity');
|
||||
|
||||
|
@@ -39,7 +39,7 @@ class AlertRule extends BaseModel
|
||||
*/
|
||||
public function scopeEnabled($query)
|
||||
{
|
||||
return $query->where('disabled', 0);
|
||||
return $query->where('alert_rules.disabled', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ class AlertRule extends BaseModel
|
||||
{
|
||||
return $query->enabled()
|
||||
->join('alerts', 'alerts.rule_id', 'alert_rules.id')
|
||||
->where('alerts.state', 1);
|
||||
->whereNotIn('alerts.state', [0, 2]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -3,10 +3,10 @@
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
$data['active_count'] = array('query' => 'SELECT COUNT(`alerts`.`id`) FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id` RIGHT JOIN `alert_rules` ON `alerts`.`rule_id`=`alert_rules`.`id` WHERE 1 AND `alerts`.`state` NOT IN (0,1)');
|
||||
$data['active_count'] = array('query' => 'SELECT COUNT(`alerts`.`id`) FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id` RIGHT JOIN `alert_rules` ON `alerts`.`rule_id`=`alert_rules`.`id` WHERE 1 AND `alerts`.`state` NOT IN (0,2) AND `devices`.`disabled` = 0 AND `devices`.`ignore` = 0');
|
||||
} else {
|
||||
$data['active_count'] = array(
|
||||
'query' => 'SELECT COUNT(`alerts`.`id`) FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id` LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id` RIGHT JOIN `alert_rules` ON `alerts`.`rule_id`=`alert_rules`.`id` WHERE 1 AND `alerts`.`state` NOT IN (0,1) AND `DP`.`user_id`=?',
|
||||
'query' => 'SELECT COUNT(`alerts`.`id`) FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id` LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id` RIGHT JOIN `alert_rules` ON `alerts`.`rule_id`=`alert_rules`.`id` WHERE 1 AND `alerts`.`state` NOT IN (0,2) AND `devices`.`disabled` = 0 AND `devices`.`ignore` = 0 AND `DP`.`user_id`=?',
|
||||
'params' => array(LegacyAuth::id()),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user