From 57680c9cf3de8f74ec7c80e7ab2cbaa79f4a6ddd Mon Sep 17 00:00:00 2001 From: Daniel Nemergut <dnemergu@nrao.edu> Date: Thu, 27 Oct 2022 10:52:15 -0400 Subject: [PATCH] WS-1267 Storing and retrieving the previously selected capability from the session --- .../active-capability-requests.component.ts | 4 ++++ .../ws-header/ws-header.component.html | 2 +- .../ws-header/ws-header.component.ts | 19 +++++++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/apps/web/src/app/workspaces/components/active-capability-requests/active-capability-requests.component.ts b/apps/web/src/app/workspaces/components/active-capability-requests/active-capability-requests.component.ts index 448be2513..0d14a02f5 100644 --- a/apps/web/src/app/workspaces/components/active-capability-requests/active-capability-requests.component.ts +++ b/apps/web/src/app/workspaces/components/active-capability-requests/active-capability-requests.component.ts @@ -35,6 +35,7 @@ import {StorageService} from "../../../shared/storage/storage.service"; import { Filter } from "./components/filter-menu/filter-menu.component"; import { FormControl } from "@angular/forms"; import { PageEvent } from '@angular/material/paginator'; +import { WsHeaderComponent } from "../../ws-header/ws-header.component"; export const defaultSortOrder = "desc" @@ -385,6 +386,9 @@ export class ActiveCapabilityRequestsComponent implements OnInit, OnDestroy { }), ); + // Store the current capability selection so the header can access it + this.storageService.saveSession(WsHeaderComponent.previousCapabilityKey, this.capabilityName) + // update query parameters to new capabilityName this.router.navigate(["."], { relativeTo: this.route, diff --git a/apps/web/src/app/workspaces/ws-header/ws-header.component.html b/apps/web/src/app/workspaces/ws-header/ws-header.component.html index 1a6e9cc6d..c59dc205b 100644 --- a/apps/web/src/app/workspaces/ws-header/ws-header.component.html +++ b/apps/web/src/app/workspaces/ws-header/ws-header.component.html @@ -7,7 +7,7 @@ <a [routerLink]="['/', 'workspaces']" routerLinkActive="active" class="btn btn-outline-light" [routerLinkActiveOptions]="{exact: true}">Home?</a> <a [routerLink]="'analyst-board'" routerLinkActive="active" class="btn btn-outline-light">Analyst Board</a> - <a [routerLink]="'active-requests'" routerLinkActive="active" class="btn btn-outline-light">Active Requests</a> + <a [routerLink]="'active-requests'" routerLinkActive="active" class="btn btn-outline-light" (click)="goToActiveRequestsPage()" >Active Requests</a> <a [routerLink]="'jobs'" routerLinkActive="active" class="btn btn-outline-light">Jobs</a> <a [routerLink]="'email-templates'" routerLinkActive="active" class="btn btn-outline-light">Email Templates</a> </div> diff --git a/apps/web/src/app/workspaces/ws-header/ws-header.component.ts b/apps/web/src/app/workspaces/ws-header/ws-header.component.ts index 85f610f0d..6278c3faa 100644 --- a/apps/web/src/app/workspaces/ws-header/ws-header.component.ts +++ b/apps/web/src/app/workspaces/ws-header/ws-header.component.ts @@ -1,5 +1,6 @@ import {Component, OnInit} from '@angular/core'; -import {ActivatedRoute} from "@angular/router"; +import {Router} from "@angular/router"; +import {StorageService} from "../../shared/storage/storage.service"; @Component({ selector: 'app-ws-header', @@ -8,8 +9,22 @@ import {ActivatedRoute} from "@angular/router"; }) export class WsHeaderComponent implements OnInit { - constructor(private route: ActivatedRoute) { + private activeRequestsPageDefaultUrl: string = "/workspaces/active-requests" + static previousCapabilityKey: string = "previousCapability" + constructor( + private router: Router, + private storageService: StorageService + ) { + } + + public goToActiveRequestsPage() { + // Set the previous capability as selected if it's found in storage + const activeRequestsPageUrl = (this.storageService.getSession(WsHeaderComponent.previousCapabilityKey)) ? + `${this.activeRequestsPageDefaultUrl}?capability=${this.storageService.getSession(WsHeaderComponent.previousCapabilityKey)}` : + `${this.activeRequestsPageDefaultUrl}` + + this.router.navigateByUrl(activeRequestsPageUrl) } ngOnInit(): void { -- GitLab