Move alert state color definition to config (#10958)

This commit is contained in:
SourceDoctor
2019-12-18 11:08:32 +01:00
committed by PipoCanaja
parent c9ae2891dd
commit b24bf02c2a
2 changed files with 27 additions and 5 deletions

View File

@@ -3,6 +3,7 @@
namespace LibreNMS\Alert;
use LibreNMS\Interfaces\Alert\Transport as TransportInterface;
use LibreNMS\Config;
abstract class Transport implements TransportInterface
{
@@ -46,12 +47,13 @@ abstract class Transport implements TransportInterface
public static function getColorForState($state)
{
$colors = array(
0 => '#00FF00', // OK - green
1 => '#FF0000', // Bad - red
2 => '#337AB7', // Acknowledged - blue
3 => '#FF0000', // Worse - red
4 => '#F0AD4E', // Better - yellow
0 => Config::get('alert_colour.ok'),
1 => Config::get('alert_colour.bad'),
2 => Config::get('alert_colour.acknowledged'),
3 => Config::get('alert_colour.worse'),
4 => Config::get('alert_colour.better'),
);
return isset($colors[$state]) ? $colors[$state] : '#337AB7';
}
}

View File

@@ -27,6 +27,26 @@
"order": 1,
"type": "boolean"
},
"alert_colour.ok": {
"default": "#00ff00",
"type": "color"
},
"alert_colour.bad": {
"default": "#ff0000",
"type": "color"
},
"alert_colour.acknowledged": {
"default": "#337ab7",
"type": "color"
},
"alert_colour.worse": {
"default": "#ff0000",
"type": "color"
},
"alert_colour.better": {
"default": "#f0ad4e",
"type": "color"
},
"alert.default_copy": {
"default": true,
"group": "alerting",