mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-27 20:58:48 +01:00
feat(demo): demo version additions
This commit is contained in:
parent
d3238ddb49
commit
93d800b676
14 changed files with 253 additions and 29 deletions
|
|
@ -1,8 +1,11 @@
|
|||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
||||
|
||||
import { NbMenuService, NbSidebarService } from '@nebular/theme';
|
||||
import { UserData } from '../../../@core/data/users';
|
||||
import { AnalyticsService } from '../../../@core/utils';
|
||||
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';
|
||||
import { LayoutService } from '../../../@core/utils';
|
||||
|
||||
@Component({
|
||||
|
|
@ -10,24 +13,44 @@ import { LayoutService } from '../../../@core/utils';
|
|||
styleUrls: ['./header.component.scss'],
|
||||
templateUrl: './header.component.html',
|
||||
})
|
||||
export class HeaderComponent implements OnInit {
|
||||
export class HeaderComponent implements OnInit , OnDestroy {
|
||||
|
||||
@Input() position = 'normal';
|
||||
|
||||
user: any;
|
||||
|
||||
hireTextVariant: string = 'solution-hire';
|
||||
userMenu = [{ title: 'Profile' }, { title: 'Log out' }];
|
||||
|
||||
private alive = true;
|
||||
|
||||
constructor(private sidebarService: NbSidebarService,
|
||||
private menuService: NbMenuService,
|
||||
private userService: UserData,
|
||||
private analyticsService: AnalyticsService,
|
||||
private analytics: AnalyticsService,
|
||||
private abService: AbService,
|
||||
private layoutService: LayoutService) {
|
||||
|
||||
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');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.userService.getUsers()
|
||||
.subscribe((users: any) => this.user = users.nick);
|
||||
|
||||
this.listenForVariants();
|
||||
}
|
||||
|
||||
toggleSidebar(): boolean {
|
||||
|
|
@ -42,6 +65,29 @@ export class HeaderComponent implements OnInit {
|
|||
}
|
||||
|
||||
startSearch() {
|
||||
this.analyticsService.trackEvent('startSearch');
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue