From 107fe1d3939a193474d0f8d23b8ca17703ee31a1 Mon Sep 17 00:00:00 2001 From: MoritzWeber Date: Mon, 11 Nov 2024 11:17:41 +0100 Subject: [PATCH] feat: Handle unready sessions in session viewer This enabled direct connection to the session viewer. Instead of a separate components to select sessions, it's no embedded into the "Active Sessions" view. This makes the session viewer more visible and requires less user interaction. Read-only sessions are now directly connected after creation. The Session Viewer shows the current status of the session and takes over the session refresh on it's own. Once the session is ready, it connects to it. --- frontend/src/app/app-routing.module.ts | 6 +- .../auth/auth-guard/auth-guard.service.ts | 2 +- .../src/app/general/header/header.stories.ts | 4 - .../app/general/nav-bar/nav-bar.service.ts | 5 - .../floating-window-manager.component.html | 87 +++++----- .../floating-window-manager.component.ts | 4 +- .../session-iframe.component.css | 12 ++ .../session-iframe.component.html | 55 ++++++- .../session-iframe.component.ts | 8 +- .../session/session-viewer.component.html | 43 +++++ .../session/session-viewer.component.ts | 72 +++++++++ .../session/session-viewer.service.ts | 75 +++++++-- .../session/session-viewer.stories.ts | 149 ++++++++++++++++++ .../sessions/session/session.component.css | 8 - .../sessions/session/session.component.html | 118 -------------- .../app/sessions/session/session.component.ts | 118 -------------- .../tiling-window-manager.component.html | 65 ++++---- .../tiling-window-manager.component.ts | 4 +- .../active-sessions.component.css | 8 +- .../active-sessions.component.docs.mdx | 50 ------ .../active-sessions.component.html | 82 ++++++---- .../active-sessions.component.ts | 42 ++++- .../create-readonly-session.component.html | 2 +- ...eate-readonly-model-options.component.html | 2 +- ...eate-readonly-session-dialog.component.css | 8 - ...readonly-session-dialog.component.docs.mdx | 36 ----- ...ate-readonly-session-dialog.component.html | 11 +- ...reate-readonly-session-dialog.component.ts | 7 +- frontend/src/styles.css | 4 +- 29 files changed, 586 insertions(+), 501 deletions(-) create mode 100644 frontend/src/app/sessions/session/session-viewer.component.html create mode 100644 frontend/src/app/sessions/session/session-viewer.component.ts create mode 100644 frontend/src/app/sessions/session/session-viewer.stories.ts delete mode 100644 frontend/src/app/sessions/session/session.component.css delete mode 100644 frontend/src/app/sessions/session/session.component.html delete mode 100644 frontend/src/app/sessions/session/session.component.ts delete mode 100644 frontend/src/app/sessions/user-sessions-wrapper/active-sessions/active-sessions.component.docs.mdx delete mode 100644 frontend/src/app/sessions/user-sessions-wrapper/create-sessions/create-readonly-session/create-readonly-session-dialog.component.css delete mode 100644 frontend/src/app/sessions/user-sessions-wrapper/create-sessions/create-readonly-session/create-readonly-session-dialog.component.docs.mdx diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index 4cbddf5a64..a0af36677b 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -12,7 +12,7 @@ import { ViewLogsDialogComponent } from 'src/app/projects/models/backup-settings import { PipelineWrapperComponent } from 'src/app/projects/models/backup-settings/wrapper/pipeline-wrapper/pipeline-wrapper.component'; import { ModelRestrictionsComponent } from 'src/app/projects/models/model-restrictions/model-restrictions.component'; import { EditProjectMetadataComponent } from 'src/app/projects/project-detail/edit-project-metadata/edit-project-metadata.component'; -import { SessionComponent } from 'src/app/sessions/session/session.component'; +import { SessionViewerComponent } from 'src/app/sessions/session/session-viewer.component'; import { ConfigurationSettingsComponent } from 'src/app/settings/core/configuration-settings/configuration-settings.component'; import { PipelinesOverviewComponent } from 'src/app/settings/core/pipelines-overview/pipelines-overview.component'; import { CreateToolComponent } from 'src/app/settings/core/tools-settings/create-tool/create-tool.component'; @@ -61,8 +61,8 @@ export const routes: Routes = [ data: { breadcrumb: 'Sessions' }, }, { - path: 'session', - component: SessionComponent, + path: 'session-viewer', + component: SessionViewerComponent, data: { breadcrumb: 'Session Viewer' }, }, { diff --git a/frontend/src/app/general/auth/auth-guard/auth-guard.service.ts b/frontend/src/app/general/auth/auth-guard/auth-guard.service.ts index cdbc883953..2a3c2c64ea 100644 --- a/frontend/src/app/general/auth/auth-guard/auth-guard.service.ts +++ b/frontend/src/app/general/auth/auth-guard/auth-guard.service.ts @@ -20,7 +20,7 @@ export const authGuard: CanActivateFn = ( return true; } else { // Needs window.location, since Router.url isn't updated yet - authService.redirectURL = window.location.pathname; + authService.redirectURL = window.location.pathname + window.location.search; authService.login(); return false; } diff --git a/frontend/src/app/general/header/header.stories.ts b/frontend/src/app/general/header/header.stories.ts index bde5913622..3f472f2313 100644 --- a/frontend/src/app/general/header/header.stories.ts +++ b/frontend/src/app/general/header/header.stories.ts @@ -27,10 +27,6 @@ class MockNavbarService implements Partial { name: 'Sessions', requiredRole: 'user', }, - { - name: 'Session viewer', - requiredRole: 'user', - }, { name: 'Session overview', requiredRole: 'administrator', diff --git a/frontend/src/app/general/nav-bar/nav-bar.service.ts b/frontend/src/app/general/nav-bar/nav-bar.service.ts index 2cf9156c46..a78e16a0c8 100644 --- a/frontend/src/app/general/nav-bar/nav-bar.service.ts +++ b/frontend/src/app/general/nav-bar/nav-bar.service.ts @@ -61,11 +61,6 @@ export class NavBarService { routerLink: '', requiredRole: 'user', }, - { - name: 'Session viewer', - routerLink: ['/session'], - requiredRole: 'user', - }, { name: 'Session overview', routerLink: ['/sessions', 'overview'], diff --git a/frontend/src/app/sessions/session/floating-window-manager/floating-window-manager.component.html b/frontend/src/app/sessions/session/floating-window-manager/floating-window-manager.component.html index a3cab34782..c8947ed764 100644 --- a/frontend/src/app/sessions/session/floating-window-manager/floating-window-manager.component.html +++ b/frontend/src/app/sessions/session/floating-window-manager/floating-window-manager.component.html @@ -3,53 +3,58 @@ ~ SPDX-License-Identifier: Apache-2.0 --> - +@if (sessionViewerService.sessions$ | async; as viewerSessions) {
-
+ @for (session of viewerSessions; track trackBySessionId) {
-
- control_camera - - {{ session.version.tool.name }} {{ session.version.name }}, - {{ session.type }} - -
- -
-
- Focusedphonelink +
+
+ control_camera + + {{ session.version.tool.name }} {{ session.version.name }}, + {{ session.type }} +
-
- Not focused - phonelink_off + +
+ @if (session.focused) { + Focusedphonelink + } @else { + Not focused + phonelink_off + }
+ + @if ((sessionViewerService.allSessions$ | async)!.length > 1) { + + }
- +
- - -
+ }
- +} diff --git a/frontend/src/app/sessions/session/floating-window-manager/floating-window-manager.component.ts b/frontend/src/app/sessions/session/floating-window-manager/floating-window-manager.component.ts index 2b0ca91759..75712b31ac 100644 --- a/frontend/src/app/sessions/session/floating-window-manager/floating-window-manager.component.ts +++ b/frontend/src/app/sessions/session/floating-window-manager/floating-window-manager.component.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ import { CdkDrag, CdkDragHandle } from '@angular/cdk/drag-drop'; -import { NgIf, NgFor, NgClass, AsyncPipe } from '@angular/common'; +import { NgClass, AsyncPipe } from '@angular/common'; import { Component, OnInit } from '@angular/core'; import { MatIcon } from '@angular/material/icon'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; @@ -16,8 +16,6 @@ import { SessionViewerService, ViewerSession } from '../session-viewer.service'; templateUrl: './floating-window-manager.component.html', standalone: true, imports: [ - NgIf, - NgFor, CdkDrag, NgClass, CdkDragHandle, diff --git a/frontend/src/app/sessions/session/session-iframe/session-iframe.component.css b/frontend/src/app/sessions/session/session-iframe/session-iframe.component.css index 7f12bf8468..8cdc5f53e2 100644 --- a/frontend/src/app/sessions/session/session-iframe/session-iframe.component.css +++ b/frontend/src/app/sessions/session/session-iframe/session-iframe.component.css @@ -12,3 +12,15 @@ z-index: 40; } + +.error { + @apply bg-error; +} + +.warning { + @apply bg-warning; +} + +.primary { + @apply bg-primary; +} diff --git a/frontend/src/app/sessions/session/session-iframe/session-iframe.component.html b/frontend/src/app/sessions/session/session-iframe/session-iframe.component.html index e69cf363d0..3e395daf7e 100644 --- a/frontend/src/app/sessions/session/session-iframe/session-iframe.component.html +++ b/frontend/src/app/sessions/session/session-iframe/session-iframe.component.html @@ -4,10 +4,57 @@ -->
-
+ @if (!session.focused) { +
+ } + + @if ( + !sessionService.beautifyState(session.preparation_state, session.state) + .success + ) { +
+
+ The session will be loaded as soon as it is ready. +
+
+
Preparation
+
+ {{ session.preparation_state }} +
+
+ {{ + sessionService.beautifyState( + session.preparation_state, + session.state + ).icon + }} +
+
Session
+
{{ session.state }}
+
+
+ @if ( + sessionService.beautifyState(session.preparation_state, session.state) + .info; + as info + ) { +
+ {{ info }} +
+ } +
+
+ }