Skip to content

Commit

Permalink
Resolved #434 Added 'noUi' matrix parameter for viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
sauterl committed Oct 4, 2023
1 parent 8efa8d7 commit d8e5a61
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mat-toolbar color="primary">
<mat-toolbar *ngIf="!(noUi | async)" color="primary">
<button mat-flat-button color="primary" (click)="openInfoDialog()" matTooltip="Click for server information"><h2 style="margin: 0;">DRES</h2></button>
<div class="spacer-small"></div>
<app-api-status></app-api-status>
Expand Down
31 changes: 29 additions & 2 deletions frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -25,14 +25,41 @@ export class AppComponent {
isAdmin: Observable<boolean>;
loggedIn: Observable<boolean>;
canJudge: Observable<boolean>;
noUi: Observable<boolean>;

constructor(
private authenticationService: AuthenticationService,
private router: Router,
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));
Expand Down

0 comments on commit d8e5a61

Please sign in to comment.