diff options
Diffstat (limited to 'webapp/src/app/@core')
-rw-r--r-- | webapp/src/app/@core/data/.gitkeep | 0 | ||||
-rw-r--r-- | webapp/src/app/@core/data/state.service.ts | 69 | ||||
-rw-r--r-- | webapp/src/app/@core/utils/.gitkeep | 0 | ||||
-rw-r--r-- | webapp/src/app/@core/utils/analytics.service.ts | 31 |
4 files changed, 100 insertions, 0 deletions
diff --git a/webapp/src/app/@core/data/.gitkeep b/webapp/src/app/@core/data/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/webapp/src/app/@core/data/.gitkeep diff --git a/webapp/src/app/@core/data/state.service.ts b/webapp/src/app/@core/data/state.service.ts new file mode 100644 index 0000000..a6bcb08 --- /dev/null +++ b/webapp/src/app/@core/data/state.service.ts @@ -0,0 +1,69 @@ +import { Injectable } from '@angular/core'; + +import { Observable } from 'rxjs/Observable'; +import { BehaviorSubject } from 'rxjs/BehaviorSubject'; +import 'rxjs/add/observable/of'; + +@Injectable() +export class StateService { + + protected layouts: any = [ + { + name: 'One Column', + icon: 'nb-layout-default', + id: 'one-column', + selected: true, + }, + { + name: 'Two Column', + icon: 'nb-layout-two-column', + id: 'two-column', + }, + { + name: 'Center Column', + icon: 'nb-layout-centre', + id: 'center-column', + }, + ]; + + protected sidebars: any = [ + { + name: 'Left Sidebar', + icon: 'nb-layout-sidebar-left', + id: 'left', + selected: true, + }, + { + name: 'Right Sidebar', + icon: 'nb-layout-sidebar-right', + id: 'right', + }, + ]; + + protected layoutState$ = new BehaviorSubject(this.layouts[0]); + protected sidebarState$ = new BehaviorSubject(this.sidebars[0]); + + setLayoutState(state: any): any { + this.layoutState$.next(state); + } + + getLayoutStates(): Observable<any[]> { + return Observable.of(this.layouts); + } + + onLayoutState(): Observable<any> { + return this.layoutState$.asObservable(); + } + + setSidebarState(state: any): any { + this.sidebarState$.next(state); + } + + getSidebarStates(): Observable<any[]> { + return Observable.of(this.sidebars); + } + + onSidebarState(): Observable<any> { + return this.sidebarState$.asObservable(); + } +} diff --git a/webapp/src/app/@core/utils/.gitkeep b/webapp/src/app/@core/utils/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/webapp/src/app/@core/utils/.gitkeep diff --git a/webapp/src/app/@core/utils/analytics.service.ts b/webapp/src/app/@core/utils/analytics.service.ts new file mode 100644 index 0000000..73f1332 --- /dev/null +++ b/webapp/src/app/@core/utils/analytics.service.ts @@ -0,0 +1,31 @@ +import { Injectable } from '@angular/core'; +import { NavigationEnd, Router } from '@angular/router'; +import { Location } from '@angular/common'; + +import { filter } from 'rxjs/operator/filter'; + +declare const ga: any; + +@Injectable() +export class AnalyticsService { + private enabled: boolean; + + constructor(private location: Location, private router: Router) { + this.enabled = false; + } + + trackPageViews() { + if (this.enabled) { + filter.call(this.router.events, (event) => event instanceof NavigationEnd) + .subscribe(() => { + ga('send', {hitType: 'pageview', page: this.location.path()}); + }); + } + } + + trackEvent(eventName: string) { + if (this.enabled) { + ga('send', 'event', eventName); + } + } +} |