First successful VNC connection

This commit is contained in:
2023-10-18 18:00:25 +02:00
parent 4f75cd918d
commit b87306f8ea
14 changed files with 422 additions and 5 deletions

View File

@ -69,6 +69,10 @@ export class VMInfo implements VMInfoInterface {
get EditURL(): string {
return `/vm/${this.uuid}/edit`;
}
get VNCURL(): string {
return `/vm/${this.uuid}/vnc`;
}
}
export class VMApi {
@ -230,4 +234,27 @@ export class VMApi {
jsonData: { keep_files },
});
}
/**
* Get a oneshot VNC connect URL
*/
static async OneShotVNCURL(vm: VMInfo): Promise<string> {
const token = (
await APIClient.exec({
uri: `/vm/${vm.uuid}/vnc_token`,
method: "GET",
})
).data.token;
let baseWSURL = APIClient.backendURL();
if (!baseWSURL.includes("://"))
baseWSURL =
window.location.protocol + "://" + window.location.hostname + baseWSURL;
return (
baseWSURL.replace("http", "ws") +
"/vnc?token=" +
encodeURIComponent(token)
);
}
}