implement ssr modal dialog for index and account
This commit is contained in:
1
ProxmoxAAS-Fabric
Submodule
1
ProxmoxAAS-Fabric
Submodule
Submodule ProxmoxAAS-Fabric added at 81815bab82
@@ -73,5 +73,30 @@
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<modal-dialog id="change-password-dialog">
|
||||
<template shadowrootmode="open">
|
||||
<link rel="stylesheet" href="modules/w3.css">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link rel="stylesheet" href="css/form.css">
|
||||
<dialog class="w3-container w3-card w3-border-0">
|
||||
<p class="w3-large" id="prompt" style="text-align: center;">
|
||||
Change Password
|
||||
</p>
|
||||
<div id="body">
|
||||
<form method="dialog" class="input-grid" style="grid-template-columns: auto 1fr;" id="form">
|
||||
<label for="new-password">New Password</label>
|
||||
<input class="w3-input w3-border" id="new-password" name="new-password" type="password" required>
|
||||
<label for="confirm-password">Confirm Password</label>
|
||||
<input class="w3-input w3-border" id="confirm-password" name="confirm-password" type="password" required>
|
||||
</form>
|
||||
</div>
|
||||
<div id="controls" class="w3-center w3-container">
|
||||
<button id="cancel" type="submit" value="cancel" form="form" class="w3-button w3-margin" style="background-color: var(--negative-color, #f00); color: var(--lightbg-text-color, black);" formnovalidate>CANCEL</button>
|
||||
<button id="confirm" type="submit" value="confirm" form="form" class="w3-button w3-margin" style="background-color: var(--positive-color, #0f0); color: var(--lightbg-text-color, black);">CONFIRM</button>
|
||||
</div>
|
||||
</dialog>
|
||||
</template>
|
||||
</modal-dialog>
|
||||
</body>
|
||||
</html>
|
@@ -63,7 +63,6 @@
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
<modal-dialog id="create-instance-dialog">
|
||||
<template shadowrootmode="open">
|
||||
@@ -115,4 +114,5 @@
|
||||
</dialog>
|
||||
</template>
|
||||
</modal-dialog>
|
||||
</body>
|
||||
</html>
|
@@ -1,24 +1,18 @@
|
||||
import { dialog } from "./dialog.js";
|
||||
import { requestAPI, setAppearance } from "./utils.js";
|
||||
import "./dialog.js";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", init);
|
||||
|
||||
async function init () {
|
||||
setAppearance();
|
||||
|
||||
document.querySelector("#change-password").addEventListener("click", handlePasswordChangeForm);
|
||||
initPasswordChangeForm();
|
||||
document.querySelector("#change-password").addEventListener("click", handlePasswordChangeButton);
|
||||
}
|
||||
|
||||
function handlePasswordChangeForm () {
|
||||
const body = `
|
||||
<form method="dialog" class="input-grid" style="grid-template-columns: auto 1fr;" id="form">
|
||||
<label for="new-password">New Password</label>
|
||||
<input class="w3-input w3-border" id="new-password" name="new-password" type="password"required>
|
||||
<label for="confirm-password">Confirm Password</label>
|
||||
<input class="w3-input w3-border" id="confirm-password" name="confirm-password" type="password" required>
|
||||
</form>
|
||||
`;
|
||||
const d = dialog("Change Password", body, async (result, form) => {
|
||||
function initPasswordChangeForm () {
|
||||
const d = document.querySelector("#change-password-dialog");
|
||||
d.setOnClose(async (result, form) => {
|
||||
if (result === "confirm") {
|
||||
const result = await requestAPI("/access/password", "POST", { password: form.get("new-password") });
|
||||
if (result.status !== 200) {
|
||||
@@ -37,3 +31,8 @@ function handlePasswordChangeForm () {
|
||||
password.addEventListener("change", validatePassword);
|
||||
confirmPassword.addEventListener("keyup", validatePassword);
|
||||
}
|
||||
|
||||
function handlePasswordChangeButton () {
|
||||
const d = document.querySelector("#change-password-dialog");
|
||||
d.showModal();
|
||||
}
|
||||
|
@@ -323,6 +323,7 @@ function sortInstances () {
|
||||
}
|
||||
|
||||
async function initInstanceAddForm () {
|
||||
// form submit logic
|
||||
const d = document.querySelector("#create-instance-dialog");
|
||||
d.setOnClose(async (result, form) => {
|
||||
if (result === "confirm") {
|
||||
@@ -352,6 +353,15 @@ async function initInstanceAddForm () {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// custom password validation checker
|
||||
const password = d.querySelector("#password");
|
||||
const confirmPassword = d.querySelector("#confirm-password");
|
||||
function validatePassword () {
|
||||
confirmPassword.setCustomValidity(password.value !== confirmPassword.value ? "Passwords Don't Match" : "");
|
||||
}
|
||||
password.addEventListener("change", validatePassword);
|
||||
confirmPassword.addEventListener("keyup", validatePassword);
|
||||
}
|
||||
|
||||
async function handleInstanceAddButton () {
|
||||
@@ -400,6 +410,7 @@ async function handleInstanceAddButton () {
|
||||
nodeSelect.addEventListener("change", async () => { // change rootfs storage based on node
|
||||
const node = nodeSelect.value;
|
||||
const storage = await requestPVE(`/nodes/${node}/storage`, "GET");
|
||||
rootfsStorage.innerHTML = "";
|
||||
storage.data.forEach((element) => {
|
||||
if (element.content.includes(rootfsContent)) {
|
||||
rootfsStorage.add(new Option(element.storage));
|
||||
@@ -443,15 +454,5 @@ async function handleInstanceAddButton () {
|
||||
}
|
||||
templateImage.selectedIndex = -1;
|
||||
|
||||
const password = d.querySelector("#password");
|
||||
const confirmPassword = d.querySelector("#confirm-password");
|
||||
|
||||
function validatePassword () {
|
||||
confirmPassword.setCustomValidity(password.value !== confirmPassword.value ? "Passwords Don't Match" : "");
|
||||
}
|
||||
|
||||
password.addEventListener("change", validatePassword);
|
||||
confirmPassword.addEventListener("keyup", validatePassword);
|
||||
|
||||
d.showModal();
|
||||
}
|
||||
|
Reference in New Issue
Block a user