2020-07-17 19:04:56 +01:00
|
|
|
import $ from 'jQuery';
|
|
|
|
import loading from 'loading';
|
|
|
|
import 'emby-button';
|
|
|
|
import 'emby-select';
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2020-07-17 19:04:56 +01:00
|
|
|
function loadPage(page, config, languageOptions) {
|
|
|
|
$('#selectLocalizationLanguage', page).html(languageOptions.map(function (l) {
|
|
|
|
return '<option value="' + l.Value + '">' + l.Name + '</option>';
|
|
|
|
})).val(config.UICulture);
|
|
|
|
loading.hide();
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2020-07-17 19:04:56 +01:00
|
|
|
function save(page) {
|
|
|
|
loading.show();
|
|
|
|
const apiClient = ApiClient;
|
|
|
|
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
|
|
|
|
config.UICulture = $('#selectLocalizationLanguage', page).val();
|
|
|
|
apiClient.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
data: config,
|
|
|
|
url: apiClient.getUrl('Startup/Configuration')
|
|
|
|
}).then(function () {
|
|
|
|
Dashboard.navigate('wizarduser.html');
|
2019-10-08 01:28:58 +03:00
|
|
|
});
|
2020-07-17 19:04:56 +01:00
|
|
|
});
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2020-07-17 19:04:56 +01:00
|
|
|
function onSubmit() {
|
|
|
|
save($(this).parents('.page'));
|
|
|
|
return false;
|
|
|
|
}
|
2019-10-08 01:28:58 +03:00
|
|
|
|
2020-07-17 19:04:56 +01:00
|
|
|
export default function (view, params) {
|
|
|
|
$('.wizardStartForm', view).on('submit', onSubmit);
|
|
|
|
view.addEventListener('viewshow', function () {
|
|
|
|
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
|
|
|
loading.show();
|
|
|
|
const page = this;
|
|
|
|
const apiClient = ApiClient;
|
|
|
|
const promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
|
|
|
|
const promise2 = apiClient.getJSON(apiClient.getUrl('Localization/Options'));
|
|
|
|
Promise.all([promise1, promise2]).then(function (responses) {
|
|
|
|
loadPage(page, responses[0], responses[1]);
|
2019-10-08 01:28:58 +03:00
|
|
|
});
|
2020-07-17 19:04:56 +01:00
|
|
|
});
|
|
|
|
view.addEventListener('viewhide', function () {
|
|
|
|
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
|
|
|
});
|
|
|
|
}
|