X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=portal-FE-common%2Fsrc%2Fapp%2Flayout%2Fcomponents%2Fsidebar%2Fsidebar.component.ts;h=9ea540c7ce402b55d2d9b949de8f071782a436c6;hb=08b693019187909148f50b2ead800b553438e10b;hp=1c689e169bf9ace40de5e09db121dcfcc6cff292;hpb=728c55e4233b5f7e449f67dea4c4ca987da701b7;p=portal.git diff --git a/portal-FE-common/src/app/layout/components/sidebar/sidebar.component.ts b/portal-FE-common/src/app/layout/components/sidebar/sidebar.component.ts index 1c689e16..9ea540c7 100644 --- a/portal-FE-common/src/app/layout/components/sidebar/sidebar.component.ts +++ b/portal-FE-common/src/app/layout/components/sidebar/sidebar.component.ts @@ -35,7 +35,7 @@ * * */ -import { Component, Output, EventEmitter, OnInit, Input } from '@angular/core'; +import { Component, Output, EventEmitter, OnInit, Input, OnChanges } from '@angular/core'; import { Router, NavigationEnd } from '@angular/router'; import { SidebarService } from '../../../shared/services/index' @@ -57,6 +57,9 @@ export class SidebarComponent implements OnInit { menuData: Array = []; page: any; + languageFinal : string; + @Input() langFromTab:string; + @Output() collapsedEvent = new EventEmitter(); constructor(public router: Router, public sidebarService: SidebarService) { @@ -71,64 +74,75 @@ export class SidebarComponent implements OnInit { }); } - ngOnInit() { + ngOnChanges() { + if(this.langFromTab) + this.changeLang(); + } + + changeLang(){ + this.menuData=[]; this.isActive = false; this.collapsed = false; + // this.languageFinal=lang; this.showMenu = ''; this.pushRightClass = 'push-right'; this.sidebarService.getLeftMenu() - .subscribe(data => { - this.result = data; - if (this.result.data && this.result.data2) { - this.leftParentData = JSON.parse(this.result.data); - this.leftChildData = JSON.parse(this.result.data2); + .subscribe(data => { + this.result = data; + if (this.result.data && this.result.data2) { + this.leftParentData = JSON.parse(this.result.data); + this.leftChildData = JSON.parse(this.result.data2); + } else { + this.labelName = this.result.label; + this.leftParentData = this.result.navItems; + this.showOnlyParentMenu = true; + } + + for (var i = 0; i < this.leftParentData.length; i++) { + var parentItem = { + name: null, + imageSrc: null, + href: null, + menuItems: [], + state: null + } + if (this.showOnlyParentMenu) { + parentItem.name = this.leftParentData[i].name; + parentItem.imageSrc = this.leftParentData[i].imageSrc; + parentItem.state = '/'+this.leftParentData[i].state; } else { - this.labelName = this.result.label; - this.leftParentData = this.result.navItems; - this.showOnlyParentMenu = true; + parentItem.name = this.leftParentData[i].label; + parentItem.imageSrc = this.leftParentData[i].imageSrc; } + // Add link to items with no subitems + if (!this.showOnlyParentMenu) { + if (this.leftChildData[i].length == 0) + parentItem.href = this.leftParentData[i].action; - for (var i = 0; i < this.leftParentData.length; i++) { - var parentItem = { - name: null, - imageSrc: null, - href: null, - menuItems: [], - state: null - } - if (this.showOnlyParentMenu) { - parentItem.name = this.leftParentData[i].name; - parentItem.imageSrc = this.leftParentData[i].imageSrc; - parentItem.state = '/'+this.leftParentData[i].state; - } else { - parentItem.name = this.leftParentData[i].label; - parentItem.imageSrc = this.leftParentData[i].imageSrc; - } - // Add link to items with no subitems - if (!this.showOnlyParentMenu) { - if (this.leftChildData[i].length == 0) - parentItem.href = this.leftParentData[i].action; - - for (var j = 0; j < this.leftChildData[i].length; j++) { - - var childItem = { - name: null, - href: null - }; - if (this.leftChildData[i][j].label != null && this.leftChildData[i][j].label.length > 0) { - - childItem.name = this.leftChildData[i][j].label; - childItem.href = this.leftChildData[i][j].action; - parentItem.menuItems.push(childItem); - } + for (var j = 0; j < this.leftChildData[i].length; j++) { + + var childItem = { + name: null, + href: null + }; + if (this.leftChildData[i][j].label != null && this.leftChildData[i][j].label.length > 0) { + + childItem.name = this.leftChildData[i][j].label; + childItem.href = this.leftChildData[i][j].action; + parentItem.menuItems.push(childItem); } } - this.menuData.push(parentItem); } + this.menuData.push(parentItem); + } - }); + }); + } + ngOnInit() { + this.changeLang(); } + eventCalled() { this.isActive = !this.isActive; } @@ -155,4 +169,4 @@ export class SidebarComponent implements OnInit { const dom: any = document.querySelector('body'); dom.classList.toggle(this.pushRightClass); } -} +} \ No newline at end of file