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.
......@@ -27,8 +27,9 @@
</div>
<div class="col-lg-9 col-md-8 col-sm-7 component-desc">
<label for="randomize_providers">
<input type="checkbox" class="enabler toggle color-primary is-material" name="randomize_providers" id="randomize_providers"
${('', 'checked')[bool(sickrage.app.config.randomize_providers)]}/>
<input type="checkbox" class="enabler toggle color-primary is-material"
name="randomize_providers" id="randomize_providers"
${('', 'checked')[bool(sickrage.app.config.randomize_providers)]}/>
${_('randomize the provider search order')}
</label>
</div>
......@@ -39,8 +40,9 @@
</div>
<div class="col-lg-9 col-md-8 col-sm-7 component-desc">
<label for="download_propers">
<input type="checkbox" class="enabler toggle color-primary is-material" name="download_propers" id="download_propers"
${('', 'checked')[bool(sickrage.app.config.download_propers)]}/>
<input type="checkbox" class="enabler toggle color-primary is-material"
name="download_propers" id="download_propers"
${('', 'checked')[bool(sickrage.app.config.download_propers)]}/>
${_('replace original download with "Proper" or "Repack" if nuked')}
</label>
</div>
......@@ -51,8 +53,9 @@
</div>
<div class="col-lg-9 col-md-8 col-sm-7 component-desc">
<label for="enable_rss_cache">
<input type="checkbox" class="enabler toggle color-primary is-material" name="enable_rss_cache" id="enable_rss_cache"
${('', 'checked')[bool(sickrage.app.config.enable_rss_cache)]}/>
<input type="checkbox" class="enabler toggle color-primary is-material"
name="enable_rss_cache" id="enable_rss_cache"
${('', 'checked')[bool(sickrage.app.config.enable_rss_cache)]}/>
${_('enables/disables provider RSS feed caching')}
</label>
</div>
......@@ -64,9 +67,10 @@
</div>
<div class="col-lg-9 col-md-8 col-sm-7 component-desc">
<label for="download_unverified_magnet_link">
<input type="checkbox" class="enabler toggle color-primary is-material" name="download_unverified_magnet_link"
<input type="checkbox" class="enabler toggle color-primary is-material"
name="download_unverified_magnet_link"
id="download_unverified_magnet_link"
${('', 'checked')[bool(sickrage.app.config.download_unverified_magnet_link)]}/>
${('', 'checked')[bool(sickrage.app.config.download_unverified_magnet_link)]}/>
${_('enables/disables downloading of unverified torrent magnet links via clients')}
</label>
</div>
......@@ -78,8 +82,9 @@
</div>
<div class="col-lg-9 col-md-8 col-sm-7 component-desc">
<label for="torrent_file_to_magnet">
<input type="checkbox" class="enabler toggle color-primary is-material" name="torrent_file_to_magnet" id="torrent_file_to_magnet"
${('', 'checked')[bool(sickrage.app.config.torrent_file_to_magnet)]}/>
<input type="checkbox" class="enabler toggle color-primary is-material"
name="torrent_file_to_magnet" id="torrent_file_to_magnet"
${('', 'checked')[bool(sickrage.app.config.torrent_file_to_magnet)]}/>
${_('enables/disables converting of public torrent provider file links to magnetic links')}
</label>
</div>
......@@ -91,8 +96,9 @@
</div>
<div class="col-lg-9 col-md-8 col-sm-7 component-desc">
<label for="use_failed_snatcher">
<input type="checkbox" class="enabler toggle color-primary is-material" name="use_failed_snatcher" id="use_failed_snatcher"
${('', 'checked')[bool(sickrage.app.config.use_failed_snatcher)]}/>
<input type="checkbox" class="enabler toggle color-primary is-material"
name="use_failed_snatcher" id="use_failed_snatcher"
${('', 'checked')[bool(sickrage.app.config.use_failed_snatcher)]}/>
${_('enables/disables failed snatch handling, automatically retries failed snatches')}
</label>
</div>
......@@ -321,7 +327,8 @@
</div>
<div class="col-lg-9 col-md-8 col-sm-7 component-desc">
<label for="use_nzbs">
<input type="checkbox" class="enabler toggle color-primary is-material" name="use_nzbs" title="Enable NZB searches"
<input type="checkbox" class="enabler toggle color-primary is-material" name="use_nzbs"
title="Enable NZB searches"
id="use_nzbs" ${('', 'checked')[bool(sickrage.app.config.use_nzbs)]}/>
${_('enable NZB searches')}
</label>
......@@ -526,7 +533,8 @@
</div>
<div class="col-lg-9 col-md-8 col-sm-7 component-desc">
<label for="sab_forced">
<input type="checkbox" class="enabler toggle color-primary is-material" name="sab_forced"
<input type="checkbox" class="enabler toggle color-primary is-material"
name="sab_forced"
id="sab_forced" ${('', 'selected')[bool(sickrage.app.config.sab_forced)]}/>
${_('enable to change priority from HIGH to FORCED')}
</label>
......@@ -542,7 +550,8 @@
</div>
<div class="col-lg-9 col-md-8 col-sm-7 component-desc">
<label for="nzbget_use_https">
<input id="nzbget_use_https" type="checkbox" class="enabler toggle color-primary is-material"
<input id="nzbget_use_https" type="checkbox"
class="enabler toggle color-primary is-material"
name="nzbget_use_https" ${('', 'selected')[bool(sickrage.app.config.nzbget_use_https)]}/>
${_('enable secure control')}
</label>
......@@ -821,7 +830,13 @@
placeholder="${_('ex. http://localhost:8000/')}"
title="URL to your torrent client"
class="form-control"
autocapitalize="off"/>
autocapitalize="off"
type="url"
pattern="https?://.+:[0-9]+/?"
required>
<div class="invalid-tooltip">
Please fill in a valid URL.
</div>
</div>
</div>
</div>
......@@ -872,7 +887,8 @@
</div>
<div class="col-lg-9 col-md-8 col-sm-7 component-desc">
<label for="torrent_verify_cert">
<input type="checkbox" class="enabler toggle color-primary is-material" name="torrent_verify_cert"
<input type="checkbox" class="enabler toggle color-primary is-material"
name="torrent_verify_cert"
id="torrent_verify_cert" ${('', 'checked')[bool(sickrage.app.config.torrent_verify_cert)]}/>
<p id="torrent_verify_deluge">
${_('disable if you get "Deluge: Authentication Error" in your log')}
......@@ -1001,7 +1017,8 @@
</div>
<div class="col-lg-9 col-md-8 col-sm-7 component-desc">
<label for="torrent_paused">
<input type="checkbox" class="enabler toggle color-primary is-material" name="torrent_paused"
<input type="checkbox" class="enabler toggle color-primary is-material"
name="torrent_paused"
id="torrent_paused" ${('', 'checked')[bool(sickrage.app.config.torrent_paused)]}/>
${_('add .torrent to client but do <b>not</b> start downloading')}
</label>
......@@ -1014,7 +1031,8 @@
</div>
<div class="col-lg-9 col-md-8 col-sm-7 component-desc">
<label for="torrent_high_bandwidth">
<input type="checkbox" class="enabler toggle color-primary is-material" name="torrent_high_bandwidth"
<input type="checkbox" class="enabler toggle color-primary is-material"
name="torrent_high_bandwidth"
id="torrent_high_bandwidth" ${('', 'checked')[bool(sickrage.app.config.torrent_high_bandwidth)]}/>
${_('use high bandwidth allocation if priority is high')}
</label>
......
......@@ -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