webui: Added validation for Oxidized API URL config (#7978)

* Add http:// to oxidized URLs missing them.

* Fixed typo.

* Form validation instead of backend fix.

* Don't update setting on invalid pattern.
This commit is contained in:
Zmegolaz
2018-01-05 09:58:42 +01:00
committed by Neil Lathwood
parent 4fc946bd21
commit d7b4a30acf
4 changed files with 26 additions and 16 deletions

View File

@@ -2174,3 +2174,8 @@ label {
vertical-align: middle;
padding: 15px;
}
.validation:invalid {
border-color: red;
}

View File

@@ -1260,8 +1260,9 @@ function generate_dynamic_config_panel($title, $config_groups, $items = array(),
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') {
$pattern = isset($item['pattern']) ? ' required pattern="' . $item['pattern'] . '"' : "";
$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'] . '">
<input id="' . $item['name'] . '" class="form-control validation" type="text" name="global-config-input" value="' . $config_groups[$item['name']]['config_value'] . '" data-config_id="' . $config_groups[$item['name']]['config_id'] . '"' . $pattern . '>
<span class="form-control-feedback"><i class="fa" aria-hidden="true"></i></span>
';
} elseif ($item['type'] == 'password') {

View File

@@ -87,6 +87,8 @@ $(document).ready(function() {
var $this = $(this);
var config_id = $this.data("config_id");
var config_value = $this.val();
var required = $this.prop('required');
if (required == false) {
$.ajax({
type: 'POST',
url: 'ajax_form.php',
@@ -103,6 +105,7 @@ $(document).ready(function() {
toastr.error(data.message);
}
});
}
});
// Select config ajax calls

View File

@@ -12,6 +12,7 @@ $oxidized_conf = array(
array('name' => 'oxidized.url',
'descr' => 'URL to your Oxidized API',
'type' => 'text',
'pattern' => '[a-zA-Z0-9]{1,5}://.*',
),
array('name' => 'oxidized.features.versioning',
'descr' => 'Enable config versioning access',