minor optimizations to instance card config and console actions
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
<main>
|
||||
<section>
|
||||
<h2><a href="index">Instances</a> / {{.config.Name}}</h2>
|
||||
<form>
|
||||
<form id="config-form">
|
||||
<fieldset class="w3-card w3-padding">
|
||||
<legend>Resources</legend>
|
||||
<div class="input-grid" id="resources" style="grid-template-columns: auto auto auto 1fr;">
|
||||
@@ -91,7 +91,7 @@
|
||||
</fieldset>
|
||||
{{end}}
|
||||
<div class="w3-container w3-center" id="form-actions">
|
||||
<button class="w3-button w3-margin" id="exit" type="button">EXIT</button>
|
||||
<button class="w3-button w3-margin" id="exit" type="submit">EXIT</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
@@ -19,7 +19,7 @@ async function init () {
|
||||
initNetworks();
|
||||
initDevices();
|
||||
|
||||
document.querySelector("#exit").addEventListener("click", handleFormExit);
|
||||
document.querySelector("#config-form").addEventListener("submit", handleFormExit);
|
||||
}
|
||||
|
||||
class VolumeAction extends HTMLElement {
|
||||
@@ -530,7 +530,8 @@ async function refreshBoot () {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleFormExit () {
|
||||
async function handleFormExit (event) {
|
||||
event.preventDefault();
|
||||
const body = {
|
||||
cores: document.querySelector("#cores").value,
|
||||
memory: document.querySelector("#ram").value
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { requestPVE, requestAPI, goToPage, setAppearance, getSearchSettings, goToURL, requestDash, setSVGSrc, setSVGAlt } from "./utils.js";
|
||||
import { requestPVE, requestAPI, setAppearance, getSearchSettings, requestDash, setSVGSrc, setSVGAlt } from "./utils.js";
|
||||
import { alert, dialog } from "./dialog.js";
|
||||
import { setupClientSync } from "./clientsync.js";
|
||||
import wfaInit from "../modules/wfa.js";
|
||||
@@ -124,17 +124,6 @@ class InstanceCard extends HTMLElement {
|
||||
powerButton.onclick = this.handlePowerButton.bind(this);
|
||||
}
|
||||
|
||||
const configButton = this.shadowRoot.querySelector("#configure-btn");
|
||||
if (configButton.classList.contains("clickable")) {
|
||||
configButton.onclick = this.handleConfigButton.bind(this);
|
||||
}
|
||||
|
||||
const consoleButton = this.shadowRoot.querySelector("#console-btn");
|
||||
if (consoleButton.classList.contains("clickable")) {
|
||||
consoleButton.classList.add("clickable");
|
||||
consoleButton.onclick = this.handleConsoleButton.bind(this);
|
||||
}
|
||||
|
||||
const deleteButton = this.shadowRoot.querySelector("#delete-btn");
|
||||
if (deleteButton.classList.contains("clickable")) {
|
||||
deleteButton.onclick = this.handleDeleteButton.bind(this);
|
||||
@@ -186,20 +175,6 @@ class InstanceCard extends HTMLElement {
|
||||
}
|
||||
}
|
||||
|
||||
handleConfigButton () {
|
||||
if (!this.actionLock && this.status === "stopped") { // if the action lock is false, and the node is stopped, then navigate to the config page with the node info in the search query
|
||||
goToPage("config", { node: this.node.name, type: this.type, vmid: this.vmid });
|
||||
}
|
||||
}
|
||||
|
||||
handleConsoleButton () {
|
||||
if (!this.actionLock && this.status === "running") {
|
||||
const data = { console: `${this.type === "qemu" ? "kvm" : "lxc"}`, vmid: this.vmid, vmname: this.name, node: this.node.name, resize: "off", cmd: "" };
|
||||
data[`${this.type === "qemu" ? "novnc" : "xtermjs"}`] = 1;
|
||||
goToURL(window.PVE, data, true);
|
||||
}
|
||||
}
|
||||
|
||||
handleDeleteButton () {
|
||||
if (!this.actionLock && this.status === "stopped") {
|
||||
const header = `Delete VM ${this.vmid}`;
|
||||
|
@@ -114,20 +114,6 @@ export function goToPage (page, data = null) {
|
||||
window.location.href = `${page}${data ? "?" : ""}${params}`;
|
||||
}
|
||||
|
||||
export function goToURL (href, data = {}, newwindow = false) {
|
||||
const url = new URL(href);
|
||||
for (const k in data) {
|
||||
url.searchParams.append(k, data[k]);
|
||||
}
|
||||
|
||||
if (newwindow) {
|
||||
window.open(url, document.title, "height=480,width=848");
|
||||
}
|
||||
else {
|
||||
window.location.assign(url.toString());
|
||||
}
|
||||
}
|
||||
|
||||
export function getURIData () {
|
||||
const url = new URL(window.location.href);
|
||||
return Object.fromEntries(url.searchParams);
|
||||
|
@@ -41,11 +41,15 @@
|
||||
{{if and (eq .NodeStatus "online") (eq .Status "running")}}
|
||||
<svg id="power-btn" class="clickable" aria-label="shutdown instance"><use href="images/actions/instance/stop.svg#symb"></svg>
|
||||
<svg id="configure-btn" aria-label=""><use href="images/actions/instance/config-inactive.svg#symb"></svg>
|
||||
<svg id="console-btn" class="clickable" aria-label="open console"><use href="images/actions/instance/console-active.svg#symb"></svg>
|
||||
<a href="{{.ConsolePath}}" target="_blank">
|
||||
<svg id="console-btn" class="clickable" aria-label="open console"><use href="images/actions/instance/console-active.svg#symb"></svg>
|
||||
</a>
|
||||
<svg id="delete-btn" aria-label=""><use href="images/actions/instance/delete-inactive.svg#symb"></svg>
|
||||
{{else if and (eq .NodeStatus "online") (eq .Status "stopped")}}
|
||||
<svg id="power-btn" class="clickable" aria-label="start instance"><use href="images/actions/instance/start.svg#symb"></svg>
|
||||
<svg id="configure-btn" class="clickable" aria-label="change configuration"><use href="images/actions/instance/config-active.svg#symb"></svg>
|
||||
<a href="{{.ConfigPath}}">
|
||||
<svg id="configure-btn" class="clickable" aria-label="change configuration"><use href="images/actions/instance/config-active.svg#symb"></svg>
|
||||
</a>
|
||||
<svg id="console-btn" aria-label=""><use href="images/actions/instance/console-inactive.svg#symb"></svg>
|
||||
<svg id="delete-btn" class="clickable" aria-label="delete instance"><use href="images/actions/instance/delete-active.svg#symb"></svg>
|
||||
{{else if and (eq .NodeStatus "online") (eq .Status "loading")}}
|
||||
|
Reference in New Issue
Block a user