@valtimo/resource 4.15.3-next-main.16 → 4.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/valtimo-resource.umd.js +534 -397
- package/bundles/valtimo-resource.umd.js.map +1 -1
- package/bundles/valtimo-resource.umd.min.js +1 -1
- package/bundles/valtimo-resource.umd.min.js.map +1 -1
- package/esm2015/lib/models/index.js +21 -0
- package/esm2015/lib/models/open-zaak.model.js +75 -0
- package/esm2015/lib/models/upload.model.js +16 -0
- package/esm2015/lib/models/uploader.model.js +26 -0
- package/esm2015/lib/resource.module.js +40 -40
- package/esm2015/lib/services/download.service.js +60 -60
- package/esm2015/lib/services/open-zaak-upload.service.js +62 -62
- package/esm2015/lib/services/open-zaak.service.js +97 -97
- package/esm2015/lib/services/s3-upload.service.js +61 -61
- package/esm2015/lib/services/s3.service.js +61 -61
- package/esm2015/lib/services/upload-provider.service.js +53 -54
- package/esm2015/public-api.js +10 -9
- package/esm2015/valtimo-resource.js +7 -7
- package/fesm2015/valtimo-resource.js +518 -384
- package/fesm2015/valtimo-resource.js.map +1 -1
- package/lib/models/index.d.ts +3 -0
- package/lib/models/open-zaak.model.d.ts +146 -0
- package/lib/models/upload.model.d.ts +27 -0
- package/lib/models/uploader.model.d.ts +30 -0
- package/lib/resource.module.d.ts +2 -2
- package/lib/services/download.service.d.ts +9 -9
- package/lib/services/open-zaak-upload.service.d.ts +15 -15
- package/lib/services/open-zaak.service.d.ts +28 -28
- package/lib/services/s3-upload.service.d.ts +10 -10
- package/lib/services/s3.service.d.ts +15 -15
- package/lib/services/upload-provider.service.d.ts +14 -14
- package/package.json +1 -1
- package/public-api.d.ts +6 -5
- package/valtimo-resource.d.ts +6 -6
- package/valtimo-resource.metadata.json +1 -1
|
@@ -1,409 +1,543 @@
|
|
|
1
1
|
import { ɵɵdefineInjectable, ɵɵinject, Injectable, INJECTOR, Injector, NgModule } from '@angular/core';
|
|
2
2
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|
3
|
-
import { ConfigService } from '@valtimo/config';
|
|
3
|
+
import { ConfigService, UploadProvider } from '@valtimo/config';
|
|
4
4
|
import { map, tap, switchMap } from 'rxjs/operators';
|
|
5
|
-
import { S3Resource, UploadProvider } from '@valtimo/contract';
|
|
6
5
|
import { v4 } from 'uuid';
|
|
7
6
|
import { NGXLogger } from 'ngx-logger';
|
|
8
7
|
|
|
9
|
-
/*
|
|
10
|
-
* Copyright 2020
|
|
11
|
-
*
|
|
12
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
13
|
-
* you may not use this file except in compliance with the License.
|
|
14
|
-
* You may obtain a copy of the License at
|
|
15
|
-
*
|
|
16
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
17
|
-
*
|
|
18
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
20
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
-
* See the License for the specific language governing permissions and
|
|
22
|
-
* limitations under the License.
|
|
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
|
-
|
|
8
|
+
/*
|
|
9
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
26
|
+
*
|
|
27
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
28
|
+
* you may not use this file except in compliance with the License.
|
|
29
|
+
* You may obtain a copy of the License at
|
|
30
|
+
*
|
|
31
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
32
|
+
*
|
|
33
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
34
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
35
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
36
|
+
* See the License for the specific language governing permissions and
|
|
37
|
+
* limitations under the License.
|
|
38
|
+
*/
|
|
39
|
+
class S3Resource {
|
|
40
|
+
constructor(file, preSignedUrl) {
|
|
41
|
+
this.id = null;
|
|
42
|
+
this.extension = null;
|
|
43
|
+
this.createdOn = null;
|
|
44
|
+
this.key = decodeURIComponent(preSignedUrl.pathname.substring(1));
|
|
45
|
+
this.name = file.name;
|
|
46
|
+
this.sizeInBytes = file.size;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
52
|
+
*
|
|
53
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
54
|
+
* you may not use this file except in compliance with the License.
|
|
55
|
+
* You may obtain a copy of the License at
|
|
56
|
+
*
|
|
57
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
58
|
+
*
|
|
59
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
60
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
61
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
62
|
+
* See the License for the specific language governing permissions and
|
|
63
|
+
* limitations under the License.
|
|
64
|
+
*/
|
|
65
|
+
class OpenZaakConfig {
|
|
66
|
+
}
|
|
67
|
+
var Archiefnominatie;
|
|
68
|
+
(function (Archiefnominatie) {
|
|
69
|
+
Archiefnominatie["blijvend_bewaren"] = "blijven_bewaren";
|
|
70
|
+
Archiefnominatie["vernietigen"] = "vernietigen";
|
|
71
|
+
})(Archiefnominatie || (Archiefnominatie = {}));
|
|
72
|
+
var Afleidingswijze;
|
|
73
|
+
(function (Afleidingswijze) {
|
|
74
|
+
Afleidingswijze["afgehandeld"] = "afgehandeld";
|
|
75
|
+
Afleidingswijze["ander_datumkenmerk"] = "ander_datumkenmerk";
|
|
76
|
+
Afleidingswijze["eigenschap"] = "eigenschap";
|
|
77
|
+
Afleidingswijze["gerelateerde_zaak"] = "gerelateerde_zaak";
|
|
78
|
+
Afleidingswijze["hoofdzaak"] = "hoofdzaak";
|
|
79
|
+
Afleidingswijze["ingangsdatum_besluit"] = "ingangsdatum_besluit";
|
|
80
|
+
Afleidingswijze["termijn"] = "termijn";
|
|
81
|
+
Afleidingswijze["vervaldatum_besluit"] = "vervaldatum_besluit";
|
|
82
|
+
Afleidingswijze["zaakobject"] = "zaakobject";
|
|
83
|
+
})(Afleidingswijze || (Afleidingswijze = {}));
|
|
84
|
+
var Objecttype;
|
|
85
|
+
(function (Objecttype) {
|
|
86
|
+
Objecttype["adres"] = "adres";
|
|
87
|
+
Objecttype["besluit"] = "besluit";
|
|
88
|
+
Objecttype["buurt"] = "buurt";
|
|
89
|
+
Objecttype["enkelvoudig_document"] = "enkelvoudig_document";
|
|
90
|
+
Objecttype["gemeente"] = "gemeente";
|
|
91
|
+
Objecttype["gemeentelijke_openbare_ruimte"] = "gemeentelijke_openbare_ruimte";
|
|
92
|
+
Objecttype["huishouden"] = "huishouden";
|
|
93
|
+
Objecttype["inrichtingselement"] = "inrichtingselement";
|
|
94
|
+
Objecttype["kadastrale_onroerende_zaak"] = "kadastrale_onroerende_zaak";
|
|
95
|
+
Objecttype["kunstwerkdeel"] = "kunstwerkdeel";
|
|
96
|
+
Objecttype["maatschappelijke_activiteit"] = "maatschappelijke_activiteit";
|
|
97
|
+
Objecttype["medewerker"] = "medewerker";
|
|
98
|
+
Objecttype["natuurlijk_persoon"] = "natuurlijk_persoon";
|
|
99
|
+
Objecttype["niet_natuurlijk_persoon"] = "niet_natuurlijk_persoon";
|
|
100
|
+
Objecttype["openbare_ruimte"] = "openbare_ruimte";
|
|
101
|
+
Objecttype["organisatorische_eenheid"] = "organisatorische_eenheid";
|
|
102
|
+
Objecttype["pand"] = "pand";
|
|
103
|
+
Objecttype["spoorbaandeel"] = "spoorbaandeel";
|
|
104
|
+
Objecttype["status"] = "status";
|
|
105
|
+
Objecttype["terreindeel"] = "terreindeel";
|
|
106
|
+
Objecttype["terrein_gebouwd_object"] = "terrein_gebouwd_object";
|
|
107
|
+
Objecttype["vestiging"] = "vestiging";
|
|
108
|
+
Objecttype["waterdeel"] = "waterdeel";
|
|
109
|
+
Objecttype["wegdeel"] = "wegdeel";
|
|
110
|
+
Objecttype["wijk"] = "wijk";
|
|
111
|
+
Objecttype["woonplaats"] = "woonplaats";
|
|
112
|
+
Objecttype["woz_deelobject"] = "woz_deelobject";
|
|
113
|
+
Objecttype["woz_object"] = "woz_object";
|
|
114
|
+
Objecttype["woz_waarde"] = "woz_waarde";
|
|
115
|
+
Objecttype["zakelijk_recht"] = "zakelijk_recht";
|
|
116
|
+
Objecttype["overige"] = "overige";
|
|
117
|
+
})(Objecttype || (Objecttype = {}));
|
|
118
|
+
var Operation;
|
|
119
|
+
(function (Operation) {
|
|
120
|
+
Operation["CREATE_ZAAK"] = "CREATE_ZAAK";
|
|
121
|
+
Operation["SET_RESULTAAT"] = "SET_RESULTAAT";
|
|
122
|
+
Operation["SET_STATUS"] = "SET_STATUS";
|
|
123
|
+
})(Operation || (Operation = {}));
|
|
124
|
+
|
|
125
|
+
/*
|
|
126
|
+
*
|
|
127
|
+
* * Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
128
|
+
* *
|
|
129
|
+
* * Licensed under EUPL, Version 1.2 (the "License");
|
|
130
|
+
* * you may not use this file except in compliance with the License.
|
|
131
|
+
* * You may obtain a copy of the License at
|
|
132
|
+
* *
|
|
133
|
+
* * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
134
|
+
* *
|
|
135
|
+
* * Unless required by applicable law or agreed to in writing, software
|
|
136
|
+
* * distributed under the License is distributed on an "AS IS" basis,
|
|
137
|
+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
138
|
+
* * See the License for the specific language governing permissions and
|
|
139
|
+
* * limitations under the License.
|
|
140
|
+
*
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
/*
|
|
144
|
+
* Copyright 2020 Dimpact.
|
|
145
|
+
*
|
|
146
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
147
|
+
* you may not use this file except in compliance with the License.
|
|
148
|
+
* You may obtain a copy of the License at
|
|
149
|
+
*
|
|
150
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
151
|
+
*
|
|
152
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
153
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
154
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
155
|
+
* See the License for the specific language governing permissions and
|
|
156
|
+
* limitations under the License.
|
|
157
|
+
*/
|
|
158
|
+
class OpenZaakService {
|
|
159
|
+
constructor(http, configService) {
|
|
160
|
+
this.http = http;
|
|
161
|
+
this.configService = configService;
|
|
162
|
+
this.valtimoApiConfig = configService.config.valtimoApi;
|
|
163
|
+
this.catalogus = configService.config.openZaak.catalogus;
|
|
164
|
+
}
|
|
165
|
+
getOpenZaakConfig() {
|
|
166
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}openzaak/config`);
|
|
167
|
+
}
|
|
168
|
+
getResource(resourceId) {
|
|
169
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}resource/${resourceId}`);
|
|
170
|
+
}
|
|
171
|
+
getZaakTypes() {
|
|
172
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}openzaak/zaaktype`);
|
|
173
|
+
}
|
|
174
|
+
getInformatieObjectTypes() {
|
|
175
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}openzaak/informatie-object-typen/${this.catalogus}`);
|
|
176
|
+
}
|
|
177
|
+
getZaakTypeLink(id) {
|
|
178
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}openzaak/link/${id}`);
|
|
179
|
+
}
|
|
180
|
+
getInformatieObjectTypeLink(id) {
|
|
181
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}openzaak/informatie-object-type-link/${id}`);
|
|
182
|
+
}
|
|
183
|
+
createZaakTypeLink(request) {
|
|
184
|
+
return this.http.post(`${this.valtimoApiConfig.endpointUri}openzaak/link`, request);
|
|
185
|
+
}
|
|
186
|
+
createInformatieObjectTypeLink(request) {
|
|
187
|
+
return this.http.post(`${this.valtimoApiConfig.endpointUri}openzaak/informatie-object-type-link`, request);
|
|
188
|
+
}
|
|
189
|
+
deleteZaakTypeLink(id) {
|
|
190
|
+
return this.http.delete(`${this.valtimoApiConfig.endpointUri}openzaak/link/${id}`);
|
|
191
|
+
}
|
|
192
|
+
deleteInformatieObjectTypeLink(id) {
|
|
193
|
+
return this.http.delete(`${this.valtimoApiConfig.endpointUri}openzaak/informatie-object-type-link/${id}`);
|
|
194
|
+
}
|
|
195
|
+
getZaakTypeLinkListByProcess(processDefinitionKey) {
|
|
196
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}openzaak/link/process/${processDefinitionKey}`);
|
|
197
|
+
}
|
|
198
|
+
getStatusTypes(zaakTypeRequest) {
|
|
199
|
+
return this.http.post(`${this.valtimoApiConfig.endpointUri}openzaak/status`, zaakTypeRequest);
|
|
200
|
+
}
|
|
201
|
+
getStatusResults(zaakTypeRequest) {
|
|
202
|
+
return this.http.post(`${this.valtimoApiConfig.endpointUri}openzaak/resultaat`, zaakTypeRequest);
|
|
203
|
+
}
|
|
204
|
+
createServiceTaskHandler(id, request) {
|
|
205
|
+
return this.http.post(`${this.valtimoApiConfig.endpointUri}openzaak/link/${id}/service-handler`, request);
|
|
206
|
+
}
|
|
207
|
+
modifyServiceTaskHandler(id, request) {
|
|
208
|
+
return this.http.put(`${this.valtimoApiConfig.endpointUri}openzaak/link/${id}/service-handler`, request);
|
|
209
|
+
}
|
|
210
|
+
deleteServiceTaskHandler(id, processDefinitionKey, serviceTaskId) {
|
|
211
|
+
return this.http.delete(`${this.valtimoApiConfig.endpointUri}openzaak/link/${id}/service-handler/${processDefinitionKey}/${serviceTaskId}`);
|
|
212
|
+
}
|
|
213
|
+
upload(file, documentDefinitionName) {
|
|
214
|
+
const formData = new FormData();
|
|
215
|
+
formData.append('file', file);
|
|
216
|
+
formData.append('documentDefinitionName', documentDefinitionName);
|
|
217
|
+
return this.http.post(`${this.valtimoApiConfig.endpointUri}resource/upload-open-zaak`, formData, {
|
|
218
|
+
reportProgress: true,
|
|
219
|
+
responseType: 'json',
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
OpenZaakService.ɵprov = ɵɵdefineInjectable({ factory: function OpenZaakService_Factory() { return new OpenZaakService(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: OpenZaakService, providedIn: "root" });
|
|
224
|
+
OpenZaakService.decorators = [
|
|
225
|
+
{ type: Injectable, args: [{
|
|
226
|
+
providedIn: 'root',
|
|
227
|
+
},] }
|
|
228
|
+
];
|
|
229
|
+
OpenZaakService.ctorParameters = () => [
|
|
230
|
+
{ type: HttpClient },
|
|
231
|
+
{ type: ConfigService }
|
|
98
232
|
];
|
|
99
233
|
|
|
100
|
-
/*
|
|
101
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
102
|
-
*
|
|
103
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
104
|
-
* you may not use this file except in compliance with the License.
|
|
105
|
-
* You may obtain a copy of the License at
|
|
106
|
-
*
|
|
107
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
108
|
-
*
|
|
109
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
110
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
111
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
112
|
-
* See the License for the specific language governing permissions and
|
|
113
|
-
* limitations under the License.
|
|
114
|
-
*/
|
|
115
|
-
class OpenZaakUploadService {
|
|
116
|
-
constructor(openZaakService, http, configService) {
|
|
117
|
-
this.openZaakService = openZaakService;
|
|
118
|
-
this.http = http;
|
|
119
|
-
this.configService = configService;
|
|
120
|
-
this.valtimoApiConfig = configService.config.valtimoApi;
|
|
121
|
-
}
|
|
122
|
-
uploadFile(file, documentDefinitionName) {
|
|
123
|
-
return this.openZaakService
|
|
124
|
-
.upload(new File([file], file.name, { type: file.type }), documentDefinitionName)
|
|
125
|
-
.pipe(map(result => this.getResourceFile(result)));
|
|
126
|
-
}
|
|
127
|
-
getResource(resourceId) {
|
|
128
|
-
return this.openZaakService.getResource(resourceId);
|
|
129
|
-
}
|
|
130
|
-
getResourceFile(result) {
|
|
131
|
-
return {
|
|
132
|
-
customUpload: true,
|
|
133
|
-
originalName: result.name,
|
|
134
|
-
size: result.sizeInBytes,
|
|
135
|
-
url: '/api/resource/' + result.resourceId + '/download',
|
|
136
|
-
storage: 'openZaak',
|
|
137
|
-
type: result.extension,
|
|
138
|
-
data: {
|
|
139
|
-
createdOn: result.createdOn,
|
|
140
|
-
name: result.name,
|
|
141
|
-
sizeInBytes: result.sizeInBytes,
|
|
142
|
-
resourceId: result.resourceId,
|
|
143
|
-
extension: result.extension,
|
|
144
|
-
},
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
OpenZaakUploadService.decorators = [
|
|
149
|
-
{ type: Injectable }
|
|
150
|
-
];
|
|
151
|
-
OpenZaakUploadService.ctorParameters = () => [
|
|
152
|
-
{ type: OpenZaakService },
|
|
153
|
-
{ type: HttpClient },
|
|
154
|
-
{ type: ConfigService }
|
|
234
|
+
/*
|
|
235
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
236
|
+
*
|
|
237
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
238
|
+
* you may not use this file except in compliance with the License.
|
|
239
|
+
* You may obtain a copy of the License at
|
|
240
|
+
*
|
|
241
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
242
|
+
*
|
|
243
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
244
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
245
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
246
|
+
* See the License for the specific language governing permissions and
|
|
247
|
+
* limitations under the License.
|
|
248
|
+
*/
|
|
249
|
+
class OpenZaakUploadService {
|
|
250
|
+
constructor(openZaakService, http, configService) {
|
|
251
|
+
this.openZaakService = openZaakService;
|
|
252
|
+
this.http = http;
|
|
253
|
+
this.configService = configService;
|
|
254
|
+
this.valtimoApiConfig = configService.config.valtimoApi;
|
|
255
|
+
}
|
|
256
|
+
uploadFile(file, documentDefinitionName) {
|
|
257
|
+
return this.openZaakService
|
|
258
|
+
.upload(new File([file], file.name, { type: file.type }), documentDefinitionName)
|
|
259
|
+
.pipe(map(result => this.getResourceFile(result)));
|
|
260
|
+
}
|
|
261
|
+
getResource(resourceId) {
|
|
262
|
+
return this.openZaakService.getResource(resourceId);
|
|
263
|
+
}
|
|
264
|
+
getResourceFile(result) {
|
|
265
|
+
return {
|
|
266
|
+
customUpload: true,
|
|
267
|
+
originalName: result.name,
|
|
268
|
+
size: result.sizeInBytes,
|
|
269
|
+
url: '/api/resource/' + result.resourceId + '/download',
|
|
270
|
+
storage: 'openZaak',
|
|
271
|
+
type: result.extension,
|
|
272
|
+
data: {
|
|
273
|
+
createdOn: result.createdOn,
|
|
274
|
+
name: result.name,
|
|
275
|
+
sizeInBytes: result.sizeInBytes,
|
|
276
|
+
resourceId: result.resourceId,
|
|
277
|
+
extension: result.extension,
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
OpenZaakUploadService.decorators = [
|
|
283
|
+
{ type: Injectable }
|
|
284
|
+
];
|
|
285
|
+
OpenZaakUploadService.ctorParameters = () => [
|
|
286
|
+
{ type: OpenZaakService },
|
|
287
|
+
{ type: HttpClient },
|
|
288
|
+
{ type: ConfigService }
|
|
155
289
|
];
|
|
156
290
|
|
|
157
|
-
/*
|
|
158
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
159
|
-
*
|
|
160
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
161
|
-
* you may not use this file except in compliance with the License.
|
|
162
|
-
* You may obtain a copy of the License at
|
|
163
|
-
*
|
|
164
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
165
|
-
*
|
|
166
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
167
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
168
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
169
|
-
* See the License for the specific language governing permissions and
|
|
170
|
-
* limitations under the License.
|
|
171
|
-
*/
|
|
172
|
-
class S3Service {
|
|
173
|
-
constructor(http, configService) {
|
|
174
|
-
this.http = http;
|
|
175
|
-
this.configService = configService;
|
|
176
|
-
this.valtimoApiConfig = configService.config.valtimoApi;
|
|
177
|
-
}
|
|
178
|
-
getPreSignedUrl(fileName) {
|
|
179
|
-
const headers = new HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');
|
|
180
|
-
const options = { headers, responseType: 'text' };
|
|
181
|
-
return this.http.get(`${this.valtimoApiConfig.endpointUri}resource/pre-signed-url/${fileName}`, options);
|
|
182
|
-
}
|
|
183
|
-
upload(url, file) {
|
|
184
|
-
const headers = new HttpHeaders().set('Content-Type', file.type);
|
|
185
|
-
return this.http.put(url.toString(), file, { headers: headers });
|
|
186
|
-
}
|
|
187
|
-
registerResource(s3ResourceDTO) {
|
|
188
|
-
return this.http.put(`${this.valtimoApiConfig.endpointUri}resource`, s3ResourceDTO);
|
|
189
|
-
}
|
|
190
|
-
get(resourceId) {
|
|
191
|
-
const headers = new HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');
|
|
192
|
-
return this.http.get(`${this.valtimoApiConfig.endpointUri}resource/${resourceId}`, { headers: headers });
|
|
193
|
-
}
|
|
194
|
-
delete(resourceId) {
|
|
195
|
-
const headers = new HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');
|
|
196
|
-
return this.http.delete(`${this.valtimoApiConfig.endpointUri}resource/${resourceId}`, {
|
|
197
|
-
headers: headers,
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
S3Service.ɵprov = ɵɵdefineInjectable({ factory: function S3Service_Factory() { return new S3Service(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: S3Service, providedIn: "root" });
|
|
202
|
-
S3Service.decorators = [
|
|
203
|
-
{ type: Injectable, args: [{
|
|
204
|
-
providedIn: 'root',
|
|
205
|
-
},] }
|
|
206
|
-
];
|
|
207
|
-
S3Service.ctorParameters = () => [
|
|
208
|
-
{ type: HttpClient },
|
|
209
|
-
{ type: ConfigService }
|
|
291
|
+
/*
|
|
292
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
293
|
+
*
|
|
294
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
295
|
+
* you may not use this file except in compliance with the License.
|
|
296
|
+
* You may obtain a copy of the License at
|
|
297
|
+
*
|
|
298
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
299
|
+
*
|
|
300
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
301
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
302
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
303
|
+
* See the License for the specific language governing permissions and
|
|
304
|
+
* limitations under the License.
|
|
305
|
+
*/
|
|
306
|
+
class S3Service {
|
|
307
|
+
constructor(http, configService) {
|
|
308
|
+
this.http = http;
|
|
309
|
+
this.configService = configService;
|
|
310
|
+
this.valtimoApiConfig = configService.config.valtimoApi;
|
|
311
|
+
}
|
|
312
|
+
getPreSignedUrl(fileName) {
|
|
313
|
+
const headers = new HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');
|
|
314
|
+
const options = { headers, responseType: 'text' };
|
|
315
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}resource/pre-signed-url/${fileName}`, options);
|
|
316
|
+
}
|
|
317
|
+
upload(url, file) {
|
|
318
|
+
const headers = new HttpHeaders().set('Content-Type', file.type);
|
|
319
|
+
return this.http.put(url.toString(), file, { headers: headers });
|
|
320
|
+
}
|
|
321
|
+
registerResource(s3ResourceDTO) {
|
|
322
|
+
return this.http.put(`${this.valtimoApiConfig.endpointUri}resource`, s3ResourceDTO);
|
|
323
|
+
}
|
|
324
|
+
get(resourceId) {
|
|
325
|
+
const headers = new HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');
|
|
326
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}resource/${resourceId}`, { headers: headers });
|
|
327
|
+
}
|
|
328
|
+
delete(resourceId) {
|
|
329
|
+
const headers = new HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');
|
|
330
|
+
return this.http.delete(`${this.valtimoApiConfig.endpointUri}resource/${resourceId}`, {
|
|
331
|
+
headers: headers,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
S3Service.ɵprov = ɵɵdefineInjectable({ factory: function S3Service_Factory() { return new S3Service(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: S3Service, providedIn: "root" });
|
|
336
|
+
S3Service.decorators = [
|
|
337
|
+
{ type: Injectable, args: [{
|
|
338
|
+
providedIn: 'root',
|
|
339
|
+
},] }
|
|
340
|
+
];
|
|
341
|
+
S3Service.ctorParameters = () => [
|
|
342
|
+
{ type: HttpClient },
|
|
343
|
+
{ type: ConfigService }
|
|
210
344
|
];
|
|
211
345
|
|
|
212
|
-
/*
|
|
213
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
214
|
-
*
|
|
215
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
216
|
-
* you may not use this file except in compliance with the License.
|
|
217
|
-
* You may obtain a copy of the License at
|
|
218
|
-
*
|
|
219
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
220
|
-
*
|
|
221
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
222
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
223
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
224
|
-
* See the License for the specific language governing permissions and
|
|
225
|
-
* limitations under the License.
|
|
226
|
-
*/
|
|
227
|
-
class S3UploadService {
|
|
228
|
-
constructor(s3Service) {
|
|
229
|
-
this.s3Service = s3Service;
|
|
230
|
-
}
|
|
231
|
-
uploadFile(file) {
|
|
232
|
-
let resourceUrl;
|
|
233
|
-
const fileName = file.name;
|
|
234
|
-
const splitFileName = fileName.split('.');
|
|
235
|
-
const fileNameWithUUID = `${splitFileName[0]}-${v4()}.${splitFileName[1]}`;
|
|
236
|
-
const renamedFile = new File([file], fileNameWithUUID, { type: file.type });
|
|
237
|
-
return this.s3Service.getPreSignedUrl(renamedFile.name).pipe(map(url => new URL(url)), tap(url => (resourceUrl = url)), switchMap(url => this.s3Service.upload(url, renamedFile)), map(() => new S3Resource(file, resourceUrl)), switchMap(s3Resource => this.s3Service.registerResource(s3Resource)), switchMap(s3Resource => this.s3Service.get(s3Resource.id)), map(result => (Object.assign(Object.assign({}, result), { originalName: file.name }))), map(result => this.getResourceFile(result)));
|
|
238
|
-
}
|
|
239
|
-
getResource(resourceId) {
|
|
240
|
-
return this.s3Service.get(resourceId);
|
|
241
|
-
}
|
|
242
|
-
getResourceFile(result) {
|
|
243
|
-
return {
|
|
244
|
-
customUpload: true,
|
|
245
|
-
originalName: result.originalName,
|
|
246
|
-
url: result.url,
|
|
247
|
-
size: result.resource.sizeInBytes,
|
|
248
|
-
storage: 'url',
|
|
249
|
-
type: result.resource.extension,
|
|
250
|
-
data: {
|
|
251
|
-
key: result.resource.key,
|
|
252
|
-
bucketName: result.resource.name,
|
|
253
|
-
createdOn: result.resource.createdOn,
|
|
254
|
-
name: result.originalName,
|
|
255
|
-
sizeInBytes: result.resource.sizeInBytes,
|
|
256
|
-
resourceId: result.resource.id.split('ResourceId(id=')[1].slice(0, -1),
|
|
257
|
-
},
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
S3UploadService.decorators = [
|
|
262
|
-
{ type: Injectable }
|
|
263
|
-
];
|
|
264
|
-
S3UploadService.ctorParameters = () => [
|
|
265
|
-
{ type: S3Service }
|
|
346
|
+
/*
|
|
347
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
348
|
+
*
|
|
349
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
350
|
+
* you may not use this file except in compliance with the License.
|
|
351
|
+
* You may obtain a copy of the License at
|
|
352
|
+
*
|
|
353
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
354
|
+
*
|
|
355
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
356
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
357
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
358
|
+
* See the License for the specific language governing permissions and
|
|
359
|
+
* limitations under the License.
|
|
360
|
+
*/
|
|
361
|
+
class S3UploadService {
|
|
362
|
+
constructor(s3Service) {
|
|
363
|
+
this.s3Service = s3Service;
|
|
364
|
+
}
|
|
365
|
+
uploadFile(file) {
|
|
366
|
+
let resourceUrl;
|
|
367
|
+
const fileName = file.name;
|
|
368
|
+
const splitFileName = fileName.split('.');
|
|
369
|
+
const fileNameWithUUID = `${splitFileName[0]}-${v4()}.${splitFileName[1]}`;
|
|
370
|
+
const renamedFile = new File([file], fileNameWithUUID, { type: file.type });
|
|
371
|
+
return this.s3Service.getPreSignedUrl(renamedFile.name).pipe(map(url => new URL(url)), tap(url => (resourceUrl = url)), switchMap(url => this.s3Service.upload(url, renamedFile)), map(() => new S3Resource(file, resourceUrl)), switchMap(s3Resource => this.s3Service.registerResource(s3Resource)), switchMap(s3Resource => this.s3Service.get(s3Resource.id)), map(result => (Object.assign(Object.assign({}, result), { originalName: file.name }))), map(result => this.getResourceFile(result)));
|
|
372
|
+
}
|
|
373
|
+
getResource(resourceId) {
|
|
374
|
+
return this.s3Service.get(resourceId);
|
|
375
|
+
}
|
|
376
|
+
getResourceFile(result) {
|
|
377
|
+
return {
|
|
378
|
+
customUpload: true,
|
|
379
|
+
originalName: result.originalName,
|
|
380
|
+
url: result.url,
|
|
381
|
+
size: result.resource.sizeInBytes,
|
|
382
|
+
storage: 'url',
|
|
383
|
+
type: result.resource.extension,
|
|
384
|
+
data: {
|
|
385
|
+
key: result.resource.key,
|
|
386
|
+
bucketName: result.resource.name,
|
|
387
|
+
createdOn: result.resource.createdOn,
|
|
388
|
+
name: result.originalName,
|
|
389
|
+
sizeInBytes: result.resource.sizeInBytes,
|
|
390
|
+
resourceId: result.resource.id.split('ResourceId(id=')[1].slice(0, -1),
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
S3UploadService.decorators = [
|
|
396
|
+
{ type: Injectable }
|
|
397
|
+
];
|
|
398
|
+
S3UploadService.ctorParameters = () => [
|
|
399
|
+
{ type: S3Service }
|
|
266
400
|
];
|
|
267
401
|
|
|
268
|
-
/*
|
|
269
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
270
|
-
*
|
|
271
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
272
|
-
* you may not use this file except in compliance with the License.
|
|
273
|
-
* You may obtain a copy of the License at
|
|
274
|
-
*
|
|
275
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
276
|
-
*
|
|
277
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
278
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
279
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
280
|
-
* See the License for the specific language governing permissions and
|
|
281
|
-
* limitations under the License.
|
|
282
|
-
*/
|
|
283
|
-
class UploadProviderService {
|
|
284
|
-
constructor(configService, injector, logger) {
|
|
285
|
-
this.configService = configService;
|
|
286
|
-
this.injector = injector;
|
|
287
|
-
this.logger = logger;
|
|
288
|
-
this.uploadService =
|
|
289
|
-
configService.config.uploadProvider === UploadProvider.S3
|
|
290
|
-
? injector.get(S3UploadService)
|
|
291
|
-
: injector.get(OpenZaakUploadService);
|
|
292
|
-
this.logger.debug('Loading UploadService as', this.uploadService);
|
|
293
|
-
}
|
|
294
|
-
uploadFile(file, documentDefinitionName) {
|
|
295
|
-
return this.uploadService.uploadFile(file, documentDefinitionName);
|
|
296
|
-
}
|
|
297
|
-
getResource(resourceId) {
|
|
298
|
-
return this.uploadService.getResource(resourceId);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
UploadProviderService.ɵprov = ɵɵdefineInjectable({ factory: function UploadProviderService_Factory() { return new UploadProviderService(ɵɵinject(ConfigService), ɵɵinject(INJECTOR), ɵɵinject(NGXLogger)); }, token: UploadProviderService, providedIn: "root" });
|
|
302
|
-
UploadProviderService.decorators = [
|
|
303
|
-
{ type: Injectable, args: [{
|
|
304
|
-
providedIn: 'root',
|
|
305
|
-
},] }
|
|
306
|
-
];
|
|
307
|
-
UploadProviderService.ctorParameters = () => [
|
|
308
|
-
{ type: ConfigService },
|
|
309
|
-
{ type: Injector },
|
|
310
|
-
{ type: NGXLogger }
|
|
402
|
+
/*
|
|
403
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
404
|
+
*
|
|
405
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
406
|
+
* you may not use this file except in compliance with the License.
|
|
407
|
+
* You may obtain a copy of the License at
|
|
408
|
+
*
|
|
409
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
410
|
+
*
|
|
411
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
412
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
413
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
414
|
+
* See the License for the specific language governing permissions and
|
|
415
|
+
* limitations under the License.
|
|
416
|
+
*/
|
|
417
|
+
class UploadProviderService {
|
|
418
|
+
constructor(configService, injector, logger) {
|
|
419
|
+
this.configService = configService;
|
|
420
|
+
this.injector = injector;
|
|
421
|
+
this.logger = logger;
|
|
422
|
+
this.uploadService =
|
|
423
|
+
configService.config.uploadProvider === UploadProvider.S3
|
|
424
|
+
? injector.get(S3UploadService)
|
|
425
|
+
: injector.get(OpenZaakUploadService);
|
|
426
|
+
this.logger.debug('Loading UploadService as', this.uploadService);
|
|
427
|
+
}
|
|
428
|
+
uploadFile(file, documentDefinitionName) {
|
|
429
|
+
return this.uploadService.uploadFile(file, documentDefinitionName);
|
|
430
|
+
}
|
|
431
|
+
getResource(resourceId) {
|
|
432
|
+
return this.uploadService.getResource(resourceId);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
UploadProviderService.ɵprov = ɵɵdefineInjectable({ factory: function UploadProviderService_Factory() { return new UploadProviderService(ɵɵinject(ConfigService), ɵɵinject(INJECTOR), ɵɵinject(NGXLogger)); }, token: UploadProviderService, providedIn: "root" });
|
|
436
|
+
UploadProviderService.decorators = [
|
|
437
|
+
{ type: Injectable, args: [{
|
|
438
|
+
providedIn: 'root',
|
|
439
|
+
},] }
|
|
440
|
+
];
|
|
441
|
+
UploadProviderService.ctorParameters = () => [
|
|
442
|
+
{ type: ConfigService },
|
|
443
|
+
{ type: Injector },
|
|
444
|
+
{ type: NGXLogger }
|
|
311
445
|
];
|
|
312
446
|
|
|
313
|
-
/*
|
|
314
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
315
|
-
*
|
|
316
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
317
|
-
* you may not use this file except in compliance with the License.
|
|
318
|
-
* You may obtain a copy of the License at
|
|
319
|
-
*
|
|
320
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
321
|
-
*
|
|
322
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
323
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
324
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
325
|
-
* See the License for the specific language governing permissions and
|
|
326
|
-
* limitations under the License.
|
|
327
|
-
*/
|
|
328
|
-
class DownloadService {
|
|
329
|
-
constructor(http, configService) {
|
|
330
|
-
this.http = http;
|
|
331
|
-
this.configService = configService;
|
|
332
|
-
}
|
|
333
|
-
downloadFile(url, name) {
|
|
334
|
-
if (url.startsWith(this.configService.config.valtimoApi.endpointUri) ||
|
|
335
|
-
url.startsWith(window.location.origin)) {
|
|
336
|
-
// if download url is on backend use angular to get the content so access token is used
|
|
337
|
-
this.http.get(url, { responseType: 'blob' }).subscribe(content => {
|
|
338
|
-
const downloadUrl = window.URL.createObjectURL(content);
|
|
339
|
-
this.openDownloadLink(downloadUrl, name);
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
// download links to external services (like amazon s3) open in a new window
|
|
344
|
-
this.openDownloadLink(url, name);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
openDownloadLink(url, name) {
|
|
348
|
-
const link = document.createElement('a');
|
|
349
|
-
link.href = url;
|
|
350
|
-
link.download = name;
|
|
351
|
-
link.target = '_blank';
|
|
352
|
-
link.click();
|
|
353
|
-
link.remove();
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
DownloadService.ɵprov = ɵɵdefineInjectable({ factory: function DownloadService_Factory() { return new DownloadService(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: DownloadService, providedIn: "root" });
|
|
357
|
-
DownloadService.decorators = [
|
|
358
|
-
{ type: Injectable, args: [{
|
|
359
|
-
providedIn: 'root',
|
|
360
|
-
},] }
|
|
361
|
-
];
|
|
362
|
-
DownloadService.ctorParameters = () => [
|
|
363
|
-
{ type: HttpClient },
|
|
364
|
-
{ type: ConfigService }
|
|
447
|
+
/*
|
|
448
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
449
|
+
*
|
|
450
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
451
|
+
* you may not use this file except in compliance with the License.
|
|
452
|
+
* You may obtain a copy of the License at
|
|
453
|
+
*
|
|
454
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
455
|
+
*
|
|
456
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
457
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
458
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
459
|
+
* See the License for the specific language governing permissions and
|
|
460
|
+
* limitations under the License.
|
|
461
|
+
*/
|
|
462
|
+
class DownloadService {
|
|
463
|
+
constructor(http, configService) {
|
|
464
|
+
this.http = http;
|
|
465
|
+
this.configService = configService;
|
|
466
|
+
}
|
|
467
|
+
downloadFile(url, name) {
|
|
468
|
+
if (url.startsWith(this.configService.config.valtimoApi.endpointUri) ||
|
|
469
|
+
url.startsWith(window.location.origin)) {
|
|
470
|
+
// if download url is on backend use angular to get the content so access token is used
|
|
471
|
+
this.http.get(url, { responseType: 'blob' }).subscribe(content => {
|
|
472
|
+
const downloadUrl = window.URL.createObjectURL(content);
|
|
473
|
+
this.openDownloadLink(downloadUrl, name);
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
// download links to external services (like amazon s3) open in a new window
|
|
478
|
+
this.openDownloadLink(url, name);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
openDownloadLink(url, name) {
|
|
482
|
+
const link = document.createElement('a');
|
|
483
|
+
link.href = url;
|
|
484
|
+
link.download = name;
|
|
485
|
+
link.target = '_blank';
|
|
486
|
+
link.click();
|
|
487
|
+
link.remove();
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
DownloadService.ɵprov = ɵɵdefineInjectable({ factory: function DownloadService_Factory() { return new DownloadService(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: DownloadService, providedIn: "root" });
|
|
491
|
+
DownloadService.decorators = [
|
|
492
|
+
{ type: Injectable, args: [{
|
|
493
|
+
providedIn: 'root',
|
|
494
|
+
},] }
|
|
495
|
+
];
|
|
496
|
+
DownloadService.ctorParameters = () => [
|
|
497
|
+
{ type: HttpClient },
|
|
498
|
+
{ type: ConfigService }
|
|
365
499
|
];
|
|
366
500
|
|
|
367
|
-
/*
|
|
368
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
369
|
-
*
|
|
370
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
371
|
-
* you may not use this file except in compliance with the License.
|
|
372
|
-
* You may obtain a copy of the License at
|
|
373
|
-
*
|
|
374
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
375
|
-
*
|
|
376
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
377
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
378
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
379
|
-
* See the License for the specific language governing permissions and
|
|
380
|
-
* limitations under the License.
|
|
381
|
-
*/
|
|
382
|
-
class ResourceModule {
|
|
383
|
-
}
|
|
384
|
-
ResourceModule.decorators = [
|
|
385
|
-
{ type: NgModule, args: [{
|
|
386
|
-
declarations: [],
|
|
387
|
-
imports: [],
|
|
388
|
-
exports: [],
|
|
389
|
-
providers: [
|
|
390
|
-
OpenZaakUploadService,
|
|
391
|
-
S3UploadService,
|
|
392
|
-
UploadProviderService,
|
|
393
|
-
OpenZaakService,
|
|
394
|
-
S3Service,
|
|
395
|
-
DownloadService,
|
|
396
|
-
],
|
|
397
|
-
},] }
|
|
501
|
+
/*
|
|
502
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
503
|
+
*
|
|
504
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
505
|
+
* you may not use this file except in compliance with the License.
|
|
506
|
+
* You may obtain a copy of the License at
|
|
507
|
+
*
|
|
508
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
509
|
+
*
|
|
510
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
511
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
512
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
513
|
+
* See the License for the specific language governing permissions and
|
|
514
|
+
* limitations under the License.
|
|
515
|
+
*/
|
|
516
|
+
class ResourceModule {
|
|
517
|
+
}
|
|
518
|
+
ResourceModule.decorators = [
|
|
519
|
+
{ type: NgModule, args: [{
|
|
520
|
+
declarations: [],
|
|
521
|
+
imports: [],
|
|
522
|
+
exports: [],
|
|
523
|
+
providers: [
|
|
524
|
+
OpenZaakUploadService,
|
|
525
|
+
S3UploadService,
|
|
526
|
+
UploadProviderService,
|
|
527
|
+
OpenZaakService,
|
|
528
|
+
S3Service,
|
|
529
|
+
DownloadService,
|
|
530
|
+
],
|
|
531
|
+
},] }
|
|
398
532
|
];
|
|
399
533
|
|
|
400
|
-
/*
|
|
401
|
-
* Public API Surface of upload
|
|
534
|
+
/*
|
|
535
|
+
* Public API Surface of upload
|
|
402
536
|
*/
|
|
403
537
|
|
|
404
|
-
/**
|
|
405
|
-
* Generated bundle index. Do not edit.
|
|
538
|
+
/**
|
|
539
|
+
* Generated bundle index. Do not edit.
|
|
406
540
|
*/
|
|
407
541
|
|
|
408
|
-
export { DownloadService, OpenZaakService, ResourceModule, S3Service, UploadProviderService, OpenZaakUploadService as ɵa, S3UploadService as ɵb };
|
|
542
|
+
export { Afleidingswijze, Archiefnominatie, DownloadService, Objecttype, OpenZaakConfig, OpenZaakService, Operation, ResourceModule, S3Resource, S3Service, UploadProviderService, OpenZaakUploadService as ɵa, S3UploadService as ɵb };
|
|
409
543
|
//# sourceMappingURL=valtimo-resource.js.map
|