Added Help menu with doc link and About modal.
[src/xds/xds-agent.git] / webapp / src / app / @theme / components / header / header.component.ts
1 import { Component, Input, OnInit } from '@angular/core';
2
3 import { NbMenuService, NbSidebarService } from '@nebular/theme';
4 // XDS_MODS
5 import { UserService } from '../../../@core-xds/services/users.service';
6 import { AnalyticsService } from '../../../@core/utils/analytics.service';
7
8 import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
9 import { AboutModalComponent } from '../../../pages/about/about-modal/about-modal.component';
10
11 @Component({
12   selector: 'ngx-header',
13   styleUrls: ['./header.component.scss'],
14   templateUrl: './header.component.html',
15 })
16 export class HeaderComponent implements OnInit {
17
18
19   @Input() position = 'normal';
20
21   user: any;
22
23   userMenu = [{ title: 'Profile' }, { title: 'Log out' }];
24
25   // XDS_MODS - FIXME: better to define own XDS component instead of reuse nb-user
26   helpName = '?';
27   helpMenu = [
28     {
29       title: 'Online XDS documentation',
30       target: '_blank',
31       url: 'http://docs.automotivelinux.org/docs/devguides/en/dev/#xcross-development-system-user\'s-guide',
32     },
33     { title: 'About' },
34   ];
35
36   constructor(private sidebarService: NbSidebarService,
37     private menuService: NbMenuService,
38     private userService: UserService,
39     private analyticsService: AnalyticsService,
40     private modalService: NgbModal,
41   ) {
42   }
43
44   ngOnInit() {
45     // XDS_MODS
46     this.userService.getUsers()
47       .subscribe((users: any) => this.user = users.anonymous);
48   }
49
50   toggleSidebar(): boolean {
51     this.sidebarService.toggle(true, 'menu-sidebar');
52     return false;
53   }
54
55   toggleSettings(): boolean {
56     this.sidebarService.toggle(false, 'settings-sidebar');
57     return false;
58   }
59
60   goToHome() {
61     this.menuService.navigateHome();
62   }
63
64   startSearch() {
65     this.analyticsService.trackEvent('startSearch');
66   }
67
68   // XDS_MODS
69   helpClick($event: any) {
70     if ($event.title === 'About') {
71         // FIXME SEB - move code in XDS part
72         const activeModal = this.modalService.open(AboutModalComponent, { size: 'lg', container: 'nb-layout' });
73     }
74
75   }
76 }