add login page
This commit is contained in:
parent
80a442f3c0
commit
1473626373
5
index.js
5
index.js
@ -5,10 +5,7 @@ window.addEventListener("DOMContentLoaded", init);
|
||||
async function init () {
|
||||
let cookie = document.cookie;
|
||||
if (cookie === '') {
|
||||
let username = prompt("username: ");
|
||||
let password = prompt("password: ")
|
||||
let ticket = await requestTicket(username, password);
|
||||
setTicket(ticket.data.ticket);
|
||||
window.location.href = "login.html";
|
||||
}
|
||||
|
||||
let nodes = await request("/nodes", "GET", null);
|
||||
|
25
login.css
Normal file
25
login.css
Normal file
@ -0,0 +1,25 @@
|
||||
.center-div {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
border: solid white 1px;
|
||||
border-radius: 5px;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
input, label, legend {
|
||||
font-family: monospace;
|
||||
color: white;
|
||||
font-size: 14px;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
input {
|
||||
border: solid white 1px;
|
||||
}
|
||||
|
||||
button {
|
||||
margin-top: 10px;
|
||||
}
|
25
login.html
Normal file
25
login.html
Normal file
@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>tronnet - client</title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
<link rel="stylesheet" href="login.css" type="text/css">
|
||||
<script src="login.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="center-div">
|
||||
<form>
|
||||
<fieldset>
|
||||
<legend>Proxmox VE Login</legend>
|
||||
<label for="username">Username: </label><input type="text" id="username" name="username"><br>
|
||||
<label for="username">Password: </label><input type="password" id="password" name="password"><br>
|
||||
<div class="btn-group">
|
||||
<button id="submit">LOGIN</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
21
login.js
Normal file
21
login.js
Normal file
@ -0,0 +1,21 @@
|
||||
import {requestTicket, setTicket} from "./utils.js";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", init);
|
||||
|
||||
function init (){
|
||||
let formSubmitButton = document.querySelector("#submit");
|
||||
formSubmitButton.addEventListener("click", loginFormSubmitHandler);
|
||||
}
|
||||
|
||||
async function loginFormSubmitHandler () {
|
||||
let form = document.querySelector("form");
|
||||
let formData = new FormData(form);
|
||||
try {
|
||||
let ticket = await requestTicket(formData.username, formData.password);
|
||||
await setTicket(ticket);
|
||||
window.location.href = "index.html";
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user