X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=portal-FE-common%2Fsrc%2Fapp%2Flayout%2Fcomponents%2Fheader%2Fheader.component.ts;h=f09c772e00bd327d5b583940684cdf98859725a2;hb=08b693019187909148f50b2ead800b553438e10b;hp=09dd4c1a1f227227ceac54ebb5d9a8f8ce28dc39;hpb=096d3ac4c7b98f98eb20978cf1f07ff5cc91d492;p=portal.git diff --git a/portal-FE-common/src/app/layout/components/header/header.component.ts b/portal-FE-common/src/app/layout/components/header/header.component.ts index 09dd4c1a..f09c772e 100644 --- a/portal-FE-common/src/app/layout/components/header/header.component.ts +++ b/portal-FE-common/src/app/layout/components/header/header.component.ts @@ -35,7 +35,7 @@ * * */ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Output, EventEmitter } from '@angular/core'; import { Router, NavigationEnd } from '@angular/router'; import { UserProfileService, MenusService } from 'src/app/shared/services'; import { CookieService } from 'ngx-cookie-service'; @@ -59,6 +59,11 @@ export class HeaderComponent implements OnInit { api = environment.api; brandName: string; brandLogoImagePath: string; + isSystemUser: boolean = false; + languages: string[] = []; + result: any; + + @Output() languageEvent = new EventEmitter(); constructor(public router: Router, private userProfileService: UserProfileService, private menusService: MenusService, private cookieService: CookieService) { @@ -86,11 +91,25 @@ export class HeaderComponent implements OnInit { if(this.api.brandLogoImagePath != ''){ this.brandLogoImagePath = this.api.brandLogoImagePath; } + + this.menusService.getAllLanguages().subscribe(data =>{ + this.result = data; + for(let lang of this.result.languageList ){ + this.languages.push(lang); + } + + this.menusService.getCurrentLang(this.loginSnippetUserid).subscribe(data=>{ + this.result = data; + this.languages.map((obj:any)=>{ + obj.selected = obj.languageId == parseInt(this.result.languageId); + }) ; + }); + }); } getUserInformation() { this.userProfileService.getFunctionalMenuStaticInfo().toPromise().then((res: any) => { - if (res == null || res.firstName == null || res.firstName == '' || res.lastName == null || res.lastName == '') { + if (res === null || res.firstName === null || res.firstName === '' || res.lastName === null || res.lastName === '') { // $log.info('HeaderCtrl: failed to get all required data, trying user profile'); this.userProfileService.getUserProfile().toPromise().then((profile: any) => { this.firstName = profile.firstName; @@ -105,6 +124,9 @@ export class HeaderComponent implements OnInit { this.loginSnippetUserid = res.userId; this.lastLogin = Date.parse(res.last_login); } + if(res != null && res.isSystemUser === 'true'){ + this.isSystemUser = true; + } sessionStorage.userId = res.userId; this.menusService.getFunctionalMenuForUser().toPromise().then((jsonHeaderMenu: any) => { // $scope.menuItems = unflatten(jsonHeaderMenu); @@ -192,4 +214,11 @@ export class HeaderComponent implements OnInit { onLoggedout() { localStorage.removeItem('isLoggedin'); } + + setLanguage(langId : string){ + + this.menusService.setLanguage(langId, this.loginSnippetUserid).subscribe(data =>{ + this.languageEvent.emit(langId); + }); + } }