Pushover fix sounds (#9519)

* Pushover fix sounds

* fix editing issue with duplicate field ids
This commit is contained in:
Tony Murray
2018-12-10 22:18:45 -06:00
committed by GitHub
parent 170b87226d
commit f451f56e98
2 changed files with 14 additions and 11 deletions

View File

@@ -50,7 +50,7 @@ class Pushover extends Transport
unset($pushover_opts['options']);
foreach (explode(PHP_EOL, $this->config['options']) as $option) {
list($k,$v) = explode('=', $option);
$pushover_opts['options'][$k] = $v;
$pushover_opts['options'][$k] = trim($v);
}
return $this->contactPushover($obj, $pushover_opts);
}
@@ -74,22 +74,22 @@ class Pushover extends Transport
switch ($obj['severity']) {
case "critical":
$data['priority'] = 1;
if (!empty($api['sound_critical'])) {
$data['sound'] = $api['sound_critical'];
if (!empty($api['options']['sound_critical'])) {
$data['sound'] = $api['options']['sound_critical'];
}
break;
case "warning":
$data['priority'] = 1;
if (!empty($api['sound_warning'])) {
$data['sound'] = $api['sound_warning'];
if (!empty($api['options']['sound_warning'])) {
$data['sound'] = $api['options']['sound_warning'];
}
break;
}
switch ($obj['state']) {
case 0:
$data['priority'] = 0;
if (!empty($api['sound_ok'])) {
$data['sound'] = $api['sound_ok'];
if (!empty($api['options']['sound_ok'])) {
$data['sound'] = $api['options']['sound_ok'];
}
break;
}

View File

@@ -235,15 +235,18 @@ foreach (scandir($transport_dir) as $transport) {
});
function loadTransport(transport) {
var form_id = transport.type+"-form";
var transport_form = $("#" + form_id);
$("#name").val(transport.name);
$("#transport-choice").val(transport.type+"-form");
$("#transport-choice").val(form_id);
$("#is_default").bootstrapSwitch('state', transport.is_default);
$(".transport").hide();
$("#" + $("#transport-choice").val()).show().find("input:text").val("");
transport_form.show().find("input:text").val("");
// Populate the field values
transport.details.forEach(function(config) {
var $field = $("#" + config.name);
var $field = transport_form.find("#" + config.name);
if ($field.prop('type') == 'checkbox') {
$field.bootstrapSwitch('state', config.value);
} else {