summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
authorSimon Rettberg2024-11-05 15:22:46 +0100
committerSimon Rettberg2024-11-05 15:22:46 +0100
commita1b7339582f82502ac6a6591fb51535c695cf074 (patch)
treea634dc77670b78869fc8d512bfaabf69fe706371 /modules-available
parent[minilinux] Handle invalid parameter (diff)
downloadslx-admin-a1b7339582f82502ac6a6591fb51535c695cf074.tar.gz
slx-admin-a1b7339582f82502ac6a6591fb51535c695cf074.tar.xz
slx-admin-a1b7339582f82502ac6a6591fb51535c695cf074.zip
[statistics] Disable non-client filter if specific filters are given
Diffstat (limited to 'modules-available')
-rw-r--r--modules-available/statistics/inc/statisticsfilterset.inc.php16
-rw-r--r--modules-available/statistics/pages/summary.inc.php4
2 files changed, 19 insertions, 1 deletions
diff --git a/modules-available/statistics/inc/statisticsfilterset.inc.php b/modules-available/statistics/inc/statisticsfilterset.inc.php
index 26595e93..5840821b 100644
--- a/modules-available/statistics/inc/statisticsfilterset.inc.php
+++ b/modules-available/statistics/inc/statisticsfilterset.inc.php
@@ -41,6 +41,22 @@ class StatisticsFilterSet
$this->cache = compact('where', 'join', 'args');
}
+ /**
+ * Are there any "specific filters" in place?
+ * We consider filters specific that filter by precise information like
+ * CPU model, IP address, MAC address, etc. In those cases we might not
+ * want to filter non-client machines in the summary view, for example.
+ */
+ public function hasSpecificFilters(): bool
+ {
+ $ignored = ['firstseen', 'lastseen', 'lastboot', 'runtime', 'state'];
+ foreach ($this->filters as $key => $_) {
+ if (!in_array($key, $ignored))
+ return true;
+ }
+ return false;
+ }
+
public function filterNonClients()
{
if (Module::get('runmode') === false || $this->hasFilter('IsClientStatisticsFilter') !== null)
diff --git a/modules-available/statistics/pages/summary.inc.php b/modules-available/statistics/pages/summary.inc.php
index 905f5d90..a540e39e 100644
--- a/modules-available/statistics/pages/summary.inc.php
+++ b/modules-available/statistics/pages/summary.inc.php
@@ -31,7 +31,9 @@ class SubPage
dechex((int)(abs((5 - $i) * 51))));
}
- $filterSet->filterNonClients();
+ if (!$filterSet->hasSpecificFilters()) {
+ $filterSet->filterNonClients();
+ }
StatisticsFilter::renderFilterBox('summary', $filterSet);
Render::openTag('div', array('class' => 'row'));
self::showSummary($filterSet);