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

70 lines
1.6 KiB
JavaScript
Raw Normal View History

define(['jQuery'], function ($) {
2014-04-26 21:35:04 -07:00
function loadPage(page, config, languageOptions) {
$('#selectLocalizationLanguage', page).html(languageOptions.map(function (l) {
return '<option value="' + l.Value + '">' + l.Name + '</option>';
2015-09-03 10:01:51 -07:00
})).val(config.UICulture);
2014-04-26 21:35:04 -07:00
Dashboard.hideLoadingMsg();
}
function save(page) {
Dashboard.showLoadingMsg();
2014-11-02 20:38:43 -07:00
var apiClient = ApiClient;
2015-12-14 08:43:03 -07:00
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
2014-04-26 21:35:04 -07:00
config.UICulture = $('#selectLocalizationLanguage', page).val();
2014-11-14 19:31:03 -07:00
apiClient.ajax({
2015-06-07 20:16:42 -07:00
2014-11-14 19:31:03 -07:00
type: 'POST',
data: config,
url: apiClient.getUrl('Startup/Configuration')
2015-12-14 08:43:03 -07:00
}).then(function () {
2014-04-26 21:35:04 -07:00
Dashboard.navigate('wizarduser.html');
});
});
2013-02-20 18:33:05 -07:00
}
2014-04-26 21:35:04 -07:00
2015-06-07 20:16:42 -07:00
function onSubmit() {
save($(this).parents('.page'));
return false;
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#wizardStartPage", function () {
2015-06-07 20:16:42 -07:00
$('.wizardStartForm').off('submit', onSubmit).on('submit', onSubmit);
2016-03-16 22:04:32 -07:00
window.ConnectionManager.clearData();
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#wizardStartPage", function () {
2014-04-26 21:35:04 -07:00
Dashboard.showLoadingMsg();
var page = this;
2014-11-02 20:38:43 -07:00
var apiClient = ApiClient;
2014-11-14 19:31:03 -07:00
var promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
2014-07-09 20:48:08 -07:00
2014-11-14 19:31:03 -07:00
var promise2 = apiClient.getJSON(apiClient.getUrl("Localization/Options"));
2014-07-09 20:48:08 -07:00
2015-12-14 08:43:03 -07:00
Promise.all([promise1, promise2]).then(function (responses) {
2014-07-09 20:48:08 -07:00
2015-12-14 08:43:03 -07:00
loadPage(page, responses[0], responses[1]);
2014-07-09 20:48:08 -07:00
});
2014-04-26 21:35:04 -07:00
});
});