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

97 lines
2.6 KiB
JavaScript
Raw Normal View History

2013-09-05 10:05:39 -07:00
(function ($, document) {
function save(page) {
Dashboard.showLoadingMsg();
2014-11-14 19:31:03 -07:00
var apiClient = ApiClient;
2014-02-26 20:57:37 -07:00
// After saving chapter task, now save server config
2014-11-14 19:31:03 -07:00
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).done(function (config) {
2013-09-05 10:05:39 -07:00
2014-02-26 20:57:37 -07:00
config.PreferredMetadataLanguage = $('#selectLanguage', page).val();
config.MetadataCountryCode = $('#selectCountry', page).val();
config.SaveLocalMeta = $('#chkSaveLocalMetadata', page).checked();
2014-03-05 22:17:13 -07:00
config.EnableInternetProviders = $('#chkEnableInternetProviders', page).checked();
2014-11-14 19:31:03 -07:00
apiClient.ajax({
type: 'POST',
data: config,
url: apiClient.getUrl('Startup/Configuration')
}).done(function () {
2013-09-05 10:05:39 -07:00
2014-02-26 20:57:37 -07:00
navigateToNextPage();
2013-09-05 10:05:39 -07:00
2013-12-22 20:46:03 -07:00
});
});
}
2013-09-05 10:05:39 -07:00
2013-12-22 20:46:03 -07:00
function reloadData(page, config, cultures, countries) {
2013-12-28 09:58:13 -07:00
Dashboard.populateLanguages($('#selectLanguage', page), cultures);
Dashboard.populateCountries($('#selectCountry', page), countries);
2013-12-22 20:46:03 -07:00
$('#selectLanguage', page).val(config.PreferredMetadataLanguage).selectmenu("refresh");
$('#selectCountry', page).val(config.MetadataCountryCode).selectmenu("refresh");
2013-12-22 20:46:03 -07:00
Dashboard.hideLoadingMsg();
}
function reload(page) {
Dashboard.showLoadingMsg();
2014-11-14 19:31:03 -07:00
var apiClient = ApiClient;
var promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
var promise2 = apiClient.getCultures();
var promise3 = apiClient.getCountries();
2013-12-22 20:46:03 -07:00
$.when(promise1, promise2, promise3).done(function (response1, response2, response3) {
reloadData(page, response1[0], response2[0], response3[0]);
});
}
2013-12-22 20:46:03 -07:00
function navigateToNextPage() {
2013-09-05 10:05:39 -07:00
2014-11-14 19:31:03 -07:00
var apiClient = ApiClient;
apiClient.getJSON(apiClient.getUrl('Startup/Info')).done(function (info) {
2014-09-08 18:15:31 -07:00
if (info.SupportsRunningAsService) {
Dashboard.navigate('wizardservice.html');
} else {
2015-01-05 20:25:23 -07:00
Dashboard.navigate('wizardagreement.html');
2014-09-08 18:15:31 -07:00
}
});
2013-12-22 20:46:03 -07:00
}
2013-09-05 10:05:39 -07:00
2015-05-18 18:46:31 -07:00
function onSubmit() {
var form = this;
2013-09-05 10:05:39 -07:00
2015-05-18 18:46:31 -07:00
save(form);
2013-09-05 10:05:39 -07:00
2015-05-18 18:46:31 -07:00
return false;
}
2013-12-22 20:46:03 -07:00
2015-05-18 18:46:31 -07:00
$(document).on('pageinitdepends', "#wizardSettingsPage", function () {
2013-12-22 20:46:03 -07:00
2015-05-23 13:44:15 -07:00
var page = this;
2015-05-18 18:46:31 -07:00
$('.wizardSettingsForm', page).off('submit', onSubmit).on('submit', onSubmit);
2013-12-22 20:46:03 -07:00
2015-05-19 12:15:40 -07:00
}).on('pageshowready', "#wizardSettingsPage", function () {
2013-12-22 20:46:03 -07:00
2015-05-18 18:46:31 -07:00
var page = this;
2013-12-22 20:46:03 -07:00
2015-05-18 18:46:31 -07:00
reload(page);
});
2013-12-22 20:46:03 -07:00
2013-09-05 10:05:39 -07:00
})(jQuery, document, window);