move wizard and user preference routes to nested folders
This commit is contained in:
parent
a353812400
commit
c0261ee487
30 changed files with 55 additions and 42 deletions
36
src/controllers/wizard/user/index.html
Normal file
36
src/controllers/wizard/user/index.html
Normal file
|
@ -0,0 +1,36 @@
|
|||
<div id="wizardUserPage" data-role="page" class="page standalonePage wizardPage">
|
||||
<div class="padded-left padded-right padded-top">
|
||||
<div class="ui-corner-all ui-shadow wizardContent">
|
||||
<form class="wizardUserForm">
|
||||
<div class="verticalSection">
|
||||
<h1 class="sectionTitle">${TellUsAboutYourself}</h1>
|
||||
<p style="margin-top:2em;">${UserProfilesIntro}</p>
|
||||
<br />
|
||||
<div class="inputContainer">
|
||||
<input is="emby-input" type="text" id="txtUsername" label="${LabelUsername}" required="required" />
|
||||
<div class="fieldDescription">${SelectAdminUsername}</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<input is="emby-input" id="txtManualPassword" type="password" label="${LabelPassword}" />
|
||||
<div class="fieldDescription">${LeaveBlankToNotSetAPassword}</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<input is="emby-input" id="txtPasswordConfirm" type="password" label="${LabelPasswordConfirm}" />
|
||||
</div>
|
||||
<p>${MoreUsersCanBeAddedLater}</p>
|
||||
</div>
|
||||
|
||||
<div class="wizardNavigation">
|
||||
<button is="emby-button" type="button" class="raised button-cancel" onclick="history.back();">
|
||||
<span class="material-icons arrow_back"></span>
|
||||
<span>${LabelPrevious}</span>
|
||||
</button>
|
||||
<button is="emby-button" type="submit" class="raised button-submit">
|
||||
<span>${LabelNext}</span>
|
||||
<span class="material-icons arrow_forward"></span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
69
src/controllers/wizard/user/index.js
Normal file
69
src/controllers/wizard/user/index.js
Normal file
|
@ -0,0 +1,69 @@
|
|||
import loading from 'loading';
|
||||
import globalize from 'globalize';
|
||||
import 'dashboardcss';
|
||||
import 'emby-input';
|
||||
import 'emby-button';
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
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