First successful VNC connection
This commit is contained in:
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user