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/dashboard/logs.js",
|
||||||
"src/controllers/user/subtitles.js",
|
"src/controllers/user/subtitles.js",
|
||||||
"src/controllers/dashboard/plugins/repositories.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-tabs/emby-tabs.js",
|
||||||
"src/elements/emby-scroller/emby-scroller.js",
|
"src/elements/emby-scroller/emby-scroller.js",
|
||||||
"src/elements/emby-radio/emby-radio.js",
|
"src/elements/emby-radio/emby-radio.js",
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
define(['loading'], function (loading) {
|
import loading from 'loading';
|
||||||
'use strict';
|
|
||||||
|
|
||||||
function onFinish() {
|
function onFinish() {
|
||||||
loading.show();
|
loading.show();
|
||||||
ApiClient.ajax({
|
ApiClient.ajax({
|
||||||
url: ApiClient.getUrl('Startup/Complete'),
|
url: ApiClient.getUrl('Startup/Complete'),
|
||||||
type: 'POST'
|
type: 'POST'
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
window.location.href = 'index.html';
|
window.location.href = 'index.html';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return function (view, params) {
|
export default function (view, params) {
|
||||||
view.querySelector('.btnWizardNext').addEventListener('click', onFinish);
|
view.querySelector('.btnWizardNext').addEventListener('click', onFinish);
|
||||||
};
|
}
|
||||||
});
|
|
||||||
|
|
|
@ -1,39 +1,40 @@
|
||||||
define(['loading', 'emby-checkbox', 'emby-button', 'emby-select'], function (loading) {
|
import loading from 'loading';
|
||||||
'use strict';
|
import 'emby-checkbox';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'emby-select';
|
||||||
|
|
||||||
function save(page) {
|
function save(page) {
|
||||||
loading.show();
|
loading.show();
|
||||||
var apiClient = ApiClient;
|
const apiClient = ApiClient;
|
||||||
var config = {};
|
const config = {};
|
||||||
config.EnableRemoteAccess = page.querySelector('#chkRemoteAccess').checked;
|
config.EnableRemoteAccess = page.querySelector('#chkRemoteAccess').checked;
|
||||||
config.EnableAutomaticPortMapping = page.querySelector('#chkEnableUpnp').checked;
|
config.EnableAutomaticPortMapping = page.querySelector('#chkEnableUpnp').checked;
|
||||||
apiClient.ajax({
|
apiClient.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: config,
|
data: config,
|
||||||
url: apiClient.getUrl('Startup/RemoteAccess')
|
url: apiClient.getUrl('Startup/RemoteAccess')
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
navigateToNextPage();
|
navigateToNextPage();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function navigateToNextPage() {
|
function navigateToNextPage() {
|
||||||
Dashboard.navigate('wizardfinish.html');
|
Dashboard.navigate('wizardfinish.html');
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSubmit(e) {
|
function onSubmit(e) {
|
||||||
save(this);
|
save(this);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return function (view, params) {
|
export default function (view, params) {
|
||||||
view.querySelector('.wizardSettingsForm').addEventListener('submit', onSubmit);
|
view.querySelector('.wizardSettingsForm').addEventListener('submit', onSubmit);
|
||||||
view.addEventListener('viewshow', function () {
|
view.addEventListener('viewshow', function () {
|
||||||
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
||||||
});
|
});
|
||||||
view.addEventListener('viewhide', function () {
|
view.addEventListener('viewhide', function () {
|
||||||
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
});
|
|
||||||
|
|
|
@ -1,84 +1,85 @@
|
||||||
define(['loading', 'emby-checkbox', 'emby-button', 'emby-select'], function (loading) {
|
import loading from 'loading';
|
||||||
'use strict';
|
import 'emby-checkbox';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'emby-select';
|
||||||
|
|
||||||
function save(page) {
|
function save(page) {
|
||||||
loading.show();
|
loading.show();
|
||||||
var apiClient = ApiClient;
|
const apiClient = ApiClient;
|
||||||
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
|
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
|
||||||
config.PreferredMetadataLanguage = page.querySelector('#selectLanguage').value;
|
config.PreferredMetadataLanguage = page.querySelector('#selectLanguage').value;
|
||||||
config.MetadataCountryCode = page.querySelector('#selectCountry').value;
|
config.MetadataCountryCode = page.querySelector('#selectCountry').value;
|
||||||
apiClient.ajax({
|
apiClient.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: config,
|
data: config,
|
||||||
url: apiClient.getUrl('Startup/Configuration')
|
url: apiClient.getUrl('Startup/Configuration')
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
navigateToNextPage();
|
navigateToNextPage();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function populateLanguages(select, languages) {
|
||||||
|
let html = '';
|
||||||
|
html += "<option value=''></option>";
|
||||||
|
|
||||||
|
for (let i = 0, length = languages.length; i < length; i++) {
|
||||||
|
const culture = languages[i];
|
||||||
|
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + '</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateLanguages(select, languages) {
|
select.innerHTML = html;
|
||||||
var html = '';
|
}
|
||||||
html += "<option value=''></option>";
|
|
||||||
|
|
||||||
for (var i = 0, length = languages.length; i < length; i++) {
|
function populateCountries(select, allCountries) {
|
||||||
var culture = languages[i];
|
let html = '';
|
||||||
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + '</option>';
|
html += "<option value=''></option>";
|
||||||
}
|
|
||||||
|
|
||||||
select.innerHTML = html;
|
for (let i = 0, length = allCountries.length; i < length; i++) {
|
||||||
|
const culture = allCountries[i];
|
||||||
|
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + '</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateCountries(select, allCountries) {
|
select.innerHTML = html;
|
||||||
var html = '';
|
}
|
||||||
html += "<option value=''></option>";
|
|
||||||
|
|
||||||
for (var i = 0, length = allCountries.length; i < length; i++) {
|
function reloadData(page, config, cultures, countries) {
|
||||||
var culture = allCountries[i];
|
populateLanguages(page.querySelector('#selectLanguage'), cultures);
|
||||||
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + '</option>';
|
populateCountries(page.querySelector('#selectCountry'), countries);
|
||||||
}
|
page.querySelector('#selectLanguage').value = config.PreferredMetadataLanguage;
|
||||||
|
page.querySelector('#selectCountry').value = config.MetadataCountryCode;
|
||||||
|
loading.hide();
|
||||||
|
}
|
||||||
|
|
||||||
select.innerHTML = html;
|
function reload(page) {
|
||||||
}
|
loading.show();
|
||||||
|
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 reloadData(page, config, cultures, countries) {
|
function navigateToNextPage() {
|
||||||
populateLanguages(page.querySelector('#selectLanguage'), cultures);
|
Dashboard.navigate('wizardremoteaccess.html');
|
||||||
populateCountries(page.querySelector('#selectCountry'), countries);
|
}
|
||||||
page.querySelector('#selectLanguage').value = config.PreferredMetadataLanguage;
|
|
||||||
page.querySelector('#selectCountry').value = config.MetadataCountryCode;
|
|
||||||
loading.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
function reload(page) {
|
function onSubmit(e) {
|
||||||
loading.show();
|
save(this);
|
||||||
var apiClient = ApiClient;
|
e.preventDefault();
|
||||||
var promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
|
return false;
|
||||||
var promise2 = apiClient.getCultures();
|
}
|
||||||
var promise3 = apiClient.getCountries();
|
|
||||||
Promise.all([promise1, promise2, promise3]).then(function (responses) {
|
|
||||||
reloadData(page, responses[0], responses[1], responses[2]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function navigateToNextPage() {
|
export default function (view, params) {
|
||||||
Dashboard.navigate('wizardremoteaccess.html');
|
view.querySelector('.wizardSettingsForm').addEventListener('submit', onSubmit);
|
||||||
}
|
view.addEventListener('viewshow', function () {
|
||||||
|
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
||||||
function onSubmit(e) {
|
reload(this);
|
||||||
save(this);
|
});
|
||||||
e.preventDefault();
|
view.addEventListener('viewhide', function () {
|
||||||
return false;
|
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
||||||
}
|
});
|
||||||
|
}
|
||||||
return function (view, params) {
|
|
||||||
view.querySelector('.wizardSettingsForm').addEventListener('submit', onSubmit);
|
|
||||||
view.addEventListener('viewshow', function () {
|
|
||||||
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
|
||||||
reload(this);
|
|
||||||
});
|
|
||||||
view.addEventListener('viewhide', function () {
|
|
||||||
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,48 +1,49 @@
|
||||||
define(['jQuery', 'loading', 'emby-button', 'emby-select'], function ($, loading) {
|
import $ from 'jQuery';
|
||||||
'use strict';
|
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) {
|
$('#selectLocalizationLanguage', page).html(languageOptions.map(function (l) {
|
||||||
return '<option value="' + l.Value + '">' + l.Name + '</option>';
|
return '<option value="' + l.Value + '">' + l.Name + '</option>';
|
||||||
})).val(config.UICulture);
|
})).val(config.UICulture);
|
||||||
loading.hide();
|
loading.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
function save(page) {
|
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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSubmit() {
|
||||||
|
save($(this).parents('.page'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function (view, params) {
|
||||||
|
$('.wizardStartForm', view).on('submit', onSubmit);
|
||||||
|
view.addEventListener('viewshow', function () {
|
||||||
|
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
||||||
loading.show();
|
loading.show();
|
||||||
var apiClient = ApiClient;
|
const page = this;
|
||||||
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
|
const apiClient = ApiClient;
|
||||||
config.UICulture = $('#selectLocalizationLanguage', page).val();
|
const promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
|
||||||
apiClient.ajax({
|
const promise2 = apiClient.getJSON(apiClient.getUrl('Localization/Options'));
|
||||||
type: 'POST',
|
Promise.all([promise1, promise2]).then(function (responses) {
|
||||||
data: config,
|
loadPage(page, responses[0], responses[1]);
|
||||||
url: apiClient.getUrl('Startup/Configuration')
|
|
||||||
}).then(function () {
|
|
||||||
Dashboard.navigate('wizarduser.html');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
view.addEventListener('viewhide', function () {
|
||||||
function onSubmit() {
|
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
||||||
save($(this).parents('.page'));
|
});
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 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'));
|
|
||||||
Promise.all([promise1, promise2]).then(function (responses) {
|
|
||||||
loadPage(page, responses[0], responses[1]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
view.addEventListener('viewhide', function () {
|
|
||||||
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,67 +1,69 @@
|
||||||
define(['loading', 'globalize', 'dashboardcss', 'emby-input', 'emby-button', 'emby-button'], function (loading, globalize) {
|
import loading from 'loading';
|
||||||
'use strict';
|
import globalize from 'globalize';
|
||||||
|
import 'dashboardcss';
|
||||||
|
import 'emby-input';
|
||||||
|
import 'emby-button';
|
||||||
|
|
||||||
function getApiClient() {
|
function getApiClient() {
|
||||||
return ApiClient;
|
return ApiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextWizardPage() {
|
||||||
|
Dashboard.navigate('wizardlibrary.html');
|
||||||
|
}
|
||||||
|
|
||||||
|
function onUpdateUserComplete(result) {
|
||||||
|
console.debug('user update complete: ' + result);
|
||||||
|
loading.hide();
|
||||||
|
nextWizardPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
function submit(form) {
|
||||||
|
loading.show();
|
||||||
|
const apiClient = getApiClient();
|
||||||
|
apiClient.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
Name: form.querySelector('#txtUsername').value,
|
||||||
|
Password: form.querySelector('#txtManualPassword').value
|
||||||
|
},
|
||||||
|
url: apiClient.getUrl('Startup/User')
|
||||||
|
}).then(onUpdateUserComplete);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSubmit(e) {
|
||||||
|
const form = this;
|
||||||
|
|
||||||
|
if (form.querySelector('#txtManualPassword').value != form.querySelector('#txtPasswordConfirm').value) {
|
||||||
|
require(['toast'], function (toast) {
|
||||||
|
toast(globalize.translate('PasswordMatchError'));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
submit(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextWizardPage() {
|
e.preventDefault();
|
||||||
Dashboard.navigate('wizardlibrary.html');
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onUpdateUserComplete(result) {
|
function onViewShow() {
|
||||||
console.debug('user update complete: ' + result);
|
loading.show();
|
||||||
|
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();
|
loading.hide();
|
||||||
nextWizardPage();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function submit(form) {
|
export default function (view, params) {
|
||||||
loading.show();
|
view.querySelector('.wizardUserForm').addEventListener('submit', onSubmit);
|
||||||
var apiClient = getApiClient();
|
view.addEventListener('viewshow', function () {
|
||||||
apiClient.ajax({
|
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
||||||
type: 'POST',
|
});
|
||||||
data: {
|
view.addEventListener('viewhide', function () {
|
||||||
Name: form.querySelector('#txtUsername').value,
|
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
||||||
Password: form.querySelector('#txtManualPassword').value
|
});
|
||||||
},
|
view.addEventListener('viewshow', onViewShow);
|
||||||
url: apiClient.getUrl('Startup/User')
|
}
|
||||||
}).then(onUpdateUserComplete);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSubmit(e) {
|
|
||||||
var form = this;
|
|
||||||
|
|
||||||
if (form.querySelector('#txtManualPassword').value != form.querySelector('#txtPasswordConfirm').value) {
|
|
||||||
require(['toast'], function (toast) {
|
|
||||||
toast(globalize.translate('PasswordMatchError'));
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
submit(form);
|
|
||||||
}
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onViewShow() {
|
|
||||||
loading.show();
|
|
||||||
var page = this;
|
|
||||||
var 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) {
|
|
||||||
view.querySelector('.wizardUserForm').addEventListener('submit', onSubmit);
|
|
||||||
view.addEventListener('viewshow', function () {
|
|
||||||
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
|
||||||
});
|
|
||||||
view.addEventListener('viewhide', function () {
|
|
||||||
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
|
||||||
});
|
|
||||||
view.addEventListener('viewshow', onViewShow);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue