2013-02-20 18:33:05 -07:00
|
|
|
|
var MetadataConfigurationPage = {
|
|
|
|
|
|
|
|
|
|
onPageShow: function () {
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
var config;
|
|
|
|
|
var allCultures;
|
|
|
|
|
var allCountries;
|
|
|
|
|
|
|
|
|
|
ApiClient.getServerConfiguration().done(function (result) {
|
|
|
|
|
|
|
|
|
|
config = result;
|
|
|
|
|
MetadataConfigurationPage.load(page, config, allCultures, allCountries);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ApiClient.getCultures().done(function (result) {
|
|
|
|
|
|
|
|
|
|
MetadataConfigurationPage.populateLanguages(result);
|
|
|
|
|
|
|
|
|
|
allCultures = result;
|
|
|
|
|
MetadataConfigurationPage.load(page, config, allCultures, allCountries);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ApiClient.getCountries().done(function (result) {
|
|
|
|
|
|
|
|
|
|
MetadataConfigurationPage.populateCountries(result);
|
|
|
|
|
|
|
|
|
|
allCountries = result;
|
|
|
|
|
MetadataConfigurationPage.load(page, config, allCultures, allCountries);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
load: function (page, config, allCultures, allCountries) {
|
|
|
|
|
|
|
|
|
|
if (!config || !allCultures || !allCountries) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#chkSaveLocal', page).checked(config.SaveLocalMeta).checkboxradio("refresh");
|
|
|
|
|
$('#txtRefreshDays', page).val(config.MetadataRefreshDays);
|
|
|
|
|
$('#selectLanguage', page).val(config.PreferredMetadataLanguage).selectmenu("refresh");
|
|
|
|
|
$('#selectCountry', page).val(config.MetadataCountryCode).selectmenu("refresh");
|
2013-07-25 13:59:28 -07:00
|
|
|
|
$('#chkEnableInternetProviders', page).checked(config.EnableInternetProviders).checkboxradio("refresh");
|
2013-10-13 16:56:56 -07:00
|
|
|
|
$('#chkEnableTmdbPersonUpdates', page).checked(config.EnableTmdbUpdates).checkboxradio("refresh");
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
populateCountries: function (allCountries) {
|
|
|
|
|
|
|
|
|
|
var html = "";
|
|
|
|
|
|
|
|
|
|
html += "<option value=''>None</option>";
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = allCountries.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var culture = allCountries[i];
|
|
|
|
|
|
|
|
|
|
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + "</option>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#selectCountry', '#metadataConfigurationPage').html(html).selectmenu("refresh");
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
populateLanguages: function (allCultures) {
|
|
|
|
|
|
|
|
|
|
var html = "";
|
|
|
|
|
|
|
|
|
|
html += "<option value=''>None</option>";
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = allCultures.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var culture = allCultures[i];
|
|
|
|
|
|
|
|
|
|
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + "</option>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#selectLanguage', '#metadataConfigurationPage').html(html).selectmenu("refresh");
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onSubmit: function () {
|
|
|
|
|
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) {
|
|
|
|
|
|
2013-10-13 16:56:56 -07:00
|
|
|
|
config.EnableTmdbUpdates = $('#chkEnableTmdbPersonUpdates', form).checked();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
config.EnableInternetProviders = $('#chkEnableInternetProviders', form).checked();
|
|
|
|
|
config.SaveLocalMeta = $('#chkSaveLocal', form).checked();
|
|
|
|
|
config.MetadataRefreshDays = $('#txtRefreshDays', form).val();
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$(document).on('pageshow', "#metadataConfigurationPage", MetadataConfigurationPage.onPageShow);
|