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