summaryrefslogtreecommitdiffstats
path: root/modules-available/rebootcontrol
diff options
context:
space:
mode:
authorSimon Rettberg2017-05-09 17:31:37 +0200
committerSimon Rettberg2017-05-09 17:31:37 +0200
commitdd497ba5a35285e9b41ee592095d3356480ed9d6 (patch)
tree61926f10ab25af423c901dc9ffe475950b467918 /modules-available/rebootcontrol
parentUpdate translations (diff)
downloadslx-admin-dd497ba5a35285e9b41ee592095d3356480ed9d6.tar.gz
slx-admin-dd497ba5a35285e9b41ee592095d3356480ed9d6.tar.xz
slx-admin-dd497ba5a35285e9b41ee592095d3356480ed9d6.zip
[rebootcontrol] Fix current session display, colors for on/off
Diffstat (limited to 'modules-available/rebootcontrol')
-rw-r--r--modules-available/rebootcontrol/inc/rebootqueries.inc.php17
-rw-r--r--modules-available/rebootcontrol/templates/_page.html4
2 files changed, 17 insertions, 4 deletions
diff --git a/modules-available/rebootcontrol/inc/rebootqueries.inc.php b/modules-available/rebootcontrol/inc/rebootqueries.inc.php
index 62092748..3b665e5b 100644
--- a/modules-available/rebootcontrol/inc/rebootqueries.inc.php
+++ b/modules-available/rebootcontrol/inc/rebootqueries.inc.php
@@ -19,12 +19,25 @@ class RebootQueries
}
$res = Database::simpleQuery("
SELECT machine.machineuuid, machine.hostname, machine.clientip,
- IF(machine.lastboot = 0 OR UNIX_TIMESTAMP() - machine.lastseen >= 600, 0, 1) AS status,
+ machine.lastboot, machine.lastseen, machine.logintime,
$sessionField, machine.currentuser, machine.locationid
FROM machine
$leftJoin
WHERE " . $where, array('locationid' => $locationId));
- return $res->fetchAll(PDO::FETCH_ASSOC);
+ $ret = $res->fetchAll(PDO::FETCH_ASSOC);
+ $NOW = time();
+ foreach ($ret as &$row) {
+ if ($row['lastboot'] == 0 || $NOW - $row['lastseen'] > 600) {
+ $row['status'] = 0;
+ } else {
+ $row['status'] = 1;
+ }
+ if ($row['status'] === 0 || $row['logintime'] == 0) {
+ $row['currentuser'] = '';
+ $row['currentsession'] = '';
+ }
+ }
+ return $ret;
}
/**
diff --git a/modules-available/rebootcontrol/templates/_page.html b/modules-available/rebootcontrol/templates/_page.html
index 690316df..065a9f01 100644
--- a/modules-available/rebootcontrol/templates/_page.html
+++ b/modules-available/rebootcontrol/templates/_page.html
@@ -40,10 +40,10 @@
<td>{{clientip}}</td>
<td class="statusColumn">
{{#status}}
- {{lang_on}}
+ <span class="text-success">{{lang_on}}</span>
{{/status}}
{{^status}}
- {{lang_off}}
+ <span class="text-danger">{{lang_off}}</span>
{{/status}}
</td>
<td>{{#status}}{{currentsession}}{{/status}}</td>