From 6d7dfdbcb9adc493ff5813d49fda916be69a8f33 Mon Sep 17 00:00:00 2001 From: "SANDHYA.JS" Date: Tue, 5 Apr 2022 12:00:23 +0530 Subject: [PATCH] Fix Bug 1978: Unable to view the NS Instances on switching between projects from History of Operations page - On switching between projects assigned to a user from History of operations page, redirected to NSInstance page. Change-Id: I046ddde4b9797dfe6fb747b26fa60ad81281304e Signed-off-by: SANDHYA.JS --- .../switch-project/SwitchProjectComponent.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/utilities/switch-project/SwitchProjectComponent.ts b/src/app/utilities/switch-project/SwitchProjectComponent.ts index 1df6a16..dffb63a 100644 --- a/src/app/utilities/switch-project/SwitchProjectComponent.ts +++ b/src/app/utilities/switch-project/SwitchProjectComponent.ts @@ -21,6 +21,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Component, Injector, Input, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { Router } from '@angular/router'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { APIURLHEADER, ERRORDATA, LOCALSTORAGE, URLPARAMS } from 'CommonModel'; import { DataService } from 'DataService'; @@ -73,12 +74,16 @@ export class SwitchProjectComponent implements OnInit { /** FormBuilder instance added to the formBuilder @private */ private formBuilder: FormBuilder; + /** Service holds the router information @private */ + private router: Router; + constructor(injector: Injector) { this.injector = injector; this.dataService = this.injector.get(DataService); this.restService = this.injector.get(RestService); this.activeModal = this.injector.get(NgbActiveModal); this.formBuilder = this.injector.get(FormBuilder); + this.router = this.injector.get(Router); } /** convenience getter for easy access to form fields */ @@ -126,10 +131,16 @@ export class SwitchProjectComponent implements OnInit { localStorage.setItem('project', data.project_name); localStorage.setItem('token_state', data.id); this.activeModal.close(); - location.reload(); + if (this.router.url.includes('history-operations')) { + this.router.navigate(['/instances/ns']).then((): void => { + location.reload(); + }).catch(); + } else { + location.reload(); + } this.isLoadingResults = false; } - }, (error: ERRORDATA) => { + }, (error: ERRORDATA): void => { this.isLoadingResults = false; this.restService.handleError(error, 'post'); this.activeModal.close(); -- 2.17.1