Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web-core): add loading state on console #8226

Merged
merged 9 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions @xen-orchestra/lite/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## **next**

- Fix persistent scrollbar on the right (PR [#8191](https://github.com/vatesfr/xen-orchestra/pull/8191))
- [Console]: Displays a loader when the console is loading (PR [#8226](https://github.com/vatesfr/xen-orchestra/pull/8226))

## **0.6.0** (2024-11-29)

Expand Down
30 changes: 21 additions & 9 deletions @xen-orchestra/lite/src/components/RemoteConsole.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<template>
<div ref="vmConsoleContainer" class="vm-console" />
<div class="remote-console">
<VtsLoadingHero :disabled="isReady" type="panel" />
<div ref="vmConsoleContainer" class="vm-console" />
</div>
</template>

<script lang="ts" setup>
import { useXenApiStore } from '@/stores/xen-api.store'
import VtsLoadingHero from '@core/components/state-hero/VtsLoadingHero.vue'
import VncClient from '@novnc/novnc/lib/rfb'
import { promiseTimeout } from '@vueuse/shared'
import { fibonacci } from 'iterable-backoff'
Expand All @@ -18,6 +22,8 @@ const N_TOTAL_TRIES = 8
const FIBONACCI_MS_ARRAY: number[] = Array.from(fibonacci().toMs().take(N_TOTAL_TRIES))

const vmConsoleContainer = ref<HTMLDivElement>()
const isReady = ref(false)

const xenApiStore = useXenApiStore()
const url = computed(() => {
if (xenApiStore.currentSessionId == null) {
Expand Down Expand Up @@ -54,9 +60,11 @@ function handleDisconnectionEvent() {

function handleConnectionEvent() {
nConnectionAttempts = 0
isReady.value = true
}

function clearVncClient() {
isReady.value = false
if (vncClient === undefined) {
return
}
Expand Down Expand Up @@ -109,17 +117,21 @@ defineExpose({
</script>

<style lang="postcss" scoped>
.vm-console {
flex: 1;
.remote-console {
flex-grow: 1;
max-width: 100%;

& > :deep(div) {
background-color: transparent !important;
}
.vm-console {
height: 100%;

/* Required because the library adds "margin: auto" to the canvas which makes the canvas centered in space and not aligned to the rest of the layout */
:deep(canvas) {
margin: 0 auto !important;
& > :deep(div) {
background-color: transparent !important;
}

/* Required because the library adds "margin: auto" to the canvas which makes the canvas centered in space and not aligned to the rest of the layout */
:deep(canvas) {
margin: 0 auto !important;
}
MathieuRA marked this conversation as resolved.
Show resolved Hide resolved
}
}
</style>
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<template>
<div :class="uiStore.isMobile ? 'mobile' : undefined" class="vts-remote-console">
<VtsLoadingHero :disabled="isReady" type="panel" />
<div ref="consoleContainer" class="console" />
</div>
</template>

<script lang="ts" setup>
import VtsLoadingHero from '@core/components/state-hero/VtsLoadingHero.vue'
import { useUiStore } from '@core/stores/ui.store'
import VncClient from '@novnc/novnc/lib/rfb'
import { promiseTimeout } from '@vueuse/shared'
Expand All @@ -19,6 +21,7 @@ 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 isReady = ref(false)

let vncClient: VncClient | undefined
let nConnectionAttempts = 0
Expand All @@ -43,9 +46,11 @@ function handleDisconnectionEvent() {

function handleConnectionEvent() {
nConnectionAttempts = 0
isReady.value = true
}

function clearVncClient() {
isReady.value = false
if (vncClient === undefined) {
return
}
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

### Enhancements

- **XO 6**:
- [Console]: Displays a loader when the console is loading (PR [#8226](https://github.com/vatesfr/xen-orchestra/pull/8226))

> Users must be able to say: “Nice enhancement, I'm eager to test it”

### Bug fixes
Expand All @@ -31,4 +34,6 @@

<!--packages-start-->

- @xen-orchestra/web-core minor

MathieuRA marked this conversation as resolved.
Show resolved Hide resolved
<!--packages-end-->
Loading