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

64 lines
2.1 KiB
JavaScript
Raw Normal View History

(function ($, document, window) {
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;
2015-12-14 08:43:03 -07:00
ApiClient.updateNamedConfiguration(metadataKey, config).then(Dashboard.processServerConfigurationUpdateResult);
});
2015-06-07 18:23:56 -07:00
// Disable default form submission
return false;
}
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 () {
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
});
});
})(jQuery, document, window);