summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
authorMichael Scherle2017-01-20 14:11:11 +0100
committerMichael Scherle2017-01-20 14:11:11 +0100
commitd1193724712d1f8652e5485a30d7dbd395464ecd (patch)
tree3e61499583fcb64a084766b35744f8044e792f34 /modules-available
parentfrontend: hide pcs with pos == null (diff)
parent[locationinfo] Take lastboot into account when calcing pc state (diff)
downloadslx-admin-d1193724712d1f8652e5485a30d7dbd395464ecd.tar.gz
slx-admin-d1193724712d1f8652e5485a30d7dbd395464ecd.tar.xz
slx-admin-d1193724712d1f8652e5485a30d7dbd395464ecd.zip
Merge branch 'location-info-panel' of git.openslx.org:openslx-ng/slx-admin into location-info-panel
Diffstat (limited to 'modules-available')
-rw-r--r--modules-available/locationinfo/api.inc.php25
-rw-r--r--modules-available/locationinfo/inc/locationinfo.inc.php11
-rw-r--r--modules-available/locationinfo/page.inc.php4
-rw-r--r--modules-available/locationinfo/templates/location-info.html30
-rw-r--r--modules-available/locationinfo/templates/pcsubtable.html24
-rw-r--r--modules-available/locationinfo/templates/timetable.html12
6 files changed, 37 insertions, 69 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php
index 515ac81f..ddbd1304 100644
--- a/modules-available/locationinfo/api.inc.php
+++ b/modules-available/locationinfo/api.inc.php
@@ -136,12 +136,28 @@ function getOpeningTimesFromParent($locationID) {
$parentlocationid = (int)$dbdata['parentlocationid'];
}
if ($parentlocationid == 0) {
- echo json_encode(array());
+ echo json_encode(createBasicClosingTime(), true);
}else {
getOpeningTimes($parentlocationid);
}
}
+function createBasicClosingTime() {
+ $weekarray = array ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
+ $array = array();
+ foreach ($weekarray as $d) {
+ $a = array();
+ $arr['HourOpen'] = '00';
+ $arr['MinutesOpen'] = '00';
+
+ $arr['HourClose'] = '23';
+ $arr['MinutesClose'] = '59';
+ $a[] = $arr;
+ $array[$d] = $a;
+ }
+ return $array;
+}
+
function getOpeningTimes($locationID) {
$error = checkIfHidden($locationID);
if ($error == true) {
@@ -209,9 +225,9 @@ function getRoomInfoJson($locationID, $coords) {
function getPcInfos($locationID, $coords) {
if ($coords == '1') {
- $dbquery = Database::simpleQuery("SELECT machineuuid, position, logintime, lastseen FROM `machine` WHERE locationid = :locationID" , array('locationID' => $locationID));
+ $dbquery = Database::simpleQuery("SELECT machineuuid, position, logintime, lastseen, lastboot FROM `machine` WHERE locationid = :locationID" , array('locationID' => $locationID));
} else {
- $dbquery = Database::simpleQuery("SELECT machineuuid, logintime, lastseen FROM `machine` WHERE locationid = :locationID" , array('locationID' => $locationID));
+ $dbquery = Database::simpleQuery("SELECT machineuuid, logintime, lastseen, lastboot FROM `machine` WHERE locationid = :locationID" , array('locationID' => $locationID));
}
$pcs = array();
@@ -228,13 +244,12 @@ function getPcInfos($locationID, $coords) {
$computer['y'] = $position['gridRow'];
}
- $computer['pcState'] = LocationInfo::getPcState((int)$pc['logintime'], (int)$pc['lastseen']);
+ $computer['pcState'] = LocationInfo::getPcState($pc);
$pcs[] = $computer;
}
$str = json_encode($pcs, true);
- error_log($str);
return $str;
}
diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php
index f81d79f6..d4bd2b0a 100644
--- a/modules-available/locationinfo/inc/locationinfo.inc.php
+++ b/modules-available/locationinfo/inc/locationinfo.inc.php
@@ -3,7 +3,7 @@
class LocationInfo
{
- public static function getPcState($logintime, $lastseen)
+ public static function getPcState($pc)
{
/* pcState:
* [0] = IDLE (NOT IN USE)
@@ -12,13 +12,16 @@ class LocationInfo
* [3] = 10 days offline (BROKEN?)
*/
+ $logintime = (int)$pc['logintime'];
+ $lastseen = (int)$pc['lastseen'];
+ $lastboot = (int)$pc['lastboot'];
$NOW = time();
- if ($NOW - $lastseen > 864000) {
+ if ($NOW - $lastseen > 14*86400) {
return 3;
- } elseif ($NOW - $lastseen > 610) {
+ } elseif (($NOW - $lastseen > 610) || $lastboot === 0) {
return 2;
- } elseif ($logintime == 0) {
+ } elseif ($logintime === 0) {
return 0;
} elseif ($logintime > 0) {
return 1;
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php
index e9ce1159..20df023c 100644
--- a/modules-available/locationinfo/page.inc.php
+++ b/modules-available/locationinfo/page.inc.php
@@ -384,7 +384,7 @@ class Page_LocationInfo extends Page
//TODO REMOVE FUNCTION. NOT NECCESSARY BUT AFTER TESTING pcSTATE
private function ajaxShowLocation($id)
{
- $dbquery = Database::simpleQuery("SELECT machineuuid, clientip, position, logintime, lastseen FROM `machine` WHERE locationid = :id", array('id' => $id));
+ $dbquery = Database::simpleQuery("SELECT machineuuid, clientip, position, logintime, lastseen, lastboot FROM `machine` WHERE locationid = :id", array('id' => $id));
$data = array();
@@ -392,7 +392,7 @@ class Page_LocationInfo extends Page
$pc = array();
$pc['id'] = $dbdata['machineuuid'];
$pc['ip'] = $dbdata['clientip'];
- $pc['pcState'] = LocationInfo::getPcState($dbdata['logintime'], $dbdata['lastseen']);
+ $pc['pcState'] = LocationInfo::getPcState($dbdata);
$position = json_decode($dbdata['position'], true);
$pc['x'] = $position['gridRow'];
diff --git a/modules-available/locationinfo/templates/location-info.html b/modules-available/locationinfo/templates/location-info.html
index 98786934..82b0ad15 100644
--- a/modules-available/locationinfo/templates/location-info.html
+++ b/modules-available/locationinfo/templates/location-info.html
@@ -78,9 +78,9 @@
</tr>
{{#list}}
- <tr id="row{{locationid}}" class="tablerow" onclick="{{#hasPcs}}slxOpenLocationInfo(this, {{locationid}}){{/hasPcs}}">
+ <tr id="row{{locationid}}" class="tablerow">
- <td><div style="display:inline-block;width:{{depth}}em"></div>{{#hasPcs}}<a>{{/hasPcs}}{{locationname}}{{#hasPcs}}</a>{{/hasPcs}}</td>
+ <td><div style="display:inline-block;width:{{depth}}em"></div>{{locationname}}</td>
<td align="center">[{{locationid}}]</td>
<td align="center">{{#hasPcs}}{{pcState}} / {{total}}{{/hasPcs}}</td>
@@ -134,32 +134,6 @@ function cbClick(cb, locID) {
window.location.href = "?do=locationinfo&action=hide&id=" + locID + "&value=" + value;
}
-function slxOpenLocationInfo(e, locationId) {
- if (lastPcSubTable !== false) {
- lastPcSubTable.hide();
- $(lastPcSubTable).prev().removeClass('active slx-bold');
- }
-
- var existing = $('#subtable' + locationId);
- if (existing.length > 0) {
- if (existing.is(lastPcSubTable)) {
- lastPcSubTable = false;
- } else {
- existing.show();
- $(e).closest('tr').addClass('active slx-bold');
- lastPcSubTable = existing;
- }
- return;
- }
-
- var td = $('<td>').attr('colspan', '3').css('padding', '0px 0px 12px');
- var tr = $('<tr>').attr('id', 'subtable' + locationId);
- tr.append(td);
- $(e).closest('tr').addClass('active slx-bold').after(tr);
- td.load("?do=locationinfo&action=pcsubtable&id=" + locationId);
- lastPcSubTable = tr;
-}
-
function loadTimeModal(locationId, locationName) {
$('#myModalHeader').text("[" + locationId + "] " + locationName).css("font-weight","Bold");
diff --git a/modules-available/locationinfo/templates/pcsubtable.html b/modules-available/locationinfo/templates/pcsubtable.html
deleted file mode 100644
index 59aa28b2..00000000
--- a/modules-available/locationinfo/templates/pcsubtable.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<div>
-<br>
-<table style="margin-bottom:0">
- <tr>
- <th width=320>{{lang_pcID}}</th>
- <th width=120>{{lang_pcIP}}</th>
- <th width=50>{{lang_pcX}}</th>
- <th width=50>{{lang_pcY}}</th>
- <th width=20>{{lang_pcState}}</th>
- </tr>
-
-{{#list}}
- <tr class="tablerow">
- <td>{{id}}</td>
- <td>{{ip}}</td>
- <td>{{x}}</td>
- <td>{{y}}</td>
- <td align="center">{{pcState}}</td>
- </tr>
-{{/list}}
-
-</table>
-<br>
-</div>
diff --git a/modules-available/locationinfo/templates/timetable.html b/modules-available/locationinfo/templates/timetable.html
index 05ef7c65..bb3f7991 100644
--- a/modules-available/locationinfo/templates/timetable.html
+++ b/modules-available/locationinfo/templates/timetable.html
@@ -27,7 +27,7 @@
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
- <input required type="text" class="form-control timepicker2" name="openingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{openingtime0}}">
+ <input type="text" class="form-control timepicker2" name="openingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{openingtime0}}">
</div>
</td>
<td>
@@ -35,7 +35,7 @@
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
- <input required type="text" class="form-control timepicker2" name="closingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{closingtime0}}">
+ <input type="text" class="form-control timepicker2" name="closingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{closingtime0}}">
</div>
</td>
</tr>
@@ -46,7 +46,7 @@
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
- <input required type="text" class="form-control timepicker2" name="openingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{openingtime1}}">
+ <input type="text" class="form-control timepicker2" name="openingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{openingtime1}}">
</div>
</td>
<td>
@@ -54,7 +54,7 @@
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
- <input required type="text" class="form-control timepicker2" name="closingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{closingtime1}}">
+ <input type="text" class="form-control timepicker2" name="closingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{closingtime1}}">
</div>
</td>
</tr>
@@ -65,7 +65,7 @@
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
- <input required type="text" class="form-control timepicker2" name="openingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{openingtime2}}">
+ <input type="text" class="form-control timepicker2" name="openingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{openingtime2}}">
</div>
</td>
<td>
@@ -73,7 +73,7 @@
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
- <input required type="text" class="form-control timepicker2" name="closingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{closingtime2}}">
+ <input type="text" class="form-control timepicker2" name="closingtime[]" id="openingtimepicker" pattern="[0-9]{1,2}:[0-9]{2}" value="{{closingtime2}}">
</div>
</td>
</tr>