feat: update to Angular 6 (#1684)

This commit is contained in:
Dmitry Nehaychik 2018-05-10 23:48:39 +03:00 committed by GitHub
parent fa3cdf731b
commit 06d2197583
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 5448 additions and 4039 deletions

View file

@ -2,7 +2,7 @@ import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core
import { CommonModule } from '@angular/common';
import { NbAuthModule, NbDummyAuthProvider } from '@nebular/auth';
import { NbSecurityModule, NbRoleProvider } from '@nebular/security';
import { of as observableOf } from 'rxjs/observable/of';
import { of as observableOf } from 'rxjs';
import { throwIfAlreadyLoaded } from './module-import-guard';
import { DataModule } from './data/data.module';
@ -26,7 +26,14 @@ const socialLinks = [
},
];
const NB_CORE_PROVIDERS = [
export class NbSimpleRoleProvider extends NbRoleProvider {
getRole() {
// here you could provide any role based on any auth flow
return observableOf('guest');
}
}
export const NB_CORE_PROVIDERS = [
...DataModule.forRoot().providers,
...NbAuthModule.forRoot({
providers: {
@ -63,12 +70,7 @@ const NB_CORE_PROVIDERS = [
},
}).providers,
{
provide: NbRoleProvider,
useValue: {
getRole: () => {
return observableOf('guest'); // here you could provide any role based on any auth flow
},
},
provide: NbRoleProvider, useClass: NbSimpleRoleProvider,
},
AnalyticsService,
];

View file

@ -1,5 +1,4 @@
import { Injectable } from '@angular/core';
import 'rxjs/add/observable/of';
export class Track {
name: string;

View file

@ -1,8 +1,7 @@
import { of as observableOf, Observable , BehaviorSubject } from 'rxjs';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import 'rxjs/add/observable/of';
@Injectable()
export class StateService {
@ -48,7 +47,7 @@ export class StateService {
}
getLayoutStates(): Observable<any[]> {
return Observable.of(this.layouts);
return observableOf(this.layouts);
}
onLayoutState(): Observable<any> {
@ -60,7 +59,7 @@ export class StateService {
}
getSidebarStates(): Observable<any[]> {
return Observable.of(this.sidebars);
return observableOf(this.sidebars);
}
onSidebarState(): Observable<any> {

View file

@ -1,6 +1,7 @@
import { of as observableOf, Observable } from 'rxjs';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
let counter = 0;
@ -23,15 +24,15 @@ export class UserService {
}
getUsers(): Observable<any> {
return Observable.of(this.users);
return observableOf(this.users);
}
getUserArray(): Observable<any[]> {
return Observable.of(this.userArray);
return observableOf(this.userArray);
}
getUser(): Observable<any> {
counter = (counter + 1) % this.userArray.length;
return Observable.of(this.userArray[counter]);
return observableOf(this.userArray[counter]);
}
}

View file

@ -1,8 +1,7 @@
import { Injectable } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { Location } from '@angular/common';
import { filter } from 'rxjs/operator/filter';
import { filter } from 'rxjs/operators';
declare const ga: any;
@ -16,7 +15,9 @@ export class AnalyticsService {
trackPageViews() {
if (this.enabled) {
filter.call(this.router.events, (event) => event instanceof NavigationEnd)
this.router.events.pipe(
filter((event) => event instanceof NavigationEnd),
)
.subscribe(() => {
ga('send', {hitType: 'pageview', page: this.location.path()});
});