jellyfin-web/dashboard-ui/scripts/metadataconfigurationpage.js

144 lines
3.8 KiB
JavaScript
Raw Normal View History

2016-08-25 10:06:30 -07:00
define(['jQuery', 'fnchecked'], function ($) {
2013-02-20 18:33:05 -07:00
2015-06-08 14:32:20 -07:00
function load(page, config, allCultures, allCountries) {
2013-02-20 18:33:05 -07:00
if (!config || !allCultures || !allCountries) {
return;
}
2015-09-03 10:01:51 -07:00
$('#selectLanguage', page).val(config.PreferredMetadataLanguage);
$('#selectCountry', page).val(config.MetadataCountryCode);
2013-02-20 18:33:05 -07:00
Dashboard.hideLoadingMsg();
2015-06-08 14:32:20 -07:00
}
function onSubmit() {
2013-02-20 18:33:05 -07:00
var form = this;
2013-04-16 21:58:32 -07:00
Dashboard.showLoadingMsg();
2015-12-14 08:43:03 -07:00
ApiClient.getServerConfiguration().then(function (config) {
2013-02-20 18:33:05 -07:00
config.PreferredMetadataLanguage = $('#selectLanguage', form).val();
config.MetadataCountryCode = $('#selectCountry', form).val();
ApiClient.updateServerConfiguration(config).then(function() {
Dashboard.processServerConfigurationUpdateResult();
showConfirmMessage(config);
});
2013-02-20 18:33:05 -07:00
});
// Disable default form submission
return false;
}
function showConfirmMessage(config) {
var msg = [];
msg.push(Globalize.translate('MetadataSettingChangeHelp'));
if (config.DownloadImagesInAdvance) {
msg.push(Globalize.translate('DownloadImagesInAdvanceWarning'));
}
if (!msg.length) {
return;
}
require(['alert'], function (alert) {
alert({
text: msg.join('<br/><br/>')
});
});
}
2016-04-12 23:02:07 -07:00
function getTabs() {
return [
{
href: 'metadata.html',
name: Globalize.translate('TabSettings')
},
{
href: 'metadataimages.html',
name: Globalize.translate('TabServices')
},
{
href: 'metadatanfo.html',
name: Globalize.translate('TabNfoSettings')
}];
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#metadataConfigurationPage", function () {
2015-06-08 14:32:20 -07:00
Dashboard.showLoadingMsg();
$('.metadataConfigurationForm').off('submit', onSubmit).on('submit', onSubmit);
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#metadataConfigurationPage", function () {
2015-06-08 14:32:20 -07:00
2016-04-12 23:02:07 -07:00
LibraryMenu.setTabs('metadata', 0, getTabs);
2015-06-08 14:32:20 -07:00
Dashboard.showLoadingMsg();
var page = this;
var config;
var allCultures;
var allCountries;
2015-12-14 08:43:03 -07:00
ApiClient.getServerConfiguration().then(function (result) {
2015-06-08 14:32:20 -07:00
config = result;
load(page, config, allCultures, allCountries);
});
2015-12-14 08:43:03 -07:00
function populateLanguages(select, languages) {
2015-06-08 14:32:20 -07:00
2015-12-14 08:43:03 -07:00
var html = "";
html += "<option value=''></option>";
for (var i = 0, length = languages.length; i < length; i++) {
var culture = languages[i];
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + "</option>";
}
select.innerHTML = html;
}
function populateCountries(select, allCountries) {
var html = "";
html += "<option value=''></option>";
for (var i = 0, length = allCountries.length; i < length; i++) {
var culture = allCountries[i];
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + "</option>";
}
select.innerHTML = html;
}
ApiClient.getCultures().then(function (result) {
populateLanguages(page.querySelector('#selectLanguage'), result);
2015-06-08 14:32:20 -07:00
allCultures = result;
load(page, config, allCultures, allCountries);
});
2015-12-14 08:43:03 -07:00
ApiClient.getCountries().then(function (result) {
2015-06-08 14:32:20 -07:00
2015-12-14 08:43:03 -07:00
populateCountries(page.querySelector('#selectCountry'), result);
2015-06-08 14:32:20 -07:00
allCountries = result;
load(page, config, allCultures, allCountries);
});
});
});