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';
|
2020-10-12 23:08:55 +01:00
|
|
|
import Dashboard from '../../scripts/clientUtils';
|
2020-07-09 08:54:12 +01:00
|
|
|
|
|
|
|
/* 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
|
|
|
}
|
2020-04-05 13:48:10 +02: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
|
|
|
}
|
2020-04-05 13:48:10 +02: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();
|
2020-04-05 13:48:10 +02:00
|
|
|
});
|
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);
|
2020-04-05 13:48:10 +02:00
|
|
|
}), !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',
|
2020-08-09 23:10:58 +09:00
|
|
|
name: globalize.translate('Display')
|
2018-10-23 01:05:09 +03:00
|
|
|
}, {
|
2020-05-04 12:44:12 +02:00
|
|
|
href: 'metadataimages.html',
|
2020-08-09 23:10:58 +09:00
|
|
|
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')
|
2020-04-05 13:48:10 +02:00
|
|
|
}];
|
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);
|
2020-04-05 13:48:10 +02:00
|
|
|
});
|
2020-07-09 08:54:12 +01:00
|
|
|
|
|
|
|
/* eslint-enable indent */
|