1717
1818<template >
1919 <a
20- v-if =" ['vm', 'systemvm', 'router', 'ilbvm', 'vnfapp'].includes($route.meta.name) && 'listVirtualMachines' in $store.getters.apis && 'createConsoleEndpoint' in $store.getters.apis"
20+ v-if =" ['vm', 'systemvm', 'router', 'ilbvm', 'vnfapp'].includes($route.meta.name) &&
21+ 'listVirtualMachines' in $store.getters.apis &&
22+ 'createConsoleEndpoint' in $store.getters.apis"
2123 @click =" consoleUrl" >
22- <a-button style =" margin-left : 5px " shape =" circle" type =" dashed" :size =" size" :disabled =" ['Stopped', 'Restoring', 'Error', 'Destroyed'].includes(resource.state) || resource.hostcontrolstate === 'Offline'" >
24+ <a-button
25+ style =" margin-left : 5px "
26+ shape =" circle"
27+ type =" dashed"
28+ :size =" size"
29+ :disabled =" ['Stopped', 'Restoring', 'Error', 'Destroyed'].includes(resource.state) ||
30+ resource.hostcontrolstate === 'Offline'" >
2331 <code-outlined v-if =" !copyUrlToClipboard" />
2432 <copy-outlined v-else />
2533 </a-button >
@@ -49,11 +57,29 @@ export default {
4957 }
5058 },
5159 methods: {
52- consoleUrl () {
53- const params = {}
54- params .virtualmachineid = this .resource .id
55- postAPI (' createConsoleEndpoint' , params).then (json => {
56- this .url = (json && json .createconsoleendpointresponse ) ? json .createconsoleendpointresponse .consoleendpoint .url : ' #/exception/404'
60+ async consoleUrl () {
61+ try {
62+ const externalUrl = this .resource ? .details ? .[' External:console_url' ]
63+ if (externalUrl) {
64+ this .url = externalUrl
65+ if (this .copyUrlToClipboard ) {
66+ this .$copyText (this .url )
67+ this .$message .success ({
68+ content: this .$t (' label.copied.clipboard' )
69+ })
70+ } else {
71+ window .open (this .url , ' _blank' )
72+ }
73+ return
74+ }
75+
76+ const params = { virtualmachineid: this .resource .id }
77+ const json = await postAPI (' createConsoleEndpoint' , params)
78+
79+ this .url = (json && json .createconsoleendpointresponse )
80+ ? json .createconsoleendpointresponse .consoleendpoint .url
81+ : ' #/exception/404'
82+
5783 if (json .createconsoleendpointresponse .consoleendpoint .success ) {
5884 if (this .copyUrlToClipboard ) {
5985 this .$copyText (this .url )
@@ -69,9 +95,9 @@ export default {
6995 description: json .createconsoleendpointresponse .consoleendpoint .details
7096 })
7197 }
72- }). catch (error => {
98+ } catch (error) {
7399 this .$notifyError (error)
74- })
100+ }
75101 }
76102 },
77103 computed: {
0 commit comments