X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Fapp%2Flayouts%2Fheader%2FHeaderComponent.ts;h=45807f948dda2d69565275e6a29f4896b4ff88ec;hb=HEAD;hp=9392177ccc41d5b5efae4c44654cc2e03c71796a;hpb=1b17c432991a95035a1732426f0c11db57e511c9;p=osm%2FNG-UI.git diff --git a/src/app/layouts/header/HeaderComponent.ts b/src/app/layouts/header/HeaderComponent.ts index 9392177..45807f9 100644 --- a/src/app/layouts/header/HeaderComponent.ts +++ b/src/app/layouts/header/HeaderComponent.ts @@ -28,7 +28,7 @@ import { MODALCLOSERESPONSEDATA } from 'CommonModel'; import { environment } from 'environment'; import { ProjectService } from 'ProjectService'; import { Observable } from 'rxjs'; -import { SharedService } from 'SharedService'; +import { SharedService, isNullOrUndefined } from 'SharedService'; import { UserSettingsComponent } from 'UserSettingsComponent'; /** @@ -75,6 +75,9 @@ export class HeaderComponent implements OnInit { /** handle translate @public */ public translateService: TranslateService; + /** Version holds version @public */ + public getLocalStorageVersion: string; + /** Utilizes auth service for any auth operations @private */ private authService: AuthenticationService; @@ -95,20 +98,25 @@ export class HeaderComponent implements OnInit { /** Lifecyle Hooks the trigger before component is instantiate @public */ public ngOnInit(): void { - this.isAdmin = (localStorage.getItem('isAdmin') === 'true') ? true : false; - this.isSystemAdmin = localStorage.getItem('admin_show') === 'true' ? true : false; + this.isAdmin = (sessionStorage.getItem('isAdmin') === 'true') ? true : false; + this.isSystemAdmin = sessionStorage.getItem('admin_show') === 'true' ? true : false; this.selectedProject = this.authService.ProjectName; this.authService.ProjectName.subscribe((projectNameFinal: string): void => { this.getSelectedProject = projectNameFinal; }); + this.sharedService.fetchOSMVersion(); this.username$ = this.authService.username; this.projectService.setHeaderProjects(); this.projectList$ = this.projectService.projectList; this.PACKAGEVERSION = environment.packageVersion; - const getLocalStorageVersion: string = localStorage.getItem('osmVersion'); - if (getLocalStorageVersion === null) { + if (!isNullOrUndefined(sessionStorage.getItem('version'))) { + this.getLocalStorageVersion = sessionStorage.getItem('version'); + } else if (!isNullOrUndefined(this.sharedService.osmVersion)) { + this.getLocalStorageVersion = this.sharedService.osmVersion; + } + if (this.getLocalStorageVersion === null) { this.showNewVersion(); - } else if (getLocalStorageVersion !== this.sharedService.osmVersion) { + } else if (this.getLocalStorageVersion !== sessionStorage.getItem('osmVersion')) { this.showNewVersion(); } } @@ -126,7 +134,7 @@ export class HeaderComponent implements OnInit { /** Close Version and add in local storage @public */ public closeVersion(): void { this.toShowNewTag = false; - localStorage.setItem('osmVersion', this.sharedService.osmVersion); + sessionStorage.setItem('osmVersion', this.sharedService.osmVersion); } /** Implementation of model for UserSettings options.@public */ @@ -139,7 +147,7 @@ export class HeaderComponent implements OnInit { public changePassword(): void { // eslint-disable-next-line security/detect-non-literal-fs-filename const modalRef: NgbModalRef = this.modalService.open(AddEditUserComponent, { backdrop: 'static' }); - modalRef.componentInstance.userID = localStorage.getItem('user_id'); + modalRef.componentInstance.userID = sessionStorage.getItem('user_id'); modalRef.componentInstance.userTitle = this.translateService.instant('PAGE.USERS.EDITCREDENTIALS'); modalRef.componentInstance.userType = 'changePassword'; modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => {