summaryrefslogtreecommitdiffstats
path: root/modules-available/locations
diff options
context:
space:
mode:
authorSimon Rettberg2021-03-17 15:39:55 +0100
committerSimon Rettberg2021-03-17 15:39:55 +0100
commitdc516c24685518b41bcce0751caf286dc65e471f (patch)
treec4db8569fe044752f9cf4ba58c8c5ad986a27b55 /modules-available/locations
parentAdd missing changes (diff)
downloadslx-admin-dc516c24685518b41bcce0751caf286dc65e471f.tar.gz
slx-admin-dc516c24685518b41bcce0751caf286dc65e471f.tar.xz
slx-admin-dc516c24685518b41bcce0751caf286dc65e471f.zip
[locations/rebootcontrol] Change ENUM constants; display next event
Diffstat (limited to 'modules-available/locations')
-rw-r--r--modules-available/locations/lang/de/template-tags.json1
-rw-r--r--modules-available/locations/lang/en/template-tags.json1
-rw-r--r--modules-available/locations/pages/details.inc.php22
-rw-r--r--modules-available/locations/permissions/permissions.json3
-rw-r--r--modules-available/locations/templates/location-subnets.html13
5 files changed, 29 insertions, 11 deletions
diff --git a/modules-available/locations/lang/de/template-tags.json b/modules-available/locations/lang/de/template-tags.json
index b8534e32..79bdbac6 100644
--- a/modules-available/locations/lang/de/template-tags.json
+++ b/modules-available/locations/lang/de/template-tags.json
@@ -36,6 +36,7 @@
"lang_moveMachines": "In durch Subnet zugeordneten Raum verschieben",
"lang_moveable": "Verschiebbar",
"lang_name": "Name",
+ "lang_nextEvent": "N\u00e4chstes geplantes Ereignis",
"lang_numMachinesWithOverrides": "Anzahl Rechner, bei denen mindestens eine Konfigurationsvariable \u00fcberschrieben wird",
"lang_offsetEarly": "Min. vorher",
"lang_offsetLate": "Min. danach",
diff --git a/modules-available/locations/lang/en/template-tags.json b/modules-available/locations/lang/en/template-tags.json
index 467af8e1..5790902b 100644
--- a/modules-available/locations/lang/en/template-tags.json
+++ b/modules-available/locations/lang/en/template-tags.json
@@ -36,6 +36,7 @@
"lang_moveMachines": "Move to room designated by IP address",
"lang_moveable": "Moveable",
"lang_name": "Name",
+ "lang_nextEvent": "Next scheduled event",
"lang_numMachinesWithOverrides": "Number of clients where at least one variable is overridden",
"lang_offsetEarly": "min. before",
"lang_offsetLate": "min. after",
diff --git a/modules-available/locations/pages/details.inc.php b/modules-available/locations/pages/details.inc.php
index e400d492..19a89c88 100644
--- a/modules-available/locations/pages/details.inc.php
+++ b/modules-available/locations/pages/details.inc.php
@@ -42,7 +42,7 @@ class SubPage
$sd = Request::post('sd', false, 'bool');
$sdoffset = Request::post('sd-offset', 0, 'int');
- User::assertPermission('location.edit.*', $locationid); // TODO: Introduce permission
+ User::assertPermission('location.edit.openingtimes', $locationid);
// Construct opening-times for database
if ($openingTimes !== '') {
@@ -405,19 +405,30 @@ class SubPage
$data['used_percent'] = $count === 0 ? 0 : round(($used / $count) * 100);
- Permission::addGlobalTags($data['perms'], $locationId, ['location.edit.name', 'location.edit.subnets', 'location.delete', '.roomplanner.edit'], 'save_button');
+ Permission::addGlobalTags($data['perms'], $locationId,
+ ['location.edit.name', 'location.edit.subnets', 'location.delete', 'location.edit.openingtimes', '.roomplanner.edit'],
+ 'save_button');
if (empty($allowedLocs)) {
$data['perms']['location']['edit']['parent']['disabled'] = 'disabled';
} else {
unset($data['perms']['save_button']);
}
+ if (Module::get('rebootcontrol') !== false) {
+ $res = Database::queryFirst("SELECT action, nextexecution FROM `reboot_scheduler`
+ WHERE locationid = :id", ['id' => $locationId]);
+ if ($res !== false) {
+ $data['next_action'] = $res['action'];
+ $data['next_time'] = Util::prettyTime($res['nextexecution']);
+ }
+ }
+
echo Render::parse('location-subnets', $data);
}
private static function ajaxOpeningTimes($id)
{
- User::assertPermission('location.edit', $id);
+ User::assertPermission('location.edit.openingtimes', $id);
$openTimes = Database::queryFirst("SELECT openingtime FROM `location` WHERE locationid = :id", array('id' => $id));
if ($openTimes !== false) {
$openingTimes = json_decode($openTimes['openingtime'], true);
@@ -432,9 +443,10 @@ class SubPage
$rebootcontrol = Module::isAvailable('rebootcontrol');
$data['rebootcontrol'] = $rebootcontrol;
if ($rebootcontrol) {
- $res = Database::queryFirst("SELECT * FROM `reboot_scheduler` WHERE locationid = :id", array('id' => $id));
+ $res = Database::queryFirst("SELECT action, nextexecution, options FROM `reboot_scheduler`
+ WHERE locationid = :id", ['id' => $id]);
if ($res !== false) {
- $data['scheduler-options'] = json_decode($res['options']);
+ $data['scheduler-options'] = json_decode($res['options'], true);
}
}
diff --git a/modules-available/locations/permissions/permissions.json b/modules-available/locations/permissions/permissions.json
index 18b24a73..108bf8e0 100644
--- a/modules-available/locations/permissions/permissions.json
+++ b/modules-available/locations/permissions/permissions.json
@@ -14,6 +14,9 @@
"location.edit.parent": {
"location-aware": true
},
+ "location.edit.openingtimes": {
+ "location-aware": true
+ },
"location.view": {
"location-aware": true
},
diff --git a/modules-available/locations/templates/location-subnets.html b/modules-available/locations/templates/location-subnets.html
index e954bf10..8a9b1c99 100644
--- a/modules-available/locations/templates/location-subnets.html
+++ b/modules-available/locations/templates/location-subnets.html
@@ -62,7 +62,7 @@
<div class="slx-bold">{{lang_locationInfo}}</div>
<div class="row">
- <div class="col-md-3">
+ <div class="col-md-5">
{{#haveDozmod}}
<div>
<span class="slx-ga2">{{lang_referencingLectures}}:</span> {{lectures}}
@@ -80,14 +80,17 @@
{{/statsLink}}
</div>
{{/haveStatistics}}
+ {{#next_action}}
+ <div>
+ {{lang_nextEvent}}: {{next_action}} – {{next_time}}
+ </div>
+ {{/next_action}}
</div>
- <div class="col-md-3 text-center">
+ <div class="col-md-7 text-right">
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#openingTimesModal{{locationid}}" onclick="loadOpeningTimes('{{locationid}}')">
<span class="glyphicon glyphicon-time"></span>
{{lang_openingTime}}
</button>
- </div>
- <div class="col-md-3 text-center">
{{#roomplanner}}
<a class="btn btn-default" href="?do=roomplanner&amp;locationid={{locationid}}" target="_blank"
onclick="window.open(this.href, '_blank', 'toolbar=0,scrollbars,resizable');return false">
@@ -96,8 +99,6 @@
{{#perms.roomplanner.edit.disabled}}{{lang_showRoomplan}}{{/perms.roomplanner.edit.disabled}}
</a>
{{/roomplanner}}
- </div>
- <div class="col-md-3 text-right">
<button {{perms.location.delete.disabled}} type="button" class="btn btn-danger" data-toggle="modal" data-target="#deleteLocationModal{{locationid}}"><span class="glyphicon glyphicon-trash"></span> {{lang_deleteLocation}}</button>
<button onclick="deleteSubnetWarning('{{locationid}}')" {{perms.save_button.disabled}} type="button" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}}</button>
</div>