From d8e5a61a0fe68eb1881a7a5705657a485f662e57 Mon Sep 17 00:00:00 2001 From: Loris Sauter Date: Wed, 4 Oct 2023 17:08:25 +0200 Subject: [PATCH] Resolved #434 Added 'noUi' matrix parameter for viewer --- frontend/src/app/app-routing.module.ts | 2 +- frontend/src/app/app.component.html | 2 +- frontend/src/app/app.component.ts | 31 ++++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index 855d26ff6..dd639db13 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -118,7 +118,7 @@ const routes: Routes = [ /* Two important 'catch-all's. */ { path: '', redirectTo: 'evaluation/list', pathMatch: 'full' }, - { path: '**', component: NotFoundComponent } + { path: '**', component: NotFoundComponent, title: "404 - Not Found!" } ]; @NgModule({ diff --git a/frontend/src/app/app.component.html b/frontend/src/app/app.component.html index c96bd789f..8b2a233df 100644 --- a/frontend/src/app/app.component.html +++ b/frontend/src/app/app.component.html @@ -1,4 +1,4 @@ - +
diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts index 4fa7f47b0..ff862b804 100644 --- a/frontend/src/app/app.component.ts +++ b/frontend/src/app/app.component.ts @@ -1,8 +1,8 @@ import { Component, inject } from "@angular/core"; -import { Router } from '@angular/router'; +import { ActivatedRoute, ActivationEnd, Router } from "@angular/router"; import { AuthenticationService } from './services/session/authentication.sevice'; import { MatSnackBar } from '@angular/material/snack-bar'; -import { map } from 'rxjs/operators'; +import { filter, map, shareReplay } from "rxjs/operators"; import { Observable } from 'rxjs'; import { AppConfig } from './app.config'; import {ApiRole, ApiUser} from '../../openapi'; @@ -25,6 +25,7 @@ export class AppComponent { isAdmin: Observable; loggedIn: Observable; canJudge: Observable; + noUi: Observable; constructor( private authenticationService: AuthenticationService, @@ -32,7 +33,33 @@ export class AppComponent { private snackBar: MatSnackBar, public config: AppConfig, private dialog: MatDialog, + private activeRoute: ActivatedRoute, ) { + + this.noUi = this.router.events.pipe( + filter(e => (e instanceof ActivationEnd)), + map((e) => { + return e instanceof ActivationEnd ? {path: e.snapshot.params, query: e.snapshot.queryParams} : {} + }), + map(dto => { + const p = dto?.path ?? {} + if(p["runId"]){ + const runIdPathParams= p["runId"].split(";") // manual handling of matrix params + for (const pram of runIdPathParams) { + // either as flag ;noUi or as value noUi=true. when having noUi=false this will negate it and the ui will be shown + if(pram.startsWith("noUi") && !pram.endsWith("false")){ + return true + } + } + return false + }else{ + // check query parameters + const p = dto?.query ?? {} + return p["noUi"] ?? false + } + }) + ); + this.user = this.authenticationService.user; this.loggedIn = this.authenticationService.isLoggedIn; this.isAdmin = this.authenticationService.user.pipe(map((u) => u?.role === ApiRole.ADMIN));