diff --git a/scripts/instance.js b/scripts/instance.js index 82e29a9..6467678 100644 --- a/scripts/instance.js +++ b/scripts/instance.js @@ -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); } } } diff --git a/scripts/utils.js b/scripts/utils.js index 95d84e6..2e0408f 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -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]); }