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

80 lines
3.1 KiB
JavaScript
Raw Normal View History

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>';
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;
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;
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;
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'));
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/>')
});
});
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')
}];
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);
loading.show();
2020-07-16 11:25:17 +01:00
const page = this;
const promise1 = ApiClient.getUsers();
const promise2 = ApiClient.getNamedConfiguration(metadataKey);
Promise.all([promise1, promise2]).then(function (responses) {
loadPage(page, responses[1], responses[0]);
});
});
/* eslint-enable indent */