From 4bbf74461048d50805b2512535781f18b4661b22 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 14 Nov 2016 15:51:04 +0100 Subject: [statistics] Show red hdd icon in client list when filtering by ID44 == 0 and machine has no HDD installed at all --- modules-available/statistics/inc/filterset.inc.php | 10 ++++++++++ modules-available/statistics/page.inc.php | 12 +++++++++++- modules-available/statistics/templates/clientlist.html | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/modules-available/statistics/inc/filterset.inc.php b/modules-available/statistics/inc/filterset.inc.php index 9676732a..c73feeef 100644 --- a/modules-available/statistics/inc/filterset.inc.php +++ b/modules-available/statistics/inc/filterset.inc.php @@ -52,6 +52,16 @@ class FilterSet $sort = " ORDER BY " . $concreteCol . " " . $this->sortDirection . ", machineuuid ASC"; } + + public function isNoId44Filter() + { + foreach ($this->filters as $filter) { + if (get_class($filter) === 'Id44Filter' && $filter->argument == 0) { + return true; + } + } + return false; + } public function getSortDirection() { diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index 512f7ead..cf33c8af 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -500,8 +500,13 @@ class Page_Statistics extends Page { $filterSet->makeFragments($where, $join, $sort, $args); + $xtra = ''; + if ($filterSet->isNoId44Filter()) { + $xtra = ', data'; + } $res = Database::simpleQuery('SELECT machineuuid, macaddr, clientip, firstseen, lastseen,' - . ' logintime, lastboot, realcores, mbram, kvmstate, cpumodel, id44mb, hostname, notes IS NOT NULL AS hasnotes, badsectors FROM machine' + . ' logintime, lastboot, realcores, mbram, kvmstate, cpumodel, id44mb, hostname, notes IS NOT NULL AS hasnotes,' + . ' badsectors ' . $xtra . ' FROM machine' . " $join WHERE $where $sort", $args); $rows = array(); $NOW = time(); @@ -529,6 +534,11 @@ class Page_Statistics extends Page if (empty($row['hostname'])) { $row['hostname'] = $row['clientip']; } + if (isset($row['data'])) { + if (!preg_match('/^Disk.*bytes$/m', $row['data'])) { + $row['nohdd'] = true; + } + } $rows[] = $row; } Render::addTemplate('clientlist', array( diff --git a/modules-available/statistics/templates/clientlist.html b/modules-available/statistics/templates/clientlist.html index 2bac29fa..73148eb8 100644 --- a/modules-available/statistics/templates/clientlist.html +++ b/modules-available/statistics/templates/clientlist.html @@ -82,6 +82,9 @@ {{badsectors}} {{/badsectors}} + {{#nohdd}}
+ +
{{/nohdd}} {{lang_realCores}}: {{realcores}}
{{cpumodel}}
-- cgit v1.2.3-55-g7522