diff --git a/src/app/elements/organization/organization.component.ts b/src/app/elements/organization/organization.component.ts index 654dd47b..70959eb7 100644 --- a/src/app/elements/organization/organization.component.ts +++ b/src/app/elements/organization/organization.component.ts @@ -1,5 +1,6 @@ -import {Component, OnInit, OnDestroy, Input} from '@angular/core'; +import {Component, Input, OnDestroy, OnInit} from '@angular/core'; import {CookieService} from 'ngx-cookie-service'; +import {ActivatedRoute, Router} from '@angular/router'; import {OrganizationService, SettingService} from '@app/services'; import {Organization} from '@app/model'; import {DEFAULT_ORG_ID, ROOT_ORG_ID} from '@app/globals'; @@ -13,14 +14,18 @@ export class ElementOrganizationComponent implements OnInit, OnDestroy { currentOrg: Organization = {id: '', name: ''}; organizations = []; @Input() isK8s: boolean = false; + constructor(private _cookie: CookieService, public _settingSvc: SettingService, - private _orgSvc: OrganizationService - ) {} + private _orgSvc: OrganizationService, + private _router: Router, + private _route: ActivatedRoute + ) { + } ngOnInit() { const cookieOrgId = this._cookie.get('X-JMS-LUNA-ORG') || this._cookie.get('X-JMS-ORG'); - this._orgSvc.orgListChange$.subscribe(async(res) => { + this._orgSvc.orgListChange$.subscribe(async (res) => { this.organizations = res; const cookieOrg = await this.organizations.find(i => i.id === cookieOrgId); if (!cookieOrg) { @@ -50,5 +55,12 @@ export class ElementOrganizationComponent implements OnInit, OnDestroy { changeOrg(event) { this.currentOrg = event.value; this._orgSvc.switchOrg(this.currentOrg); + const query = {...this._route.snapshot.queryParams}; + delete query['oid']; + delete query['_']; + this._router.navigate([], { + relativeTo: this._route, + queryParams: query, + }); } }