Admin webui with one single option

This commit is contained in:
Ethan O'Brien
2024-05-27 15:09:17 -05:00
parent 30caa814f4
commit dae95f5aa3
4 changed files with 89 additions and 8 deletions

View File

@ -29,6 +29,11 @@ function Login() {
e.preventDefault();
window.location.href = "/import/";
}
const adminPanel = (e) => {
e.preventDefault();
window.location.href = "/admin/";
}
return (
<div id="login-form">
@ -40,7 +45,8 @@ function Login() {
<input type="password" id="password" name="password" onChange={(event) => {password = event.target.value}} />
<input type="submit" value="Submit" onClick={handleSubmit}/>
<div id="sub_div">
<button onClick={import_user}>Import User</button>
<button onClick={import_user}>Import User</button><br/><br/>
<button hidden={!["127.0.0.1", "localhost"].includes(window.location.hostname)} onClick={adminPanel}>Admin panel</button>
{ error[0] ? <p>Error: { error[0] } </p> : <p></p> }
</div>
</form>

View File

@ -3,6 +3,7 @@ import ReactDOM from 'react-dom/client'
import Login from './login/Login.jsx'
import Home from './home/Home.jsx'
import Import from './import/Import.jsx'
import Admin from './admin/Admin.jsx'
let Elem;
switch (window.location.pathname) {
@ -15,12 +16,17 @@ switch (window.location.pathname) {
case "/import/":
Elem = Import;
break;
case "/admin/":
Elem = Admin;
break;
default:
window.location.pathname = "/";
}
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<Elem />
</React.StrictMode>,
)
if (Elem) {
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<Elem />
</React.StrictMode>,
)
}