From f9b348ace798b6fbc890e583ee6bfd0bf4976d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 29 May 2019 23:45:33 -0400 Subject: [PATCH] Improvement to settings and wizard template to reuse providers instead of duplicating everything and also to simplify new development. --- static/js/settings_validation.js | 174 ++ static/js/wizard_validation.js | 156 ++ views/providers.tpl | 753 ++++++++ views/settings.tpl | 2990 +----------------------------- views/settings_general.tpl | 834 +++++++++ views/settings_notifications.tpl | 72 + views/settings_radarr.tpl | 198 ++ views/settings_sonarr.tpl | 200 ++ views/settings_subtitles.tpl | 726 ++++++++ views/wizard.tpl | 2017 +------------------- views/wizard_general.tpl | 231 +++ views/wizard_radarr.tpl | 204 ++ views/wizard_sonarr.tpl | 204 ++ views/wizard_subtitles.tpl | 387 ++++ 14 files changed, 4225 insertions(+), 4921 deletions(-) create mode 100644 static/js/settings_validation.js create mode 100644 static/js/wizard_validation.js create mode 100644 views/providers.tpl create mode 100644 views/settings_general.tpl create mode 100644 views/settings_notifications.tpl create mode 100644 views/settings_radarr.tpl create mode 100644 views/settings_sonarr.tpl create mode 100644 views/settings_subtitles.tpl create mode 100644 views/wizard_general.tpl create mode 100644 views/wizard_radarr.tpl create mode 100644 views/wizard_sonarr.tpl create mode 100644 views/wizard_subtitles.tpl diff --git a/static/js/settings_validation.js b/static/js/settings_validation.js new file mode 100644 index 000000000..a3da8b271 --- /dev/null +++ b/static/js/settings_validation.js @@ -0,0 +1,174 @@ +$('#settings_form') + .form({ + fields: { + settings_general_ip : { + rules : [ + { + type : 'regExp[/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/]', + prompt : '"General / Start-Up / Listening IP address" must be a valid IPv4 address' + }, + { + type : 'empty', + prompt : '"General / Start-Up / Listening IP address" must have a value' + } + ] + }, + settings_general_port : { + rules : [ + { + type : 'integer[1..65535]', + prompt : '"General / Start-Up / Listening port" must be an integer between 1 and 65535' + }, + { + type : 'empty', + prompt : '"General / Start-Up / Listening port" must have a value' + } + ] + }, + settings_general_chmod: { + rules: [ + { + type: 'regExp[^([0-7]{4})$]', + prompt : '"General / Start-Up / Set subtitle file permissions to" must be a 4-digit octal (e.g.: 0775)' + } + ] + }, + settings_auth_password : { + depends: 'settings_auth_username', + rules : [ + { + type : 'empty', + prompt : '"General / Security settings / Password" must have a value and you must type it again if you change your username.' + } + ] + }, + sonarr_validated_checkbox : { + depends: 'settings_general_use_sonarr', + rules : [ + { + type : 'checked', + prompt : '"Sonarr / Connection settings / Test" must be successful before going further' + } + ] + }, + settings_sonarr_ip : { + depends: 'settings_general_use_sonarr', + rules : [ + { + type : 'empty', + prompt : '"Sonarr / Connection settings / Hostname or IP address" must have a value' + } + ] + }, + settings_sonarr_port : { + depends: 'settings_general_use_sonarr', + rules : [ + { + type : 'integer[1..65535]', + prompt : '"Sonarr / Connection settings / Listening port" must be an integer between 1 and 65535' + }, + { + type : 'empty', + prompt : '"Sonarr / Connection settings / Listening port" must have a value' + } + ] + }, + settings_sonarr_apikey : { + depends: 'settings_general_use_sonarr', + rules : [ + { + type : 'exactLength[32]', + prompt : '"Sonarr / Connection settings / API key" must be exactly {ruleValue} characters' + }, + { + type : 'empty', + prompt : '"Sonarr / Connection settings / API key" must have a value' + } + ] + }, + radarr_validated_checkbox : { + depends: 'settings_general_use_radarr', + rules : [ + { + type : 'checked', + prompt : '"Radarr / Connection settings / Test" must be successful before going further' + } + ] + }, + settings_radarr_ip : { + depends: 'settings_general_use_radarr', + rules : [ + { + type : 'empty', + prompt : '"Radarr / Connection settings / Hostname or IP address" must have a value' + } + ] + }, + settings_radarr_port : { + depends: 'settings_general_use_radarr', + rules : [ + { + type : 'integer[1..65535]', + prompt : '"Radarr / Connection settings / Listening port" must be an integer between 1 and 65535' + }, + { + type : 'empty', + prompt : '"Radarr / Connection settings / Listening port" must have a value' + } + ] + }, + settings_radarr_apikey : { + depends: 'settings_general_use_radarr', + rules : [ + { + type : 'exactLength[32]', + prompt : '"Radarr / Connection settings / API key" must be exactly {ruleValue} characters' + }, + { + type : 'empty', + prompt : '"Radarr / Connection settings / API key" must have a value' + } + ] + }, + settings_subliminal_providers : { + rules : [ + { + type : 'minCount[1]', + prompt : '"Subtitles / Subtitles providers" must have at least one enabled provider' + } + ] + }, + settings_subliminal_languages : { + rules : [ + { + type : 'minCount[1]', + prompt : '"Subtitles / Subtitles languages / Enabled languages" must have at least one enabled language' + } + ] + }, + settings_days_to_upgrade_subs : { + depends: 'settings_upgrade_subs', + rules : [ + { + type : 'integer[1..30]', + prompt : '"Subtitles / Subtitles options / Number of days to go back in history..." must be an integer between 1 and 30' + } + ] + } + }, + inline : false, + selector : { + message: '#form_validation_error' + }, + on : 'change', + onFailure: function(){ + $('.submit').addClass('disabled'); + return false; + }, + onSuccess: function(){ + $('.submit').removeClass('disabled'); + $('#loader').addClass('active'); + } + }) +; + diff --git a/static/js/wizard_validation.js b/static/js/wizard_validation.js new file mode 100644 index 000000000..bb9b50299 --- /dev/null +++ b/static/js/wizard_validation.js @@ -0,0 +1,156 @@ +$('#wizard_form') + .form({ + fields: { + settings_general_ip : { + rules : [ + { + type : 'regExp[/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/]', + prompt : '"General / Start-Up / Listening IP address" must be a valid IPv4 address' + }, + { + type : 'empty', + prompt : '"General / Start-Up / Listening IP address" must have a value' + } + ] + }, + settings_general_port : { + rules : [ + { + type : 'integer[1..65535]', + prompt : '"General / Start-Up / Listening port" must be an integer between 1 and 65535' + }, + { + type : 'empty', + prompt : '"General / Start-Up / Listening port" must have a value' + } + ] + }, + sonarr_validated_checkbox : { + depends: 'settings_general_use_sonarr', + rules : [ + { + type : 'checked', + prompt : '"Sonarr / Connection settings / Test" must be successful before going further' + } + ] + }, + settings_sonarr_ip : { + depends: 'settings_general_use_sonarr', + rules : [ + { + type : 'empty', + prompt : '"Sonarr / Connection settings / Hostname or IP address" must have a value' + } + ] + }, + settings_sonarr_port : { + depends: 'settings_general_use_sonarr', + rules : [ + { + type : 'integer[1..65535]', + prompt : '"Sonarr / Connection settings / Listening port" must be an integer between 1 and 65535' + }, + { + type : 'empty', + prompt : '"Sonarr / Connection settings / Listening port" must have a value' + } + ] + }, + settings_sonarr_apikey : { + depends: 'settings_general_use_sonarr', + rules : [ + { + type : 'exactLength[32]', + prompt : '"Sonarr / Connection settings / API key" must be exactly {ruleValue} characters' + }, + { + type : 'empty', + prompt : '"Sonarr / Connection settings / API key" must have a value' + } + ] + }, + radarr_validated_checkbox : { + depends: 'settings_general_use_radarr', + rules : [ + { + type : 'checked', + prompt : '"Radarr / Connection settings / Test" must be successful before going further' + } + ] + }, + settings_radarr_ip : { + depends: 'settings_general_use_radarr', + rules : [ + { + type : 'empty', + prompt : '"Radarr / Connection settings / Hostname or IP address" must have a value' + } + ] + }, + settings_radarr_port : { + depends: 'settings_general_use_radarr', + rules : [ + { + type : 'integer[1..65535]', + prompt : '"Radarr / Connection settings / Listening port" must be an integer between 1 and 65535' + }, + { + type : 'empty', + prompt : '"Radarr / Connection settings / Listening port" must have a value' + } + ] + }, + settings_radarr_apikey : { + depends: 'settings_general_use_radarr', + rules : [ + { + type : 'exactLength[32]', + prompt : '"Radarr / Connection settings / API key" must be exactly {ruleValue} characters' + }, + { + type : 'empty', + prompt : '"Radarr / Connection settings / API key" must have a value' + } + ] + }, + settings_subliminal_providers : { + rules : [ + { + type : 'minCount[1]', + prompt : '"Subtitles / Subtitles providers" must have at least one enabled provider' + } + ] + }, + settings_subliminal_languages : { + rules : [ + { + type : 'minCount[1]', + prompt : '"Subtitles / Subtitles languages / Enabled languages" must have at least one enabled language' + } + ] + } + }, + inline : false, + selector : { + message: '#form_validation_error' + }, + on : 'change', + onFailure: function(){ + $('#submit').addClass('disabled'); + $('.prev2').addClass('disabled'); + $('.prev3').addClass('disabled'); + $('.next2').addClass('disabled'); + $('.next3').addClass('disabled'); + + + return false; + }, + onSuccess: function(){ + $('#submit').removeClass('disabled'); + $('.prev2').removeClass('disabled'); + $('.prev3').removeClass('disabled'); + $('.next2').removeClass('disabled'); + $('.next3').removeClass('disabled'); + } + }) +; \ No newline at end of file diff --git a/views/providers.tpl b/views/providers.tpl new file mode 100644 index 000000000..dad93b014 --- /dev/null +++ b/views/providers.tpl @@ -0,0 +1,753 @@ +