2018-06-21 17:09:29 +03:00
|
|
|
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
2017-04-18 19:12:29 +03:00
|
|
|
|
2017-09-20 12:54:26 +03:00
|
|
|
import { NbMenuService, NbSidebarService } from '@nebular/theme';
|
2019-01-18 16:25:35 +03:00
|
|
|
import { UserData } from '../../../@core/data/users';
|
2018-06-21 17:09:29 +03:00
|
|
|
import { AnalyticsService } from '../../../@core/utils/analytics.service';
|
|
|
|
|
import { takeWhile } from 'rxjs/operators/takeWhile';
|
|
|
|
|
import { fromEvent as observableFromEvent } from 'rxjs/observable/fromEvent';
|
|
|
|
|
import { AbService } from '../../../@core/utils/ab.service';
|
2019-01-08 16:17:20 +03:00
|
|
|
import { LayoutService } from '../../../@core/utils';
|
2017-04-18 19:12:29 +03:00
|
|
|
|
|
|
|
|
@Component({
|
2017-05-06 14:52:41 +03:00
|
|
|
selector: 'ngx-header',
|
2017-04-28 15:14:05 +03:00
|
|
|
styleUrls: ['./header.component.scss'],
|
2017-09-07 16:43:31 +03:00
|
|
|
templateUrl: './header.component.html',
|
2017-04-18 19:12:29 +03:00
|
|
|
})
|
2018-06-21 17:09:29 +03:00
|
|
|
export class HeaderComponent implements OnInit , OnDestroy {
|
2017-04-29 18:41:44 +03:00
|
|
|
|
2017-10-20 17:31:36 +03:00
|
|
|
@Input() position = 'normal';
|
2017-07-28 14:54:29 +03:00
|
|
|
|
2017-07-13 11:49:38 +03:00
|
|
|
user: any;
|
2018-06-21 17:09:29 +03:00
|
|
|
hireTextVariant: string = 'solution-hire';
|
2017-09-07 16:43:31 +03:00
|
|
|
userMenu = [{ title: 'Profile' }, { title: 'Log out' }];
|
2017-04-29 18:41:44 +03:00
|
|
|
|
2018-06-21 17:09:29 +03:00
|
|
|
private alive = true;
|
|
|
|
|
|
2017-08-01 17:42:21 +03:00
|
|
|
constructor(private sidebarService: NbSidebarService,
|
|
|
|
|
private menuService: NbMenuService,
|
2019-01-18 16:25:35 +03:00
|
|
|
private userService: UserData,
|
2018-06-21 17:09:29 +03:00
|
|
|
private analytics: AnalyticsService,
|
|
|
|
|
private abService: AbService,
|
2018-08-09 15:24:44 +03:00
|
|
|
private layoutService: LayoutService) {
|
2018-06-21 17:09:29 +03:00
|
|
|
|
|
|
|
|
observableFromEvent(document, 'mouseup')
|
|
|
|
|
.pipe(takeWhile(() => this.alive))
|
|
|
|
|
.subscribe(() => {
|
|
|
|
|
let selection: any;
|
|
|
|
|
if (window.getSelection) {
|
|
|
|
|
selection = window.getSelection();
|
|
|
|
|
} else if ((<any> document).selection) {
|
|
|
|
|
selection = (<any> document).selection.createRange();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (selection && selection.toString() === 'contact@akveo.com') {
|
|
|
|
|
this.analytics.trackEvent('contactEmail', 'select');
|
|
|
|
|
}
|
|
|
|
|
});
|
2017-07-13 18:34:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
this.userService.getUsers()
|
|
|
|
|
.subscribe((users: any) => this.user = users.nick);
|
2018-06-21 17:09:29 +03:00
|
|
|
|
|
|
|
|
this.listenForVariants();
|
2017-04-18 19:12:29 +03:00
|
|
|
}
|
|
|
|
|
|
2017-06-21 17:34:10 +03:00
|
|
|
toggleSidebar(): boolean {
|
2017-07-28 14:54:29 +03:00
|
|
|
this.sidebarService.toggle(true, 'menu-sidebar');
|
2018-08-09 15:24:44 +03:00
|
|
|
this.layoutService.changeLayoutSize();
|
|
|
|
|
|
2017-07-28 14:54:29 +03:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-21 17:23:44 +03:00
|
|
|
goToHome() {
|
|
|
|
|
this.menuService.navigateHome();
|
|
|
|
|
}
|
2017-09-20 15:48:30 +03:00
|
|
|
|
|
|
|
|
startSearch() {
|
2018-06-21 17:09:29 +03:00
|
|
|
this.analytics.trackEvent('startSearch');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
trackEmailClick() {
|
|
|
|
|
this.analytics.trackEvent('contactEmail', 'click');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
|
this.alive = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listenForVariants() {
|
|
|
|
|
const variants = [
|
|
|
|
|
AbService.VARIANT_DEVELOPERS_HIRE,
|
|
|
|
|
AbService.VARIANT_HIGHLIGHT_HIRE,
|
|
|
|
|
AbService.VARIANT_SOLUTION_HIRE,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
this.abService.onAbEvent()
|
|
|
|
|
.subscribe((e: { name: string }) => {
|
|
|
|
|
if (variants.includes(e.name)) {
|
|
|
|
|
this.hireTextVariant = e.name;
|
|
|
|
|
}
|
|
|
|
|
});
|
2017-09-20 15:48:30 +03:00
|
|
|
}
|
2017-04-18 19:12:29 +03:00
|
|
|
}
|