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

77 lines
1.8 KiB
JavaScript
Raw Normal View History

2014-04-26 21:35:04 -07:00
(function (window, $) {
function loadPage(page, config, languageOptions) {
$('#selectLocalizationLanguage', page).html(languageOptions.map(function (l) {
return '<option value="' + l.Value + '">' + l.Name + '</option>';
})).val(config.UICulture).selectmenu('refresh');
Dashboard.hideLoadingMsg();
}
function save(page) {
Dashboard.showLoadingMsg();
2014-11-02 20:38:43 -07:00
var apiClient = ApiClient;
apiClient.getServerConfiguration().done(function (config) {
2014-04-26 21:35:04 -07:00
config.UICulture = $('#selectLocalizationLanguage', page).val();
2014-11-02 20:38:43 -07:00
apiClient.updateServerConfiguration(config).done(function (result) {
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
2014-11-02 20:38:43 -07:00
$(document).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;
apiClient.getPublicUsers().done(function (u) {
2014-04-26 21:35:04 -07:00
2014-07-09 20:48:08 -07:00
var user = u.filter(function (i) {
return i.Configuration.IsAdministrator;
})[0];
2014-04-26 21:35:04 -07:00
2014-11-02 20:38:43 -07:00
apiClient.authenticateUserByName(user.Name, '').done(function (result) {
2014-04-26 21:35:04 -07:00
2014-07-09 20:48:08 -07:00
user = result.User;
2014-04-26 21:35:04 -07:00
2014-07-09 20:48:08 -07:00
Dashboard.setCurrentUser(user.Id, result.AccessToken);
2014-11-02 20:38:43 -07:00
var promise1 = apiClient.getServerConfiguration();
2014-07-09 20:48:08 -07:00
2014-11-02 20:38:43 -07:00
var promise2 = apiClient.getJSON(apiClient.getUrl("Localization/Options"));
2014-07-09 20:48:08 -07:00
$.when(promise1, promise2).done(function (response1, response2) {
2014-04-26 21:35:04 -07:00
2014-07-09 20:48:08 -07:00
loadPage(page, response1[0], response2[0]);
});
});
});
2014-04-26 21:35:04 -07:00
});
window.WizardStartPage = {
onSubmit: function () {
save($(this).parents('.page'));
return false;
}
};
})(window, jQuery);