use proxmox builtin consoles

This commit is contained in:
Arthur Lu 2023-02-17 05:12:28 +00:00
parent 604035d3a8
commit 17f243a006
2 changed files with 19 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import {requestPVE, goToPage, instances, getCookie} from "./utils.js";
import {requestPVE, goToPage, goToURL, instances} from "./utils.js";
export class Instance extends HTMLElement {
constructor () {
@ -131,7 +131,9 @@ export class Instance extends HTMLElement {
handleConsoleButton () {
if (this.status === "running") {
//goToPage("pve-xtermjs/index.html", {type: this.type, vmid: this.vmid, name: this.name, node: this.node.name, user: getCookie("username"), url: "pve.tronnet.net/api2/json"}, true);
let 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("https://pve.tronnet.net", data, true);
}
}
}

View File

@ -149,7 +149,21 @@ async function request (url, content) {
}
export function goToPage (page, data={}, newwindow = false) {
let url = new URL(`https://client.tronnet.net/${page}`);
let url = new URL(`https://${window.location.host}/${page}`);
for(let k in data) {
url.searchParams.append(k, data[k]);
}
if (newwindow) {
window.open(url, "tronnet - client", "height=480,width=848");
}
else {
window.location.assign(url.toString());
}
}
export function goToURL (href, data={}, newwindow = false) {
let url = new URL(href);
for(let k in data) {
url.searchParams.append(k, data[k]);
}