1 |
f8b9a3a2
|
hlavja
|
/* tslint:disable */
|
2 |
|
|
/* eslint-disable */
|
3 |
|
|
import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core';
|
4 |
|
|
import { HttpClient } from '@angular/common/http';
|
5 |
|
|
import { ApiConfiguration, ApiConfigurationParams } from './api-configuration';
|
6 |
|
|
|
7 |
|
|
import { LoginService } from './services/login.service';
|
8 |
|
|
import { GroupService } from './services/group.service';
|
9 |
db9d0213
|
hlavja
|
import { ObservationService } from './services/observation.service';
|
10 |
1d6ec56f
|
hlavja
|
import { DataService } from './services/data.service';
|
11 |
a7285540
|
hlavja
|
import { AnalyticsService } from './services/analytics.service';
|
12 |
f8b9a3a2
|
hlavja
|
|
13 |
|
|
/**
|
14 |
|
|
* Module that provides all services and configuration.
|
15 |
|
|
*/
|
16 |
|
|
@NgModule({
|
17 |
|
|
imports: [],
|
18 |
|
|
exports: [],
|
19 |
|
|
declarations: [],
|
20 |
|
|
providers: [
|
21 |
|
|
LoginService,
|
22 |
|
|
GroupService,
|
23 |
db9d0213
|
hlavja
|
ObservationService,
|
24 |
1d6ec56f
|
hlavja
|
DataService,
|
25 |
a7285540
|
hlavja
|
AnalyticsService,
|
26 |
f8b9a3a2
|
hlavja
|
ApiConfiguration
|
27 |
|
|
],
|
28 |
|
|
})
|
29 |
|
|
export class ApiModule {
|
30 |
|
|
static forRoot(params: ApiConfigurationParams): ModuleWithProviders<ApiModule> {
|
31 |
|
|
return {
|
32 |
|
|
ngModule: ApiModule,
|
33 |
|
|
providers: [
|
34 |
|
|
{
|
35 |
|
|
provide: ApiConfiguration,
|
36 |
|
|
useValue: params
|
37 |
|
|
}
|
38 |
|
|
]
|
39 |
|
|
}
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
constructor(
|
43 |
|
|
@Optional() @SkipSelf() parentModule: ApiModule,
|
44 |
|
|
@Optional() http: HttpClient
|
45 |
|
|
) {
|
46 |
|
|
if (parentModule) {
|
47 |
|
|
throw new Error('ApiModule is already loaded. Import in your base AppModule only.');
|
48 |
|
|
}
|
49 |
|
|
if (!http) {
|
50 |
|
|
throw new Error('You need to import the HttpClientModule in your AppModule! \n' +
|
51 |
|
|
'See also https://github.com/angular/angular/issues/20575');
|
52 |
|
|
}
|
53 |
|
|
}
|
54 |
|
|
}
|