Device Maintenance configurable duration (#11821)

* Device Maintenance configurable duration

* increase hour range

* positionize button

* remove wrench icon
This commit is contained in:
SourceDoctor
2020-06-16 14:13:19 +02:00
committed by GitHub
parent 998cdc39fc
commit 6a0366c1e8
3 changed files with 132 additions and 36 deletions

View File

@@ -3,6 +3,8 @@
use App\Models\Device;
use App\Models\Location;
require_once 'includes/html/modal/device_maintenance.inc.php';
$device_model = Device::find($device['device_id']);
if ($_POST['editing']) {
@@ -269,7 +271,7 @@ if (\LibreNMS\Config::get('distributed_poller') === true) {
<div class="form-group">
<label for="maintenance" class="col-sm-2 control-label"></label>
<div class="col-sm-6">
<button type="submit" id="maintenance" data-device_id="<?php echo($device['device_id']); ?>" <?php echo(\LibreNMS\Alert\AlertUtil::isMaintenance($device['device_id']) ? 'disabled class="btn btn-warning"' : 'class="btn btn-success"')?> name="maintenance"><i class="fa fa-wrench"></i> Maintenance Mode (1 hour)</button>
<button type="button" id="maintenance" data-device_id="<?php echo($device['device_id']); ?>" <?php echo(\LibreNMS\Alert\AlertUtil::isMaintenance($device['device_id']) ? 'disabled class="btn btn-warning"' : 'class="btn btn-success"')?> name="maintenance"><i class="fa fa-wrench"></i> Maintenance Mode</button>
</div>
</div>
@@ -307,38 +309,8 @@ If `devices.ignore = 0` or `macros.device = 1` condition is is set and ignore al
<script>
$('[type="checkbox"]').bootstrapSwitch('offColor', 'danger');
$("#maintenance").click(function(event) {
event.preventDefault();
var device_id = $(this).data("device_id");
var title = '<?=display($device['hostname']);?>';
var notes = '';
var recurring = 0;
var start = '<?=date("Y-m-d H:i:00");?>';
var duration = 1;
$.ajax({
type: 'POST',
url: 'ajax_form.php',
data: { type: "schedule-maintenance",
sub_type: 'new-maintenance',
title: title,
notes: notes,
recurring: recurring,
start: start,
duration: duration,
maps: [device_id]
},
dataType: "json",
success: function(data){
if(data['status'] == 'ok') {
toastr.success(data['message']);
} else {
toastr.error(data['message']);
}
},
error:function(){
toastr.error('An error occured setting this device into maintenance mode');
}
});
$("#maintenance").click(function() {
$("#device_maintenance_modal").modal('show');
});
$("#rediscover").click(function() {
var device_id = $(this).data("device_id");