diff --git a/index.js b/index.js index 15b6adc..87551ee 100644 --- a/index.js +++ b/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); diff --git a/login.css b/login.css new file mode 100644 index 0000000..d09f67d --- /dev/null +++ b/login.css @@ -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; +} \ No newline at end of file diff --git a/login.html b/login.html new file mode 100644 index 0000000..6e4ef00 --- /dev/null +++ b/login.html @@ -0,0 +1,25 @@ + + + + + + tronnet - client + + + + + +
+
+
+ Proxmox VE Login +
+
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/login.js b/login.js new file mode 100644 index 0000000..0a82244 --- /dev/null +++ b/login.js @@ -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); + } +} \ No newline at end of file