diff options
Diffstat (limited to 'modules-available/statistics/inc/statisticsstyling.inc.php')
-rw-r--r-- | modules-available/statistics/inc/statisticsstyling.inc.php | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/modules-available/statistics/inc/statisticsstyling.inc.php b/modules-available/statistics/inc/statisticsstyling.inc.php new file mode 100644 index 00000000..0e158026 --- /dev/null +++ b/modules-available/statistics/inc/statisticsstyling.inc.php @@ -0,0 +1,62 @@ +<?php + +class StatisticsStyling +{ + + public static function ramColorClass(int $mb): string + { + if ($mb < 2500) { + return 'danger'; + } + if ($mb < 5100) { + return 'warning'; + } + + return ''; + } + + public static function kvmColorClass(string $state): string + { + if ($state === 'DISABLED') { + return 'danger'; + } + if ($state === 'UNKNOWN' || $state === 'UNSUPPORTED') { + return 'warning'; + } + + return ''; + } + + public static function hddColorClass(int $gb): string + { + if ($gb < 7) { + return 'danger'; + } + if ($gb < 25) { + return 'warning'; + } + + return ''; + } + + /** + * Take a machine state enum value, return a matching glyphicon class. + * @param string $state State value (OFFLINE, IDLE, ...) + */ + public static function machineStateToIcon(string $state): string + { + switch ($state) { + case 'OFFLINE': + return 'glyphicon-off'; + case 'IDLE': + return 'glyphicon-ok green'; + case 'OCCUPIED': + return 'glyphicon-user red'; + case 'STANDBY': + return 'glyphicon-off green'; + default: + return 'glyphicon-question-sign'; + } + } + +}
\ No newline at end of file |