This repository has been archived by the owner on Jan 11, 2022. It is now read-only.
/
app.config.ts
154 lines (122 loc) · 3.9 KB
/
app.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import { CaseEventData, AbstractAppConfig, Config } from '@hmcts/ccd-case-ui-toolkit';
import { environment } from '../environments/environment';
@Injectable()
export class AppConfig extends AbstractAppConfig {
constructor(private http: Http) {
super();
}
public load(): Promise<void> {
console.log('Loading app config...');
let configUrl = environment.configUrl;
return new Promise<void>((resolve, reject) => {
this.http
.get(configUrl)
.map(response => response.json())
.catch((error: any): any => {
console.error(`Configuration ${configUrl} could not be read`, error);
reject();
return Observable.throw(error.json().error || 'Server error');
})
.subscribe((config: Config) => {
this.config = config;
console.log('Loading app config: OK');
resolve();
});
});
}
public getLoginUrl(): string {
return this.config.login_url;
}
public getLogoutUrl(): string {
return this.config.logout_url;
}
public getApiUrl() {
return this.config.api_url;
}
public getCaseDataUrl() {
return this.config.case_data_url;
}
public getDocumentManagementUrl() {
return this.config.document_management_url;
}
public getRemoteDocumentManagementUrl() {
return this.config.remote_document_management_url;
}
public getPaginationPageSize() {
return this.config.pagination_page_size;
}
public getPostcodeLookupUrl() {
return this.config.postcode_lookup_url;
}
public getOAuth2TokenEndpointUrl() {
return this.config.oauth2_token_endpoint_url;
}
public getOAuth2ClientId() {
return this.config.oauth2_client_id;
}
public getPrintServiceUrl() {
return this.config.print_service_url;
}
public getRemotePrintServiceUrl() {
return this.config.remote_print_service_url;
}
public getSmartSurveyUrl() {
return this.config.smart_survey_url;
}
public getUnsupportedBrowserUrl() {
return this.config.unsupported_browser_url;
}
public getActivityUrl() {
return this.config.activity_url;
}
public getActivityNexPollRequestMs() {
return this.config.activity_next_poll_request_ms;
}
public getActivityRetry() {
return this.config.activity_retry;
}
public getActivityBatchCollectionDelayMs() {
return this.config.activity_batch_collection_delay_ms;
}
public getActivityMaxRequestPerBatch() {
return this.config.activity_max_request_per_batch;
}
public getPaymentsUrl() {
return this.config.payments_url;
}
public getChromeMinRequiredVersion() {
return this.config.chrome_min_required_version;
}
public getIEMinRequiredVersion() {
return this.config.ie_min_required_version;
}
public getEdgeMinRequiredVersion() {
return this.config.edge_min_required_version;
}
public getFirefoxMinRequiredVersion() {
return this.config.firefox_min_required_version;
}
public getCaseHistoryUrl(jurisdictionId: string,
caseTypeId: string,
caseId: string,
eventId: string) {
return this.getApiUrl()
+ `/caseworkers/:uid`
+ `/jurisdictions/${jurisdictionId}`
+ `/case-types/${caseTypeId}`
+ `/cases/${caseId}`
+ `/events/${eventId}`
+ `/case-history`;
}
public getCreateOrUpdateDraftsUrl(jid: string, ctid: string, eventData: CaseEventData) {
return this.getCaseDataUrl() + `/caseworkers/:uid/jurisdictions/${jid}/case-types/${ctid}/event-trigger/${eventData.event.id}/drafts/`;
}
public getViewOrDeleteDraftsUrl(jid: string, ctid: string, did: string) {
return this.getCaseDataUrl() + `/caseworkers/:uid/jurisdictions/${jid}/case-types/${ctid}/drafts/${did}`;
}
}