Migration of wizard to ES6 modules
This commit is contained in:
parent
a9246f8f39
commit
c11977c9fe
6 changed files with 235 additions and 227 deletions
|
@ -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) {
|
||||
require(['toast'], function (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…
Add table
Add a link
Reference in a new issue