2020-07-09 08:54:12 +01:00
|
|
|
import $ from 'jQuery';
|
|
|
|
import loading from 'loading';
|
|
|
|
import libraryMenu from 'libraryMenu';
|
|
|
|
import globalize from 'globalize';
|
|
|
|
|
|
|
|
/* eslint-disable indent */
|
2018-10-23 01:05:09 +03:00
|
|
|
|
|
|
|
function loadPage(page, config, users) {
|
2020-07-16 11:25:17 +01:00
|
|
|
let html = '<option value="" selected="selected">' + globalize.translate('OptionNone') + '</option>';
|
2019-11-06 13:43:39 +03:00
|
|
|
html += users.map(function (user) {
|
2020-05-04 12:44:12 +02:00
|
|
|
return '<option value="' + user.Id + '">' + user.Name + '</option>';
|
|
|
|
}).join('');
|
|
|
|
$('#selectUser', page).html(html).val(config.UserId || '');
|
|
|
|
$('#selectReleaseDateFormat', page).val(config.ReleaseDateFormat);
|
|
|
|
page.querySelector('#chkSaveImagePaths').checked = config.SaveImagePathsInNfo;
|
|
|
|
page.querySelector('#chkEnablePathSubstitution').checked = config.EnablePathSubstitution;
|
|
|
|
page.querySelector('#chkEnableExtraThumbs').checked = config.EnableExtraThumbsDuplication;
|
2019-11-06 13:43:39 +03:00
|
|
|
loading.hide();
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function onSubmit() {
|
|
|
|
loading.show();
|
2020-07-16 11:25:17 +01:00
|
|
|
const form = this;
|
2019-11-06 13:43:39 +03:00
|
|
|
ApiClient.getNamedConfiguration(metadataKey).then(function (config) {
|
2020-05-04 12:44:12 +02:00
|
|
|
config.UserId = $('#selectUser', form).val() || null;
|
|
|
|
config.ReleaseDateFormat = $('#selectReleaseDateFormat', form).val();
|
|
|
|
config.SaveImagePathsInNfo = form.querySelector('#chkSaveImagePaths').checked;
|
|
|
|
config.EnablePathSubstitution = form.querySelector('#chkEnablePathSubstitution').checked;
|
|
|
|
config.EnableExtraThumbsDuplication = form.querySelector('#chkEnableExtraThumbs').checked;
|
2019-11-06 13:43:39 +03:00
|
|
|
ApiClient.updateNamedConfiguration(metadataKey, config).then(function () {
|
|
|
|
Dashboard.processServerConfigurationUpdateResult();
|
|
|
|
showConfirmMessage(config);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return false;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function showConfirmMessage(config) {
|
2020-07-16 11:25:17 +01:00
|
|
|
const msg = [];
|
2020-05-04 12:44:12 +02:00
|
|
|
msg.push(globalize.translate('MetadataSettingChangeHelp'));
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-07-09 08:54:12 +01:00
|
|
|
import('alert').then(({default: alert}) => {
|
2018-10-23 01:05:09 +03:00
|
|
|
alert({
|
2020-05-04 12:44:12 +02:00
|
|
|
text: msg.join('<br/><br/>')
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getTabs() {
|
|
|
|
return [{
|
2020-05-04 12:44:12 +02:00
|
|
|
href: 'library.html',
|
|
|
|
name: globalize.translate('HeaderLibraries')
|
2018-10-23 01:05:09 +03:00
|
|
|
}, {
|
2020-05-04 12:44:12 +02:00
|
|
|
href: 'librarydisplay.html',
|
|
|
|
name: globalize.translate('TabDisplay')
|
2018-10-23 01:05:09 +03:00
|
|
|
}, {
|
2020-05-04 12:44:12 +02:00
|
|
|
href: 'metadataimages.html',
|
|
|
|
name: globalize.translate('TabMetadata')
|
2018-10-23 01:05:09 +03:00
|
|
|
}, {
|
2020-05-04 12:44:12 +02:00
|
|
|
href: 'metadatanfo.html',
|
|
|
|
name: globalize.translate('TabNfoSettings')
|
2019-11-06 13:43:39 +03:00
|
|
|
}];
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-06-10 14:44:52 -07:00
|
|
|
|
2020-07-16 11:25:17 +01:00
|
|
|
const metadataKey = 'xbmcmetadata';
|
2020-05-04 12:44:12 +02:00
|
|
|
$(document).on('pageinit', '#metadataNfoPage', function () {
|
|
|
|
$('.metadataNfoForm').off('submit', onSubmit).on('submit', onSubmit);
|
|
|
|
}).on('pageshow', '#metadataNfoPage', function () {
|
|
|
|
libraryMenu.setTabs('metadata', 3, getTabs);
|
2019-11-06 13:43:39 +03:00
|
|
|
loading.show();
|
2020-07-16 11:25:17 +01:00
|
|
|
const page = this;
|
|
|
|
const promise1 = ApiClient.getUsers();
|
|
|
|
const promise2 = ApiClient.getNamedConfiguration(metadataKey);
|
2019-11-06 13:43:39 +03:00
|
|
|
Promise.all([promise1, promise2]).then(function (responses) {
|
|
|
|
loadPage(page, responses[1], responses[0]);
|
|
|
|
});
|
|
|
|
});
|
2020-07-09 08:54:12 +01:00
|
|
|
|
|
|
|
/* eslint-enable indent */
|