Clarify disable, ignore and disable all alerts in device edit section (#11011)

* Clarify disable, ignore tag and disable all alerts in device edit section

* remove alert settings section

* fix device attribs

* update doc

* update doc

* fix checks
This commit is contained in:
louis-oui
2020-01-09 13:07:29 +01:00
committed by Kevin Krumm
parent 859e18ea65
commit c03c281b6c
4 changed files with 73 additions and 119 deletions

View File

@@ -26,7 +26,6 @@ if (!Auth::user()->hasGlobalAdmin()) {
if (!$device['snmp_disable']) {
$panes['apps'] = 'Applications';
}
$panes['alerts'] = 'Alert Settings';
$panes['alert-rules'] = 'Alert Rules';
if (!$device['snmp_disable']) {
$panes['modules'] = 'Modules';

View File

@@ -1,112 +0,0 @@
<?php
if ($_POST['editing']) {
if (Auth::user()->hasGlobalAdmin()) {
$override_sysContact_bool = mres($_POST['override_sysContact']);
if (isset($_POST['sysContact'])) {
$override_sysContact_string = mres($_POST['sysContact']);
}
$disable_notify = mres($_POST['disable_notify']);
if ($override_sysContact_bool) {
set_dev_attrib($device, 'override_sysContact_bool', '1');
} else {
del_dev_attrib($device, 'override_sysContact_bool');
}
if (isset($override_sysContact_string)) {
set_dev_attrib($device, 'override_sysContact_string', $override_sysContact_string);
};
if ($disable_notify) {
set_dev_attrib($device, 'disable_notify', '1');
} else {
del_dev_attrib($device, 'disable_notify');
}
$update_message = 'Device alert settings updated.';
$updated = 1;
} else {
include 'includes/html/error-no-perm.inc.php';
}//end if
}//end if
if ($updated && $update_message) {
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
}
$override_sysContact_bool = get_dev_attrib($device, 'override_sysContact_bool');
$override_sysContact_string = get_dev_attrib($device, 'override_sysContact_string');
$disable_notify = get_dev_attrib($device, 'disable_notify');
?>
<h3>Alert settings</h3>
<div class="row">
<div class="col-md-12">
<span id="message"></span>
</div>
</div>
<form id="edit" name="edit" method="post" action="" role="form" class="form-horizontal">
<?php echo csrf_field() ?>
<input type="hidden" name="editing" value="yes">
<div class="form-group">
<label for="override_sysContact" class="col-sm-3 control-label">Override sysContact</label>
<div class="col-sm-6">
<input onChange="edit.sysContact.disabled=!edit.override_sysContact.checked" type="checkbox" id="override_sysContact" name="override_sysContact" data-size="small"
<?php
if ($override_sysContact_bool) {
echo ' checked="1"';
};
?>
/>
</div>
</div>
<div class="form-group">
<div class="col-sm-3">
</div>
<div class="col-sm-6">
<input id="sysContact" class="form-control" name="sysContact" size="32"
<?php
if (!$override_sysContact_bool) {
echo ' disabled="1"';
};
?>
value="<?php echo $override_sysContact_string; ?>" />
</div>
</div>
<div class="form-group">
<label for="disable_notify" class="col-sm-3 control-label">Disable all alerting for this host</label>
<div class="col-sm-6">
<input id="disable_notify" type="checkbox" name="disable_notify" data-size="small"
<?php
if ($disable_notify) {
echo ' checked="1"';
};
?>
/>
</div>
</div>
<div class="row">
<div class="col-md-1 col-md-offset-3">
<button type="submit" name="Submit" class="btn btn-default"><i class="fa fa-check"></i> Save</button>
</div>
</div>
</form>
<?php
require_once 'includes/html/modal/new_alert_rule.inc.php';
?>
<br>
<div class="row">
<div class="col-md-1 col-md-offset-3">
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#create-alert" data-device_id="<?php echo $device['device_id']; ?>"><i class="fa fa-plus"></i> Create new alert rule</button>
</div>
</div>
<script>
$('[type="checkbox"]').bootstrapSwitch();
</script>

View File

@@ -64,12 +64,42 @@ if ($_POST['editing']) {
Toastr::error('Only administrative users may update the device hostname');
}
}
$override_sysContact_bool = mres($_POST['override_sysContact']);
if (isset($_POST['sysContact'])) {
$override_sysContact_string = mres($_POST['sysContact']);
}
$disable_notify = mres($_POST['disable_notify']);
if ($override_sysContact_bool) {
set_dev_attrib($device, 'override_sysContact_bool', '1');
} else {
set_dev_attrib($device, 'override_sysContact_bool', '0');
}
if (isset($override_sysContact_string)) {
set_dev_attrib($device, 'override_sysContact_string', $override_sysContact_string);
};
if ($disable_notify) {
set_dev_attrib($device, 'disable_notify', '1');
} else {
set_dev_attrib($device, 'disable_notify', '0');
}
//$update_message = 'Device alert settings updated.';
//$updated = 1;
} else {
include 'includes/html/error-no-perm.inc.php';
}
}
$override_sysContact_bool = get_dev_attrib($device, 'override_sysContact_bool');
$override_sysContact_string = get_dev_attrib($device, 'override_sysContact_string');
$disable_notify = get_dev_attrib($device, 'disable_notify');
?>
<h3> Device Settings </h3>
<div class="row">
<div class="col-md-1 col-md-offset-2">
@@ -152,6 +182,31 @@ if ($_POST['editing']) {
?> value="<?php echo display($device_model->location); ?>" />
</div>
</div>
<div class="form-group">
<label for="override_sysContact" class="col-sm-2 control-label">Override sysContact</label>
<div class="col-sm-6">
<input onChange="edit.sysContact.disabled=!edit.override_sysContact.checked" type="checkbox" id="override_sysContact" name="override_sysContact" data-size="small"
<?php
if ($override_sysContact_bool) {
echo ' checked="1"';
};
?>
/>
</div>
</div>
<div class="form-group">
<div class="col-sm-2">
</div>
<div class="col-sm-6">
<input id="sysContact" class="form-control" name="sysContact" size="32"
<?php
if (!$override_sysContact_bool) {
echo ' disabled="1"';
};
?>
value="<?php echo $override_sysContact_string; ?>" />
</div>
</div>
<div class="form-group">
<label for="parent_id" class="col-sm-2 control-label">This device depends on:</label>
<div class="col-sm-6">
@@ -180,7 +235,7 @@ if ($_POST['editing']) {
</div>
</div>
<div class="form-group">
<label for="disabled" class="col-sm-2 control-label">Disable polling:</label>
<label for="disabled" class="col-sm-2 control-label">Disable polling and alerting:</label>
<div class="col-sm-6">
<input name="disabled" type="checkbox" id="disabled" value="1" data-size="small"
<?php
@@ -191,7 +246,19 @@ if ($_POST['editing']) {
</div>
</div>
<div class="form-group">
<label for="ignore" class="col-sm-2 control-label">Ignore alerts:</label>
<label for="disable_notify" class="col-sm-2 control-label">Disable alerting:</label>
<div class="col-sm-6">
<input id="disable_notify" type="checkbox" name="disable_notify" data-size="small"
<?php
if ($disable_notify) {
echo ' checked="1"';
};
?>
/>
</div>
</div>
<div class="form-group">
<label for="ignore" class="col-sm-2 control-label" title="help">Ignore alert tag:</label>
<div class="col-sm-6">
<input name="ignore" type="checkbox" id="ignore" value="1" data-size="small"
<?php