summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/inc/statisticsstyling.inc.php
blob: 0e1580260489fc20db6c5e28e5ab99dee767e3aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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';
		}
	}

}