diff --git a/themes-default/slim/static/js/add-show-options.js b/themes-default/slim/static/js/add-show-options.js
index 4ea832c159..4506e66844 100644
--- a/themes-default/slim/static/js/add-show-options.js
+++ b/themes-default/slim/static/js/add-show-options.js
@@ -2,10 +2,10 @@ $(document).ready(() => {
$(document.body).on('click', '#saveDefaultsButton', event => {
const anyQualArray = [];
const bestQualArray = [];
- $('#allowed_qualities option:selected').each((i, d) => {
+ $('select[name="allowed_qualities"] option:selected').each((i, d) => {
anyQualArray.push($(d).val());
});
- $('#preferred_qualities option:selected').each((i, d) => {
+ $('select[name="preferred_qualities"] option:selected').each((i, d) => {
bestQualArray.push($(d).val());
});
@@ -31,11 +31,11 @@ $(document).ready(() => {
});
});
- $(document.body).on('change', '#statusSelect, #qualityPreset, #season_folders, #allowed_qualities, #preferred_qualities, #subtitles, #scene, #anime, #statusSelectAfter', () => {
+ $(document.body).on('change', '#statusSelect, select[name="quality_preset"], #season_folders, select[name="allowed_qualities"], select[name="preferred_qualities"], #subtitles, #scene, #anime, #statusSelectAfter', () => {
$('#saveDefaultsButton').prop('disabled', false);
});
- $(document.body).on('change', '#qualityPreset', () => {
+ $(document.body).on('change', 'select[name="quality_preset"]', () => {
// Fix issue #181 - force re-render to correct the height of the outer div
$('span.prev').click();
$('span.next').click();
diff --git a/themes-default/slim/static/js/add-shows/new-show.js b/themes-default/slim/static/js/add-shows/new-show.js
index 8077b4840c..3f1fdfc578 100644
--- a/themes-default/slim/static/js/add-shows/new-show.js
+++ b/themes-default/slim/static/js/add-shows/new-show.js
@@ -163,10 +163,6 @@ MEDUSA.addShows.newShow = function() {
$('#addShowForm').submit();
});
- $('#qualityPreset').on('change', () => {
- myform.loadsection(2); // eslint-disable-line no-use-before-define
- });
-
/* JQuery Form to Form Wizard- (c) Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more. */
@@ -207,6 +203,10 @@ MEDUSA.addShows.newShow = function() {
myform.loadsection(2);
});
+ $(document.body).on('change', 'select[name="quality_preset"]', () => {
+ setTimeout(() => myform.loadsection(2), 100);
+ });
+
$('#rootDirs').on('change', () => {
updateSampleText();
});
diff --git a/themes-default/slim/static/js/quality-chooser.js b/themes-default/slim/static/js/quality-chooser.js
deleted file mode 100644
index 87bfa3104b..0000000000
--- a/themes-default/slim/static/js/quality-chooser.js
+++ /dev/null
@@ -1,139 +0,0 @@
-$(document).ready(() => {
- function setFromPresets(preset) {
- if (parseInt(preset, 10) === 0) {
- $('#customQuality').show();
- return;
- }
-
- $('#customQuality').hide();
-
- $('#allowed_qualities option').each((index, element) => {
- const result = preset & $(element).val();
- if (result > 0) {
- $(element).prop('selected', true);
- } else {
- $(element).prop('selected', false);
- }
- });
-
- $('#preferred_qualities option').each((index, element) => {
- const result = preset & ($(element).val() << 16);
- if (result > 0) {
- $(element).prop('selected', true);
- } else {
- $(element).prop('selected', false);
- }
- });
- }
-
- function backloggedEpisodes() {
- const selectedPreffered = [];
- const selectedAllowed = [];
- $('#preferred_qualities :selected').each((i, selected) => {
- selectedPreffered[i] = $(selected).val();
- });
- $('#allowed_qualities :selected').each((i, selected) => {
- selectedAllowed[i] = $(selected).val();
- });
- const url = 'series/' + $('#series-slug').attr('value') +
- '/legacy/backlogged' +
- '?allowed=' + selectedAllowed +
- '&preferred=' + selectedPreffered;
- api.get(url).then(response => {
- const newBacklogged = response.data.new;
- const existingBacklogged = response.data.existing;
- const variation = Math.abs(newBacklogged - existingBacklogged);
- let html = 'Current backlog: ' + existingBacklogged + ' episodes
';
- if (newBacklogged === -1 || existingBacklogged === -1) {
- html = 'No qualities selected';
- } else if (newBacklogged === existingBacklogged) {
- html += 'This change won\'t affect your backlogged episodes';
- } else {
- html += '
New backlog: ' + newBacklogged + ' episodes';
- html += '
';
- let change = '';
- if (newBacklogged > existingBacklogged) {
- html += 'WARNING: ';
- change = 'increase';
- // Only show the archive action div if we have backlog increase
- $('#archive').show();
- } else {
- change = 'decrease';
- }
- html += 'Backlog will ' + change + ' by ' + variation + ' episodes.';
- }
- $('#backloggedEpisodes').html(html);
- });
- }
-
- function archiveEpisodes() {
- const url = 'series/' + $('#series-slug').attr('value') + '/operation';
- api.post(url, { type: 'ARCHIVE_EPISODES' }).then(response => {
- let html = '';
- if (response.status === 201) {
- html = 'Successfully archived episodes';
- // Recalculate backlogged episodes after we archive it
- backloggedEpisodes();
- } else if (response.status === 204) {
- html = 'No episodes to be archived';
- }
- $('#archivedStatus').html(html);
- // Restore button text
- $('#archiveEpisodes').val('Finished');
- $('#archiveEpisodes').prop('disabled', true);
- });
- }
-
- function setQualityText() {
- const preferred = $.map($('#preferred_qualities option:selected'), option => {
- return option.text;
- });
- const allowed = $.map($('#allowed_qualities option:selected'), option => {
- return option.text;
- });
- const both = allowed.concat(preferred.filter(item => {
- return allowed.indexOf(item) < 0;
- }));
-
- const allowedPreferredExplanation = both.join(', ');
- const preferredExplanation = preferred.join(', ');
- const allowedExplanation = allowed.join(', ');
-
- $('#allowedPreferredExplanation').text(allowedPreferredExplanation);
- $('#preferredExplanation').text(preferredExplanation);
- $('#allowedExplanation').text(allowedExplanation);
-
- $('#allowedText').hide();
- $('#preferredText1').hide();
- $('#preferredText2').hide();
- $('#qualityExplanation').show();
-
- if (preferred.length >= 1) {
- $('#preferredText1').show();
- $('#preferredText2').show();
- } else if (allowed.length >= 1) {
- $('#allowedText').show();
- } else {
- $('#qualityExplanation').hide();
- }
- }
-
- $(document.body).on('click', '#archiveEpisodes', event => {
- $.get($(event.currentTarget).attr('href'));
- $(event.currentTarget).val('Archiving...');
- archiveEpisodes();
- return false;
- });
-
- $(document.body).on('change', '#qualityPreset', () => {
- setFromPresets($('#qualityPreset :selected').val());
- });
-
- $(document.body).on('change', '#qualityPreset, #preferred_qualities, #allowed_qualities', () => {
- setQualityText();
- backloggedEpisodes();
- });
-
- setFromPresets($('#qualityPreset :selected').val());
- setQualityText();
-});
diff --git a/themes-default/slim/static/js/vue-submit-form.js b/themes-default/slim/static/js/vue-submit-form.js
new file mode 100644
index 0000000000..4b66f55790
--- /dev/null
+++ b/themes-default/slim/static/js/vue-submit-form.js
@@ -0,0 +1,21 @@
+window.vueSubmitForm = async function(formId) {
+ const element = document.getElementById(formId);
+ const formData = new FormData(element);
+ const method = element.getAttribute('method');
+ const base = document.getElementsByTagName('base')[0].getAttribute('href');
+ const path = element.getAttribute('action');
+ const redirect = element.getAttribute('redirect');
+
+ // @TODO: Add this back when we're JSON only
+ // This converts formData to JSON
+ // const body = Array.from(formData.entries()).reduce((memo, pair) => ({
+ // ...memo,
+ // [pair[0]]: pair[1]
+ // }), {});
+ this.$http[method](path, { body: formData, redirect: 'follow' })
+ .then(() => {
+ if (redirect) {
+ window.location.href = base + redirect;
+ }
+ });
+};
diff --git a/themes-default/slim/views/addShows_addExistingShow.mako b/themes-default/slim/views/addShows_addExistingShow.mako
index 6ce29aa747..d890a03af5 100644
--- a/themes-default/slim/views/addShows_addExistingShow.mako
+++ b/themes-default/slim/views/addShows_addExistingShow.mako
@@ -3,7 +3,6 @@
from medusa import app
%>
<%block name="scripts">
-
+
+
+
% if enable_anime_options:
% endif
diff --git a/themes-default/slim/views/addShows_trendingShows.mako b/themes-default/slim/views/addShows_trendingShows.mako
index 436ce5298a..363402437f 100644
--- a/themes-default/slim/views/addShows_trendingShows.mako
+++ b/themes-default/slim/views/addShows_trendingShows.mako
@@ -3,7 +3,6 @@
from medusa import app
%>
<%block name="scripts">
-
% if enable_anime_options:
% endif
diff --git a/themes-default/slim/views/editShow.mako b/themes-default/slim/views/editShow.mako
index 7f0a2bc977..3ad7566153 100644
--- a/themes-default/slim/views/editShow.mako
+++ b/themes-default/slim/views/editShow.mako
@@ -13,7 +13,6 @@
%block>
<%block name="scripts">
-
% if show.is_anime:
@@ -71,8 +70,7 @@ const startVue = () => {
diff --git a/themes-default/slim/views/inc_addShowOptions.mako b/themes-default/slim/views/inc_addShowOptions.mako
index 9159a85071..4f16b8c000 100644
--- a/themes-default/slim/views/inc_addShowOptions.mako
+++ b/themes-default/slim/views/inc_addShowOptions.mako
@@ -8,8 +8,7 @@
diff --git a/themes-default/slim/views/inc_qualityChooser.mako b/themes-default/slim/views/inc_qualityChooser.mako
deleted file mode 100644
index ac2e625a79..0000000000
--- a/themes-default/slim/views/inc_qualityChooser.mako
+++ /dev/null
@@ -1,62 +0,0 @@
-<%!
- from medusa import app
- from medusa.common import Quality, qualityPresets, qualityPresetStrings
-%>
-<%
-if not show is UNDEFINED:
- __quality = int(show.quality)
-else:
- __quality = int(app.QUALITY_DEFAULT)
-allowed_qualities, preferred_qualities = Quality.split_quality(__quality)
-overall_quality = Quality.combine_qualities(allowed_qualities, preferred_qualities)
-selected = None
-%>
-
-
Preferred qualities will replace those in allowed, even if they are lower.
-