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/metadataImages.js

78 lines
3.1 KiB
JavaScript
Raw Normal View History

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';
import '../../components/listview/listview.css';
import Dashboard from '../../scripts/clientUtils';
/* eslint-disable indent */
2018-10-23 01:05:09 +03:00
function populateLanguages(select) {
return ApiClient.getCultures().then(function(languages) {
2020-07-16 11:25:17 +01:00
let html = '';
2018-10-23 01:05:09 +03:00
html += "<option value=''></option>";
2020-07-16 11:25:17 +01:00
for (let i = 0, length = languages.length; i < length; i++) {
const culture = languages[i];
2020-05-04 12:44:12 +02:00
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + '</option>';
2018-10-23 01:05:09 +03:00
}
select.innerHTML = html;
});
2018-10-23 01:05:09 +03:00
}
function populateCountries(select) {
return ApiClient.getCountries().then(function(allCountries) {
2020-07-16 11:25:17 +01:00
let html = '';
2018-10-23 01:05:09 +03:00
html += "<option value=''></option>";
2020-07-16 11:25:17 +01:00
for (let i = 0, length = allCountries.length; i < length; i++) {
const culture = allCountries[i];
2020-05-04 12:44:12 +02:00
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + '</option>';
2018-10-23 01:05:09 +03:00
}
select.innerHTML = html;
});
2018-10-23 01:05:09 +03:00
}
function loadPage(page) {
2020-07-16 11:25:17 +01:00
const promises = [ApiClient.getServerConfiguration(), populateLanguages(page.querySelector('#selectLanguage')), populateCountries(page.querySelector('#selectCountry'))];
2018-10-23 01:05:09 +03:00
Promise.all(promises).then(function(responses) {
2020-07-16 11:25:17 +01:00
const config = responses[0];
2020-05-14 23:25:22 +02:00
page.querySelector('#selectLanguage').value = config.PreferredMetadataLanguage || '';
page.querySelector('#selectCountry').value = config.MetadataCountryCode || '';
loading.hide();
});
2018-10-23 01:05:09 +03:00
}
function onSubmit() {
2020-07-16 11:25:17 +01:00
const form = this;
2018-10-23 01:05:09 +03:00
return loading.show(), ApiClient.getServerConfiguration().then(function(config) {
2020-05-14 23:25:22 +02:00
config.PreferredMetadataLanguage = form.querySelector('#selectLanguage').value;
config.MetadataCountryCode = form.querySelector('#selectCountry').value;
ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult);
}), !1;
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('Display')
2018-10-23 01:05:09 +03:00
}, {
2020-05-04 12:44:12 +02:00
href: 'metadataimages.html',
name: globalize.translate('Metadata')
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-05-04 12:44:12 +02:00
$(document).on('pageinit', '#metadataImagesConfigurationPage', function() {
$('.metadataImagesConfigurationForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshow', '#metadataImagesConfigurationPage', function() {
2020-05-14 23:25:22 +02:00
libraryMenu.setTabs('metadata', 2, getTabs);
loading.show();
loadPage(this);
});
/* eslint-enable indent */