mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Migration of wizard to ES6 modules
This commit is contained in:
parent
a9246f8f39
commit
c11977c9fe
6 changed files with 235 additions and 227 deletions
|
@ -141,6 +141,11 @@
|
|||
"src/controllers/dashboard/logs.js",
|
||||
"src/controllers/user/subtitles.js",
|
||||
"src/controllers/dashboard/plugins/repositories.js",
|
||||
"src/controllers/wizard/finish.js",
|
||||
"src/controllers/wizard/remoteaccess.js",
|
||||
"src/controllers/wizard/settings.js",
|
||||
"src/controllers/wizard/start.js",
|
||||
"src/controllers/wizard/user.js",
|
||||
"src/elements/emby-tabs/emby-tabs.js",
|
||||
"src/elements/emby-scroller/emby-scroller.js",
|
||||
"src/elements/emby-radio/emby-radio.js",
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
define(['loading'], function (loading) {
|
||||
'use strict';
|
||||
import loading from 'loading';
|
||||
|
||||
function onFinish() {
|
||||
function onFinish() {
|
||||
loading.show();
|
||||
ApiClient.ajax({
|
||||
url: ApiClient.getUrl('Startup/Complete'),
|
||||
|
@ -10,9 +9,8 @@ define(['loading'], function (loading) {
|
|||
loading.hide();
|
||||
window.location.href = 'index.html';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return function (view, params) {
|
||||
export default function (view, params) {
|
||||
view.querySelector('.btnWizardNext').addEventListener('click', onFinish);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
define(['loading', 'emby-checkbox', 'emby-button', 'emby-select'], function (loading) {
|
||||
'use strict';
|
||||
import loading from 'loading';
|
||||
import 'emby-checkbox';
|
||||
import 'emby-button';
|
||||
import 'emby-select';
|
||||
|
||||
function save(page) {
|
||||
function save(page) {
|
||||
loading.show();
|
||||
var apiClient = ApiClient;
|
||||
var config = {};
|
||||
const apiClient = ApiClient;
|
||||
const config = {};
|
||||
config.EnableRemoteAccess = page.querySelector('#chkRemoteAccess').checked;
|
||||
config.EnableAutomaticPortMapping = page.querySelector('#chkEnableUpnp').checked;
|
||||
apiClient.ajax({
|
||||
|
@ -15,19 +17,19 @@ define(['loading', 'emby-checkbox', 'emby-button', 'emby-select'], function (loa
|
|||
loading.hide();
|
||||
navigateToNextPage();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function navigateToNextPage() {
|
||||
function navigateToNextPage() {
|
||||
Dashboard.navigate('wizardfinish.html');
|
||||
}
|
||||
}
|
||||
|
||||
function onSubmit(e) {
|
||||
function onSubmit(e) {
|
||||
save(this);
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return function (view, params) {
|
||||
export default function (view, params) {
|
||||
view.querySelector('.wizardSettingsForm').addEventListener('submit', onSubmit);
|
||||
view.addEventListener('viewshow', function () {
|
||||
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
||||
|
@ -35,5 +37,4 @@ define(['loading', 'emby-checkbox', 'emby-button', 'emby-select'], function (loa
|
|||
view.addEventListener('viewhide', function () {
|
||||
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
define(['loading', 'emby-checkbox', 'emby-button', 'emby-select'], function (loading) {
|
||||
'use strict';
|
||||
import loading from 'loading';
|
||||
import 'emby-checkbox';
|
||||
import 'emby-button';
|
||||
import 'emby-select';
|
||||
|
||||
function save(page) {
|
||||
function save(page) {
|
||||
loading.show();
|
||||
var apiClient = ApiClient;
|
||||
const apiClient = ApiClient;
|
||||
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
|
||||
config.PreferredMetadataLanguage = page.querySelector('#selectLanguage').value;
|
||||
config.MetadataCountryCode = page.querySelector('#selectCountry').value;
|
||||
|
@ -16,62 +18,62 @@ define(['loading', 'emby-checkbox', 'emby-button', 'emby-select'], function (loa
|
|||
navigateToNextPage();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function populateLanguages(select, languages) {
|
||||
var html = '';
|
||||
function populateLanguages(select, languages) {
|
||||
let html = '';
|
||||
html += "<option value=''></option>";
|
||||
|
||||
for (var i = 0, length = languages.length; i < length; i++) {
|
||||
var culture = languages[i];
|
||||
for (let i = 0, length = languages.length; i < length; i++) {
|
||||
const culture = languages[i];
|
||||
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + '</option>';
|
||||
}
|
||||
|
||||
select.innerHTML = html;
|
||||
}
|
||||
}
|
||||
|
||||
function populateCountries(select, allCountries) {
|
||||
var html = '';
|
||||
function populateCountries(select, allCountries) {
|
||||
let html = '';
|
||||
html += "<option value=''></option>";
|
||||
|
||||
for (var i = 0, length = allCountries.length; i < length; i++) {
|
||||
var culture = allCountries[i];
|
||||
for (let i = 0, length = allCountries.length; i < length; i++) {
|
||||
const culture = allCountries[i];
|
||||
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + '</option>';
|
||||
}
|
||||
|
||||
select.innerHTML = html;
|
||||
}
|
||||
}
|
||||
|
||||
function reloadData(page, config, cultures, countries) {
|
||||
function reloadData(page, config, cultures, countries) {
|
||||
populateLanguages(page.querySelector('#selectLanguage'), cultures);
|
||||
populateCountries(page.querySelector('#selectCountry'), countries);
|
||||
page.querySelector('#selectLanguage').value = config.PreferredMetadataLanguage;
|
||||
page.querySelector('#selectCountry').value = config.MetadataCountryCode;
|
||||
loading.hide();
|
||||
}
|
||||
}
|
||||
|
||||
function reload(page) {
|
||||
function reload(page) {
|
||||
loading.show();
|
||||
var apiClient = ApiClient;
|
||||
var promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
|
||||
var promise2 = apiClient.getCultures();
|
||||
var promise3 = apiClient.getCountries();
|
||||
const apiClient = ApiClient;
|
||||
const promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
|
||||
const promise2 = apiClient.getCultures();
|
||||
const promise3 = apiClient.getCountries();
|
||||
Promise.all([promise1, promise2, promise3]).then(function (responses) {
|
||||
reloadData(page, responses[0], responses[1], responses[2]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function navigateToNextPage() {
|
||||
function navigateToNextPage() {
|
||||
Dashboard.navigate('wizardremoteaccess.html');
|
||||
}
|
||||
}
|
||||
|
||||
function onSubmit(e) {
|
||||
function onSubmit(e) {
|
||||
save(this);
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return function (view, params) {
|
||||
export default function (view, params) {
|
||||
view.querySelector('.wizardSettingsForm').addEventListener('submit', onSubmit);
|
||||
view.addEventListener('viewshow', function () {
|
||||
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
||||
|
@ -80,5 +82,4 @@ define(['loading', 'emby-checkbox', 'emby-button', 'emby-select'], function (loa
|
|||
view.addEventListener('viewhide', function () {
|
||||
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
define(['jQuery', 'loading', 'emby-button', 'emby-select'], function ($, loading) {
|
||||
'use strict';
|
||||
import $ from 'jQuery';
|
||||
import loading from 'loading';
|
||||
import 'emby-button';
|
||||
import 'emby-select';
|
||||
|
||||
function loadPage(page, config, languageOptions) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
function save(page) {
|
||||
function save(page) {
|
||||
loading.show();
|
||||
var apiClient = ApiClient;
|
||||
const apiClient = ApiClient;
|
||||
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
|
||||
config.UICulture = $('#selectLocalizationLanguage', page).val();
|
||||
apiClient.ajax({
|
||||
|
@ -21,22 +23,22 @@ define(['jQuery', 'loading', 'emby-button', 'emby-select'], function ($, loading
|
|||
Dashboard.navigate('wizarduser.html');
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onSubmit() {
|
||||
function onSubmit() {
|
||||
save($(this).parents('.page'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return function (view, params) {
|
||||
export default function (view, params) {
|
||||
$('.wizardStartForm', view).on('submit', onSubmit);
|
||||
view.addEventListener('viewshow', function () {
|
||||
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
||||
loading.show();
|
||||
var page = this;
|
||||
var apiClient = ApiClient;
|
||||
var promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
|
||||
var promise2 = apiClient.getJSON(apiClient.getUrl('Localization/Options'));
|
||||
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]);
|
||||
});
|
||||
|
@ -44,5 +46,4 @@ define(['jQuery', 'loading', 'emby-button', 'emby-select'], function ($, loading
|
|||
view.addEventListener('viewhide', function () {
|
||||
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,23 +1,26 @@
|
|||
define(['loading', 'globalize', 'dashboardcss', 'emby-input', 'emby-button', 'emby-button'], function (loading, globalize) {
|
||||
'use strict';
|
||||
import loading from 'loading';
|
||||
import globalize from 'globalize';
|
||||
import 'dashboardcss';
|
||||
import 'emby-input';
|
||||
import 'emby-button';
|
||||
|
||||
function getApiClient() {
|
||||
function getApiClient() {
|
||||
return ApiClient;
|
||||
}
|
||||
}
|
||||
|
||||
function nextWizardPage() {
|
||||
function nextWizardPage() {
|
||||
Dashboard.navigate('wizardlibrary.html');
|
||||
}
|
||||
}
|
||||
|
||||
function onUpdateUserComplete(result) {
|
||||
function onUpdateUserComplete(result) {
|
||||
console.debug('user update complete: ' + result);
|
||||
loading.hide();
|
||||
nextWizardPage();
|
||||
}
|
||||
}
|
||||
|
||||
function submit(form) {
|
||||
function submit(form) {
|
||||
loading.show();
|
||||
var apiClient = getApiClient();
|
||||
const apiClient = getApiClient();
|
||||
apiClient.ajax({
|
||||
type: 'POST',
|
||||
data: {
|
||||
|
@ -26,10 +29,10 @@ define(['loading', 'globalize', 'dashboardcss', 'emby-input', 'emby-button', 'em
|
|||
},
|
||||
url: apiClient.getUrl('Startup/User')
|
||||
}).then(onUpdateUserComplete);
|
||||
}
|
||||
}
|
||||
|
||||
function onSubmit(e) {
|
||||
var form = this;
|
||||
function onSubmit(e) {
|
||||
const form = this;
|
||||
|
||||
if (form.querySelector('#txtManualPassword').value != form.querySelector('#txtPasswordConfirm').value) {
|
||||
require(['toast'], function (toast) {
|
||||
|
@ -41,20 +44,20 @@ define(['loading', 'globalize', 'dashboardcss', 'emby-input', 'emby-button', 'em
|
|||
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function onViewShow() {
|
||||
function onViewShow() {
|
||||
loading.show();
|
||||
var page = this;
|
||||
var apiClient = getApiClient();
|
||||
const page = this;
|
||||
const apiClient = getApiClient();
|
||||
apiClient.getJSON(apiClient.getUrl('Startup/User')).then(function (user) {
|
||||
page.querySelector('#txtUsername').value = user.Name || '';
|
||||
page.querySelector('#txtManualPassword').value = user.Password || '';
|
||||
loading.hide();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return function (view, params) {
|
||||
export default function (view, params) {
|
||||
view.querySelector('.wizardUserForm').addEventListener('submit', onSubmit);
|
||||
view.addEventListener('viewshow', function () {
|
||||
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
||||
|
@ -63,5 +66,4 @@ define(['loading', 'globalize', 'dashboardcss', 'emby-input', 'emby-button', 'em
|
|||
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
||||
});
|
||||
view.addEventListener('viewshow', onViewShow);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue