jellyfin-web/dashboard-ui/scripts/metadatanfo.js

98 lines
2.9 KiB
JavaScript
Raw Normal View History

define(['jQuery'], function ($) {
var metadataKey = "xbmcmetadata";
2015-06-07 18:23:56 -07:00
function loadPage(page, config, users) {
var html = '<option value="" selected="selected"></option>';
html += users.map(function (user) {
return '<option value="' + user.Id + '">' + user.Name + '</option>';
}).join('');
2015-09-03 10:01:51 -07:00
$('#selectUser', page).html(html).val(config.UserId || '');
$('#selectReleaseDateFormat', page).val(config.ReleaseDateFormat);
2016-02-11 21:33:14 -07:00
page.querySelector('#chkSaveImagePaths').checked = config.SaveImagePathsInNfo;
page.querySelector('#chkEnablePathSubstitution').checked = config.EnablePathSubstitution;
page.querySelector('#chkEnableExtraThumbs').checked = config.EnableExtraThumbsDuplication;
Dashboard.hideLoadingMsg();
}
2015-06-07 18:23:56 -07:00
function onSubmit() {
Dashboard.showLoadingMsg();
2015-06-07 18:23:56 -07:00
var form = this;
2015-12-14 08:43:03 -07:00
ApiClient.getNamedConfiguration(metadataKey).then(function (config) {
2015-06-07 18:23:56 -07:00
config.UserId = $('#selectUser', form).val() || null;
config.ReleaseDateFormat = $('#selectReleaseDateFormat', form).val();
2016-02-11 21:33:14 -07:00
config.SaveImagePathsInNfo = form.querySelector('#chkSaveImagePaths').checked;
config.EnablePathSubstitution = form.querySelector('#chkEnablePathSubstitution').checked;
config.EnableExtraThumbsDuplication = form.querySelector('#chkEnableExtraThumbs').checked;
2016-04-19 22:32:37 -07:00
ApiClient.updateNamedConfiguration(metadataKey, config).then(function () {
Dashboard.processServerConfigurationUpdateResult();
showConfirmMessage(config);
});
});
2015-06-07 18:23:56 -07:00
// Disable default form submission
return false;
}
2016-04-19 22:32:37 -07:00
function showConfirmMessage(config) {
var msg = [];
msg.push(Globalize.translate('MetadataSettingChangeHelp'));
require(['alert'], function (alert) {
alert({
text: msg.join('<br/><br/>')
});
});
}
2016-04-12 23:02:07 -07:00
function getTabs() {
return [
{
href: 'metadata.html',
name: Globalize.translate('TabSettings')
},
{
href: 'metadataimages.html',
name: Globalize.translate('TabServices')
},
{
href: 'metadatanfo.html',
name: Globalize.translate('TabNfoSettings')
}];
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#metadataNfoPage", function () {
2015-06-07 18:23:56 -07:00
$('.metadataNfoForm').off('submit', onSubmit).on('submit', onSubmit);
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#metadataNfoPage", function () {
2016-04-12 23:02:07 -07:00
LibraryMenu.setTabs('metadata', 2, getTabs);
2015-06-07 18:23:56 -07:00
Dashboard.showLoadingMsg();
2015-06-07 18:23:56 -07:00
var page = this;
2015-06-07 18:23:56 -07:00
var promise1 = ApiClient.getUsers();
var promise2 = ApiClient.getNamedConfiguration(metadataKey);
2015-12-14 08:43:03 -07:00
Promise.all([promise1, promise2]).then(function (responses) {
2015-12-30 11:48:14 -07:00
loadPage(page, responses[1], responses[0]);
2015-06-07 18:23:56 -07:00
});
});
});