Fixed login screen.

This commit is contained in:
Magnus Åhall 2023-07-18 07:09:03 +02:00
parent 2cd17871b5
commit cc9c1ca82e
7 changed files with 154 additions and 80 deletions

View file

@ -28,14 +28,20 @@ class App extends Component {
this.setStartNode()
}//}}}
render() {//{{{
let app_el = document.getElementById('app')
if(!this.session.initialized) {
return html`<div>Validating session</div>`
}
if(!this.session.authenticated()) {
app_el.classList.remove('node')
app_el.classList.add('login')
return html`<${Login} ref=${this.login} />`
}
app_el.classList.remove('login')
app_el.classList.add('node')
return html`
<${Tree} app=${this} ref=${this.tree} />
<${NodeUI} app=${this} ref=${this.nodeUI} />
@ -162,11 +168,16 @@ class Login extends Component {
return html`
<div id="login">
<h1>Notes</h1>
<input id="username" type="text" placeholder="Username" value=${username} oninput=${evt=>this.setState({ username: evt.target.value})} onkeydown=${evt=>{ if(evt.code == 'Enter') this.login() }} />
<input id="password" type="password" placeholder="Password" value=${password} oninput=${evt=>this.setState({ password: evt.target.value})} onkeydown=${evt=>{ if(evt.code == 'Enter') this.login() }} />
<button onclick=${()=>this.login()}>Login</button>
${authentication_failed}
<div class="header">
<h1>Notes</h1>
</div>
<div class="fields">
<input id="username" type="text" placeholder="Username" value=${username} oninput=${evt=>this.setState({ username: evt.target.value})} onkeydown=${evt=>{ if(evt.code == 'Enter') this.login() }} />
<input id="password" type="password" placeholder="Password" value=${password} oninput=${evt=>this.setState({ password: evt.target.value})} onkeydown=${evt=>{ if(evt.code == 'Enter') this.login() }} />
<button onclick=${()=>this.login()}>Login</button>
${authentication_failed}
</div>
</div>
`
}//}}}