summaryrefslogtreecommitdiffstats
path: root/modules-available/locations
diff options
context:
space:
mode:
authorChristian Hofmaier2021-03-16 20:03:58 +0100
committerChristian Hofmaier2021-03-16 20:03:58 +0100
commit834b95629832fc3735756727b6c7cb1826d0e9d8 (patch)
treeff465ef0063c59d92f8c77e89f15a2a7a2405977 /modules-available/locations
parent[sysconfig] yes -> true (diff)
downloadslx-admin-834b95629832fc3735756727b6c7cb1826d0e9d8.tar.gz
slx-admin-834b95629832fc3735756727b6c7cb1826d0e9d8.tar.xz
slx-admin-834b95629832fc3735756727b6c7cb1826d0e9d8.zip
[rebootcontrol] Handle scheduler overlaps
- Overlaps < 5 min are ignored, < 15 triggers reboot - Database: Make 1 line out of 2
Diffstat (limited to 'modules-available/locations')
-rw-r--r--modules-available/locations/pages/details.inc.php34
-rw-r--r--modules-available/locations/templates/ajax-opening-location.html8
2 files changed, 17 insertions, 25 deletions
diff --git a/modules-available/locations/pages/details.inc.php b/modules-available/locations/pages/details.inc.php
index 2f444157..fd45646b 100644
--- a/modules-available/locations/pages/details.inc.php
+++ b/modules-available/locations/pages/details.inc.php
@@ -89,25 +89,25 @@ class SubPage
array('locationid' => $locationid, 'openingtime' => $openingTimes));
if (Module::isAvailable('rebootcontrol')) {
- if ($wol) {
+ if ($wol || $sd) {
$options = array();
+
// Sanity checks
if ($woloffset > 15) $woloffset = 15;
else if ($woloffset < 0) $woloffset = 0;
- $options['wol-offset'] = $woloffset;
- Scheduler::updateSchedule($locationid, 'wol', $options, $openingTimes);
- } else {
- Scheduler::deleteSchedule($locationid, 'wol');
- }
- if ($sd) {
- $options = array();
- // Sanity checks
if ($sdoffset > 15) $sdoffset = 15;
else if ($sdoffset < 0) $sdoffset = 0;
+
+ // Set options
+ $options['wol'] = $wol;
+ $options['wol-offset'] = $woloffset;
+ $options['sd'] = $sd;
$options['sd-offset'] = $sdoffset;
- Scheduler::updateSchedule($locationid, 'sd', $options, $openingTimes);
+
+ Scheduler::updateSchedule($locationid, $options, $openingTimes);
+
} else {
- Scheduler::deleteSchedule($locationid, 'sd');
+ Scheduler::deleteSchedule($locationid);
}
}
}
@@ -423,16 +423,8 @@ class SubPage
$rebootcontrol = Module::isAvailable('rebootcontrol');
$data['rebootcontrol'] = $rebootcontrol;
if ($rebootcontrol) {
- $wol = Database::queryFirst("SELECT options FROM `reboot_scheduler` WHERE locationid = :id AND action = 'wol'", array('id' => $id));
- if ($wol !== false) {
- $data['wol'] = true;
- $data['wol-options'] = json_decode($wol['options']);
- }
- $sd = Database::queryFirst("SELECT options FROM `reboot_scheduler` WHERE locationid = :id AND action = 'sd'", array('id' => $id));
- if ($sd !== false) {
- $data['sd'] = true;
- $data['sd-options'] = json_decode($sd['options']);
- }
+ $res = Database::queryFirst("SELECT * FROM `reboot_scheduler` WHERE locationid = :id", array('id' => $id));
+ if ($res !== false) $data['scheduler-options'] = json_decode($res['options']);
}
echo Render::parse('ajax-opening-location', $data);
diff --git a/modules-available/locations/templates/ajax-opening-location.html b/modules-available/locations/templates/ajax-opening-location.html
index a2bb357d..b1aea2e2 100644
--- a/modules-available/locations/templates/ajax-opening-location.html
+++ b/modules-available/locations/templates/ajax-opening-location.html
@@ -128,14 +128,14 @@
<div class="row wol">
<div class="col-sm-4">
<div class="checkbox checkbox-inline">
- <input id="wol-check-{{id}}" name="wol" type="checkbox" {{#wol}}checked{{/wol}}>
+ <input id="wol-check-{{id}}" name="wol" type="checkbox" {{#scheduler-options.wol}}checked{{/scheduler-options.wol}}>
<label for="wol-check-{{id}}">{{lang_wakeonlan}}</label>
</div>
</div>
<div class="col-sm-8">
<div class="input-group">
<input disabled type="number" id="wol-offset-{{id}}" name="wol-offset" class="form-control"
- value="{{wol-options.wol-offset}}" placeholder="0" min="0" max="15">
+ value="{{scheduler-options.wol-offset}}" placeholder="0" min="0" max="15">
<span class="input-group-addon slx-ga2">
<label for="wol-offset-{{id}}">{{lang_offsetEarly}}</label>
</span>
@@ -145,14 +145,14 @@
<div class="row shutdown">
<div class="col-sm-4">
<div class="checkbox checkbox-inline">
- <input id="sd-check-{{id}}" name="sd" type="checkbox" {{#sd}}checked{{/sd}}>
+ <input id="sd-check-{{id}}" name="sd" type="checkbox" {{#scheduler-options.sd}}checked{{/scheduler-options.sd}}>
<label for="sd-check-{{id}}">{{lang_shutdown}}</label>
</div>
</div>
<div class="col-sm-8">
<div class="input-group">
<input disabled type="number" id="sd-offset-{{id}}" name="sd-offset" class="form-control"
- value="{{sd-options.sd-offset}}" placeholder="0" min="0" max="15">
+ value="{{scheduler-options.sd-offset}}" placeholder="0" min="0" max="15">
<span class="input-group-addon slx-ga2">
<label for="sd-offset-{{id}}">{{lang_offsetLate}}</label>
</span>