Files
harvester-ui-extension/extensions/harvester/1.10.0-dev/plugin/harvester-1.10.0-dev.umd.min.989.js
T

2 lines
36 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(("undefined"!==typeof self?self:this)["webpackChunkharvester_1_10_0_dev"]=("undefined"!==typeof self?self:this)["webpackChunkharvester_1_10_0_dev"]||[]).push([[989],{3532:function(e,t,n){"use strict";n.a(e,async function(e,s){try{var o=n(55512),i=n(3485),r=(n(91352),n(92274),n(47433)),a=e([i]),l=a.then?(await a)():a;i=l[0];const c=(0,r.A)(i.Ay,[["render",o.X],["__scopeId","data-v-0efee1ed"]]);t.Ay=c,s()}catch(c){s(c)}})},9103:function(e,t,n){"use strict";n.d(t,{A:function(){return E}});var s=n(9274);const o={class:"row"},i={class:"col span-12"},r={class:"row"},a={class:"col span-12"},l=["disabled"],c={class:"displayed-keys mt-20"},d={class:"text-default-text"},u={class:"displayed-banners"},h={class:"actions"};function m(e,t,n,m,v,p){const y=(0,s.resolveComponent)("t"),f=(0,s.resolveComponent)("Banner"),g=(0,s.resolveComponent)("AsyncButton"),b=(0,s.resolveComponent)("ModalWithCard"),k=(0,s.resolveDirective)("clean-html");return(0,s.openBlock)(),(0,s.createBlock)(b,{name:"recordShortcutKeys",width:550},{title:(0,s.withCtx)(()=>[(0,s.createVNode)(y,{k:"harvester.virtualMachine.detail.console.customShortcutKeys"})]),content:(0,s.withCtx)(()=>[(0,s.createElementVNode)("div",o,[(0,s.createElementVNode)("div",i,[(0,s.createVNode)(f,{color:"info"},{default:(0,s.withCtx)(()=>[(0,s.withDirectives)((0,s.createElementVNode)("span",null,null,512),[[k,p.keysRecordFormat]])]),_:1})])]),(0,s.createElementVNode)("div",r,[(0,s.createElementVNode)("div",a,[(0,s.createElementVNode)("button",{class:"btn bg-primary",onClick:t[0]||(t[0]=(...e)=>p.toggleRecording&&p.toggleRecording(...e))},[(0,s.createVNode)(y,{k:p.recordButton},null,8,["k"]),(0,s.createElementVNode)("i",{class:(0,s.normalizeClass)(["icon icon-fw",v.isRecording?"icon-dot-open":"icon-dot"])},null,2)]),(0,s.createElementVNode)("button",{disabled:!p.canAdd,class:"btn bg-primary",onClick:t[1]||(t[1]=(...e)=>p.addShortcutKey&&p.addShortcutKey(...e))},[(0,s.createVNode)(y,{k:"generic.add"})],8,l)])]),t[3]||(t[3]=(0,s.createElementVNode)("hr",null,null,-1)),(0,s.createElementVNode)("div",c,[(0,s.withDirectives)((0,s.createElementVNode)("h4",d,null,512),[[k,e.t("harvester.virtualMachine.detail.console.record.preferredKeys")]]),(0,s.createElementVNode)("div",u,[((0,s.openBlock)(!0),(0,s.createElementBlock)(s.Fragment,null,(0,s.renderList)(p.displayedKeys,(e,t)=>((0,s.openBlock)(),(0,s.createBlock)(f,{key:t,closable:!0,onClose:e=>p.removeKey(t)},{default:(0,s.withCtx)(()=>[(0,s.withDirectives)((0,s.createElementVNode)("span",null,null,512),[[k,e]])]),_:2},1032,["onClose"]))),128))])])]),footer:(0,s.withCtx)(()=>[(0,s.createElementVNode)("div",h,[(0,s.createElementVNode)("button",{class:"btn role-secondary mr-20",onClick:t[2]||(t[2]=(0,s.withModifiers)((...e)=>p.closeRecordingModal&&p.closeRecordingModal(...e),["prevent"]))},[(0,s.createVNode)(y,{k:"generic.cancel"})]),(0,s.createVNode)(g,{mode:"edit",onClick:p.saveKeys},null,8,["onClick"])])]),_:1})}var v=n(35664),p=n(15554),y=n(30699),f=n(24151);const g="prefered-shortcut-keys";var b={name:"NovncConsoleCustomKeys",emits:["close"],components:{ModalWithCard:f.A,Banner:p.A,AsyncButton:y.A},data(){return{keysRecord:[],addedShortcutKeys:[],preferredShortcutKeys:[],isRecording:!1}},computed:{savedShortcutKeys(){const e=this.$store.getters["management/all"](v.m4.PREFERENCE),t=e?.[0]?.data?.[g];let n=[];if(!t)return n;try{n=JSON.parse(t)}catch(s){this.$store.dispatch("growl/fromError",{title:this.t("generic.notification.title.error",{name:this.t("harvester.virtualMachine.detail.console.customShortcutKeys")}),err:s},{root:!0})}return n},displayedKeys(){const e=this.addedShortcutKeys.concat(this.preferredShortcutKeys).map(e=>{const t=e.map(e=>` <code>${e.key.charAt(0).toUpperCase()+e.key.slice(1)}</code>`);return t.join(",")});return e},recordButton(){return this.isRecording?"harvester.virtualMachine.detail.console.record.stop":"harvester.virtualMachine.detail.console.record.start"},keysRecordFormat(){if(!this.isRecording&&0===this.keysRecord.length)return this.t("harvester.virtualMachine.detail.console.record.tips");const e=this.keysRecord.map(e=>` <code>${e.key.charAt(0).toUpperCase()+e.key.slice(1)}</code>`);return`Keys: ${e.join(",")}`},canAdd(){const e=this.keysRecord.length>0;let t=[].concat(this.preferredShortcutKeys,this.addedShortcutKeys);return!!e&&(t.push(this.keysRecord),t=t.map(e=>{const t=e.map(e=>e.key);return t.join(",")}),t.length===new Set(t).size)}},watch:{savedShortcutKeys:{handler(){this.preferredShortcutKeys=[].concat(this.savedShortcutKeys)||[]},immediate:!0}},methods:{closeRecordingModal(){window.removeEventListener("keydown",this.handleShortcut),this.$emit("close")},toggleRecording(){this.isRecording=!this.isRecording,this.isRecording?(this.keysRecord=[],window.addEventListener("keydown",this.handleShortcut)):window.removeEventListener("keydown",this.handleShortcut)},handleShortcut(e){e.preventDefault();const{key:t,keyCode:n,code:s,location:o,charCode:i}=e;this.keysRecord.push({key:t,keyCode:n,code:s,location:o,charCode:i})},addShortcutKey(){this.addedShortcutKeys.push([].concat(this.keysRecord))},removeKey(e){const t=this.addedShortcutKeys.length;e<t?this.addedShortcutKeys.splice(e,1):this.preferredShortcutKeys.splice(e-t,1)},async saveKeys(e){const t=[].concat(this.preferredShortcutKeys,this.addedShortcutKeys),n=this.$store.getters["management/all"](v.m4.PREFERENCE)?.[0];try{n.data[g]=JSON.stringify(t),await n.save(),this.closeRecordingModal(),e(!0)}catch(s){e(!1)}}}},k=(n(87306),n(47433));const C=(0,k.A)(b,[["render",m],["__scopeId","data-v-23f4fb4f"]]);var E=C},11497:function(e,t,n){"use strict";n.d(t,{A:function(){return u}});var s=n(9274);const o={class:"list-unstyled dropdown combination-keys__container"},i=["onClick"],r=["onClick"];function a(e,t,n,a,l,c){const d=(0,s.resolveComponent)("novnc-console-item",!0),u=(0,s.resolveComponent)("v-dropdown");return(0,s.openBlock)(),(0,s.createElementBlock)("ul",o,[((0,s.openBlock)(!0),(0,s.createElementBlock)(s.Fragment,null,(0,s.renderList)(n.items,(e,t)=>((0,s.openBlock)(),(0,s.createElementBlock)("li",{key:t},[e.keys?((0,s.openBlock)(),(0,s.createBlock)(u,{key:0,placement:"right-start",trigger:"click",container:!1},{popper:(0,s.withCtx)(()=>[(0,s.createVNode)(d,{items:e.keys,path:n.path,pos:n.pos+1,onUpdate:c.addKeys,onSendKeys:c.sendKeys},null,8,["items","path","pos","onUpdate","onSendKeys"])]),default:(0,s.withCtx)(()=>[(0,s.createElementVNode)("span",{class:(0,s.normalizeClass)([{open:c.getOpenStatus(t,n.pos)},"p-10 hand"]),onClick:e=>c.addKeys({key:t,pos:n.pos})},(0,s.toDisplayString)(e.label),11,i)]),_:2},1024)):((0,s.openBlock)(),(0,s.createElementBlock)("span",{key:1,class:"p-10 hand",onClick:e=>c.keysDown(t,n.pos)},(0,s.toDisplayString)(e.label),9,r))]))),128))])}var l={name:"NovncConsoleItem",emits:["send-keys","update"],props:{items:{type:Object,required:!0,default:()=>({})},path:{type:Array,required:!0,default:()=>[]},pos:{type:Number,required:!0,default:0}},methods:{keysDown(e,t){this.addKeys({key:e,pos:t}),this.$emit("send-keys")},addKeys({key:e,pos:t}){this.$emit("update",{key:e,pos:t})},sendKeys(){this.$emit("send-keys")},getOpenStatus(e,t){return this.path[t]===e}}},c=(n(83301),n(47433));const d=(0,c.A)(l,[["render",a],["__scopeId","data-v-11c334cb"]]);var u=d},12989:function(e,t,n){"use strict";n.a(e,async function(e,s){try{n.r(t),n.d(t,{CONFIRM_ACTION:function(){return i.Q}});var o=n(63859),i=n(92356),r=(n(71085),n(96363),n(47433)),a=e([i]),l=a.then?(await a)():a;i=l[0];const c=(0,r.A)(i.A,[["render",o.X],["__scopeId","data-v-6eb29beb"]]);t["default"]=c,s()}catch(c){s(c)}})},1183:function(e,t,n){"use strict";n.r(t);var s=n(36758),o=n.n(s),i=n(40935),r=n.n(i),a=r()(o());a.push([e.id,".novnc-console[data-v-0efee1ed]{position:relative;box-sizing:border-box;height:100%;padding:8px;overflow:hidden}.novnc-screen[data-v-0efee1ed]{height:100%}.novnc-overlay[data-v-0efee1ed]{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;display:flex;align-items:center;justify-content:center;overflow:auto;background:rgba(0,0,0,.75);color:#fff}.novnc-overlay h2[data-v-0efee1ed],.novnc-overlay h3[data-v-0efee1ed]{color:#fff}.novnc-overlay p[data-v-0efee1ed]{color:hsla(0,0%,100%,.8)}.novnc-overlay__card[data-v-0efee1ed]{max-width:480px;padding:0 20px}.take-over-actions[data-v-0efee1ed]{display:flex;justify-content:flex-end;width:100%}",""]),t["default"]=a},55437:function(e,t,n){"use strict";n.r(t);var s=n(36758),o=n.n(s),i=n(40935),r=n.n(i),a=r()(o());a.push([e.id,".novnc-screen.is-focused canvas{box-shadow:0 0 0 2px var(--primary)}",""]),t["default"]=a},78154:function(e,t,n){"use strict";n.r(t);var s=n(36758),o=n.n(s),i=n(40935),r=n.n(i),a=r()(o());a.push([e.id,".displayed-keys .banner[data-v-23f4fb4f]{margin:0}.displayed-banners[data-v-23f4fb4f]{max-height:155px;overflow:auto}.actions[data-v-23f4fb4f]{width:100%;display:flex;justify-content:flex-end}",""]),t["default"]=a},38245:function(e,t,n){"use strict";n.r(t);var s=n(36758),o=n.n(s),i=n(40935),r=n.n(i),a=r()(o());a.push([e.id,".combination-keys__container[data-v-11c334cb]{max-width:60px}.combination-keys__container DIV[data-v-11c334cb],.combination-keys__container SPAN[data-v-11c334cb]{display:block;text-align:center}.combination-keys__container SPAN[data-v-11c334cb]{border-radius:3px}.combination-keys__container SPAN.open[data-v-11c334cb],.combination-keys__container SPAN[data-v-11c334cb]:hover{color:var(--primary-hover-text);background:var(--primary-hover-bg)}",""]),t["default"]=a},85843:function(e,t,n){"use strict";n.r(t);var s=n(36758),o=n.n(s),i=n(40935),r=n.n(i),a=r()(o());a.push([e.id,".vm-console[data-v-6eb29beb]{height:100vh;height:100dvh;display:grid;grid-template-rows:32px minmax(0,1fr)}.combination-keys[data-v-6eb29beb]{display:flex;align-items:center;justify-content:space-between;background:#282828}.toolbar-group[data-v-6eb29beb]{display:flex;align-items:center;gap:4px}.confirm-actions[data-v-6eb29beb]{display:flex;justify-content:flex-end;width:100%}.custom-shortcut+.custom-shortcut[data-v-6eb29beb]{margin-top:7px}.console-status[data-v-6eb29beb]{color:#fff;font-size:12px;margin-right:8px}.console-panel[data-v-6eb29beb]{display:flex;flex-direction:column;width:260px;padding:4px}.console-panel__zoom-label[data-v-6eb29beb]{display:flex;justify-content:space-between;margin-top:8px;font-variant-numeric:tabular-nums}.console-panel__zoom[data-v-6eb29beb]{width:100%;margin:4px 0 8px}.console-panel__option[data-v-6eb29beb]{display:flex;align-items:center;gap:6px;margin:2px 0}",""]),t["default"]=a},81806:function(e,t,n){"use strict";n.r(t);var s=n(36758),o=n.n(s),i=n(40935),r=n.n(i),a=r()(o());a.push([e.id,".vm-console .v-popper__arrow-container{display:none}.vm-console .v-popper__popper{margin-top:8px}.vm-console .v-popper__inner{overflow-y:visible}",""]),t["default"]=a},32741:function(e,t,n){"use strict";n.a(e,async function(e,s){try{var o=n(24151),i=n(30894),r=e([i]),a=r.then?(await r)():r;i=a[0];const l={CONNECTING:"connecting",CONNECTED:"connected",RECONNECTING:"reconnecting",DISCONNECTED:"disconnected",FAILED:"failed"},c={IN_USE:"inUse",UNAVAILABLE:"unavailable",DROPPED:"dropped",ERROR:"error"},d=10,u=1e3,h=3e4,m=(e,t)=>{const n=Number.parseInt(e,10);return Number.isNaN(n)?t:Math.min(Math.max(n,0),9)};t.Ay={name:"NovncConsole",components:{ModalWithCard:o.A},props:{url:{type:String,default:""},settings:{type:Object,default:()=>({})},preserveSession:{type:Boolean,default:!0},vmRunning:{type:Boolean,default:!0}},emits:["status-changed","capabilities"],data(){return{rfb:null,status:l.CONNECTING,statusDetail:"",desktopName:"",retryTimes:0,maximumRetryTimes:d,reconnectTimer:null,isClosed:!1,failure:"",showTakeOverModal:!1,focused:!1}},computed:{statusInfo(){return{status:this.status,detail:this.statusDetail,desktopName:this.desktopName,retryTimes:this.retryTimes,maximumRetryTimes:this.maximumRetryTimes}},showError(){return this.status===l.FAILED||this.status===l.DISCONNECTED&&this.failure===c.DROPPED},canTakeOver(){return this.preserveSession&&!this.isClosed},failureTitle(){return this.t(`harvester.virtualMachine.detail.console.failure.${this.failure||c.ERROR}`)},showReconnecting(){return this.status===l.RECONNECTING}},watch:{url(){this.reconnect()},settings:{deep:!0,handler:"applySettings"},statusInfo:{immediate:!0,handler(e){this.$emit("status-changed",e)}}},mounted(){this.$refs.view.addEventListener("focusin",this.onFocusIn),this.$refs.view.addEventListener("focusout",this.onFocusOut),this.$nextTick(()=>{this.connect()})},beforeUnmount(){this.$refs.view?.removeEventListener("focusin",this.onFocusIn),this.$refs.view?.removeEventListener("focusout",this.onFocusOut),this.isClosed=!0,this.clearReconnectTimer(),this.teardown()},methods:{connect(e=!1){if(!this.url||this.isClosed)return;let t;this.teardown(),this.failure="",this.status=this.retryTimes>0?l.RECONNECTING:l.CONNECTING;try{const n=new URL(this.url);this.preserveSession&&n.searchParams.set("preserveSession",!0===e?"false":"true"),t=new i.A(this.$refs.view,n.href,{shared:!0})}catch(n){return this.statusDetail=n?.message||`${n}`,void(this.status=l.FAILED)}t.addEventListener("connect",this.onConnect),t.addEventListener("disconnect",this.onDisconnect),t.addEventListener("securityfailure",this.onSecurityFailure),t.addEventListener("credentialsrequired",this.onCredentialsRequired),t.addEventListener("desktopname",this.onDesktopName),t.addEventListener("capabilities",this.onCapabilities),this.rfb=t,this.applySettings()},reconnect(){this.clearReconnectTimer(),this.isClosed=!1,this.retryTimes=0,this.statusDetail="",this.connect()},takeOver(){this.showTakeOverModal=!0},cancelTakeOver(){this.showTakeOverModal=!1},confirmTakeOver(){this.showTakeOverModal=!1,this.clearReconnectTimer(),this.isClosed=!1,this.retryTimes=0,this.statusDetail="",this.connect(!0)},disconnect(){this.isClosed=!0,this.clearReconnectTimer(),this.teardown(),this.status=l.DISCONNECTED},onConnect(){this.clearReconnectTimer(),this.retryTimes=0,this.statusDetail="",this.status=l.CONNECTED,this.applySettings(),this.focus()},focus(){this.rfb?.focus()},onFocusIn(){this.focused=!0},onFocusOut(){this.focused=!1},onDisconnect(){const e=this.status===l.CONNECTED,t=this.status===l.RECONNECTING;this.teardown(!1),this.isClosed?this.status!==l.FAILED&&(this.status=l.DISCONNECTED):e&&!this.preserveSession?(this.clearReconnectTimer(),this.failure=c.DROPPED,this.statusDetail=this.t("harvester.virtualMachine.detail.console.failureDetail.dropped"),this.status=l.DISCONNECTED):e?this.scheduleReconnect():t?(this.statusDetail=this.t("harvester.virtualMachine.detail.console.status.inUse"),this.scheduleReconnect()):(this.clearReconnectTimer(),this.fail(this.preserveSession&&this.vmRunning?c.IN_USE:c.UNAVAILABLE))},fail(e,t){this.failure=e,this.statusDetail=t??this.t(`harvester.virtualMachine.detail.console.failureDetail.${e}`),this.status=l.FAILED},onSecurityFailure(e){this.isClosed=!0,this.clearReconnectTimer(),this.fail(c.ERROR,e?.detail?.reason||"")},onCredentialsRequired(){this.isClosed=!0,this.clearReconnectTimer(),this.teardown(),this.fail(c.ERROR,this.t("harvester.virtualMachine.detail.console.status.credentialsRequired"))},onDesktopName(e){this.desktopName=e?.detail?.name||""},onCapabilities(e){this.$emit("capabilities",e?.detail?.capabilities||{})},scheduleReconnect(){if(this.clearReconnectTimer(),this.isClosed)return;if(this.retryTimes>=this.maximumRetryTimes)return void this.fail(this.vmRunning?c.IN_USE:c.UNAVAILABLE);this.retryTimes+=1,this.status=l.RECONNECTING;const e=Math.min(u*2**(this.retryTimes-1),h);this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)},clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)},teardown(e=!0){const t=this.rfb;if(t&&(this.rfb=null,t.removeEventListener("connect",this.onConnect),t.removeEventListener("disconnect",this.onDisconnect),t.removeEventListener("securityfailure",this.onSecurityFailure),t.removeEventListener("credentialsrequired",this.onCredentialsRequired),t.removeEventListener("desktopname",this.onDesktopName),t.removeEventListener("capabilities",this.onCapabilities),e))try{t.disconnect()}catch(n){}},applySettings(){const e=this.rfb;if(!e)return;const t=this.settings||{};e.viewOnly=!!t.viewOnly,e.scaleViewport=!!t.scaleViewport,e.resizeSession=!!t.resizeSession,e.clipViewport=!!t.clipViewport,e.dragViewport=!!t.dragViewport,e.zoomPercent=t.zoomPercent,e.focusOnClick=!1!==t.focusOnClick,e.qualityLevel=m(t.qualityLevel,6),e.compressionLevel=m(t.compressionLevel,2)},ctrlAltDelete(){this.rfb?.sendCtrlAltDel()},sendKey(e,t,n){this.rfb?.sendKey(e,t,n)}}},s()}catch(l){s(l)}})},61628:function(e,t,n){"use strict";n.a(e,async function(e,s){try{n.d(t,{Q:function(){return b}});var o=n(35664),i=n(24151),r=n(92043),a=n(88339),l=n(25931),c=n(22885),d=n(32766),u=n(3532),h=n(11497),m=n(9103),v=n(30894),p=e([c,u,v]),y=p.then?(await p)():p;c=y[0],u=y[1],v=y[2];const f="harvester-vnc-console-settings",g="prefered-shortcut-keys",b={CTRL_ALT_DEL:"ctrlAltDel",SOFT_REBOOT:"softReboot"},k={SCALE:"scale",NONE:"none"},C={viewMode:k.NONE,zoomPercent:100,viewOnly:!1,qualityLevel:6,compressionLevel:2},E={ControlLeft:{label:"Ctrl",value:l.A.XK_Control_L},AltLeft:{label:"Alt",value:l.A.XK_Alt_L}},N={Delete:{label:"Del",value:l.A.XK_Delete},PrintScreen:{label:"Print Screen",value:l.A.XK_Print}},w={KeyN:{label:"N",value:l.A.XK_n},KeyT:{label:"T",value:l.A.XK_t},KeyW:{label:"W",value:l.A.XK_w},KeyY:{label:"Y",value:l.A.XK_y}},S={F1:{label:"F1",value:l.A.XK_F1},F2:{label:"F2",value:l.A.XK_F2},F3:{label:"F3",value:l.A.XK_F3},F4:{label:"F4",value:l.A.XK_F4},F5:{label:"F5",value:l.A.XK_F5},F6:{label:"F6",value:l.A.XK_F6},F7:{label:"F7",value:l.A.XK_F7},F8:{label:"F8",value:l.A.XK_F8},F9:{label:"F9",value:l.A.XK_F9},F10:{label:"F10",value:l.A.XK_F10},F11:{label:"F11",value:l.A.XK_F11},F12:{label:"F12",value:l.A.XK_F12}};t.A={name:"NovncConsoleWrapper",components:{ModalWithCard:i.A,NovncConsole:u.Ay,NovncConsoleItem:h.A,NovncConsoleCustomKeys:m.A},async fetch(){const e={vmResource:this.$store.dispatch("harvester/find",{type:d.rk.VM,id:this.value.id})},t=await(0,a.kR)(e);this.vmResource=t.vmResource},props:{value:{type:Object,required:!0,default:()=>({})}},data(){return{keysRecord:[],vmResource:{},renderKeysModal:!1,settings:{...C},capabilities:{},isFullscreen:!1,confirmAction:null,consoleStatus:{status:"connecting",retryTimes:0,maximumRetryTimes:0,desktopName:""}}},computed:{preference(){return this.$store.getters["management/all"](o.m4.PREFERENCE)?.[0]},hideCustomKeysBar(){return!this.preference?.data},savedShortcutKeys(){const e=this.preference?.data?.[g];if(!e)return[];try{return JSON.parse(e)}catch(t){return[]}},preferredShortcutKeys(){return(this.savedShortcutKeys||[]).map(e=>({label:e.map(e=>e.key.charAt(0).toUpperCase()+e.key.slice(1)).join("+"),value:e}))},canSendKeys(){return"connected"===this.consoleStatus.status&&!this.settings.viewOnly},isDown(){return this.isEmpty(this.value)},preserveSession(){return!!this.$store.getters["harvester-common/getFeatureEnabled"]("vncPreserveSession")},vmRunning(){return"Running"===this.value?.status?.phase},url(){const e=`${window.location.hostname}:${window.location.port}`;return`wss://${e}${this.value?.getVMIApiPath}`},allKeys(){return{...E,...N,...w,...S}},keymap(){const e={...E,PrintScreen:N.PrintScreen,...S};return e.AltLeft={...E.AltLeft,keys:{PrintScreen:N.PrintScreen,...S}},e.ControlLeft={...E.ControlLeft,keys:{AltLeft:{...E.AltLeft,keys:{Delete:N.Delete}},...w}},e},hasSoftRebootAction(){return!!this.vmResource?.actions?.softreboot},rfbSettings(){return{viewOnly:this.settings.viewOnly,scaleViewport:this.settings.viewMode===k.SCALE,zoomPercent:(0,v.n)(this.settings.zoomPercent),resizeSession:!1,clipViewport:!1,dragViewport:!1,qualityLevel:this.settings.qualityLevel,compressionLevel:this.settings.compressionLevel}},viewModeOptions(){return Object.values(k).map(e=>({value:e,label:this.t(`harvester.virtualMachine.detail.console.settings.viewMode.${e}`)}))},statusLabel(){const{status:e,retryTimes:t,maximumRetryTimes:n}=this.consoleStatus;return"reconnecting"===e?this.t("harvester.virtualMachine.detail.console.status.reconnecting",{retryTimes:t,maximumRetryTimes:n}):"connected"===e&&this.settings.viewOnly?this.t("harvester.virtualMachine.detail.console.status.connectedViewOnly"):this.t(`harvester.virtualMachine.detail.console.status.${e}`)}},watch:{settings:{deep:!0,handler(e){window.localStorage.setItem(f,JSON.stringify(e))}}},mounted(){this.loadSettings(),document.addEventListener("fullscreenchange",this.onFullscreenChange)},beforeUnmount(){document.removeEventListener("fullscreenchange",this.onFullscreenChange)},methods:{isEmpty(e){return void 0!==e&&0===Object.keys(e).length},close(){this.$refs.novncConsole.disconnect()},update({key:e,pos:t}){this.keysRecord.splice(t,this.keysRecord.length-t,e)},sendKeys(){this.canSendKeys&&this.$refs.novncConsole&&(this.keysRecord.forEach(e=>{this.$refs.novncConsole.sendKey(this.allKeys[e].value,e,!0)}),[...this.keysRecord].reverse().forEach(e=>{this.$refs.novncConsole.sendKey(this.allKeys[e].value,e,!1)}),this.$refs.popover.hide(),this.keysRecord=[],this.$refs.novncConsole.focus())},sendCustomKeys(e){if(!this.canSendKeys||!this.$refs.novncConsole)return;const t=[].concat(e);t.forEach(e=>{this.$refs.novncConsole.sendKey(c.Hn(e),c.lv(e),!0)}),[...t].reverse().forEach(e=>{this.$refs.novncConsole.sendKey(c.Hn(e),c.lv(e),!1)}),this.$refs.novncConsole.focus()},showKeysModal(){this.renderKeysModal=!0},hideKeysModal(){this.renderKeysModal=!1},reconnect(){this.$refs.novncConsole.reconnect()},loadSettings(){try{const e=JSON.parse(window.localStorage.getItem(f)||"{}");this.settings={viewMode:Object.values(k).includes(e?.viewMode)?e.viewMode:C.viewMode,zoomPercent:(0,v.n)(e?.zoomPercent??C.zoomPercent),viewOnly:!0===e?.viewOnly,qualityLevel:e?.qualityLevel??C.qualityLevel,compressionLevel:e?.compressionLevel??C.compressionLevel}}catch(e){this.settings={...C}}},onStatusChanged(e){this.consoleStatus=e},onCapabilities(e){this.capabilities=e},ctrlAltDelete(){this.canSendKeys&&(this.confirmAction=b.CTRL_ALT_DEL)},softReboot(){this.confirmAction=b.SOFT_REBOOT},cancelConfirm(){this.confirmAction=null},runConfirmedAction(){const e=this.confirmAction;this.confirmAction=null,e===b.CTRL_ALT_DEL&&this.canSendKeys?this.$refs.novncConsole?.ctrlAltDelete():e===b.SOFT_REBOOT&&this.vmResource.doSoftReboot()},async toggleFullscreen(){try{document.fullscreenElement?await document.exitFullscreen():(await document.documentElement.requestFullscreen(),await(navigator.keyboard?.lock?.(["KeyW","F11"])))}catch(e){this.$store.dispatch("growl/fromError",{title:this.t("generic.notification.title.error",{name:(0,r.ZD)(this.value.metadata.name)}),err:e},{root:!0})}},onFullscreenChange(){this.isFullscreen=!!document.fullscreenElement,this.isFullscreen||navigator.keyboard?.unlock?.()}}},s()}catch(f){s(f)}})},30894:function(e,t,n){"use strict";n.a(e,async function(e,s){try{n.d(t,{A:function(){return c},n:function(){return l}});var o=n(89840),i=e([o]),r=i.then?(await i)():i;function l(e){const t=Number(e);return Number.isFinite(t)?Math.min(200,Math.max(50,10*Math.round(t/10))):100}o=r[0];class c extends o.A{get zoomPercent(){return this._zoomPercent??100}set zoomPercent(e){this._zoomPercent=l(e),this._updateScale()}_updateScale(){this.scaleViewport?super._updateScale():(this._display.scale=this.zoomPercent/100,this._fixScrollbars())}}s()}catch(a){s(a)}})},3485:function(e,t,n){"use strict";n.a(e,async function(e,s){try{n.d(t,{Ay:function(){return o.Ay}});var o=n(32741),i=e([o]),r=i.then?(await i)():i;o=r[0],s()}catch(a){s(a)}})},92356:function(e,t,n){"use strict";n.a(e,async function(e,s){try{n.d(t,{A:function(){return o.A},Q:function(){return o.Q}});var o=n(61628),i=e([o]),r=i.then?(await i)():i;o=r[0],s()}catch(a){s(a)}})},55512:function(e,t,n){"use strict";n.d(t,{X:function(){return u}});var s=n(9274);const o={class:"novnc-console"},i={key:0,class:"novnc-overlay"},r={key:0,class:"novnc-overlay__card text-center"},a={key:0,class:"mt-10"},l={key:1,class:"text-center"},c={key:0,class:"mt-10"},d={class:"take-over-actions"};function u(e,t,n,u,h,m){const v=(0,s.resolveComponent)("ModalWithCard");return(0,s.openBlock)(),(0,s.createElementBlock)("div",o,[(0,s.createElementVNode)("div",{ref:"view",class:(0,s.normalizeClass)(["novnc-screen",{"is-focused":h.focused}])},null,2),m.showError||m.showReconnecting?((0,s.openBlock)(),(0,s.createElementBlock)("div",i,[m.showError?((0,s.openBlock)(),(0,s.createElementBlock)("div",r,[(0,s.createElementVNode)("h3",null,(0,s.toDisplayString)(m.failureTitle),1),h.statusDetail?((0,s.openBlock)(),(0,s.createElementBlock)("p",a,(0,s.toDisplayString)(h.statusDetail),1)):(0,s.createCommentVNode)("",!0),(0,s.createElementVNode)("button",{class:"btn role-primary mt-20",onClick:t[0]||(t[0]=(...e)=>m.reconnect&&m.reconnect(...e))},(0,s.toDisplayString)(e.t("harvester.action.reconnect")),1),m.canTakeOver?((0,s.openBlock)(),(0,s.createElementBlock)("button",{key:1,class:"btn role-secondary mt-20 ml-10",onClick:t[1]||(t[1]=(...e)=>m.takeOver&&m.takeOver(...e))},(0,s.toDisplayString)(e.t("harvester.virtualMachine.detail.console.takeOver.label")),1)):(0,s.createCommentVNode)("",!0)])):((0,s.openBlock)(),(0,s.createElementBlock)("div",l,[(0,s.createElementVNode)("h2",null,(0,s.toDisplayString)(e.t("vncConsole.reconnecting.message"))+":"+(0,s.toDisplayString)(h.retryTimes)+" of "+(0,s.toDisplayString)(h.maximumRetryTimes),1),h.statusDetail?((0,s.openBlock)(),(0,s.createElementBlock)("p",c,(0,s.toDisplayString)(h.statusDetail),1)):(0,s.createCommentVNode)("",!0)]))])):(0,s.createCommentVNode)("",!0),h.showTakeOverModal?((0,s.openBlock)(),(0,s.createBlock)(v,{key:1,name:"takeOverConsole",width:480,onFinish:m.cancelTakeOver},{title:(0,s.withCtx)(()=>[(0,s.createTextVNode)((0,s.toDisplayString)(e.t("harvester.virtualMachine.detail.console.takeOver.title")),1)]),content:(0,s.withCtx)(()=>[(0,s.createElementVNode)("p",null,(0,s.toDisplayString)(e.t("harvester.virtualMachine.detail.console.takeOver.confirm")),1)]),footer:(0,s.withCtx)(()=>[(0,s.createElementVNode)("div",d,[(0,s.createElementVNode)("button",{class:"btn role-secondary mr-10",onClick:t[2]||(t[2]=(...e)=>m.cancelTakeOver&&m.cancelTakeOver(...e))},(0,s.toDisplayString)(e.t("generic.cancel")),1),(0,s.createElementVNode)("button",{class:"btn role-primary",onClick:t[3]||(t[3]=(...e)=>m.confirmTakeOver&&m.confirmTakeOver(...e))},(0,s.toDisplayString)(e.t("harvester.virtualMachine.detail.console.takeOver.label")),1)])]),_:1},8,["onFinish"])):(0,s.createCommentVNode)("",!0)])}},63859:function(e,t,n){"use strict";n.d(t,{X:function(){return S}});var s=n(9274);const o={id:"app"},i={class:"vm-console"},r={class:"combination-keys"},a={class:"toolbar-group"},l=["disabled"],c=["disabled"],d={class:"btn btn-sm bg-primary"},u=["disabled","onClick"],h={class:"btn btn-sm bg-primary"},m={class:"console-panel"},v={class:"console-panel__option"},p=["value"],y={for:"vnc-zoom",class:"console-panel__zoom-label"},f=["disabled","aria-valuetext"],g={class:"console-panel__option"},b={for:"vnc-quality",class:"console-panel__zoom-label"},k={for:"vnc-compression",class:"console-panel__zoom-label"},C={class:"toolbar-group"},E={class:"console-status",role:"status","aria-live":"polite"},N={key:1},w={class:"confirm-actions"};function S(e,t,n,S,_,A){const D=(0,s.resolveComponent)("novnc-console-item"),R=(0,s.resolveComponent)("v-dropdown"),V=(0,s.resolveComponent)("NovncConsole"),K=(0,s.resolveComponent)("ModalWithCard"),M=(0,s.resolveComponent)("NovncConsoleCustomKeys");return(0,s.openBlock)(),(0,s.createElementBlock)("div",o,[(0,s.createElementVNode)("div",i,[(0,s.createElementVNode)("div",r,[(0,s.createElementVNode)("div",a,[(0,s.createVNode)(R,{ref:"popover",placement:"top",trigger:"click",container:!1,onAutoHide:t[0]||(t[0]=e=>_.keysRecord=[])},{popper:(0,s.withCtx)(()=>[(0,s.createVNode)(D,{items:A.keymap,path:_.keysRecord,pos:0,onUpdate:A.update,onSendKeys:A.sendKeys},null,8,["items","path","onUpdate","onSendKeys"])]),default:(0,s.withCtx)(()=>[(0,s.createElementVNode)("button",{class:"btn btn-sm bg-primary",disabled:!A.canSendKeys},(0,s.toDisplayString)(e.t("harvester.virtualMachine.detail.console.shortcutKeys")),9,l)]),_:1},512),(0,s.createElementVNode)("button",{class:"btn btn-sm bg-primary",disabled:!A.canSendKeys,onClick:t[1]||(t[1]=(...e)=>A.ctrlAltDelete&&A.ctrlAltDelete(...e))},(0,s.toDisplayString)(e.t("harvester.virtualMachine.detail.console.ctrlAltDel")),9,c),A.hideCustomKeysBar?(0,s.createCommentVNode)("",!0):((0,s.openBlock)(),(0,s.createBlock)(R,{key:0,placement:"top",trigger:"click",container:!1},{popper:(0,s.withCtx)(()=>[(0,s.createElementVNode)("div",null,[(0,s.createElementVNode)("button",{class:"btn btn-sm bg-primary",onClick:t[2]||(t[2]=(...e)=>A.showKeysModal&&A.showKeysModal(...e))},(0,s.toDisplayString)(e.t("harvester.virtualMachine.detail.console.management")),1)]),t[13]||(t[13]=(0,s.createElementVNode)("hr",null,null,-1)),((0,s.openBlock)(!0),(0,s.createElementBlock)(s.Fragment,null,(0,s.renderList)(A.preferredShortcutKeys,(e,t)=>((0,s.openBlock)(),(0,s.createElementBlock)("div",{key:t,class:"custom-shortcut"},[(0,s.createElementVNode)("button",{class:"btn btn-sm bg-primary",disabled:!A.canSendKeys,onClick:t=>A.sendCustomKeys(e.value)},(0,s.toDisplayString)(e.label),9,u)]))),128))]),default:(0,s.withCtx)(()=>[(0,s.createElementVNode)("button",d,(0,s.toDisplayString)(e.t("harvester.virtualMachine.detail.console.customShortcutKeys")),1)]),_:1})),(0,s.createVNode)(R,{placement:"top",trigger:"click",container:!1},{popper:(0,s.withCtx)(()=>[(0,s.createElementVNode)("div",m,[(0,s.createElementVNode)("label",null,(0,s.toDisplayString)(e.t("harvester.virtualMachine.detail.console.settings.viewMode.label")),1),((0,s.openBlock)(!0),(0,s.createElementBlock)(s.Fragment,null,(0,s.renderList)(A.viewModeOptions,e=>((0,s.openBlock)(),(0,s.createElementBlock)("div",{key:e.value},[(0,s.createElementVNode)("label",v,[(0,s.withDirectives)((0,s.createElementVNode)("input",{"onUpdate:modelValue":t[3]||(t[3]=e=>_.settings.viewMode=e),type:"radio",value:e.value},null,8,p),[[s.vModelRadio,_.settings.viewMode]]),(0,s.createTextVNode)(" "+(0,s.toDisplayString)(e.label),1)])]))),128)),(0,s.createElementVNode)("label",y,[(0,s.createElementVNode)("span",null,(0,s.toDisplayString)(e.t("harvester.virtualMachine.detail.console.settings.zoom")),1),(0,s.createElementVNode)("span",null,(0,s.toDisplayString)(_.settings.zoomPercent)+"%",1)]),(0,s.withDirectives)((0,s.createElementVNode)("input",{id:"vnc-zoom","onUpdate:modelValue":t[4]||(t[4]=e=>_.settings.zoomPercent=e),class:"console-panel__zoom",type:"range",min:"50",max:"200",step:"10",disabled:"scale"===_.settings.viewMode,"aria-valuetext":`${_.settings.zoomPercent}%`},null,8,f),[[s.vModelText,_.settings.zoomPercent,void 0,{number:!0}]]),(0,s.createElementVNode)("label",g,[(0,s.withDirectives)((0,s.createElementVNode)("input",{"onUpdate:modelValue":t[5]||(t[5]=e=>_.settings.viewOnly=e),type:"checkbox"},null,512),[[s.vModelCheckbox,_.settings.viewOnly]]),(0,s.createTextVNode)(" "+(0,s.toDisplayString)(e.t("harvester.virtualMachine.detail.console.settings.viewOnly")),1)]),(0,s.createElementVNode)("label",b,[(0,s.createElementVNode)("span",null,(0,s.toDisplayString)(e.t("harvester.virtualMachine.detail.console.settings.quality")),1),(0,s.createElementVNode)("span",null,(0,s.toDisplayString)(_.settings.qualityLevel),1)]),(0,s.withDirectives)((0,s.createElementVNode)("input",{id:"vnc-quality","onUpdate:modelValue":t[6]||(t[6]=e=>_.settings.qualityLevel=e),class:"console-panel__zoom",type:"range",min:"0",max:"9",step:"1"},null,512),[[s.vModelText,_.settings.qualityLevel,void 0,{number:!0}]]),(0,s.createElementVNode)("label",k,[(0,s.createElementVNode)("span",null,(0,s.toDisplayString)(e.t("harvester.virtualMachine.detail.console.settings.compression")),1),(0,s.createElementVNode)("span",null,(0,s.toDisplayString)(_.settings.compressionLevel),1)]),(0,s.withDirectives)((0,s.createElementVNode)("input",{id:"vnc-compression","onUpdate:modelValue":t[7]||(t[7]=e=>_.settings.compressionLevel=e),class:"console-panel__zoom",type:"range",min:"0",max:"9",step:"1"},null,512),[[s.vModelText,_.settings.compressionLevel,void 0,{number:!0}]])])]),default:(0,s.withCtx)(()=>[(0,s.createElementVNode)("button",h,(0,s.toDisplayString)(e.t("harvester.virtualMachine.detail.console.settings.label")),1)]),_:1})]),(0,s.createElementVNode)("div",C,[(0,s.createElementVNode)("span",E,(0,s.toDisplayString)(A.statusLabel),1),A.hasSoftRebootAction?((0,s.openBlock)(),(0,s.createElementBlock)("button",{key:0,class:"btn btn-sm bg-primary",onClick:t[8]||(t[8]=(...e)=>A.softReboot&&A.softReboot(...e))},(0,s.toDisplayString)(e.t("harvester.action.softreboot")),1)):(0,s.createCommentVNode)("",!0),(0,s.createElementVNode)("button",{class:"btn btn-sm bg-primary",onClick:t[9]||(t[9]=(...e)=>A.reconnect&&A.reconnect(...e))},(0,s.toDisplayString)(e.t("harvester.action.reconnect")),1),(0,s.createElementVNode)("button",{class:"btn btn-sm bg-primary",onClick:t[10]||(t[10]=(...e)=>A.toggleFullscreen&&A.toggleFullscreen(...e))},(0,s.toDisplayString)(_.isFullscreen?e.t("harvester.virtualMachine.detail.console.fullscreen.exit"):e.t("harvester.virtualMachine.detail.console.fullscreen.enter")),1)])]),A.url&&!A.isDown?((0,s.openBlock)(),(0,s.createBlock)(V,{key:0,ref:"novncConsole",url:A.url,settings:A.rfbSettings,"preserve-session":A.preserveSession,"vm-running":A.vmRunning,onStatusChanged:A.onStatusChanged,onCapabilities:A.onCapabilities},null,8,["url","settings","preserve-session","vm-running","onStatusChanged","onCapabilities"])):(0,s.createCommentVNode)("",!0),A.isDown?((0,s.openBlock)(),(0,s.createElementBlock)("p",N,(0,s.toDisplayString)(e.t("harvester.virtualMachine.detail.console.down")),1)):(0,s.createCommentVNode)("",!0),_.confirmAction?((0,s.openBlock)(),(0,s.createBlock)(K,{key:2,name:"confirmConsoleAction",width:480,"return-focus-selector":".novnc-screen canvas",onFinish:A.cancelConfirm},{title:(0,s.withCtx)(()=>[(0,s.createTextVNode)((0,s.toDisplayString)(e.t(`harvester.virtualMachine.detail.console.confirm.${_.confirmAction}.title`)),1)]),content:(0,s.withCtx)(()=>[(0,s.createElementVNode)("p",null,(0,s.toDisplayString)(e.t(`harvester.virtualMachine.detail.console.confirm.${_.confirmAction}.message`)),1)]),footer:(0,s.withCtx)(()=>[(0,s.createElementVNode)("div",w,[(0,s.createElementVNode)("button",{class:"btn role-secondary mr-10",onClick:t[11]||(t[11]=(...e)=>A.cancelConfirm&&A.cancelConfirm(...e))},(0,s.toDisplayString)(e.t("generic.cancel")),1),(0,s.createElementVNode)("button",{class:"btn role-primary","data-testid":"vnc-confirm-action",onClick:t[12]||(t[12]=(...e)=>A.runConfirmedAction&&A.runConfirmedAction(...e))},(0,s.toDisplayString)(e.t(`harvester.virtualMachine.detail.console.confirm.${_.confirmAction}.button`)),1)])]),_:1},8,["onFinish"])):(0,s.createCommentVNode)("",!0),_.renderKeysModal?((0,s.openBlock)(),(0,s.createBlock)(M,{key:3,onClose:A.hideKeysModal},null,8,["onClose"])):(0,s.createCommentVNode)("",!0)])])}},91352:function(e,t,n){"use strict";n(93599)},92274:function(e,t,n){"use strict";n(67533)},71085:function(e,t,n){"use strict";n(76320)},96363:function(e,t,n){"use strict";n(93326)},93599:function(e,t,n){var s=n(1183);s.__esModule&&(s=s.default),"string"===typeof s&&(s=[[e.id,s,""]]),s.locals&&(e.exports=s.locals);var o=n(74825).A;o("11a9ef73",s,!0,{sourceMap:!1,shadowMode:!1})},67533:function(e,t,n){var s=n(55437);s.__esModule&&(s=s.default),"string"===typeof s&&(s=[[e.id,s,""]]),s.locals&&(e.exports=s.locals);var o=n(74825).A;o("f9337742",s,!0,{sourceMap:!1,shadowMode:!1})},87306:function(e,t,n){var s=n(78154);s.__esModule&&(s=s.default),"string"===typeof s&&(s=[[e.id,s,""]]),s.locals&&(e.exports=s.locals);var o=n(74825).A;o("d079895e",s,!0,{sourceMap:!1,shadowMode:!1})},83301:function(e,t,n){var s=n(38245);s.__esModule&&(s=s.default),"string"===typeof s&&(s=[[e.id,s,""]]),s.locals&&(e.exports=s.locals);var o=n(74825).A;o("5e3edba4",s,!0,{sourceMap:!1,shadowMode:!1})},76320:function(e,t,n){var s=n(85843);s.__esModule&&(s=s.default),"string"===typeof s&&(s=[[e.id,s,""]]),s.locals&&(e.exports=s.locals);var o=n(74825).A;o("5b7894df",s,!0,{sourceMap:!1,shadowMode:!1})},93326:function(e,t,n){var s=n(81806);s.__esModule&&(s=s.default),"string"===typeof s&&(s=[[e.id,s,""]]),s.locals&&(e.exports=s.locals);var o=n(74825).A;o("23ec3cf3",s,!0,{sourceMap:!1,shadowMode:!1})}}]);
//# sourceMappingURL=harvester-1.10.0-dev.umd.min.989.js.map