summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/page.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2017-11-13 23:38:56 +0100
committerSimon Rettberg2017-11-13 23:38:56 +0100
commit83097db5279b319cd7b6631aad52c7ab43d0d11b (patch)
tree64c0a72fc3b81371f72b3ebd5e68fe51f9e79db9 /modules-available/statistics/page.inc.php
parent[syslog] Tweak machineuuid index in installer (diff)
downloadslx-admin-83097db5279b319cd7b6631aad52c7ab43d0d11b.tar.gz
slx-admin-83097db5279b319cd7b6631aad52c7ab43d0d11b.tar.xz
slx-admin-83097db5279b319cd7b6631aad52c7ab43d0d11b.zip
[statistics] Show client details if filter has exactly one result
Diffstat (limited to 'modules-available/statistics/page.inc.php')
-rw-r--r--modules-available/statistics/page.inc.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php
index 2b12c69f..479f3089 100644
--- a/modules-available/statistics/page.inc.php
+++ b/modules-available/statistics/page.inc.php
@@ -308,6 +308,14 @@ class Page_Statistics extends Page
}
}
+ private function redirectFirst($where, $join, $args)
+ {
+ $res = Database::queryFirst("SELECT machineuuid FROM machine $join WHERE ($where) LIMIT 1", $args);
+ if ($res !== false) {
+ Util::redirect('?do=statistics&uuid=' . $res['machineuuid']);
+ }
+ }
+
/**
* @param \FilterSet $filterSet
*/
@@ -316,6 +324,10 @@ class Page_Statistics extends Page
$filterSet->makeFragments($where, $join, $sort, $args);
$known = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE ($where)", $args);
+ // If we only have one machine, redirect to machine details
+ if ($known['val'] == 1) {
+ $this->redirectFirst($where, $join, $args);
+ }
$on = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE lastboot <> 0 AND ($where)", $args);
$used = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE lastboot <> 0 AND logintime <> 0 AND ($where)", $args);
$hdd = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE badsectors >= 10 AND ($where)", $args);
@@ -565,7 +577,13 @@ class Page_Statistics extends Page
. " $join WHERE $where $sort", $args);
$rows = array();
$NOW = time();
+ $singleMachine = 'none';
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ if ($singleMachine === 'none') {
+ $singleMachine = $row['machineuuid'];
+ } else {
+ $singleMachine = false;
+ }
if ($row['lastboot'] == 0) {
$row['state_off'] = true;
} elseif ($row['logintime'] == 0) {
@@ -596,6 +614,9 @@ class Page_Statistics extends Page
}
$rows[] = $row;
}
+ if ($singleMachine !== false && $singleMachine !== 'none') {
+ Util::redirect('?do=statistics&uuid=' . $singleMachine);
+ }
Render::addTemplate('clientlist', array(
'rowCount' => count($rows),
'rows' => $rows,