blob: 522b11ade545f8fa9878e2c2f986d45273d82f4d [file] [log] [blame]
Skip Wonnell2c977e22018-03-01 08:30:15 -06001/*
2============LICENSE_START==========================================
3===================================================================
4Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
IBM602-PC0F1E3C\Arundathi435e57f2018-07-13 15:34:30 +05305
6Copyright (C) 2018 IBM Intellectual Property. All rights reserved.
Skip Wonnell2c977e22018-03-01 08:30:15 -06007===================================================================
8
9Unless otherwise specified, all software contained herein is licensed
10under the Apache License, Version 2.0 (the License);
11you may not use this software except in compliance with the License.
12You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16Unless required by applicable law or agreed to in writing, software
17distributed under the License is distributed on an "AS IS" BASIS,
18WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19See the License for the specific language governing permissions and
20limitations under the License.
21
22ECOMP is a trademark and service mark of AT&T Intellectual Property.
23============LICENSE_END============================================
24*/
25
26
IBM602-PC0F1E3C\Arundathi435e57f2018-07-13 15:34:30 +053027import { Component, Input, OnInit, OnDestroy } from '@angular/core';
28import { Router } from '@angular/router';
29import { Subscription } from 'rxjs/Subscription';
30import { EmitterService } from '../../services/emitter.service';
Skip Wonnell2c977e22018-03-01 08:30:15 -060031
32
IBM602-PC0F1E3C\Arundathi435e57f2018-07-13 15:34:30 +053033@Component({ selector: 'app-navigation', templateUrl: './navigation.component.html', styleUrls: ['./navigation.component.css'] })
34export class NavigationComponent implements OnInit, OnDestroy {
Skip Wonnell2c977e22018-03-01 08:30:15 -060035 navigationTabs: Array<Object> = [];
36 //@ViewChild(GoldenConfigurationComponent) goldenConfig: GoldenConfigurationComponent;
37 @Input() id: string;
38 userLoggedIn = false;
39 userId: string = localStorage['userId'];
IBM602-PC0F1E3C\Arundathi435e57f2018-07-13 15:34:30 +053040 subscription: Subscription;
Skip Wonnell2c977e22018-03-01 08:30:15 -060041
42 constructor(private router: Router) {
43 };
44
45 ngOnChanges() {
IBM602-PC0F1E3C\Arundathi435e57f2018-07-13 15:34:30 +053046 this.subscription = EmitterService
Skip Wonnell2c977e22018-03-01 08:30:15 -060047 .get(this.id)
48 .subscribe((value) => {
49 if (value != null && value != '' && value != undefined && value != 'undefined') {
50 this.userId = value;
51 this.userLoggedIn = true;
52 localStorage['userId'] = this.userId;
53 } else {
54 this.logout();
55 }
56
57 });
58 }
59
60 ngOnInit() {
61 this.userId = localStorage['userId'];
62 if (this.userId != undefined && this.userId != '') {
63 this.userLoggedIn = true;
64 }
65
66 this.navigationTabs = [
67
68 {
69 name: 'Home',
70 url: '/home'
71 }, {
72 name: 'MY VNFs',
73 url: 'vnfs'
74 },
75 {
76 name: 'Test',
77 url: 'test',
78 },
79 {
80 name: 'About us',
81 url: 'aboutUs'
82 }
83
84 ];
85 }
86
IBM602-PC0F1E3C\Arundathi435e57f2018-07-13 15:34:30 +053087 ngOnDestroy() {
88 if (this.subscription) {
89 this.subscription.unsubscribe();
90 }
91 }
92
Skip Wonnell2c977e22018-03-01 08:30:15 -060093
94 gotoDetail(url) {
95
96 if (url == 'vnfs') {
97 if (localStorage['userId'] != undefined && localStorage['userId'] != '' && localStorage['userId'] != null) {
98 this.router.navigate(['/vnfs/list']);
99 } else {
100 this.router.navigate(url);
101 }
102 } else {
103 this.router.navigate(url);
104 }
105
106
107 }
108
109 logout() {
110 window.localStorage.clear();
111 sessionStorage.clear();
112 localStorage.clear();
113 this.userLoggedIn = false;
114 //window.location.replace("/home");
115 this.router.navigate(['home']);
116
117
118 }
119
120}