Work on user selection.
This commit is contained in:
parent
a0752bb73a
commit
1815547daf
3 changed files with 58 additions and 15 deletions
|
@ -4,10 +4,10 @@
|
|||
|
||||
** 0.2
|
||||
|
||||
- [ ] use localStorage to store user
|
||||
- [-] use localStorage to store user
|
||||
- [ ] add barcode scanner to get the user
|
||||
- [ ] allow editing
|
||||
- [ ] add UserSelect component
|
||||
- [X] allow editing
|
||||
- [X] add UserSelect component
|
||||
- [X] integrate script for starting build qemu system
|
||||
- [X] add org file to the repository after cleanup
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
(define -db-user- (make-parameter #f))
|
||||
(define -db-name- (make-parameter #f))
|
||||
(define -db-pass- (make-parameter #f))
|
||||
(define -db-enabled- (make-parameter #t))
|
||||
|
||||
(command-line
|
||||
print-help
|
||||
|
@ -82,6 +83,8 @@
|
|||
(-db-user- dbuser))
|
||||
(-dp (dbpass) "Database password"
|
||||
(-db-pass- dbpass))
|
||||
(-dd () "Disable database"
|
||||
(-db-enabled- #f))
|
||||
)
|
||||
|
||||
(define ssl? (and (-certificate-) (-key-) #t))
|
||||
|
@ -120,7 +123,8 @@
|
|||
(print "current user id: " (current-user-id))
|
||||
(print "current effective user id: " (current-effective-user-id))
|
||||
|
||||
(bar-db-init! (-db-name-) (-db-host-) (-db-user-) (-db-pass-))
|
||||
(when (-db-enabled-)
|
||||
(bar-db-init! (-db-name-) (-db-host-) (-db-user-) (-db-pass-)))
|
||||
|
||||
(define (handle-api-calls)
|
||||
(define plst (cdr (uri-path (request-uri (current-request)))))
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
import { useState } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import BarcodeScannerComponent from 'react-qr-barcode-scanner';
|
||||
import { Container, Row, Col } from 'react-bootstrap';
|
||||
import Container from 'react-bootstrap/Container';
|
||||
import Row from 'react-bootstrap/Row';
|
||||
import Col from 'react-bootstrap/Col';
|
||||
import Table from 'react-bootstrap/Table';
|
||||
import Alert from 'react-bootstrap/Alert';
|
||||
import Form from 'react-bootstrap/Form';
|
||||
import Button from 'react-bootstrap/Button';
|
||||
|
||||
import './App.css';
|
||||
import 'bootstrap/dist/css/bootstrap.min.css';
|
||||
|
@ -10,15 +14,15 @@ import 'bootstrap/dist/css/bootstrap.min.css';
|
|||
function App() {
|
||||
// Ensure we have persistent (informal) user information
|
||||
const [user, setUser] = useState("");
|
||||
useEffect(() => {
|
||||
localStorage.setItem('user', user);
|
||||
}, [user]);
|
||||
useEffect(() => {
|
||||
const user = localStorage.getItem('user');
|
||||
if (user) {
|
||||
setUser(user);
|
||||
}
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
localStorage.setItem('user', user);
|
||||
}, [user]);
|
||||
|
||||
// If no user, must be scanned/set otherwise
|
||||
return (
|
||||
|
@ -26,17 +30,52 @@ function App() {
|
|||
{user === "" ?
|
||||
<NoUserView setUser={setUser} />
|
||||
:
|
||||
<UserView user={user} />}
|
||||
<UserView user={user} setUser={setUser} />}
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
function NoUserView({setUser}) {
|
||||
return <p>No user!</p>;
|
||||
const [preUser, setPreUser] = useState("");
|
||||
return (
|
||||
<>
|
||||
<Row>
|
||||
<Col>
|
||||
<Form.Group>
|
||||
<Form.Label>User:</Form.Label>
|
||||
<Form.Control type="text" placeholder="Username"
|
||||
value={preUser} onChange={(v) => setPreUser(v.target.value)} />
|
||||
<Form.Text>Which user is using this App?</Form.Text>
|
||||
</Form.Group>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col>
|
||||
Scanner
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col>
|
||||
<Button variant="primary"
|
||||
onClick={() => setUser(preUser)}>Set!</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function UserView({user}) {
|
||||
return <p>User={user}</p>;
|
||||
function UserView({user, setUser}) {
|
||||
return (
|
||||
<Row>
|
||||
<Col>
|
||||
{user}
|
||||
</Col>
|
||||
<Col>
|
||||
<Button variant="info" onClick={() => setUser('')}>Change</Button>
|
||||
</Col>
|
||||
<BarItemScanner />
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
||||
function BarItemScanner() {
|
||||
|
@ -69,7 +108,7 @@ function BarItemScanner() {
|
|||
};
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<>
|
||||
<Row>
|
||||
<Col>
|
||||
<BarcodeScannerComponent
|
||||
|
@ -103,7 +142,7 @@ function BarItemScanner() {
|
|||
<Alert variant={msgType}>{statusMsg}</Alert>
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue