mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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:
@@ -2174,3 +2174,8 @@ label {
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.validation:invalid {
|
||||||
|
border-color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1260,8 +1260,9 @@ function generate_dynamic_config_panel($title, $config_groups, $items = array(),
|
|||||||
if ($item['type'] == 'checkbox') {
|
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'] . '">';
|
$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') {
|
} elseif ($item['type'] == 'text') {
|
||||||
|
$pattern = isset($item['pattern']) ? ' required pattern="' . $item['pattern'] . '"' : "";
|
||||||
$output .= '
|
$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>
|
<span class="form-control-feedback"><i class="fa" aria-hidden="true"></i></span>
|
||||||
';
|
';
|
||||||
} elseif ($item['type'] == 'password') {
|
} elseif ($item['type'] == 'password') {
|
||||||
|
@@ -87,6 +87,8 @@ $(document).ready(function() {
|
|||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var config_id = $this.data("config_id");
|
var config_id = $this.data("config_id");
|
||||||
var config_value = $this.val();
|
var config_value = $this.val();
|
||||||
|
var required = $this.prop('required');
|
||||||
|
if (required == false) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: 'ajax_form.php',
|
url: 'ajax_form.php',
|
||||||
@@ -103,6 +105,7 @@ $(document).ready(function() {
|
|||||||
toastr.error(data.message);
|
toastr.error(data.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Select config ajax calls
|
// Select config ajax calls
|
||||||
|
@@ -12,6 +12,7 @@ $oxidized_conf = array(
|
|||||||
array('name' => 'oxidized.url',
|
array('name' => 'oxidized.url',
|
||||||
'descr' => 'URL to your Oxidized API',
|
'descr' => 'URL to your Oxidized API',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
|
'pattern' => '[a-zA-Z0-9]{1,5}://.*',
|
||||||
),
|
),
|
||||||
array('name' => 'oxidized.features.versioning',
|
array('name' => 'oxidized.features.versioning',
|
||||||
'descr' => 'Enable config versioning access',
|
'descr' => 'Enable config versioning access',
|
||||||
|
Reference in New Issue
Block a user