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=7a8e7095b5bde36e2b41e93f03f2a855be55ee29;hb=a209e51c8758828e6b6ddec4edcab8d3240adef5;hp=429587d9b4eb3f19e78e221a42b7aacb355fa71e;hpb=e276ad30dc38f55e06877df8fd0d3372534c8f47;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 429587d9..7a8e7095 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'; @@ -60,6 +60,10 @@ export class HeaderComponent implements OnInit { 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) { @@ -87,6 +91,23 @@ export class HeaderComponent implements OnInit { if(this.api.brandLogoImagePath != ''){ this.brandLogoImagePath = this.api.brandLogoImagePath; } + + } + + getLanguageInfo() { + 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() { @@ -105,6 +126,7 @@ export class HeaderComponent implements OnInit { this.loginSnippetEmail = res.email; this.loginSnippetUserid = res.userId; this.lastLogin = Date.parse(res.last_login); + this.getLanguageInfo(); } if(res != null && res.isSystemUser === 'true'){ this.isSystemUser = true; @@ -196,4 +218,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); + }); + } }