mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Globalize getColorForState function (#10944)
* globalize getColorForState function
This commit is contained in:
@@ -37,4 +37,21 @@ abstract class Transport implements TransportInterface
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hex color string for a particular state
|
||||
* @param integer $state State code from alert
|
||||
* @return string Hex color, default to #337AB7 blue if state unrecognised
|
||||
*/
|
||||
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
|
||||
);
|
||||
return isset($colors[$state]) ? $colors[$state] : '#337AB7';
|
||||
}
|
||||
}
|
||||
|
@@ -76,7 +76,6 @@ class Hipchat extends Transport
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data[] = "message=" . urlencode($obj["msg"]);
|
||||
if ($version == 1) {
|
||||
$data[] = "room_id=" . urlencode($option["room_id"]);
|
||||
|
@@ -52,24 +52,6 @@ class Msteams extends Transport
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hex color string for a particular state
|
||||
* @param integer $state State code from alert
|
||||
* @return string Hex color, default to #337AB7 blue if state unrecognised
|
||||
*/
|
||||
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
|
||||
);
|
||||
|
||||
return isset($colors[$state]) ? $colors[$state] : '#337AB7';
|
||||
}
|
||||
|
||||
public static function configTemplate()
|
||||
{
|
||||
return [
|
||||
|
Reference in New Issue
Block a user