1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/scripts/metadatanfo.js

64 lines
2.1 KiB
JavaScript
Raw Normal View History

define(['jQuery'], function ($) {
var metadataKey = "xbmcmetadata";
2015-06-07 21:23:56 -04: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 13:01:51 -04:00
$('#selectUser', page).html(html).val(config.UserId || '');
$('#selectReleaseDateFormat', page).val(config.ReleaseDateFormat);
2016-02-11 23:33:14 -05:00
page.querySelector('#chkSaveImagePaths').checked = config.SaveImagePathsInNfo;
page.querySelector('#chkEnablePathSubstitution').checked = config.EnablePathSubstitution;
page.querySelector('#chkEnableExtraThumbs').checked = config.EnableExtraThumbsDuplication;
Dashboard.hideLoadingMsg();
}
2015-06-07 21:23:56 -04:00
function onSubmit() {
Dashboard.showLoadingMsg();
2015-06-07 21:23:56 -04:00
var form = this;
2015-12-14 10:43:03 -05:00
ApiClient.getNamedConfiguration(metadataKey).then(function (config) {
2015-06-07 21:23:56 -04:00
config.UserId = $('#selectUser', form).val() || null;
config.ReleaseDateFormat = $('#selectReleaseDateFormat', form).val();
2016-02-11 23:33:14 -05:00
config.SaveImagePathsInNfo = form.querySelector('#chkSaveImagePaths').checked;
config.EnablePathSubstitution = form.querySelector('#chkEnablePathSubstitution').checked;
config.EnableExtraThumbsDuplication = form.querySelector('#chkEnableExtraThumbs').checked;
2015-12-14 10:43:03 -05:00
ApiClient.updateNamedConfiguration(metadataKey, config).then(Dashboard.processServerConfigurationUpdateResult);
});
2015-06-07 21:23:56 -04:00
// Disable default form submission
return false;
}
2015-09-01 10:01:59 -04:00
$(document).on('pageinit', "#metadataNfoPage", function () {
2015-06-07 21:23:56 -04:00
$('.metadataNfoForm').off('submit', onSubmit).on('submit', onSubmit);
2015-09-24 13:08:10 -04:00
}).on('pageshow', "#metadataNfoPage", function () {
2015-06-07 21:23:56 -04:00
Dashboard.showLoadingMsg();
2015-06-07 21:23:56 -04:00
var page = this;
2015-06-07 21:23:56 -04:00
var promise1 = ApiClient.getUsers();
var promise2 = ApiClient.getNamedConfiguration(metadataKey);
2015-12-14 10:43:03 -05:00
Promise.all([promise1, promise2]).then(function (responses) {
2015-12-30 13:48:14 -05:00
loadPage(page, responses[1], responses[0]);
2015-06-07 21:23:56 -04:00
});
});
});