diff options
author | Christian Hofmaier | 2020-12-03 12:58:52 +0100 |
---|---|---|
committer | Christian Hofmaier | 2020-12-03 12:58:52 +0100 |
commit | 2d49c621abeff1909b7f4c90d5273157a4f70286 (patch) | |
tree | 5bf548871469c1309f4fa9d43cfd63ec52f89a43 /modules-available/locations | |
parent | [statistics_reporting/statistics] Include system/runmode total counts (diff) | |
download | slx-admin-2d49c621abeff1909b7f4c90d5273157a4f70286.tar.gz slx-admin-2d49c621abeff1909b7f4c90d5273157a4f70286.tar.xz slx-admin-2d49c621abeff1909b7f4c90d5273157a4f70286.zip |
[locations] Add scheduler to openingtimes modal
- only load/safe without further functionality
- add backend to rebootcontrol
Diffstat (limited to 'modules-available/locations')
5 files changed, 95 insertions, 4 deletions
diff --git a/modules-available/locations/lang/de/template-tags.json b/modules-available/locations/lang/de/template-tags.json index 18176278..94f95ded 100644 --- a/modules-available/locations/lang/de/template-tags.json +++ b/modules-available/locations/lang/de/template-tags.json @@ -37,6 +37,8 @@ "lang_moveable": "Verschiebbar", "lang_name": "Name", "lang_numMachinesWithOverrides": "Anzahl Rechner, bei denen mindestens eine Konfigurationsvariable \u00fcberschrieben wird", + "lang_offsetEarly": "Min. vorher", + "lang_offsetLate": "Min. danach", "lang_openingTime": "\u00d6ffnungszeit", "lang_overridenVarsForLocation": "Anzahl Variablen, die an diesem Ort \u00fcberschrieben werden", "lang_parentLocation": "\u00dcbergeordneter Ort", @@ -51,11 +53,13 @@ "lang_shortTuesday": "Di", "lang_shortWednesday": "Mi", "lang_showRoomplan": "Raumplan anzeigen", + "lang_shutdown": "Herunterfahren", "lang_startAddress": "Startadresse", "lang_subnet": "IP-Bereich", "lang_sunday": "Sonntag", "lang_sysConfig": "Lokalisierung", "lang_thisListByLocation": "Orte", "lang_thisListBySubnet": "Subnetze", - "lang_unassignedMachines": "Rechner, die in keinen definierten Ort fallen" + "lang_unassignedMachines": "Rechner, die in keinen definierten Ort fallen", + "lang_wakeonlan": "WakeOnLan" }
\ No newline at end of file diff --git a/modules-available/locations/lang/en/template-tags.json b/modules-available/locations/lang/en/template-tags.json index c4fabdb0..467af8e1 100644 --- a/modules-available/locations/lang/en/template-tags.json +++ b/modules-available/locations/lang/en/template-tags.json @@ -37,6 +37,8 @@ "lang_moveable": "Moveable", "lang_name": "Name", "lang_numMachinesWithOverrides": "Number of clients where at least one variable is overridden", + "lang_offsetEarly": "min. before", + "lang_offsetLate": "min. after", "lang_openingTime": "Opening Time", "lang_overridenVarsForLocation": "Number of variables that get overridden for this location", "lang_parentLocation": "Parent location", @@ -51,11 +53,13 @@ "lang_shortTuesday": "Tue", "lang_shortWednesday": "Wed", "lang_showRoomplan": "Show room plan", + "lang_shutdown": "Shutdown", "lang_startAddress": "Start address", "lang_subnet": "IP range", "lang_sunday": "Sunday", "lang_sysConfig": "Localization\/Integration", "lang_thisListByLocation": "Locations", "lang_thisListBySubnet": "Subnets", - "lang_unassignedMachines": "Machines not matching any location" + "lang_unassignedMachines": "Machines not matching any location", + "lang_wakeonlan": "WakeOnLan" }
\ No newline at end of file diff --git a/modules-available/locations/pages/details.inc.php b/modules-available/locations/pages/details.inc.php index a55460cf..81c2f2fa 100644 --- a/modules-available/locations/pages/details.inc.php +++ b/modules-available/locations/pages/details.inc.php @@ -36,6 +36,10 @@ class SubPage private static function updateOpeningTimes() { $openingTimes = Request::post('openingtimes', '', 'string'); $locationid = Request::post('locationid', false, 'int'); + $wol = Request::post('wol', false, 'bool'); + $woloffset = Request::post('wol-offset', 0, 'int'); + $sd = Request::post('sd', false, 'bool'); + $sdoffset = Request::post('sd-offset', 0, 'int'); User::assertPermission('location.edit', $locationid); @@ -83,6 +87,29 @@ class SubPage Database::exec('UPDATE location SET openingtime = :openingtime WHERE locationid = :locationid', array('locationid' => $locationid, 'openingtime' => $openingTimes)); + if (Module::isAvailable('rebootcontrol')) { + if ($wol) { + $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; + $options['sd-offset'] = $sdoffset; + Scheduler::updateSchedule($locationid, 'sd', $options, $openingTimes); + } else { + Scheduler::deleteSchedule($locationid, 'sd'); + } + } + return true; } @@ -394,6 +421,21 @@ class SubPage $data['expertMode'] = !self::isSimpleMode($openingTimes); $data['schedule_data'] = json_encode($openingTimes); + $rebootcontrol = Module::isAvailable('rebootcontrol'); + $data['rebootcontrol'] = $rebootcontrol; + if ($rebootcontrol) { + $wol = Database::queryFirst("SELECT options FROM `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 `scheduler` WHERE locationid = :id AND action = 'sd'", array('id' => $id)); + if ($sd !== false) { + $data['sd'] = true; + $data['sd-options'] = json_decode($sd['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 09fe7869..3b2ea7ae 100644 --- a/modules-available/locations/templates/ajax-opening-location.html +++ b/modules-available/locations/templates/ajax-opening-location.html @@ -124,7 +124,49 @@ </div> </div> +{{#rebootcontrol}} +<hr> +<div class="row"> + <div class="col-sm-4"> + <div class="checkbox checkbox-inline"> + <input id="wol" name="wol" class="wol" type="checkbox"> + <label for="wol">{{lang_wakeonlan}}</label> + </div> + </div> + <div class="col-sm-8"> + <input disabled type="number" id="wol-offset" name="wol-offset" class="wol-offset" value="{{wol-options.wol-offset}}" placeholder="0" min="0" max="15"> + <label for="wol-offset">{{lang_offsetEarly}}</label> + </div> + <div class="col-sm-4"> + <div class="checkbox checkbox-inline"> + <input id="sd" name="sd" class="sd" type="checkbox"> + <label for="sd">{{lang_shutdown}}</label> + </div> + </div> + <div class="col-sm-8"> + <input disabled type="number" id="sd-offset" name="sd-offset" class="sd-offset" value="{{sd-options.sd-offset}}" placeholder="0" min="0" max="15"> + <label for="sd-offset">{{lang_offsetLate}}</label> + </div> +</div> +{{/rebootcontrol}} + <script type="application/javascript"><!-- + let wol = $('#wol'); + let sd = $('#sd'); + + wol.attr('checked',{{wol}}); + sd.attr('checked',{{sd}}); + $('#wol-offset').attr('disabled', !$('#wol').is(':checked')); + $('#sd-offset').attr('disabled', !$('#sd').is(':checked')); + + wol.on('click', function(){ + $('#wol-offset').attr('disabled', !$(this).is(':checked')); + }); + + sd.on('click', function(){ + $('#sd-offset').attr('disabled', !$(this).is(':checked')); + }); + (function() { var scheduleData = {{{schedule_data}}}; @@ -167,7 +209,6 @@ $('#simple-mode').remove(); $('#expert-mode').show(); }); - })(); //--></script> diff --git a/modules-available/locations/templates/location-subnets.html b/modules-available/locations/templates/location-subnets.html index b85ddbec..f88e2908 100644 --- a/modules-available/locations/templates/location-subnets.html +++ b/modules-available/locations/templates/location-subnets.html @@ -151,7 +151,7 @@ <div class="modal-header">{{locationname}}</div> <div class="modal-body"></div> <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal">{{lang_close}}</button> + <button type="button" class="btn btn-default" data-dismiss="modal" onclick="$('#openingTimesModal{{locationid}} .modal-body').html('')">{{lang_close}}</button> <button type="submit" class="btn btn-primary"> <span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}} |