Commit e78b093c authored by echel0n's avatar echel0n

Added custom form validation for search clients and URLs

parent b9e1cec5
......@@ -41,6 +41,8 @@ class DelugeDAPI(GenericClient):
def connect(self, reconnect=False):
hostname = self.host.replace("/", "").split(':')
if not len(hostname) == 3:
return self.drpc
if not self.drpc or reconnect:
self.drpc = DelugeRPC(hostname[1], port=hostname[2], username=self.username, password=self.password)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -5,7 +5,7 @@
<%block name="content">
<div class="row">
<div class="col-lg-10 mx-auto">
<form id="configForm" action="${self.formaction()}" method="post">
<form id="configForm" action="${self.formaction()}" class="needs-validation" method="post" novalidate>
<div class="card">
<div class="card-header">
<h3 class="float-md-left"><i class="fas fa-wrench"></i> ${title}</h3>
......@@ -20,8 +20,7 @@
</div>
<div class="card-footer">
<div class="float-left">
<input type="submit"
class="btn config_submitter" value="${_('Save Changes')}"/>
<button type="submit" class="btn config_submitter">${_('Save Changes')}</button>
<input type="button" href="/config/reset"
class="btn resetConfig" value="${_('Reset to Defaults')}"/>
</div>
......
......@@ -550,6 +550,18 @@ $(document).ready(function ($) {
});
SICKRAGE.text_viewer();
// Custom form validation with Bootstrap 4
let forms = document.getElementsByClassName('needs-validation');
SICKRAGE.forms_validation = Array.prototype.filter.call(forms, function (form) {
form.addEventListener('submit', function (event) {
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
}, false);
});
}
},
......@@ -2879,6 +2891,10 @@ $(document).ready(function ($) {
$('#configForm').ajaxForm({
beforeSubmit: function () {
if (SICKRAGE.forms_validation === false) {
return false
}
$('.config_submitter .config_submitter_refresh').each(function () {
$(this).attr("disabled", "disabled");
$(this).after('<span>' + SICKRAGE.loadingHTML + gt(' Saving...') + '</span>');
......@@ -2917,7 +2933,7 @@ $(document).ready(function ($) {
});
// on load of the page: switch to the currently selected tab
$('#config-menus a[href="' + window.location.hash + '"]').tab('show')
$('#config-menus a[href="' + window.location.hash + '"]').tab('show');
$('a.resetConfig').confirm({
theme: 'dark',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment