Skip to content

Commit

Permalink
feat(xo-6): add Ctrl+Alt+Del (#8239)
Browse files Browse the repository at this point in the history
functionality to console
  • Loading branch information
S3bastianCZ authored Jan 20, 2025
1 parent a96d5e6 commit 9c97ac9
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 17 deletions.
6 changes: 3 additions & 3 deletions @xen-orchestra/lite/src/views/host/HostConsoleView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<UiStatusPanel v-else-if="!isHostRunning" :image-source="monitor" :title="$t('power-on-host-for-console')" />
<template v-else-if="host && hostConsole">
<VtsLayoutConsole>
<VtsRemoteConsole v-if="url" ref="consoleElement" :url :is-console-available="isConsoleAvailable" />
<VtsRemoteConsole v-if="url" ref="console-element" :url :is-console-available="isConsoleAvailable" />
<template #actions>
<VtsActionsConsole
:open-in-new-tab="openInNewTab"
Expand Down Expand Up @@ -39,7 +39,7 @@ import VtsLayoutConsole from '@core/components/console/VtsLayoutConsole.vue'
import VtsRemoteConsole from '@core/components/console/VtsRemoteConsole.vue'
import VtsDivider from '@core/components/divider/VtsDivider.vue'
import { useUiStore } from '@core/stores/ui.store'
import { computed, ref } from 'vue'
import { computed, useTemplateRef } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRoute, useRouter } from 'vue-router'
Expand Down Expand Up @@ -102,7 +102,7 @@ const isConsoleAvailable = computed(() =>
controlDomain.value !== undefined ? !isHostOperationPending(host.value!, STOP_OPERATIONS) : false
)
const consoleElement = ref()
const consoleElement = useTemplateRef('console-element')
const sendCtrlAltDel = () => consoleElement.value?.sendCtrlAltDel()
Expand Down
6 changes: 3 additions & 3 deletions @xen-orchestra/lite/src/views/vm/VmConsoleView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<UiStatusPanel v-else-if="!isVmRunning" :image-source="monitor" :title="$t('power-on-vm-for-console')" />
<template v-else-if="vm && vmConsole">
<VtsLayoutConsole>
<VtsRemoteConsole v-if="url" ref="consoleElement" :url :is-console-available="isConsoleAvailable" />
<VtsRemoteConsole v-if="url" ref="console-element" :url :is-console-available="isConsoleAvailable" />
<template #actions>
<VtsActionsConsole
:open-in-new-tab="openInNewTab"
Expand Down Expand Up @@ -40,7 +40,7 @@ import VtsDivider from '@core/components/divider/VtsDivider.vue'
import { useUiStore } from '@core/stores/ui.store'
import { useActiveElement, useMagicKeys, whenever } from '@vueuse/core'
import { logicAnd } from '@vueuse/math'
import { computed, ref } from 'vue'
import { computed, useTemplateRef } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRoute, useRouter } from 'vue-router'
Expand Down Expand Up @@ -101,7 +101,7 @@ const isConsoleAvailable = computed(() =>
vm.value !== undefined ? !isVmOperationPending(vm.value, STOP_OPERATIONS) : false
)
const consoleElement = ref()
const consoleElement = useTemplateRef('console-element')
const sendCtrlAltDel = () => consoleElement.value?.sendCtrlAltDel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
{{ $t('open-console-in-new-tab') }}
</UiButton>
<UiButton
v-tooltip="sendCtrlAltDel === undefined ? $t('coming-soon') : undefined"
class="button"
accent="info"
variant="tertiary"
size="medium"
:disabled="sendCtrlAltDel === undefined"
:left-icon="faKeyboard"
@click="sendCtrlAltDel"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div :class="uiStore.isMobile ? 'mobile' : undefined" class="vts-remote-console">
<VtsLoadingHero :disabled="isReady" type="panel" />
<div ref="consoleContainer" class="console" />
<div ref="console-container" class="console" />
</div>
</template>

Expand All @@ -11,7 +11,7 @@ import { useUiStore } from '@core/stores/ui.store'
import VncClient from '@novnc/novnc/lib/rfb'
import { promiseTimeout } from '@vueuse/shared'
import { fibonacci } from 'iterable-backoff'
import { onBeforeUnmount, ref, watchEffect } from 'vue'
import { onBeforeUnmount, ref, useTemplateRef, watchEffect } from 'vue'
const props = defineProps<{
url: URL
Expand All @@ -23,7 +23,7 @@ const uiStore = useUiStore()
const N_TOTAL_TRIES = 8
const FIBONACCI_MS_ARRAY: number[] = Array.from(fibonacci().toMs().take(N_TOTAL_TRIES))
const consoleContainer = ref<HTMLDivElement | null>(null)
const consoleContainer = useTemplateRef<HTMLDivElement | null>('console-container')
const isReady = ref(false)
let vncClient: VncClient | undefined
Expand Down
9 changes: 6 additions & 3 deletions @xen-orchestra/web/src/pages/host/[id]/console.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<p v-if="!isHostConsoleRunning" class="typo h5-medium">{{ $t('power-on-host-for-console') }}</p>
<VtsLayoutConsole v-else>
<VtsRemoteConsole :url :is-console-available="isHostConsoleAvailable" />
<VtsRemoteConsole ref="console-element" :url :is-console-available="isHostConsoleAvailable" />
<template #actions>
<VtsActionsConsole />
<VtsActionsConsole :send-ctrl-alt-del="sendCtrlAltDel" />
<VtsDivider type="stretch" />
<VtsClipboardConsole />
</template>
Expand All @@ -18,7 +18,7 @@ import VtsClipboardConsole from '@core/components/console/VtsClipboardConsole.vu
import VtsLayoutConsole from '@core/components/console/VtsLayoutConsole.vue'
import VtsRemoteConsole from '@core/components/console/VtsRemoteConsole.vue'
import VtsDivider from '@core/components/divider/VtsDivider.vue'
import { computed } from 'vue'
import { computed, useTemplateRef } from 'vue'
const props = defineProps<{
host: XoHost
Expand All @@ -37,4 +37,7 @@ const isHostConsoleRunning = computed(() => props.host.power_state === 'Running'
const isHostConsoleAvailable = computed(() =>
props.host.controlDomain !== undefined ? !isHostOperationPending(props.host!, STOP_OPERATIONS) : false
)
const consoleElement = useTemplateRef('console-element')
const sendCtrlAltDel = () => consoleElement.value?.sendCtrlAltDel()
</script>
9 changes: 6 additions & 3 deletions @xen-orchestra/web/src/pages/vm/[id]/console.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<p v-if="!isVmConsoleRunning" class="typo h5-medium">{{ $t('power-on-vm-for-console') }}</p>
<VtsLayoutConsole v-else>
<VtsRemoteConsole :url :is-console-available="isConsoleAvailable" />
<VtsRemoteConsole ref="console-element" :url :is-console-available="isConsoleAvailable" />
<template #actions>
<VtsActionsConsole />
<VtsActionsConsole :send-ctrl-alt-del="sendCtrlAltDel" />
<VtsDivider type="stretch" />
<VtsClipboardConsole />
</template>
Expand All @@ -19,7 +19,7 @@ import VtsClipboardConsole from '@core/components/console/VtsClipboardConsole.vu
import VtsLayoutConsole from '@core/components/console/VtsLayoutConsole.vue'
import VtsRemoteConsole from '@core/components/console/VtsRemoteConsole.vue'
import VtsDivider from '@core/components/divider/VtsDivider.vue'
import { computed } from 'vue'
import { computed, useTemplateRef } from 'vue'
const props = defineProps<{
vm: XoVm
Expand All @@ -44,4 +44,7 @@ const isVmConsoleRunning = computed(() => props.vm.power_state === 'Running' &&
const isConsoleAvailable = computed(() =>
props.vm !== undefined ? !isVmOperatingPending(props.vm, STOP_OPERATIONS) : false
)
const consoleElement = useTemplateRef('console-element')
const sendCtrlAltDel = () => consoleElement.value?.sendCtrlAltDel()
</script>
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- **XO 6**:
- [Console]: Displays a loader when the console is loading (PR [#8226](https://github.com/vatesfr/xen-orchestra/pull/8226))
- [i18n] Add Spanish translation (contribution made by [@DSJ2](https://github.com/DSJ2)) (PR [#8220](https://github.com/vatesfr/xen-orchestra/pull/8220))
- [Console]: Add Ctrl+Alt+Del functionality to console (PR [#8239](https://github.com/vatesfr/xen-orchestra/pull/8239))

### Bug fixes

Expand Down

0 comments on commit 9c97ac9

Please sign in to comment.