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

78 lines
2.5 KiB
JavaScript
Raw Normal View History

2015-06-08 14:32:20 -07:00
(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;
}
2014-02-26 20:57:37 -07:00
$('#chkEnableInternetProviders', page).checked(config.EnableInternetProviders).checkboxradio("refresh");
2013-02-20 18:33:05 -07:00
$('#chkSaveLocal', page).checked(config.SaveLocalMeta).checkboxradio("refresh");
$('#selectLanguage', page).val(config.PreferredMetadataLanguage).selectmenu("refresh");
$('#selectCountry', page).val(config.MetadataCountryCode).selectmenu("refresh");
2014-02-02 06:36:31 -07:00
$('#selectImageSavingConvention', page).val(config.ImageSavingConvention).selectmenu("refresh");
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();
2013-02-20 18:33:05 -07:00
ApiClient.getServerConfiguration().done(function (config) {
2014-02-02 06:36:31 -07:00
config.ImageSavingConvention = $('#selectImageSavingConvention', form).val();
2014-02-26 20:57:37 -07:00
config.EnableInternetProviders = $('#chkEnableInternetProviders', form).checked();
2013-02-20 18:33:05 -07:00
config.SaveLocalMeta = $('#chkSaveLocal', form).checked();
config.PreferredMetadataLanguage = $('#selectLanguage', form).val();
config.MetadataCountryCode = $('#selectCountry', form).val();
2013-04-16 21:58:32 -07:00
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
2013-02-20 18:33:05 -07:00
});
// Disable default form submission
return false;
}
2015-06-08 14:32:20 -07:00
$(document).on('pageinitdepends', "#metadataConfigurationPage", function () {
Dashboard.showLoadingMsg();
$('.metadataConfigurationForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshowready', "#metadataConfigurationPage", function () {
Dashboard.showLoadingMsg();
var page = this;
var config;
var allCultures;
var allCountries;
ApiClient.getServerConfiguration().done(function (result) {
config = result;
load(page, config, allCultures, allCountries);
});
ApiClient.getCultures().done(function (result) {
Dashboard.populateLanguages($('#selectLanguage', page), result);
allCultures = result;
load(page, config, allCultures, allCountries);
});
ApiClient.getCountries().done(function (result) {
Dashboard.populateCountries($('#selectCountry', page), result);
allCountries = result;
load(page, config, allCultures, allCountries);
});
});
})();