mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #2120 from laf/config-function
Simplify adding config options to WebUI
This commit is contained in:
50
doc/Developing/Dynamic-Config.md
Normal file
50
doc/Developing/Dynamic-Config.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Adding new config options to WebUI
|
||||
|
||||
Adding support for users to update a new config option via the WebUI is now a lot easier for general options. This
|
||||
document shows you how to add a new config option and even section to the WebUI.
|
||||
|
||||
#### Update DB
|
||||
|
||||
Firstly you will need to add the config option to the database. Here's an example:
|
||||
|
||||
```sql
|
||||
insert into config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('alert.tolerance_window','','','Tolerance window in seconds','alerting',0,'general',0,'0','0');
|
||||
```
|
||||
|
||||
This will determine the default config option for `$config['alert']['tolerance_window']`.
|
||||
|
||||
#### Update WebUI
|
||||
|
||||
If the sub-section you want to add the new config option already exists then update the relevant file within
|
||||
`html/pages/settings/` otherwise you will need to create the new sub-section page. Here's an example of this:
|
||||
|
||||
[Commit example](https://github.com/librenm/librenms/commit/c5998f9ee27acdac0c0f7d3092fc830c51ff684c)
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
$no_refresh = true;
|
||||
|
||||
$config_groups = get_config_by_group('alerting');
|
||||
|
||||
$mail_conf = array(
|
||||
array('name' => 'alert.tolerance_window',
|
||||
'descr' => 'Tolerance window for cron',
|
||||
'type' => 'text',
|
||||
),
|
||||
);
|
||||
|
||||
echo '
|
||||
<div class="panel-group" id="accordion">
|
||||
<form class="form-horizontal" role="form" action="" method="post">
|
||||
';
|
||||
|
||||
echo generate_dynamic_config_panel('Email transport',true,$config_groups,$mail_conf,'mail');
|
||||
|
||||
echo '
|
||||
</form>
|
||||
</div>
|
||||
';
|
||||
```
|
||||
|
||||
And that should be it!
|
||||
@@ -23,7 +23,7 @@ $config_type = mres($_POST['config_type']);
|
||||
$status = 'error';
|
||||
|
||||
if (!is_numeric($config_id)) {
|
||||
$message = 'ERROR: No alert selected';
|
||||
$message = 'ERROR: No config item';
|
||||
}
|
||||
else if ($action == 'update-textarea') {
|
||||
$extras = explode(PHP_EOL, $_POST['config_value']);
|
||||
|
||||
@@ -1179,3 +1179,73 @@ function dynamic_override_config($type, $name, $device) {
|
||||
return '<input type="checkbox" id="override_config" name="override_config" data-attrib="'.$name.'" data-device_id="'.$device['device_id'].'" data-size="small" '.$checked.'>';
|
||||
}
|
||||
}//end dynamic_override_config()
|
||||
|
||||
function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$items=array(),$transport='') {
|
||||
$anchor = md5($title);
|
||||
$output = '
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#'.$anchor.'">'.$title.'</a>
|
||||
';
|
||||
if (!empty($transport)) {
|
||||
$output .= '<button name="test-alert" id="test-alert" type="button" data-transport="'.$transport.'" class="btn btn-primary btn-xs pull-right">Test transport</button>';
|
||||
}
|
||||
$output .= '
|
||||
</h4>
|
||||
</div>
|
||||
<div id="'.$anchor.'" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
';
|
||||
|
||||
if (!empty($items)) {
|
||||
foreach ($items as $item) {
|
||||
$output .= '
|
||||
<div class="form-group has-feedback">
|
||||
<label for="'.$item['name'].'"" class="col-sm-4 control-label">'.$item['descr'].' </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups[$item['name']]['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
';
|
||||
if ($item['type'] == 'checkbox') {
|
||||
$output .= '<input id="'.$item['name'].'" type="checkbox" name="global-config-check" '.$config_groups[$item['name']]['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups[$item['name']]['config_id'].'">';
|
||||
}
|
||||
elseif ($item['type'] == 'text') {
|
||||
$output .= '
|
||||
<input id="'.$item['name'].'" class="form-control" type="text" name="global-config-input" value="'.$config_groups[$item['name']]['config_value'].'" data-config_id="'.$config_groups[$item['name']]['config_id'].'">
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
';
|
||||
}
|
||||
elseif ($item['type'] == 'select') {
|
||||
$output .= '
|
||||
<select id="'.$config_groups[$item['name']]['name'].'" class="form-control" name="global-config-select" data-config_id="'.$config_groups[$item['name']]['config_id'].'">
|
||||
';
|
||||
if (!empty($item['options'])) {
|
||||
foreach ($item['options'] as $option) {
|
||||
$output .= '<option value="'.$option.'"';
|
||||
if ($option == $config_groups[$item['name']]['config_value']) {
|
||||
$output .= ' selected';
|
||||
}
|
||||
$output .= '>'.$option.'</option>';
|
||||
}
|
||||
}
|
||||
$output .='
|
||||
</select>
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
';
|
||||
}
|
||||
$output .= '
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
}
|
||||
|
||||
if ($end_panel === true) {
|
||||
$output .= '
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
return $output;
|
||||
}//end generate_dynamic_config_panel()
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,12 +23,28 @@
|
||||
* @package LibreNMS
|
||||
* @subpackage Page
|
||||
*/
|
||||
$pagetitle[] = 'Global Settings';
|
||||
|
||||
if (empty($vars['sub'])) {
|
||||
$page_name = 'Global';
|
||||
}
|
||||
else {
|
||||
$page_name = ucfirst($vars['sub']);
|
||||
}
|
||||
|
||||
$pagetitle[] = $page_name . ' Settings';
|
||||
$config['memcached']['enable'] = false;
|
||||
?>
|
||||
|
||||
<script src="js/librenms.js"></script>
|
||||
|
||||
<div class="container-fluid">
|
||||
<h2>Global Settings</h2>
|
||||
<h2>
|
||||
<?php
|
||||
|
||||
echo $pagetitle[0];
|
||||
|
||||
?>
|
||||
</h2>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@@ -59,7 +75,7 @@ else {
|
||||
foreach (dbFetchRows("SELECT `config_group` FROM `config` GROUP BY `config_group`") as $sub_page) {
|
||||
$sub_page = $sub_page['config_group'];
|
||||
?>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
||||
<a class="btn btn-primary" href="<?php echo(generate_url(array('page'=>'settings','sub'=>$sub_page))); ?>"><?php echo ucfirst($sub_page); ?> Settings</a>
|
||||
</div>
|
||||
<?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 '
|
||||
<div class="panel-group" id="accordion">
|
||||
<form class="form-horizontal" role="form" action="" method="post">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#general_settings_expand">General alert settings</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="general_settings_expand" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label for="admins" class="col-sm-4 control-label">Issue alerts to admins </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['alert.admins']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="admins" type="checkbox" name="global-config-check" '.$config_groups['alert.admins']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['alert.admins']['config_id'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="globals" class="col-sm-4 control-label">Issue alerts to read only users </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['alert.globals']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="globals" type="checkbox" name="global-config-check" '.$config_groups['alert.globals']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['alert.globals']['config_id'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="syscontact" class="col-sm-4 control-label">Issue alerts to sysContact </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['alert.syscontact']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="admins" type="checkbox" name="global-config-check" '.$config_groups['alert.syscontact']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['alert.syscontact']['config_id'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="default_only" class="col-sm-4 control-label">Send alerts to default contact only </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['alert.default_only']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="default_only" type="checkbox" name="global-config-check" '.$config_groups['alert.default_only']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['alert.default_only']['config_id'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label for="default_mail" class="col-sm-4 control-label">Default contact </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['alert.default_mail']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="default_mail" class="form-control" type="text" name="global-config-input" value="'.$config_groups['alert.default_mail']['config_value'].'" data-config_id="'.$config_groups['alert.default_mail']['config_id'].'">
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label for="tolerance_window" class="col-sm-4 control-label">Tolerance window for cron </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['alert.tolerance_window']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="tolerance_window" class="form-control" type="text" name="global-config-input" value="'.$config_groups['alert.tolerance_window']['config_value'].'" data-config_id="'.$config_groups['alert.tolerance_window']['config_id'].'">
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="fixed_contacts" class="col-sm-4 control-label">Updates to contact email addresses not honored </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['alert.fixed-contacts']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="fixed_contacts" type="checkbox" name="global-config-check" '.$config_groups['alert.fixed-contacts']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['alert.fixed-contacts']['config_id'].'">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#email_transport_expand">Email transport</a> <button name="test-alert" id="test-alert" type="button" data-transport="mail" class="btn btn-primary btn-xs pull-right">Test transport</button>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="email_transport_expand" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label for="default_only" class="col-sm-4 control-label">Enable email alerting </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['alert.transports.mail']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="mail_transport" type="checkbox" name="global-config-check" '.$config_groups['alert.transports.mail']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['alert.transports.mail']['config_id'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label for="email_backend" class="col-sm-4 control-label">How to deliver mail </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['email_backend']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<select id="email_backend" class="form-control" name="global-config-select" data-config_id="'.$config_groups['email_backend']['config_id'].'">';
|
||||
foreach ($dyn_config['email_backend'] as $backend) {
|
||||
echo '<option value="'.$backend.'"';
|
||||
if ($config_groups['email_backend']['config_value'] == $backend) {
|
||||
echo ' selected';
|
||||
}
|
||||
';
|
||||
|
||||
echo '>'.$backend.'</option>';
|
||||
}
|
||||
echo generate_dynamic_config_panel('General alert settings',true,$config_groups,$general_conf);
|
||||
echo generate_dynamic_config_panel('Email transport',true,$config_groups,$mail_conf,'mail');
|
||||
|
||||
|
||||
echo '</select>
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label for="email_from" class="col-sm-4 control-label">From address </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['email_from']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_from" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_from']['config_value'].'" data-config_id="'.$config_groups['email_from']['config_id'].'">
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label for="email_user" class="col-sm-4 control-label">From name </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['email_user']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_user" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_user']['config_value'].'" data-config_id="'.$config_groups['email_user']['config_id'].'">
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label for="email_sendmail_path" class="col-sm-4 control-label">Sendmail path </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['email_sendmail_path']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_sendmail_path" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_sendmail_path']['config_value'].'" data-config_id="'.$config_groups['email_sendmail_path']['config_id'].'">
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label for="email_smtp_host" class="col-sm-4 control-label">SMTP Host </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['email_smtp_host']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_smtp_host" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_smtp_host']['config_value'].'" data-config_id="'.$config_groups['email_smtp_host']['config_id'].'">
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label for="email_smtp_port" class="col-sm-4 control-label">SMTP Port </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['email_smtp_port']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_smtp_port" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_smtp_port']['config_value'].'" data-config_id="'.$config_groups['email_smtp_port']['config_id'].'">
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label for="email_smtp_timeout" class="col-sm-4 control-label">SMTP Timeout </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['email_smtp_timeout']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_smtp_timeout" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_smtp_timeout']['config_value'].'" data-config_id="'.$config_groups['email_smtp_timeout']['config_id'].'">
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label for="email_smtp_secure" class="col-sm-4 control-label">SMTP Secure </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['email_smtp_secure']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<select id="email_smtp_secure" class="form-control"name="global-config-select" data-config_id="'.$config_groups['email_smtp_secure']['config_id'].'">';
|
||||
foreach ($dyn_config['email_smtp_secure'] as $secure) {
|
||||
echo "<option value='$secure'";
|
||||
if ($config_groups['email_smtp_secure']['config_value'] == $secure) {
|
||||
echo ' selected';
|
||||
}
|
||||
|
||||
echo ">$secure</option>";
|
||||
}
|
||||
|
||||
echo '</select>
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email_smtp_auth" class="col-sm-4 control-label">SMTP Authentication </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['email_smtp_auth']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_smtp_auth" type="checkbox" name="global-config-check" '.$config_groups['email_smtp_auth']['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups['email_smtp_auth']['config_id'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label for="email_smtp_username" class="col-sm-4 control-label">SMTP Authentication username </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['email_smtp_username']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_smtp_username" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_smtp_username']['config_value'].'" data-config_id="'.$config_groups['email_smtp_username']['config_id'].'">
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<label for="email_smtp_password" class="col-sm-4 control-label">SMTP Authentication password </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups['email_smtp_password']['config_descr'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_smtp_password" class="form-control" type="text" name="global-config-input" value="'.$config_groups['email_smtp_password']['config_value'].'" data-config_id="'.$config_groups['email_smtp_password']['config_id'].'">
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
echo '
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
@@ -1158,58 +1056,6 @@ echo '<div id="boxcar_appkey_template" class="hide">
|
||||
});
|
||||
});// 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('<div class="alert alert-info">' + data.message + '</div>');
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$("#message").html('<div class="alert alert-info">An error occurred.</div>');
|
||||
}
|
||||
});
|
||||
});
|
||||
$(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('<div class="alert alert-info">An error occurred.</div>');
|
||||
}
|
||||
});
|
||||
});
|
||||
$( 'select[name="global-config-select"]').change(function(event) {
|
||||
event.preventDefault();
|
||||
var $this = $(this);
|
||||
|
||||
32
html/pages/settings/external.inc.php
Normal file
32
html/pages/settings/external.inc.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
$no_refresh = true;
|
||||
|
||||
$config_groups = get_config_by_group('external');
|
||||
|
||||
$oxidized_conf = array(
|
||||
array('name' => 'oxidized.enabled',
|
||||
'descr' => 'Enable Oxidized support',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array('name' => 'oxidized.url',
|
||||
'descr' => 'URL to your Oxidized API',
|
||||
'type' => 'text',
|
||||
),
|
||||
array('name' => 'oxidized.features.versioning',
|
||||
'descr' => 'Enable config versioning access',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
);
|
||||
|
||||
echo '
|
||||
<div class="panel-group" id="accordion">
|
||||
<form class="form-horizontal" role="form" action="" method="post">
|
||||
';
|
||||
|
||||
echo generate_dynamic_config_panel('Oxidized integration',true,$config_groups,$oxidized_conf);
|
||||
|
||||
echo '
|
||||
</form>
|
||||
</div>
|
||||
';
|
||||
1
sql-schema/074.sql
Normal file
1
sql-schema/074.sql
Normal file
@@ -0,0 +1 @@
|
||||
INSERT INTO config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('oxidized.enabled','false','false','Enable Oxidized support','external',0,'oxidized',0,'0','0'),('oxidized.url','','','Oxidized API url','external',0,'oxidized',0,'0','0'),('oxidized.features.versioning','false','false','Enable Oxidized config versioning','external',0,'oxidized',0,'0','0');
|
||||
Reference in New Issue
Block a user