diff options
Diffstat (limited to 'modules-available/statistics')
5 files changed, 55 insertions, 7 deletions
diff --git a/modules-available/statistics/inc/filter.inc.php b/modules-available/statistics/inc/filter.inc.php index be6df752..1686f328 100644 --- a/modules-available/statistics/inc/filter.inc.php +++ b/modules-available/statistics/inc/filter.inc.php @@ -88,15 +88,17 @@ class Filter $lhs = trim(substr($q, 0, $pos)); $rhs = trim(substr($q, $pos + strlen($operator))); - if ($lhs == 'gbram') { + if ($lhs === 'gbram') { $filters[] = new RamGbFilter($operator, $rhs); - } elseif ($lhs == 'state') { + } elseif ($lhs === 'runtime') { + $filters[] = new RuntimeFilter($operator, $rhs); + } elseif ($lhs === 'state') { $filters[] = new StateFilter($operator, $rhs); - } elseif ($lhs == 'hddgb') { + } elseif ($lhs === 'hddgb') { $filters[] = new Id44Filter($operator, $rhs); - } elseif ($lhs == 'location') { + } elseif ($lhs === 'location') { $filters[] = new LocationFilter($operator, $rhs); - } elseif ($lhs == 'subnet') { + } elseif ($lhs === 'subnet') { $filters[] = new SubnetFilter($operator, $rhs); } else { if (array_key_exists($lhs, Page_Statistics::$columns) && Page_Statistics::$columns[$lhs]['column']) { @@ -143,6 +145,38 @@ class RamGbFilter extends Filter } } +class RuntimeFilter extends Filter +{ + public function __construct($operator, $argument) + { + parent::__construct('lastboot', $operator, $argument); + } + + public function whereClause(&$args, &$joins) + { + global $SIZE_RAM; + $lower = time() + (int)$this->argument * 3600; + $upper = $lower + 3600; + $common = "state IN ('OCCUPIED', 'IDLE', 'STANDBY') AND"; + if ($this->operator == '=') { + return "$common ({$this->column} BETWEEN $lower AND $upper)"; + } elseif ($this->operator == '<') { + return "$common {$this->column} < $lower"; + } elseif ($this->operator == '<=') { + return "$common {$this->column} < $upper"; + } elseif ($this->operator == '>') { + return "$common {$this->column} > $upper"; + } elseif ($this->operator == '>=') { + return "$common {$this->column} > $lower"; + } elseif ($this->operator == '!=') { + return "$common ({$this->column} < $lower OR {$this->column} > $upper)"; + } else { + error_log("unimplemented operator in RuntimeFilter: $this->operator"); + return ' 1'; + } + } +} + class Id44Filter extends Filter { public function __construct($operator, $argument) diff --git a/modules-available/statistics/lang/de/template-tags.json b/modules-available/statistics/lang/de/template-tags.json index 3cdde813..b8cf0bb1 100644 --- a/modules-available/statistics/lang/de/template-tags.json +++ b/modules-available/statistics/lang/de/template-tags.json @@ -68,6 +68,7 @@ "lang_reallocatedSectors": "Defekte Sektoren", "lang_runMode": "Betriebsmodus", "lang_runmodeMachines": "Mit besonderem Betriebsmodus", + "lang_runtimeHours": "Laufzeit (Stunden)", "lang_screens": "Bildschirme", "lang_serialNo": "Serien-Nr", "lang_showList": "Liste", diff --git a/modules-available/statistics/lang/en/template-tags.json b/modules-available/statistics/lang/en/template-tags.json index 35c4e68a..3529b7d0 100644 --- a/modules-available/statistics/lang/en/template-tags.json +++ b/modules-available/statistics/lang/en/template-tags.json @@ -68,6 +68,7 @@ "lang_reallocatedSectors": "Bad sectors", "lang_runMode": "Mode of operation", "lang_runmodeMachines": "With special mode of operation", + "lang_runtimeHours": "Runtime (hours)", "lang_screens": "Screens", "lang_serialNo": "Serial no", "lang_showList": "List", diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index 77b52e0d..09359342 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -104,6 +104,11 @@ class Page_Statistics extends Page 'type' => 'string', 'column' => true ], + 'hostname' => [ + 'op' => Page_Statistics::$op_stringcmp, + 'type' => 'string', + 'column' => true + ], 'subnet' => [ 'op' => Page_Statistics::$op_nominal, 'type' => 'string', @@ -119,7 +124,12 @@ class Page_Statistics extends Page 'type' => 'enum', 'column' => true, 'values' => ['occupied', 'on', 'off', 'idle', 'standby'] - ] + ], + 'runtime' => [ + 'op' => Page_Statistics::$op_ordinal, + 'type' => 'int', + 'column' => true + ], ]; if (Module::isAvailable('locations')) { Page_Statistics::$columns['location'] = [ diff --git a/modules-available/statistics/templates/filterbox.html b/modules-available/statistics/templates/filterbox.html index 758bc287..58b66a75 100644 --- a/modules-available/statistics/templates/filterbox.html +++ b/modules-available/statistics/templates/filterbox.html @@ -99,7 +99,9 @@ var slxFilterNames = { state: '{{lang_usageState}}', location: '{{lang_location}}', currentuser: '{{lang_currentUser}}', - subnet: '{{lang_subnet}}' + subnet: '{{lang_subnet}}', + runtime: '{{lang_runtimeHours}}', + hostname: '{{lang_hostname}}' }; slxLocations = {{{locations}}}; |