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

77 lines
2.9 KiB
JavaScript
Raw Normal View History

2022-01-30 00:27:26 +03:00
import escapeHtml from 'escape-html';
2020-08-14 08:46:34 +02:00
import 'jquery';
import loading from '../../components/loading/loading';
import libraryMenu from '../../scripts/libraryMenu';
import globalize from '../../scripts/globalize';
2022-04-10 02:22:13 -04:00
import Dashboard from '../../utils/dashboard';
import alert from '../../components/alert';
2023-04-19 01:56:05 -04:00
function loadPage(page, config, users) {
let html = '<option value="" selected="selected">' + globalize.translate('None') + '</option>';
html += users.map(function (user) {
return '<option value="' + user.Id + '">' + escapeHtml(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
2023-04-19 01:56:05 -04:00
function onSubmit() {
loading.show();
const form = this;
ApiClient.getNamedConfiguration(metadataKey).then(function (config) {
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();
});
2023-04-19 01:56:05 -04:00
});
return false;
}
2018-10-23 01:05:09 +03:00
2023-04-19 01:56:05 -04:00
function showConfirmMessage() {
const msg = [];
msg.push(globalize.translate('MetadataSettingChangeHelp'));
alert({
text: msg.join('<br/><br/>')
});
}
2018-10-23 01:05:09 +03:00
2023-04-19 01:56:05 -04:00
function getTabs() {
return [{
2023-09-25 00:00:36 -04:00
href: '#/dashboard/libraries',
2023-04-19 01:56:05 -04:00
name: globalize.translate('HeaderLibraries')
}, {
2023-09-25 00:00:36 -04:00
href: '#/dashboard/libraries/display',
2023-04-19 01:56:05 -04:00
name: globalize.translate('Display')
}, {
2023-09-25 00:00:36 -04:00
href: '#/dashboard/libraries/metadata',
2023-04-19 01:56:05 -04:00
name: globalize.translate('Metadata')
}, {
2023-09-25 00:00:36 -04:00
href: '#/dashboard/libraries/nfo',
2023-04-19 01:56:05 -04:00
name: globalize.translate('TabNfoSettings')
}];
}
2019-06-10 14:44:52 -07:00
2023-04-19 01:56:05 -04:00
const metadataKey = 'xbmcmetadata';
$(document).on('pageinit', '#metadataNfoPage', function () {
$('.metadataNfoForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshow', '#metadataNfoPage', function () {
libraryMenu.setTabs('metadata', 3, getTabs);
loading.show();
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]);
});
2023-04-19 01:56:05 -04:00
});