Migration to AGL gerrit (update go import)
[src/xds/xds-agent.git] / webapp / src / app / @core-xds / core-xds.module.ts
1 /**
2 * @license
3 * Copyright (C) 2017-2018 "IoT.bzh"
4 * Author Sebastien Douheret <sebastien@iot.bzh>
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *   http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
20 import { CommonModule } from '@angular/common';
21
22 import { NbAuthModule, NbDummyAuthProvider } from '@nebular/auth';
23 import { CookieModule } from 'ngx-cookie';
24
25 import { throwIfAlreadyLoaded } from './module-import-guard';
26 import { XdsServicesModule } from './services/@core-xds-services.module';
27 import { AnalyticsService } from '../@core/utils/analytics.service';
28 import { StateService } from '../@core/data/state.service';
29
30 const NB_COREXDS_PROVIDERS = [
31   ...XdsServicesModule.forRoot().providers,
32   ...NbAuthModule.forRoot({
33     providers: {
34       email: {
35         service: NbDummyAuthProvider,
36         config: {
37           delay: 3000,
38           login: {
39             rememberMe: true,
40           },
41         },
42       },
43     },
44   }).providers,
45   AnalyticsService,
46   StateService,
47 ];
48
49 @NgModule({
50   imports: [
51     CommonModule,
52     CookieModule.forRoot(),
53   ],
54   exports: [
55     NbAuthModule,
56   ],
57   declarations: [],
58 })
59 export class CoreXdsModule {
60   constructor( @Optional() @SkipSelf() parentModule: CoreXdsModule) {
61     throwIfAlreadyLoaded(parentModule, 'CoreXdsModule');
62   }
63
64   static forRoot(): ModuleWithProviders {
65     return <ModuleWithProviders>{
66       ngModule: CoreXdsModule,
67       providers: [
68         ...NB_COREXDS_PROVIDERS,
69       ],
70     };
71   }
72 }