summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Hofmaier2018-12-03 19:03:24 +0100
committerChristian Hofmaier2018-12-03 19:03:24 +0100
commitf57731abf206bf3030a7a95a9019aa398c3dea2e (patch)
tree5d7df13c1028fae8a659f8e39c91b9e1e66e03c0
parent[dozmod] networkshares: Use {{password_type}} for password field (diff)
downloadslx-admin-f57731abf206bf3030a7a95a9019aa398c3dea2e.tar.gz
slx-admin-f57731abf206bf3030a7a95a9019aa398c3dea2e.tar.xz
slx-admin-f57731abf206bf3030a7a95a9019aa398c3dea2e.zip
[locationinfo] add new settings for panels (counter, updaterate)
- setting: consider only clients in roomplaner, instead of ip range - add option to set update rate in summary panels - directly initialize when mode is "only calendar" - Set counter to "-" if room has ongoing event - fix some spelling / unused code
-rw-r--r--modules-available/locationinfo/api.inc.php23
-rw-r--r--modules-available/locationinfo/inc/locationinfo.inc.php7
-rw-r--r--modules-available/locationinfo/lang/de/template-tags.json2
-rw-r--r--modules-available/locationinfo/lang/en/template-tags.json2
-rw-r--r--modules-available/locationinfo/page.inc.php18
-rwxr-xr-xmodules-available/locationinfo/templates/frontend-default.html25
-rw-r--r--modules-available/locationinfo/templates/frontend-summary.html74
-rw-r--r--modules-available/locationinfo/templates/page-config-panel-default.html16
-rw-r--r--modules-available/locationinfo/templates/page-config-panel-summary.html44
9 files changed, 139 insertions, 72 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php
index ad71de8b..c33c528e 100644
--- a/modules-available/locationinfo/api.inc.php
+++ b/modules-available/locationinfo/api.inc.php
@@ -7,7 +7,7 @@
HandleParameters();
/**
- * Handles the API paramenters.
+ * Handles the API parameters.
*/
function HandleParameters()
{
@@ -20,7 +20,7 @@ function HandleParameters()
} elseif ($get === "machines") {
$locationIds = LocationInfo::getLocationsOr404($uuid);
$output = array();
- InfoPanel::appendMachineData($output, $locationIds, false);
+ InfoPanel::appendMachineData($output, $locationIds, true);
$output = array_values($output);
} elseif ($get === "config") {
$type = InfoPanel::getConfig($uuid, $output);
@@ -30,7 +30,7 @@ function HandleParameters()
}
} elseif ($get === "pcstates") {
$locationIds = LocationInfo::getLocationsOr404($uuid);
- $output = getPcStates($locationIds);
+ $output = getPcStates($locationIds, $uuid);
} elseif ($get === "locationtree") {
$locationIds = LocationInfo::getLocationsOr404($uuid);
$output = getLocationTree($locationIds);
@@ -84,7 +84,7 @@ function getLastChangeTs($paneluuid)
* @param int[] $idList list of the location ids.
* @return array aggregated PC states
*/
-function getPcStates($idList)
+function getPcStates($idList, $paneluuid)
{
$pcStates = array();
foreach ($idList as $id) {
@@ -99,13 +99,24 @@ function getPcStates($idList)
}
$locationInfoList = array();
- InfoPanel::appendMachineData($locationInfoList, $idList);
+ InfoPanel::appendMachineData($locationInfoList, $idList, true);
+
+ $panel = Database::queryFirst('SELECT paneluuid, panelconfig FROM locationinfo_panel WHERE paneluuid = :paneluuid',
+ compact('paneluuid'));
+ $config = json_decode($panel['panelconfig'], true);
+
foreach ($locationInfoList as $locationInfo) {
$id = $locationInfo['id'];
foreach ($locationInfo['machines'] as $pc) {
$key = strtolower($pc['pcState']);
if (isset($pcStates[$id][$key])) {
- $pcStates[$id][$key]++;
+ if ($config['roomplaner']) {
+ if (isset($pc['x']) && isset($pc['y'])) {
+ $pcStates[$id][$key]++;
+ }
+ } else {
+ $pcStates[$id][$key]++;
+ }
}
}
}
diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php
index c51be666..88f96d29 100644
--- a/modules-available/locationinfo/inc/locationinfo.inc.php
+++ b/modules-available/locationinfo/inc/locationinfo.inc.php
@@ -80,6 +80,7 @@ class LocationInfo
'vertical' => false,
'eco' => false,
'prettytime' => true,
+ 'roomplaner' => true,
'scaledaysauto' => true,
'daystoshow' => 7,
'rotation' => 0,
@@ -93,9 +94,9 @@ class LocationInfo
if ($type === 'SUMMARY') {
return array(
'language' => defined('LANG') ? LANG : 'en',
- 'calupdate' => 30,
- 'roomupdate' => 15,
- 'configupdate' => 180,
+ 'roomplaner' => true,
+ 'eco' => false,
+ 'panelupdate' => 60,
);
}
return array();
diff --git a/modules-available/locationinfo/lang/de/template-tags.json b/modules-available/locationinfo/lang/de/template-tags.json
index 7862297c..e93d83a9 100644
--- a/modules-available/locationinfo/lang/de/template-tags.json
+++ b/modules-available/locationinfo/lang/de/template-tags.json
@@ -78,6 +78,7 @@
"lang_room": "Raum",
"lang_roomId": "Raum ID",
"lang_roomIdTooltip": "Die Raum ID, die der Server ben\u00f6tigt, um Kalenderdaten abzurufen (bei Exchange die Postfachadresse)",
+ "lang_roomplanerTooltip": "Nur PCs berücksichtigen, die im Raumplaner gesetzt wurden",
"lang_roomupdateTooltip": "Zeit nach der die PCs aktualisiert werden (in Sekunden)",
"lang_rotation": "Rotation",
"lang_rotation0": "0\u00b0",
@@ -119,6 +120,7 @@
"lang_url": "URL",
"lang_urlPanel": "URL-Panel",
"lang_urlTooltip": "URL die aufgerufen wird",
+ "lang_useRoomplaner": "Raumplaner benutzen",
"lang_vertical": "Vertikaler Modus",
"lang_verticalTooltip": "Legt fest, ob Kalender und Raum \u00fcbereinander angezeigt werden sollen"
} \ No newline at end of file
diff --git a/modules-available/locationinfo/lang/en/template-tags.json b/modules-available/locationinfo/lang/en/template-tags.json
index 2a191379..8a6e0724 100644
--- a/modules-available/locationinfo/lang/en/template-tags.json
+++ b/modules-available/locationinfo/lang/en/template-tags.json
@@ -78,6 +78,7 @@
"lang_room": "Room",
"lang_roomId": "Room ID",
"lang_roomIdTooltip": "The ID of the room the server needs, for querying the calendar data (when using exchange the room mailbox)",
+ "lang_roomplanerTooltip": "Only consider PCs which were set in the roomplaner",
"lang_roomupdateTooltip": "Time the PCs in the room gets updated (in seconds)",
"lang_rotation": "Rotation",
"lang_rotation0": "0\u00b0",
@@ -119,6 +120,7 @@
"lang_url": "URL",
"lang_urlPanel": "URL panel",
"lang_urlTooltip": "URL which is shown by the panel",
+ "lang_useRoomplaner": "Use roomplans",
"lang_vertical": "Vertical mode",
"lang_verticalTooltip": "Defines whether the room and calendar are shown above each other"
} \ No newline at end of file
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php
index 3ff80927..26fa6c4e 100644
--- a/modules-available/locationinfo/page.inc.php
+++ b/modules-available/locationinfo/page.inc.php
@@ -359,6 +359,7 @@ class Page_LocationInfo extends Page
'vertical' => Request::post('vertical', false, 'bool'),
'eco' => Request::post('eco', false, 'bool'),
'prettytime' => Request::post('prettytime', false, 'bool'),
+ 'roomplaner' => Request::post('roomplaner', false, 'bool'),
'scaledaysauto' => Request::post('scaledaysauto', false, 'bool'),
'daystoshow' => Request::post('daystoshow', 7, 'int'),
'rotation' => Request::post('rotation', 0, 'int'),
@@ -388,9 +389,19 @@ class Page_LocationInfo extends Page
private function preparePanelConfigSummary()
{
+ // Build json structure
+ $conf = array(
+ 'language' => Request::post('language', 'en', 'string'),
+ 'eco' => Request::post('eco', false, 'bool'),
+ 'roomplaner' => Request::post('roomplaner', false, 'bool'),
+ 'panelupdate' => Request::post('panelupdate', 30, 'int')
+ );
+ if ($conf['panelupdate'] < 15) {
+ $conf['panelupdate'] = 15;
+ }
// Check locations
$locationids = self::getLocationIdsFromRequest(true);
- return array('locationids' => $locationids);
+ return array('config' => $conf, 'locationids' => $locationids);
}
/**
@@ -922,6 +933,7 @@ class Page_LocationInfo extends Page
'vertical_checked' => $config['vertical'] ? 'checked' : '',
'eco_checked' => $config['eco'] ? 'checked' : '',
'prettytime_checked' => $config['prettytime'] ? 'checked' : '',
+ 'roomplaner_checked' => $config['roomplaner'] ? 'checked' : '',
'scaledaysauto_checked' => $config['scaledaysauto'] ? 'checked' : '',
'daystoshow' => $config['daystoshow'],
'rotation' => $config['rotation'],
@@ -947,9 +959,11 @@ class Page_LocationInfo extends Page
'uuid' => $id,
'panelname' => $panel['panelname'],
'languages' => $langs,
- 'roomupdate' => $config['roomupdate'],
+ 'panelupdate' => $config['panelupdate'],
+ 'roomplaner_checked' => $config['roomplaner'] ? 'checked' : '',
'locations' => Location::getLocations(),
'locationids' => $panel['locationids'],
+ 'eco_checked' => $config['eco'] ? 'checked' : '',
));
}
}
diff --git a/modules-available/locationinfo/templates/frontend-default.html b/modules-available/locationinfo/templates/frontend-default.html
index d1ecaae8..7317f8e2 100755
--- a/modules-available/locationinfo/templates/frontend-default.html
+++ b/modules-available/locationinfo/templates/frontend-default.html
@@ -619,6 +619,11 @@ optional:
generateProgressBar();
}
+ // Manually initialize mode 2, as initRoomLayout isn't called for this mode
+ if (room.config.mode === 2) {
+ queryCalendars();
+ queryRooms();
+ }
mainUpdateLoop();
setInterval(mainUpdateLoop, 10000);
setInterval(updateHeaders, globalConfig.eco ? 10000 : 1000);
@@ -1116,12 +1121,11 @@ optional:
* @param room Room
*/
function SetFreeSeats(room) {
- room.$.seatsCounter.text(room.freePcs >= 0 ? room.freePcs : '');
+ // if room has no allowed value, set text in the box to -
+ room.$.seatsCounter.text(room.freePcs >= 0 ? room.freePcs : '-');
room.$.seatsCounter.data('state', JSON.stringify(room.state));
if (room.freePcs > 0 && room.state && room.state.free) {
- room.$.seatsBackground.css('background-color', '#250');
- } else if (room.freePcs === -1) {
- room.$.seatsBackground.css('background-color', 'red');
+ room.$.seatsBackground.css('background-color', '#250');
} else {
room.$.seatsBackground.css('background-color', 'red');
}
@@ -1148,7 +1152,8 @@ optional:
if (!same) newText = t("closed");
} else if (tmp.state === "CalendarEvent") {
if (!same) newText = tmp.title;
- seats = -1;
+ // whilst event is running set freePcs to -, hopefully not breaking anything else with this
+ room.freePcs = "-";
} else if (tmp.state === "Free") {
if (!same) newText = t("free");
} else if (tmp.state === "FreeNoEnd") {
@@ -1496,8 +1501,14 @@ optional:
for (var i = 0; i < update.length; i++) {
var $div = $("#pc_" + room.id + "_" + update[i].id);
// Pc free
- if (update[i].pcState === "IDLE" || update[i].pcState === "OFFLINE" || update[i].pcState === "STANDBY") {
- freePcs++;
+ if (room.config.roomplaner === true) {
+ if ((update[i].pcState === "IDLE" || update[i].pcState === "OFFLINE" || update[i].pcState === "STANDBY") && !isNaN(update[i].x) && !isNaN(update[i].y)) {
+ freePcs++;
+ }
+ } else {
+ if ((update[i].pcState === "IDLE" || update[i].pcState === "OFFLINE" || update[i].pcState === "STANDBY")) {
+ freePcs++;
+ }
}
$div.removeClass('BROKEN OFFLINE IDLE OCCUPIED STANDBY'.replace(update[i].pcState, '')).addClass(update[i].pcState);
diff --git a/modules-available/locationinfo/templates/frontend-summary.html b/modules-available/locationinfo/templates/frontend-summary.html
index 4105dd16..0053d1ff 100644
--- a/modules-available/locationinfo/templates/frontend-summary.html
+++ b/modules-available/locationinfo/templates/frontend-summary.html
@@ -116,6 +116,7 @@
var startdate;
var roomidsString = "";
var config = {{{config}}};
+ var lastPanelUpdate = 0;
$(document).ready(function () {
init();
@@ -139,6 +140,7 @@
SetUpDate(time);
generateLayout(config.tree);
update();
+ setInterval(update, 10000);
}
function SetUpDate(d) {
@@ -165,7 +167,7 @@
*/
function generateObject(json, myParent, outermost) {
var obj;
- if (!json.children || json.children.length == 0) {
+ if (!json.children || json.children.length === 0) {
obj = generateChild(myParent, json.locationid, json.locationname, outermost);
} else {
obj = generateParent(myParent, json.locationid, json.locationname, outermost);
@@ -178,59 +180,24 @@
}
/**
- * Helper function to generate id string used in query functions
- * @param list A string, wicht contains ids or not(for now)
- * @param id An ID which should be added to the list
+ * Main Update loop, this loop runs every 10 seconds
*/
- function addIdToUpdateList(list, id) {
- if (list == "") {
- list += id;
- } else {
- list += ("," + id);
- }
- return list;
- }
-
-
- const ROOMUPDATE_MS = 2*60*1000;
- const CALUPDATE_MS = 20*60*1000;
- var timeout = null;
-
function update() {
- var calendarUpdateIds = "";
- var rommUpdateIds = "";
- var count = 0;
- var nextUpdate = 15000;
- var property;
- // TODO: Only query a few rooms is not possible with the new api stuff ...
- for (property in rooms) {
- if (rooms[property].lastCalendarUpdate === null || rooms[property].lastCalendarUpdate + CALUPDATE_MS < MyDate().getTime()) {
- // TODO: NOT NECESSARY ANYMORE?!
- calendarUpdateIds = addIdToUpdateList(calendarUpdateIds, rooms[property].id);
- count++;
- rooms[property].lastCalendarUpdate = MyDate().getTime();
- }
- if (rooms[property].lastRoomUpdate === null || rooms[property].lastRoomUpdate + ROOMUPDATE_MS < MyDate().getTime()) {
- // TODO: NOT NECESSARY ANYMORE?!
- rommUpdateIds = addIdToUpdateList(rommUpdateIds, rooms[property].id);
- count++;
- rooms[property].lastRoomUpdate = MyDate().getTime();
- }
- // TODO if (count > 7) break;
- }
- if (calendarUpdateIds !== "") {
- queryCalendars();
- nextUpdate = 1000;
- }
- if (rommUpdateIds !== "") {
+ var date = MyDate();
+ var now = date.getTime();
+ if (lastPanelUpdate + (config.panelupdate * 1000) < now) {
+ // Set Roomupdate Interval has passed, update.
queryRooms();
- nextUpdate = 1000;
- }
- if (nextUpdate !== 1000) {
+ queryCalendars();
+ lastPanelUpdate = now;
+ for (var property in rooms) {
+ rooms[property].lastCalendarUpdate = now;
+ rooms[property].lastRoomUpdate = now;
+ }
+ } else {
+ // Set Roomupdate Interval has NOT passed, check if panel was changed since last call and reload if true.
queryPanelChange();
}
- clearTimeout(timeout);
- setTimeout(update, nextUpdate);
}
function cleanDate(d) {
@@ -283,7 +250,6 @@
cache: false,
timeout: 30000,
success: function (result) {
- var l = result.length;
if (result[0] == null) {
console.log("Error: Backend reported null back for RoomUpdate, this might happend if the room isn't" +
"configurated.");
@@ -331,7 +297,7 @@
function updatePcStates(json) {
var l = json.length;
for (var i = 0; i < l; i++) {
- updateRoomUsage(json[i].id, json[i].idle, json[i].occupied, json[i].offline, json[i].broken, json[i].standby)
+ updateRoomUsage(json[i].id, json[i].idle, json[i].occupied, json[i].offline, json[i].broken, json[i].standby);
}
}
@@ -428,8 +394,8 @@
/**
* computes state of a room, states are:
- * closed, FreeNoEnd, Free, ClaendarEvent.
- * @param Room Object
+ * closed, FreeNoEnd, Free, CalendarEvent.
+ * @param room Object
*/
function ComputeCurrentState(room) {
if (room.lastRoomUpdate === null) {
@@ -479,7 +445,7 @@
/**
* checks if a room is open
* @param room Room object
- * @returns bool for open or not
+ * @returns boolean for open or not
*/
function IsOpenNow(room) {
var now = new MyDate();
diff --git a/modules-available/locationinfo/templates/page-config-panel-default.html b/modules-available/locationinfo/templates/page-config-panel-default.html
index f7009764..c2915298 100644
--- a/modules-available/locationinfo/templates/page-config-panel-default.html
+++ b/modules-available/locationinfo/templates/page-config-panel-default.html
@@ -107,6 +107,22 @@
</div>
</div>
</div>
+
+ <div class="list-group-item">
+ <div class="row">
+ <div class="col-sm-3">
+ <label for="input-roomplaner">{{lang_useRoomplaner}}</label>
+ </div>
+ <div class="col-sm-7">
+ <input id="input-roomplaner" type="checkbox" name="roomplaner" {{roomplaner_checked}}>
+ </div>
+ <div class="col-sm-2">
+ <p class="btn btn-static helptext" title="{{lang_roomplanerTooltip}}">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </p>
+ </div>
+ </div>
+ </div>
</div>
</div>
</div>
diff --git a/modules-available/locationinfo/templates/page-config-panel-summary.html b/modules-available/locationinfo/templates/page-config-panel-summary.html
index 11f0dc65..737eef1f 100644
--- a/modules-available/locationinfo/templates/page-config-panel-summary.html
+++ b/modules-available/locationinfo/templates/page-config-panel-summary.html
@@ -70,6 +70,22 @@
</div>
</div>
</div>
+
+ <div class="list-group-item">
+ <div class="row">
+ <div class="col-sm-3">
+ <label for="input-roomplaner">{{lang_useRoomplaner}}</label>
+ </div>
+ <div class="col-sm-7">
+ <input id="input-roomplaner" type="checkbox" name="roomplaner" {{roomplaner_checked}}>
+ </div>
+ <div class="col-sm-2">
+ <p class="btn btn-static helptext" title="{{lang_roomplanerTooltip}}">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </p>
+ </div>
+ </div>
+ </div>
<!--
<div class="list-group-item">
<div class="row">
@@ -91,6 +107,34 @@
</div>
</div>
</div>
+
+ <div class="col-md-6">
+ <div class="panel panel-default">
+ <div class="panel-heading">{{lang_updateRates}}</div>
+ <div class="panel-body">
+ <div class="list-group">
+
+ <div class="list-group-item">
+ <div class="row">
+ <div class="col-sm-3">
+ <label for="form-panelupdate">{{lang_panel}}</label>
+ </div>
+ <div class="col-sm-7">
+ <input class="form-control" name="panelupdate" type="number" min="15" id="form-panelupdate"
+ max="86400" value="{{panelupdate}}" required>
+ </div>
+ <div class="col-sm-2">
+ <p class="btn btn-static helptext" title="{{lang_panelupdateTooltip}}">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </p>
+ </div>
+ </div>
+ </div>
+
+ </div>
+ </div>
+ </div>
+ </div>
</div>
<div class="modify-inputs">