mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 19:08:18 -07:00
Merge pull request #1585 from Camc314/migrate-to-ES6-32
Migration of wizard/ to ES6 modules
This commit is contained in:
commit
79336d778c
@ -171,6 +171,11 @@
|
||||
"src/controllers/dashboard/networking.js",
|
||||
"src/controllers/dashboard/playback.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/controllers/shows/episodes.js",
|
||||
"src/controllers/shows/tvgenres.js",
|
||||
"src/controllers/shows/tvlatest.js",
|
||||
|
@ -1,18 +1,16 @@
|
||||
define(['loading'], function (loading) {
|
||||
'use strict';
|
||||
import loading from 'loading';
|
||||
|
||||
function onFinish() {
|
||||
loading.show();
|
||||
ApiClient.ajax({
|
||||
url: ApiClient.getUrl('Startup/Complete'),
|
||||
type: 'POST'
|
||||
}).then(function () {
|
||||
loading.hide();
|
||||
window.location.href = 'index.html';
|
||||
});
|
||||
}
|
||||
function onFinish() {
|
||||
loading.show();
|
||||
ApiClient.ajax({
|
||||
url: ApiClient.getUrl('Startup/Complete'),
|
||||
type: 'POST'
|
||||
}).then(function () {
|
||||
loading.hide();
|
||||
window.location.href = 'index.html';
|
||||
});
|
||||
}
|
||||
|
||||
return function (view, params) {
|
||||
view.querySelector('.btnWizardNext').addEventListener('click', onFinish);
|
||||
};
|
||||
});
|
||||
export default function (view, params) {
|
||||
view.querySelector('.btnWizardNext').addEventListener('click', onFinish);
|
||||
}
|
||||
|
@ -1,39 +1,40 @@
|
||||
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) {
|
||||
loading.show();
|
||||
var apiClient = ApiClient;
|
||||
var config = {};
|
||||
config.EnableRemoteAccess = page.querySelector('#chkRemoteAccess').checked;
|
||||
config.EnableAutomaticPortMapping = page.querySelector('#chkEnableUpnp').checked;
|
||||
apiClient.ajax({
|
||||
type: 'POST',
|
||||
data: config,
|
||||
url: apiClient.getUrl('Startup/RemoteAccess')
|
||||
}).then(function () {
|
||||
loading.hide();
|
||||
navigateToNextPage();
|
||||
});
|
||||
}
|
||||
function save(page) {
|
||||
loading.show();
|
||||
const apiClient = ApiClient;
|
||||
const config = {};
|
||||
config.EnableRemoteAccess = page.querySelector('#chkRemoteAccess').checked;
|
||||
config.EnableAutomaticPortMapping = page.querySelector('#chkEnableUpnp').checked;
|
||||
apiClient.ajax({
|
||||
type: 'POST',
|
||||
data: config,
|
||||
url: apiClient.getUrl('Startup/RemoteAccess')
|
||||
}).then(function () {
|
||||
loading.hide();
|
||||
navigateToNextPage();
|
||||
});
|
||||
}
|
||||
|
||||
function navigateToNextPage() {
|
||||
Dashboard.navigate('wizardfinish.html');
|
||||
}
|
||||
function navigateToNextPage() {
|
||||
Dashboard.navigate('wizardfinish.html');
|
||||
}
|
||||
|
||||
function onSubmit(e) {
|
||||
save(this);
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
function onSubmit(e) {
|
||||
save(this);
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
return function (view, params) {
|
||||
view.querySelector('.wizardSettingsForm').addEventListener('submit', onSubmit);
|
||||
view.addEventListener('viewshow', function () {
|
||||
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
||||
});
|
||||
view.addEventListener('viewhide', function () {
|
||||
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
||||
});
|
||||
};
|
||||
});
|
||||
export default function (view, params) {
|
||||
view.querySelector('.wizardSettingsForm').addEventListener('submit', onSubmit);
|
||||
view.addEventListener('viewshow', function () {
|
||||
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
||||
});
|
||||
view.addEventListener('viewhide', function () {
|
||||
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
||||
});
|
||||
}
|
||||
|
@ -1,84 +1,85 @@
|
||||
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) {
|
||||
loading.show();
|
||||
var apiClient = ApiClient;
|
||||
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
|
||||
config.PreferredMetadataLanguage = page.querySelector('#selectLanguage').value;
|
||||
config.MetadataCountryCode = page.querySelector('#selectCountry').value;
|
||||
apiClient.ajax({
|
||||
type: 'POST',
|
||||
data: config,
|
||||
url: apiClient.getUrl('Startup/Configuration')
|
||||
}).then(function () {
|
||||
loading.hide();
|
||||
navigateToNextPage();
|
||||
});
|
||||
function save(page) {
|
||||
loading.show();
|
||||
const apiClient = ApiClient;
|
||||
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
|
||||
config.PreferredMetadataLanguage = page.querySelector('#selectLanguage').value;
|
||||
config.MetadataCountryCode = page.querySelector('#selectCountry').value;
|
||||
apiClient.ajax({
|
||||
type: 'POST',
|
||||
data: config,
|
||||
url: apiClient.getUrl('Startup/Configuration')
|
||||
}).then(function () {
|
||||
loading.hide();
|
||||
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) {
|
||||
var html = '';
|
||||
html += "<option value=''></option>";
|
||||
select.innerHTML = html;
|
||||
}
|
||||
|
||||
for (var i = 0, length = languages.length; i < length; i++) {
|
||||
var culture = languages[i];
|
||||
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + '</option>';
|
||||
}
|
||||
function populateCountries(select, allCountries) {
|
||||
let html = '';
|
||||
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) {
|
||||
var html = '';
|
||||
html += "<option value=''></option>";
|
||||
select.innerHTML = html;
|
||||
}
|
||||
|
||||
for (var i = 0, length = allCountries.length; i < length; i++) {
|
||||
var culture = allCountries[i];
|
||||
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + '</option>';
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
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) {
|
||||
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 navigateToNextPage() {
|
||||
Dashboard.navigate('wizardremoteaccess.html');
|
||||
}
|
||||
|
||||
function reload(page) {
|
||||
loading.show();
|
||||
var apiClient = ApiClient;
|
||||
var promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
|
||||
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 onSubmit(e) {
|
||||
save(this);
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
function navigateToNextPage() {
|
||||
Dashboard.navigate('wizardremoteaccess.html');
|
||||
}
|
||||
|
||||
function onSubmit(e) {
|
||||
save(this);
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
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');
|
||||
});
|
||||
};
|
||||
});
|
||||
export default 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) {
|
||||
'use strict';
|
||||
import $ from 'jQuery';
|
||||
import loading from 'loading';
|
||||
import 'emby-button';
|
||||
import 'emby-select';
|
||||
|
||||
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 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();
|
||||
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();
|
||||
var 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');
|
||||
});
|
||||
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]);
|
||||
});
|
||||
}
|
||||
|
||||
function onSubmit() {
|
||||
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');
|
||||
});
|
||||
};
|
||||
});
|
||||
});
|
||||
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) {
|
||||
'use strict';
|
||||
import loading from 'loading';
|
||||
import globalize from 'globalize';
|
||||
import 'dashboardcss';
|
||||
import 'emby-input';
|
||||
import 'emby-button';
|
||||
|
||||
function getApiClient() {
|
||||
return ApiClient;
|
||||
function getApiClient() {
|
||||
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) {
|
||||
import('toast').then(({default: toast}) => {
|
||||
toast(globalize.translate('PasswordMatchError'));
|
||||
});
|
||||
} else {
|
||||
submit(form);
|
||||
}
|
||||
|
||||
function nextWizardPage() {
|
||||
Dashboard.navigate('wizardlibrary.html');
|
||||
}
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
function onUpdateUserComplete(result) {
|
||||
console.debug('user update complete: ' + result);
|
||||
function onViewShow() {
|
||||
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();
|
||||
nextWizardPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function submit(form) {
|
||||
loading.show();
|
||||
var 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) {
|
||||
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);
|
||||
};
|
||||
});
|
||||
export default 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…
Reference in New Issue
Block a user