diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index e29c1d863..21121d0ce 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -1179,3 +1179,73 @@ function dynamic_override_config($type, $name, $device) { return ''; } }//end dynamic_override_config() + +function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$items=array(),$transport='') { + $anchor = md5($title); + $output = ' +
+
+

+ '.$title.' + '; + if (!empty($transport)) { + $output .= ''; + } + $output .= ' +

+
+
+
+ '; + + if (!empty($items)) { + foreach ($items as $item) { + $output .= ' +
+ +
+
+ '; + if ($item['type'] == 'checkbox') { + $output .= ''; + } + elseif ($item['type'] == 'text') { + $output .= ' + + + '; + } + elseif ($item['type'] == 'select') { + $output .= ' + + + '; + } + $output .= ' +
+
+ '; + } + } + + if ($end_panel === true) { + $output .= ' +
+
+
+ '; + } + return $output; +}//end generate_dynamic_config_panel() diff --git a/html/js/librenms.js b/html/js/librenms.js index cd9af4fd6..c205352d2 100644 --- a/html/js/librenms.js +++ b/html/js/librenms.js @@ -1,4 +1,5 @@ $(document).ready(function() { + // Device override ajax calls $("[name='override_config']").bootstrapSwitch('offColor','danger'); $('input[name="override_config"]').on('switchChange.bootstrapSwitch', function(event, state) { event.preventDefault(); @@ -23,4 +24,76 @@ $(document).ready(function() { } }); }); + + // Checkbox config ajax calls + $("[name='global-config-check']").bootstrapSwitch('offColor','danger'); + $('input[name="global-config-check"]').on('switchChange.bootstrapSwitch', function(event, state) { + event.preventDefault(); + var $this = $(this); + var config_id = $this.data("config_id"); + $.ajax({ + type: 'POST', + url: 'ajax_form.php', + data: {type: "update-config-item", config_id: config_id, config_value: state}, + dataType: "json", + success: function (data) { + if (data.status == 'ok') { + toastr.success('Config updated'); + } else { + toastr.error(data.message); + } + }, + error: function () { + toastr.error(data.message); + } + }); + }); + + // Input field config ajax calls + $(document).on('blur', 'input[name="global-config-input"]', function(event) { + event.preventDefault(); + var $this = $(this); + var config_id = $this.data("config_id"); + var config_value = $this.val(); + $.ajax({ + type: 'POST', + url: 'ajax_form.php', + data: {type: "update-config-item", config_id: config_id, config_value: config_value}, + dataType: "json", + success: function (data) { + if (data.status == 'ok') { + toastr.success('Config updated'); + } else { + toastr.error(data.message); + } + }, + error: function () { + toastr.error(data.message); + } + }); + }); + + // Select config ajax calls + $( 'select[name="global-config-select"]').change(function(event) { + event.preventDefault(); + var $this = $(this); + var config_id = $this.data("config_id"); + var config_value = $this.val(); + $.ajax({ + type: 'POST', + url: 'ajax_form.php', + data: {type: "update-config-item", config_id: config_id, config_value: config_value}, + dataType: "json", + success: function (data) { + if (data.status == 'ok') { + toastr.success('Config updated'); + } else { + toastr.error(data.message); + } + }, + error: function () { + toastr.error(data.message); + } + }); + }); }); diff --git a/html/pages/settings.inc.php b/html/pages/settings.inc.php index 2f7a9517e..71c3cc3ee 100644 --- a/html/pages/settings.inc.php +++ b/html/pages/settings.inc.php @@ -27,6 +27,8 @@ $pagetitle[] = 'Global Settings'; $config['memcached']['enable'] = false; ?> + +

Global Settings


diff --git a/html/pages/settings/alerting.inc.php b/html/pages/settings/alerting.inc.php index f6c1bda0a..d76303183 100644 --- a/html/pages/settings/alerting.inc.php +++ b/html/pages/settings/alerting.inc.php @@ -195,197 +195,95 @@ else { $callback = urlencode($callback); +$general_conf = array( + array('name' => 'alert.admins', + 'descr' => 'Issue alerts to admins', + 'type' => 'checkbox', + ), + array('name' => 'alert.globals', + 'descr' => 'Issue alerts to read only users', + 'type' => 'checkbox', + ), + array('name' => 'alert.syscontact', + 'descr' => 'Issue alerts to sysContact', + 'type' => 'checkbox', + ), + array('name' => 'alert.default_only', + 'descr' => 'Send alerts to default contact only', + 'type' => 'checkbox', + ), + array('name' => 'alert.default_mail', + 'descr' => 'Default contact', + 'type' => 'text', + ), + array('name' => 'alert.tolerance_window', + 'descr' => 'Tolerance window for cron', + 'type' => 'text', + ), + array('name' => 'alert.fixed-contacts', + 'descr' => 'Updates to contact email addresses not honored', + 'type' => 'checkbox', + ), +); + +$mail_conf = array( + array('name' => 'alert.transports.mail', + 'descr' => 'Enable email alerting', + 'type' => 'checkbox', + ), + array('name' => 'email_backend', + 'descr' => 'How to deliver mail', + 'options' => $dyn_config['email_backend'], + 'type' => 'select', + ), + array('name' => 'email_user', + 'descr' => 'From name', + 'type' => 'text', + ), + array('name' => 'email_sendmail_path', + 'descr' => 'Sendmail path', + 'type' => 'text', + ), + array('name' => 'email_smtp_host', + 'descr' => 'SMTP Host', + 'type' => 'text', + ), + array('name' => 'email_smtp_port', + 'descr' => 'SMTP Port', + 'type' => 'text', + ), + array('name' => 'email_smtp_timeout', + 'descr' => 'SMTP Timeout', + 'type' => 'text', + ), + array('name' => 'email_smtp_secure', + 'descr' => 'SMTP Secure', + 'type' => 'select', + 'options' => $dyn_config['email_smtp_secure'], + ), + array('name' => 'email_smtp_auth', + 'descr' => 'SMTP Authentication', + 'type' => 'checkbox', + ), + array('name' => 'email_smtp_username', + 'descr' => 'SMTP Authentication Username', + 'type' => 'text', + ), + array('name' => 'email_smtp_password', + 'descr' => 'SMTP Authentication Password', + 'type' => 'text', + ), +); + echo '
-
- -
-
-
- -
-
- -
-
-
- -
-
- -
-
-
- -
-
- -
-
-
- -
-
- -
-
-
- -
-
- - -
-
-
- -
-
- - -
-
-
- -
-
- -
-
-
-
-
-
-
-

- Email transport -

-
-
-
-
- -
-
- -
-
-
- -
-
- - -
-
-
- -
-
- - -
-
-
- -
-
- - -
-
-
- -
-
- - -
-
-
- -
-
- - -
-
-
- -
-
- - -
-
-
- -
-
- - -
-
-
- -
-
- - -
-
-
- -
-
- -
-
-
- -
-
- - -
-
-
- -
-
- - -
-
-
-
-
+echo '

@@ -1158,58 +1056,6 @@ echo '
}); });// End delete Boxcar config - $("[name='global-config-check']").bootstrapSwitch('offColor','danger'); - $('input[name="global-config-check"]').on('switchChange.bootstrapSwitch', function(event, state) { - event.preventDefault(); - var config_id = $(this).data("config_id"); - $.ajax({ - type: 'POST', - url: 'ajax_form.php', - data: {type: "update-config-item", config_id: config_id, config_value: state}, - dataType: "json", - success: function (data) { - if (data.status == 'ok') { - } else { - $("#message").html('
' + data.message + '
'); - } - }, - error: function () { - $("#message").html('
An error occurred.
'); - } - }); - }); - $(document).on('blur', 'input[name="global-config-input"]', function(event) { - event.preventDefault(); - var $this = $(this); - var config_id = $this.data("config_id"); - var config_value = $this.val(); - $.ajax({ - type: 'POST', - url: 'ajax_form.php', - data: {type: "update-config-item", config_id: config_id, config_value: config_value}, - dataType: "json", - success: function (data) { - if (data.status == 'ok') { - $this.closest('.form-group').addClass('has-success'); - $this.next().addClass('glyphicon-ok'); - setTimeout(function(){ - $this.closest('.form-group').removeClass('has-success'); - $this.next().removeClass('glyphicon-ok'); - }, 2000); - } else { - $(this).closest('.form-group').addClass('has-error'); - $this.next().addClass('glyphicon-remove'); - setTimeout(function(){ - $this.closest('.form-group').removeClass('has-error'); - $this.next().removeClass('glyphicon-remove'); - }, 2000); - } - }, - error: function () { - $("#message").html('
An error occurred.
'); - } - }); - }); $( 'select[name="global-config-select"]').change(function(event) { event.preventDefault(); var $this = $(this);