summaryrefslogtreecommitdiffstats
path: root/webapp/src/app/@theme/components/header/header.component.ts
blob: 4a9ac0f6875eb2fa1c241fa98ba79f26e0da5bd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { Component, Input, OnInit } from '@angular/core';

import { NbMenuService, NbSidebarService } from '@nebular/theme';
// XDS_MODS
import { UserService } from '../../../@core-xds/services/users.service';
import { AnalyticsService } from '../../../@core/utils/analytics.service';

import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { AboutModalComponent } from '../../../pages/about/about-modal/about-modal.component';

@Component({
  selector: 'ngx-header',
  styleUrls: ['./header.component.scss'],
  templateUrl: './header.component.html',
})
export class HeaderComponent implements OnInit {


  @Input() position = 'normal';

  user: any;

  userMenu = [{ title: 'Profile' }, { title: 'Log out' }];

  // XDS_MODS - FIXME: better to define own XDS component instead of reuse nb-user
  helpName = '?';
  helpMenu = [
    {
      title: 'Online XDS documentation',
      target: '_blank',
      url: 'http://docs.automotivelinux.org/docs/devguides/en/dev/#xcross-development-system-user\'s-guide',
    },
    { title: 'About' },
  ];

  constructor(private sidebarService: NbSidebarService,
    private menuService: NbMenuService,
    private userService: UserService,
    private analyticsService: AnalyticsService,
    private modalService: NgbModal,
  ) {
  }

  ngOnInit() {
    // XDS_MODS
    this.userService.getUsers()
      .subscribe((users: any) => this.user = users.anonymous);
  }

  toggleSidebar(): boolean {
    this.sidebarService.toggle(true, 'menu-sidebar');
    return false;
  }

  toggleSettings(): boolean {
    this.sidebarService.toggle(false, 'settings-sidebar');
    return false;
  }

  goToHome() {
    this.menuService.navigateHome();
  }

  startSearch() {
    this.analyticsService.trackEvent('startSearch');
  }

  // XDS_MODS
  helpClick($event: any) {
    if ($event.title === 'About') {
        // FIXME SEB - move code in XDS part
        const activeModal = this.modalService.open(AboutModalComponent, { size: 'lg', container: 'nb-layout' });
    }

  }
}