@valtimo/process 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.
@@ -8,432 +8,466 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
8
8
  import * as BpmnJS from 'bpmn-js/dist/bpmn-navigated-viewer.production.min.js';
9
9
  import { create } from 'heatmap.js-fixed/build/heatmap.js';
10
10
 
11
- /*
12
- * Copyright 2015-2020 Ritense BV, the Netherlands.
13
- *
14
- * Licensed under EUPL, Version 1.2 (the "License");
15
- * you may not use this file except in compliance with the License.
16
- * You may obtain a copy of the License at
17
- *
18
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
19
- *
20
- * Unless required by applicable law or agreed to in writing, software
21
- * distributed under the License is distributed on an "AS IS" basis,
22
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
- * See the License for the specific language governing permissions and
24
- * limitations under the License.
25
- */
26
- class ProcessService {
27
- constructor(http, configService) {
28
- this.http = http;
29
- this.valtimoEndpointUri = configService.config.valtimoApi.endpointUri;
30
- }
31
- getProcessDefinitions() {
32
- return this.http.get(`${this.valtimoEndpointUri}process/definition`);
33
- }
34
- getProcessDefinitionVersions(key) {
35
- return this.http.get(`${this.valtimoEndpointUri}process/definition/${key}/versions`);
36
- }
37
- getProcessDefinition(key) {
38
- return this.http.get(`${this.valtimoEndpointUri}process/definition/${key}`);
39
- }
40
- getProcessDefinitionStartFormData(processDefinitionKey) {
41
- return this.http.get(`${this.valtimoEndpointUri}process/definition/${processDefinitionKey}/start-form`);
42
- }
43
- startProcesInstance(key, businessKey, variables) {
44
- return this.http.post(`${this.valtimoEndpointUri}process/definition/${key}/${businessKey}/start`, variables);
45
- }
46
- getProcessDefinitionXml(processDefinitionId) {
47
- return this.http.get(`${this.valtimoEndpointUri}process/definition/${processDefinitionId}/xml`);
48
- }
49
- getProcessXml(id) {
50
- return this.http.get(`${this.valtimoEndpointUri}process/${id}/xml`);
51
- }
52
- getProcessCount(id) {
53
- return this.http.post(`${this.valtimoEndpointUri}v2/process/definition/${id}/count`, {
54
- key: id,
55
- processVariables: [{ '@type': 'boolean', name: 'active', value: true }],
56
- });
57
- }
58
- getProcessHeatmapCount(processDefinition) {
59
- return this.http.get(`${this.valtimoEndpointUri}process/definition/${processDefinition.key}/heatmap/count?version=${processDefinition.version}`);
60
- }
61
- getProcessHeatmapDuration(processDefinition) {
62
- return this.http.get(`${this.valtimoEndpointUri}process/definition/${processDefinition.key}/heatmap/duration?version=${processDefinition.version}`);
63
- }
64
- getProcessInstances(key, page, size, sort) {
65
- const params = new HttpParams()
66
- .set('page', page.toString())
67
- .set('size', size.toString())
68
- .set('sort', sort);
69
- return this.http.post(`${this.valtimoEndpointUri}v2/process/${key}/search`, {}, { params: params });
70
- }
71
- getProcessInstance(processInstanceId) {
72
- return this.http.get(`${this.valtimoEndpointUri}process/${processInstanceId}`, {});
73
- }
74
- getProcessInstanceTasks(id) {
75
- return this.http.get(`${this.valtimoEndpointUri}process/${id}/tasks`, {});
76
- }
77
- getProcessInstanceVariables(id, variableNames) {
78
- return this.http.post(`${this.valtimoEndpointUri}process-instance/${id}/variables`, variableNames);
79
- }
80
- addProcessInstancesDefaultVariablesValues(processInstances) {
81
- processInstances.forEach(processInstance => this.addDefaultVariablesValues(processInstance));
82
- return processInstances;
83
- }
84
- addDefaultVariablesValues(processInstance) {
85
- if (!processInstance['startUser']) {
86
- processInstance.startUser = processInstance.startUserId;
87
- }
88
- if (!processInstance['processStarted']) {
89
- processInstance.processStarted = processInstance.startTime;
90
- }
91
- if (!processInstance['processEnded']) {
92
- processInstance.processEnded = processInstance.endTime;
93
- }
94
- if (!processInstance['active']) {
95
- processInstance.active = processInstance.endTime == null;
96
- }
97
- return processInstance;
98
- }
99
- getInstancesStatistics(fromDate, toDate, processFilter) {
100
- const params = new HttpParams();
101
- params.set('fromDate', fromDate);
102
- params.set('toDate', toDate);
103
- params.set('processFilter', processFilter);
104
- return this.http.get(`${this.valtimoEndpointUri}reporting/instancesstatistics`, {
105
- params: params,
106
- });
107
- }
108
- deployProcess(processXml) {
109
- const formData = new FormData();
110
- formData.append('file', new File([processXml], 'process.bpmn'));
111
- formData.append('deployment-name', 'valtimoConsoleApp');
112
- formData.append('deployment-source', 'process application');
113
- return this.http.post(`${this.valtimoEndpointUri}camunda-rest/engine/default/deployment/create`, formData);
114
- }
115
- migrateProcess(processDefinition1Id, processDefinition2Id, params) {
116
- return this.http.post(`${this.valtimoEndpointUri}process/definition/${processDefinition1Id}/${processDefinition2Id}/migrate`, params);
117
- }
118
- }
119
- ProcessService.ɵprov = ɵɵdefineInjectable({ factory: function ProcessService_Factory() { return new ProcessService(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: ProcessService, providedIn: "root" });
120
- ProcessService.decorators = [
121
- { type: Injectable, args: [{
122
- providedIn: 'root',
123
- },] }
124
- ];
125
- ProcessService.ctorParameters = () => [
126
- { type: HttpClient },
127
- { type: ConfigService }
11
+ /*
12
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
13
+ *
14
+ * Licensed under EUPL, Version 1.2 (the "License");
15
+ * you may not use this file except in compliance with the License.
16
+ * You may obtain a copy of the License at
17
+ *
18
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software
21
+ * distributed under the License is distributed on an "AS IS" basis,
22
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ * See the License for the specific language governing permissions and
24
+ * limitations under the License.
25
+ */
26
+
27
+ /*
28
+ *
29
+ * * Copyright 2015-2020 Ritense BV, the Netherlands.
30
+ * *
31
+ * * Licensed under EUPL, Version 1.2 (the "License");
32
+ * * you may not use this file except in compliance with the License.
33
+ * * You may obtain a copy of the License at
34
+ * *
35
+ * * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
36
+ * *
37
+ * * Unless required by applicable law or agreed to in writing, software
38
+ * * distributed under the License is distributed on an "AS IS" basis,
39
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40
+ * * See the License for the specific language governing permissions and
41
+ * * limitations under the License.
42
+ *
43
+ */
44
+
45
+ /*
46
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
47
+ *
48
+ * Licensed under EUPL, Version 1.2 (the "License");
49
+ * you may not use this file except in compliance with the License.
50
+ * You may obtain a copy of the License at
51
+ *
52
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
53
+ *
54
+ * Unless required by applicable law or agreed to in writing, software
55
+ * distributed under the License is distributed on an "AS IS" basis,
56
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
57
+ * See the License for the specific language governing permissions and
58
+ * limitations under the License.
59
+ */
60
+ class ProcessService {
61
+ constructor(http, configService) {
62
+ this.http = http;
63
+ this.valtimoEndpointUri = configService.config.valtimoApi.endpointUri;
64
+ }
65
+ getProcessDefinitions() {
66
+ return this.http.get(`${this.valtimoEndpointUri}process/definition`);
67
+ }
68
+ getProcessDefinitionVersions(key) {
69
+ return this.http.get(`${this.valtimoEndpointUri}process/definition/${key}/versions`);
70
+ }
71
+ getProcessDefinition(key) {
72
+ return this.http.get(`${this.valtimoEndpointUri}process/definition/${key}`);
73
+ }
74
+ getProcessDefinitionStartFormData(processDefinitionKey) {
75
+ return this.http.get(`${this.valtimoEndpointUri}process/definition/${processDefinitionKey}/start-form`);
76
+ }
77
+ startProcesInstance(key, businessKey, variables) {
78
+ return this.http.post(`${this.valtimoEndpointUri}process/definition/${key}/${businessKey}/start`, variables);
79
+ }
80
+ getProcessDefinitionXml(processDefinitionId) {
81
+ return this.http.get(`${this.valtimoEndpointUri}process/definition/${processDefinitionId}/xml`);
82
+ }
83
+ getProcessXml(id) {
84
+ return this.http.get(`${this.valtimoEndpointUri}process/${id}/xml`);
85
+ }
86
+ getProcessCount(id) {
87
+ return this.http.post(`${this.valtimoEndpointUri}v2/process/definition/${id}/count`, {
88
+ key: id,
89
+ processVariables: [{ '@type': 'boolean', name: 'active', value: true }],
90
+ });
91
+ }
92
+ getProcessHeatmapCount(processDefinition) {
93
+ return this.http.get(`${this.valtimoEndpointUri}process/definition/${processDefinition.key}/heatmap/count?version=${processDefinition.version}`);
94
+ }
95
+ getProcessHeatmapDuration(processDefinition) {
96
+ return this.http.get(`${this.valtimoEndpointUri}process/definition/${processDefinition.key}/heatmap/duration?version=${processDefinition.version}`);
97
+ }
98
+ getProcessInstances(key, page, size, sort) {
99
+ const params = new HttpParams()
100
+ .set('page', page.toString())
101
+ .set('size', size.toString())
102
+ .set('sort', sort);
103
+ return this.http.post(`${this.valtimoEndpointUri}v2/process/${key}/search`, {}, { params: params });
104
+ }
105
+ getProcessInstance(processInstanceId) {
106
+ return this.http.get(`${this.valtimoEndpointUri}process/${processInstanceId}`, {});
107
+ }
108
+ getProcessInstanceTasks(id) {
109
+ return this.http.get(`${this.valtimoEndpointUri}process/${id}/tasks`, {});
110
+ }
111
+ getProcessInstanceVariables(id, variableNames) {
112
+ return this.http.post(`${this.valtimoEndpointUri}process-instance/${id}/variables`, variableNames);
113
+ }
114
+ addProcessInstancesDefaultVariablesValues(processInstances) {
115
+ processInstances.forEach(processInstance => this.addDefaultVariablesValues(processInstance));
116
+ return processInstances;
117
+ }
118
+ addDefaultVariablesValues(processInstance) {
119
+ if (!processInstance['startUser']) {
120
+ processInstance.startUser = processInstance.startUserId;
121
+ }
122
+ if (!processInstance['processStarted']) {
123
+ processInstance.processStarted = processInstance.startTime;
124
+ }
125
+ if (!processInstance['processEnded']) {
126
+ processInstance.processEnded = processInstance.endTime;
127
+ }
128
+ if (!processInstance['active']) {
129
+ processInstance.active = processInstance.endTime == null;
130
+ }
131
+ return processInstance;
132
+ }
133
+ getInstancesStatistics(fromDate, toDate, processFilter) {
134
+ const params = new HttpParams();
135
+ params.set('fromDate', fromDate);
136
+ params.set('toDate', toDate);
137
+ params.set('processFilter', processFilter);
138
+ return this.http.get(`${this.valtimoEndpointUri}reporting/instancesstatistics`, {
139
+ params: params,
140
+ });
141
+ }
142
+ deployProcess(processXml) {
143
+ const formData = new FormData();
144
+ formData.append('file', new File([processXml], 'process.bpmn'));
145
+ formData.append('deployment-name', 'valtimoConsoleApp');
146
+ formData.append('deployment-source', 'process application');
147
+ return this.http.post(`${this.valtimoEndpointUri}camunda-rest/engine/default/deployment/create`, formData);
148
+ }
149
+ migrateProcess(processDefinition1Id, processDefinition2Id, params) {
150
+ return this.http.post(`${this.valtimoEndpointUri}process/definition/${processDefinition1Id}/${processDefinition2Id}/migrate`, params);
151
+ }
152
+ }
153
+ ProcessService.ɵprov = ɵɵdefineInjectable({ factory: function ProcessService_Factory() { return new ProcessService(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: ProcessService, providedIn: "root" });
154
+ ProcessService.decorators = [
155
+ { type: Injectable, args: [{
156
+ providedIn: 'root',
157
+ },] }
158
+ ];
159
+ ProcessService.ctorParameters = () => [
160
+ { type: HttpClient },
161
+ { type: ConfigService }
128
162
  ];
129
163
 
130
- /*
131
- * Copyright 2015-2020 Ritense BV, the Netherlands.
132
- *
133
- * Licensed under EUPL, Version 1.2 (the "License");
134
- * you may not use this file except in compliance with the License.
135
- * You may obtain a copy of the License at
136
- *
137
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
138
- *
139
- * Unless required by applicable law or agreed to in writing, software
140
- * distributed under the License is distributed on an "AS IS" basis,
141
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
142
- * See the License for the specific language governing permissions and
143
- * limitations under the License.
144
- */
145
- class ProcessDiagramComponent {
146
- constructor(processService) {
147
- this.processService = processService;
148
- this.importDone = new EventEmitter();
149
- this.enumHeatmapOptions = ['count', 'duration'];
150
- }
151
- ngOnInit() {
152
- if (this.processDefinitionKey) {
153
- this.loadProcessDefinitionFromKey(this.processDefinitionKey);
154
- }
155
- if (this.processInstanceId) {
156
- this.loadProcessInstanceXml(this.processInstanceId);
157
- }
158
- this.bpmnJS = new BpmnJS();
159
- this.bpmnJS.on('import.done', ({ error }) => {
160
- if (!error) {
161
- const canvas = this.bpmnJS.get('canvas'), eventBus = this.bpmnJS.get('eventBus');
162
- if (this.processDiagram.historicActivityInstances) {
163
- this.processDiagram.historicActivityInstances.forEach(instance => {
164
- // exclude multiInstanceBody
165
- if (instance.activityType !== 'multiInstanceBody') {
166
- canvas.addMarker(instance.activityId, instance.endTime ? 'highlight-overlay-past' : 'highlight-overlay-current');
167
- }
168
- });
169
- }
170
- canvas.zoom('fit-viewport', 'auto');
171
- if (this.processDefinitionVersions) {
172
- eventBus.on('canvas.init', () => {
173
- if (this.showHeatmap) {
174
- this.clearHeatmap();
175
- }
176
- this.loadHeatmapData();
177
- });
178
- eventBus.on('canvas.viewbox.changing', () => {
179
- if (this.showHeatmap) {
180
- this.clearHeatmap();
181
- }
182
- });
183
- eventBus.on('canvas.viewbox.changed', () => {
184
- this.loadHeatmapData();
185
- });
186
- }
187
- }
188
- });
189
- }
190
- ngOnChanges() {
191
- if (this.processDefinitionKey) {
192
- this.loadProcessDefinitionFromKey(this.processDefinitionKey);
193
- }
194
- else if (this.processInstanceId) {
195
- this.loadProcessInstanceXml(this.processInstanceId);
196
- }
197
- }
198
- ngOnDestroy() {
199
- if (this.bpmnJS) {
200
- this.bpmnJS.destroy();
201
- }
202
- }
203
- loadProcessDefinition(processDefinitionKey) {
204
- this.processService.getProcessDefinition(processDefinitionKey).subscribe(response => {
205
- this.heatmapOption = this.enumHeatmapOptions[0];
206
- this.version = response.version;
207
- this.loadProcessDefinitionXml(response.id);
208
- });
209
- }
210
- loadProcessDefinitionVersions(processDefinitionKey) {
211
- this.processService.getProcessDefinitionVersions(processDefinitionKey).subscribe(response => {
212
- this.processDefinitionVersions = response;
213
- });
214
- }
215
- loadProcessDefinitionFromKey(processDefinitionKey) {
216
- this.loadProcessDefinitionVersions(processDefinitionKey);
217
- this.loadProcessDefinition(processDefinitionKey);
218
- }
219
- loadProcessDefinitionXml(processDefinitionId) {
220
- this.processService.getProcessDefinitionXml(processDefinitionId).subscribe(response => {
221
- this.processDiagram = response;
222
- this.bpmnJS.importXML(this.processDiagram.bpmn20Xml);
223
- this.bpmnJS.attachTo(this.el.nativeElement);
224
- });
225
- }
226
- loadProcessInstanceXml(processInstanceId) {
227
- this.processService.getProcessXml(processInstanceId).subscribe(response => {
228
- this.processDiagram = response;
229
- this.bpmnJS.importXML(this.processDiagram.bpmn20Xml);
230
- this.bpmnJS.attachTo(this.el.nativeElement);
231
- });
232
- }
233
- loadProcessDefinitionHeatmapCount(processDefinition) {
234
- this.processService.getProcessHeatmapCount(processDefinition).subscribe(response => {
235
- this.inputData = response;
236
- this.valueKey = 'totalCount';
237
- this.heatPoints = { data: [] };
238
- this.min = 0;
239
- this.max = 0;
240
- Object.keys(this.inputData).forEach(key => {
241
- const diagramContainer = this.el.nativeElement.querySelector('svg').getBoundingClientRect(), diagramElm = this.el.nativeElement
242
- .querySelector(`g[data-element-id=${key}]`)
243
- .getBoundingClientRect();
244
- this.setMax(key);
245
- this.heatPoints.data.push({
246
- x: Math.round(diagramElm.x - diagramContainer.x + diagramElm.width / 2),
247
- y: Math.round(diagramElm.y - diagramContainer.y + diagramElm.height / 2),
248
- value: this.inputData[key][this.valueKey],
249
- radius: diagramElm.width / 2,
250
- });
251
- this.addCounterActiveOverlays(key, this.inputData);
252
- });
253
- this.clearHeatmap();
254
- if (this.showHeatmap) {
255
- this.loadHeatmap();
256
- }
257
- });
258
- }
259
- onWindowResize() {
260
- const oldCanvas = this.el.nativeElement.querySelector('canvas[class=heatmap-canvas]');
261
- if (oldCanvas) {
262
- oldCanvas.remove();
263
- this.heatMapInstance = null;
264
- }
265
- if (this.showHeatmap) {
266
- this.loadHeatmap();
267
- }
268
- }
269
- loadProcessDefinitionHeatmapDuration(processDefinition) {
270
- this.processService.getProcessHeatmapDuration(processDefinition).subscribe(response => {
271
- this.inputData = response;
272
- this.valueKey = 'averageDurationInMilliseconds';
273
- this.heatPoints = { data: [] };
274
- this.min = 0;
275
- this.max = 0;
276
- Object.keys(this.inputData).forEach(key => {
277
- const diagramContainer = this.el.nativeElement.querySelector('svg').getBoundingClientRect(), diagramElm = this.el.nativeElement
278
- .querySelector(`g[data-element-id=${key}]`)
279
- .getBoundingClientRect();
280
- this.setMax(key);
281
- this.heatPoints.data.push({
282
- x: Math.round(diagramElm.x - diagramContainer.x + diagramElm.width / 2),
283
- y: Math.round(diagramElm.y - diagramContainer.y + diagramElm.height / 2),
284
- value: this.inputData[key][this.valueKey],
285
- radius: diagramElm.width / 2,
286
- });
287
- this.addCounterActiveOverlays(key, this.inputData);
288
- });
289
- this.clearHeatmap();
290
- if (this.showHeatmap) {
291
- this.loadHeatmap();
292
- }
293
- });
294
- }
295
- setProcessDefinitionKey(processDefinitionKey) {
296
- this.processDefinitionKey = processDefinitionKey;
297
- this.loadProcessDefinitionFromKey(this.processDefinitionKey);
298
- }
299
- setProcessDefinitionVersion(version) {
300
- this.version = +version;
301
- this.loadHeatmapData();
302
- }
303
- setHeatmapOption(heatmapOption) {
304
- this.heatmapOption = heatmapOption;
305
- this.loadHeatmapData();
306
- }
307
- toggleShowHeatmap() {
308
- this.showHeatmap = !this.showHeatmap;
309
- this.loadHeatmapData();
310
- }
311
- loadHeatmap() {
312
- if (!this.heatMapInstance) {
313
- this.heatMapInstance = create({
314
- radius: 54,
315
- blur: 0.7,
316
- maxOpacity: 0.4,
317
- minOpacity: 0,
318
- container: this.el.nativeElement,
319
- });
320
- }
321
- this.heatMapInstance.setData({
322
- min: this.min,
323
- max: this.max,
324
- data: this.heatPoints.data,
325
- });
326
- }
327
- clearHeatmap() {
328
- if (this.heatMapInstance) {
329
- this.heatMapInstance.setData({ data: [] });
330
- }
331
- }
332
- loadHeatmapData() {
333
- this.processDefinition = this.processDefinitionVersions.find(definition => definition.version === this.version);
334
- if (this.heatmapOption === 'count') {
335
- this.loadProcessDefinitionHeatmapCount(this.processDefinition);
336
- }
337
- if (this.heatmapOption === 'duration') {
338
- this.loadProcessDefinitionHeatmapDuration(this.processDefinition);
339
- }
340
- }
341
- setMax(key) {
342
- if (this.heatmapDuration) {
343
- this.max = Math.max(this.heatmapDuration[key].averageDurationInMilliseconds, this.max);
344
- }
345
- else if (this.heatmapCount) {
346
- this.max = Math.max(this.heatmapCount[key].totalCount + this.heatmapCount[key].count, this.max);
347
- }
348
- }
349
- addCounterActiveOverlays(key, inputData) {
350
- const overlays = this.bpmnJS.get('overlays');
351
- overlays.add(key, {
352
- position: {
353
- bottom: 13,
354
- left: -12,
355
- },
356
- show: {
357
- minZoom: 0,
358
- maxZoom: 5.0,
359
- },
360
- html: `<span class="badge badge-pill badge-primary">${inputData[key].count}</span>`,
361
- });
362
- }
363
- }
364
- ProcessDiagramComponent.decorators = [
365
- { type: Component, args: [{
366
- selector: 'valtimo-process-diagram',
367
- template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n<div class=\"process-diagram-container\">\n <div *ngIf=\"processDefinitionKey\" class=\"diagram-container-switch-holder\">\n <div class=\"container-fluid\">\n <div class=\"row p-4 bg-light\">\n <div class=\"col-4\">\n <label><strong>Version</strong></label\n ><br />\n <select class=\"form-control\" (change)=\"setProcessDefinitionVersion($event.target.value)\">\n <option\n *ngFor=\"let processDefinitionVersion of processDefinitionVersions\"\n [value]=\"processDefinitionVersion.version\"\n [selected]=\"processDefinitionVersion.version === version\"\n >\n {{ processDefinitionVersion.version }}\n </option>\n </select>\n </div>\n <div class=\"col-4\">\n <label><strong>Heatmap type</strong></label\n ><br />\n <select class=\"form-control\" (change)=\"setHeatmapOption($event.target.value)\">\n <option\n *ngFor=\"let option of enumHeatmapOptions\"\n [value]=\"option\"\n [selected]=\"option === heatmapOption\"\n >\n {{ option }}\n </option>\n </select>\n </div>\n <div class=\"col-4 text-right\">\n <label><strong>Show heatmap</strong></label\n ><br />\n <div class=\"text-left switch-button switch-button-sm switch-button-success\">\n <input\n type=\"checkbox\"\n id=\"toggleHeatmap\"\n [checked]=\"showHeatmap\"\n (click)=\"toggleShowHeatmap()\"\n /><span> <label for=\"toggleHeatmap\"></label></span>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <div #ref (window:resize)=\"onWindowResize()\" class=\"diagram-container\"></div>\n\n <div *ngIf=\"processInstanceId\" class=\"p-4 text-center legenda-holder\">\n <span\n ><div class=\"legenda highlight-overlay-past\"></div>\n Executed tasks</span\n >\n <span class=\"ml-3\"\n ><div class=\"legenda highlight-overlay-current\"></div>\n Current tasks</span\n >\n </div>\n\n <div *ngIf=\"processDefinitionKey\" class=\"p-4 text-center legenda-holder\">\n <span\n ><span class=\"badge badge-pill badge-primary\">N</span>&nbsp;&nbsp;Amount of currently active\n instances of this task.</span\n >\n <span\n >&nbsp;&nbsp;|&nbsp;&nbsp;Red/yellow/green orbs: The amount of times the task is executed in\n comparison to the other tasks.</span\n >\n </div>\n</div>\n",
368
- encapsulation: ViewEncapsulation.None,
369
- styles: [".process-diagram-container .diagram-container{height:50vh;width:100%}.process-diagram-container .diagram-container-switch-holder{position:absolute;width:100%;z-index:1000}.process-diagram-container .highlight-overlay-past:not(.djs-connection) .djs-visual>:first-child{fill:#d8d8d8!important}.process-diagram-container .highlight-overlay-current:not(.djs-connection) .djs-visual>:first-child{fill:#b2e0ff!important}.process-diagram-container .legenda-holder{font-size:1em}.process-diagram-container .legenda{border:2px solid #000;border-radius:3px;display:inline-block;margin-bottom:-4px;margin-right:5px;padding:7px}.process-diagram-container .legenda.highlight-overlay-past{background-color:#d8d8d8}.process-diagram-container .legenda.highlight-overlay-current{background-color:#b2e0ff}"]
370
- },] }
371
- ];
372
- ProcessDiagramComponent.ctorParameters = () => [
373
- { type: ProcessService }
374
- ];
375
- ProcessDiagramComponent.propDecorators = {
376
- el: [{ type: ViewChild, args: ['ref', { static: true },] }],
377
- importDone: [{ type: Output }],
378
- processDefinitionKey: [{ type: Input }],
379
- processInstanceId: [{ type: Input }]
164
+ /*
165
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
166
+ *
167
+ * Licensed under EUPL, Version 1.2 (the "License");
168
+ * you may not use this file except in compliance with the License.
169
+ * You may obtain a copy of the License at
170
+ *
171
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
172
+ *
173
+ * Unless required by applicable law or agreed to in writing, software
174
+ * distributed under the License is distributed on an "AS IS" basis,
175
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
176
+ * See the License for the specific language governing permissions and
177
+ * limitations under the License.
178
+ */
179
+ class ProcessDiagramComponent {
180
+ constructor(processService) {
181
+ this.processService = processService;
182
+ this.importDone = new EventEmitter();
183
+ this.enumHeatmapOptions = ['count', 'duration'];
184
+ }
185
+ ngOnInit() {
186
+ if (this.processDefinitionKey) {
187
+ this.loadProcessDefinitionFromKey(this.processDefinitionKey);
188
+ }
189
+ if (this.processInstanceId) {
190
+ this.loadProcessInstanceXml(this.processInstanceId);
191
+ }
192
+ this.bpmnJS = new BpmnJS();
193
+ this.bpmnJS.on('import.done', ({ error }) => {
194
+ if (!error) {
195
+ const canvas = this.bpmnJS.get('canvas'), eventBus = this.bpmnJS.get('eventBus');
196
+ if (this.processDiagram.historicActivityInstances) {
197
+ this.processDiagram.historicActivityInstances.forEach(instance => {
198
+ // exclude multiInstanceBody
199
+ if (instance.activityType !== 'multiInstanceBody') {
200
+ canvas.addMarker(instance.activityId, instance.endTime ? 'highlight-overlay-past' : 'highlight-overlay-current');
201
+ }
202
+ });
203
+ }
204
+ canvas.zoom('fit-viewport', 'auto');
205
+ if (this.processDefinitionVersions) {
206
+ eventBus.on('canvas.init', () => {
207
+ if (this.showHeatmap) {
208
+ this.clearHeatmap();
209
+ }
210
+ this.loadHeatmapData();
211
+ });
212
+ eventBus.on('canvas.viewbox.changing', () => {
213
+ if (this.showHeatmap) {
214
+ this.clearHeatmap();
215
+ }
216
+ });
217
+ eventBus.on('canvas.viewbox.changed', () => {
218
+ this.loadHeatmapData();
219
+ });
220
+ }
221
+ }
222
+ });
223
+ }
224
+ ngOnChanges() {
225
+ if (this.processDefinitionKey) {
226
+ this.loadProcessDefinitionFromKey(this.processDefinitionKey);
227
+ }
228
+ else if (this.processInstanceId) {
229
+ this.loadProcessInstanceXml(this.processInstanceId);
230
+ }
231
+ }
232
+ ngOnDestroy() {
233
+ if (this.bpmnJS) {
234
+ this.bpmnJS.destroy();
235
+ }
236
+ }
237
+ loadProcessDefinition(processDefinitionKey) {
238
+ this.processService.getProcessDefinition(processDefinitionKey).subscribe(response => {
239
+ this.heatmapOption = this.enumHeatmapOptions[0];
240
+ this.version = response.version;
241
+ this.loadProcessDefinitionXml(response.id);
242
+ });
243
+ }
244
+ loadProcessDefinitionVersions(processDefinitionKey) {
245
+ this.processService.getProcessDefinitionVersions(processDefinitionKey).subscribe(response => {
246
+ this.processDefinitionVersions = response;
247
+ });
248
+ }
249
+ loadProcessDefinitionFromKey(processDefinitionKey) {
250
+ this.loadProcessDefinitionVersions(processDefinitionKey);
251
+ this.loadProcessDefinition(processDefinitionKey);
252
+ }
253
+ loadProcessDefinitionXml(processDefinitionId) {
254
+ this.processService.getProcessDefinitionXml(processDefinitionId).subscribe(response => {
255
+ this.processDiagram = response;
256
+ this.bpmnJS.importXML(this.processDiagram.bpmn20Xml);
257
+ this.bpmnJS.attachTo(this.el.nativeElement);
258
+ });
259
+ }
260
+ loadProcessInstanceXml(processInstanceId) {
261
+ this.processService.getProcessXml(processInstanceId).subscribe(response => {
262
+ this.processDiagram = response;
263
+ this.bpmnJS.importXML(this.processDiagram.bpmn20Xml);
264
+ this.bpmnJS.attachTo(this.el.nativeElement);
265
+ });
266
+ }
267
+ loadProcessDefinitionHeatmapCount(processDefinition) {
268
+ this.processService.getProcessHeatmapCount(processDefinition).subscribe(response => {
269
+ this.inputData = response;
270
+ this.valueKey = 'totalCount';
271
+ this.heatPoints = { data: [] };
272
+ this.min = 0;
273
+ this.max = 0;
274
+ Object.keys(this.inputData).forEach(key => {
275
+ const diagramContainer = this.el.nativeElement.querySelector('svg').getBoundingClientRect(), diagramElm = this.el.nativeElement
276
+ .querySelector(`g[data-element-id=${key}]`)
277
+ .getBoundingClientRect();
278
+ this.setMax(key);
279
+ this.heatPoints.data.push({
280
+ x: Math.round(diagramElm.x - diagramContainer.x + diagramElm.width / 2),
281
+ y: Math.round(diagramElm.y - diagramContainer.y + diagramElm.height / 2),
282
+ value: this.inputData[key][this.valueKey],
283
+ radius: diagramElm.width / 2,
284
+ });
285
+ this.addCounterActiveOverlays(key, this.inputData);
286
+ });
287
+ this.clearHeatmap();
288
+ if (this.showHeatmap) {
289
+ this.loadHeatmap();
290
+ }
291
+ });
292
+ }
293
+ onWindowResize() {
294
+ const oldCanvas = this.el.nativeElement.querySelector('canvas[class=heatmap-canvas]');
295
+ if (oldCanvas) {
296
+ oldCanvas.remove();
297
+ this.heatMapInstance = null;
298
+ }
299
+ if (this.showHeatmap) {
300
+ this.loadHeatmap();
301
+ }
302
+ }
303
+ loadProcessDefinitionHeatmapDuration(processDefinition) {
304
+ this.processService.getProcessHeatmapDuration(processDefinition).subscribe(response => {
305
+ this.inputData = response;
306
+ this.valueKey = 'averageDurationInMilliseconds';
307
+ this.heatPoints = { data: [] };
308
+ this.min = 0;
309
+ this.max = 0;
310
+ Object.keys(this.inputData).forEach(key => {
311
+ const diagramContainer = this.el.nativeElement.querySelector('svg').getBoundingClientRect(), diagramElm = this.el.nativeElement
312
+ .querySelector(`g[data-element-id=${key}]`)
313
+ .getBoundingClientRect();
314
+ this.setMax(key);
315
+ this.heatPoints.data.push({
316
+ x: Math.round(diagramElm.x - diagramContainer.x + diagramElm.width / 2),
317
+ y: Math.round(diagramElm.y - diagramContainer.y + diagramElm.height / 2),
318
+ value: this.inputData[key][this.valueKey],
319
+ radius: diagramElm.width / 2,
320
+ });
321
+ this.addCounterActiveOverlays(key, this.inputData);
322
+ });
323
+ this.clearHeatmap();
324
+ if (this.showHeatmap) {
325
+ this.loadHeatmap();
326
+ }
327
+ });
328
+ }
329
+ setProcessDefinitionKey(processDefinitionKey) {
330
+ this.processDefinitionKey = processDefinitionKey;
331
+ this.loadProcessDefinitionFromKey(this.processDefinitionKey);
332
+ }
333
+ setProcessDefinitionVersion(version) {
334
+ this.version = +version;
335
+ this.loadHeatmapData();
336
+ }
337
+ setHeatmapOption(heatmapOption) {
338
+ this.heatmapOption = heatmapOption;
339
+ this.loadHeatmapData();
340
+ }
341
+ toggleShowHeatmap() {
342
+ this.showHeatmap = !this.showHeatmap;
343
+ this.loadHeatmapData();
344
+ }
345
+ loadHeatmap() {
346
+ if (!this.heatMapInstance) {
347
+ this.heatMapInstance = create({
348
+ radius: 54,
349
+ blur: 0.7,
350
+ maxOpacity: 0.4,
351
+ minOpacity: 0,
352
+ container: this.el.nativeElement,
353
+ });
354
+ }
355
+ this.heatMapInstance.setData({
356
+ min: this.min,
357
+ max: this.max,
358
+ data: this.heatPoints.data,
359
+ });
360
+ }
361
+ clearHeatmap() {
362
+ if (this.heatMapInstance) {
363
+ this.heatMapInstance.setData({ data: [] });
364
+ }
365
+ }
366
+ loadHeatmapData() {
367
+ this.processDefinition = this.processDefinitionVersions.find(definition => definition.version === this.version);
368
+ if (this.heatmapOption === 'count') {
369
+ this.loadProcessDefinitionHeatmapCount(this.processDefinition);
370
+ }
371
+ if (this.heatmapOption === 'duration') {
372
+ this.loadProcessDefinitionHeatmapDuration(this.processDefinition);
373
+ }
374
+ }
375
+ setMax(key) {
376
+ if (this.heatmapDuration) {
377
+ this.max = Math.max(this.heatmapDuration[key].averageDurationInMilliseconds, this.max);
378
+ }
379
+ else if (this.heatmapCount) {
380
+ this.max = Math.max(this.heatmapCount[key].totalCount + this.heatmapCount[key].count, this.max);
381
+ }
382
+ }
383
+ addCounterActiveOverlays(key, inputData) {
384
+ const overlays = this.bpmnJS.get('overlays');
385
+ overlays.add(key, {
386
+ position: {
387
+ bottom: 13,
388
+ left: -12,
389
+ },
390
+ show: {
391
+ minZoom: 0,
392
+ maxZoom: 5.0,
393
+ },
394
+ html: `<span class="badge badge-pill badge-primary">${inputData[key].count}</span>`,
395
+ });
396
+ }
397
+ }
398
+ ProcessDiagramComponent.decorators = [
399
+ { type: Component, args: [{
400
+ selector: 'valtimo-process-diagram',
401
+ template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n<div class=\"process-diagram-container\">\n <div *ngIf=\"processDefinitionKey\" class=\"diagram-container-switch-holder\">\n <div class=\"container-fluid\">\n <div class=\"row p-4 bg-light\">\n <div class=\"col-4\">\n <label><strong>Version</strong></label\n ><br />\n <select class=\"form-control\" (change)=\"setProcessDefinitionVersion($event.target.value)\">\n <option\n *ngFor=\"let processDefinitionVersion of processDefinitionVersions\"\n [value]=\"processDefinitionVersion.version\"\n [selected]=\"processDefinitionVersion.version === version\"\n >\n {{ processDefinitionVersion.version }}\n </option>\n </select>\n </div>\n <div class=\"col-4\">\n <label><strong>Heatmap type</strong></label\n ><br />\n <select class=\"form-control\" (change)=\"setHeatmapOption($event.target.value)\">\n <option\n *ngFor=\"let option of enumHeatmapOptions\"\n [value]=\"option\"\n [selected]=\"option === heatmapOption\"\n >\n {{ option }}\n </option>\n </select>\n </div>\n <div class=\"col-4 text-right\">\n <label><strong>Show heatmap</strong></label\n ><br />\n <div class=\"text-left switch-button switch-button-sm switch-button-success\">\n <input\n type=\"checkbox\"\n id=\"toggleHeatmap\"\n [checked]=\"showHeatmap\"\n (click)=\"toggleShowHeatmap()\"\n /><span> <label for=\"toggleHeatmap\"></label></span>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <div #ref (window:resize)=\"onWindowResize()\" class=\"diagram-container\"></div>\n\n <div *ngIf=\"processInstanceId\" class=\"p-4 text-center legenda-holder\">\n <span\n ><div class=\"legenda highlight-overlay-past\"></div>\n Executed tasks</span\n >\n <span class=\"ml-3\"\n ><div class=\"legenda highlight-overlay-current\"></div>\n Current tasks</span\n >\n </div>\n\n <div *ngIf=\"processDefinitionKey\" class=\"p-4 text-center legenda-holder\">\n <span\n ><span class=\"badge badge-pill badge-primary\">N</span>&nbsp;&nbsp;Amount of currently active\n instances of this task.</span\n >\n <span\n >&nbsp;&nbsp;|&nbsp;&nbsp;Red/yellow/green orbs: The amount of times the task is executed in\n comparison to the other tasks.</span\n >\n </div>\n</div>\n",
402
+ encapsulation: ViewEncapsulation.None,
403
+ styles: [".process-diagram-container .diagram-container{height:50vh;width:100%}.process-diagram-container .diagram-container-switch-holder{position:absolute;width:100%;z-index:1000}.process-diagram-container .highlight-overlay-past:not(.djs-connection) .djs-visual>:first-child{fill:#d8d8d8!important}.process-diagram-container .highlight-overlay-current:not(.djs-connection) .djs-visual>:first-child{fill:#b2e0ff!important}.process-diagram-container .legenda-holder{font-size:1em}.process-diagram-container .legenda{border:2px solid #000;border-radius:3px;display:inline-block;margin-bottom:-4px;margin-right:5px;padding:7px}.process-diagram-container .legenda.highlight-overlay-past{background-color:#d8d8d8}.process-diagram-container .legenda.highlight-overlay-current{background-color:#b2e0ff}"]
404
+ },] }
405
+ ];
406
+ ProcessDiagramComponent.ctorParameters = () => [
407
+ { type: ProcessService }
408
+ ];
409
+ ProcessDiagramComponent.propDecorators = {
410
+ el: [{ type: ViewChild, args: ['ref', { static: true },] }],
411
+ importDone: [{ type: Output }],
412
+ processDefinitionKey: [{ type: Input }],
413
+ processInstanceId: [{ type: Input }]
380
414
  };
381
415
 
382
- /*
383
- * Copyright 2015-2020 Ritense BV, the Netherlands.
384
- *
385
- * Licensed under EUPL, Version 1.2 (the "License");
386
- * you may not use this file except in compliance with the License.
387
- * You may obtain a copy of the License at
388
- *
389
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
390
- *
391
- * Unless required by applicable law or agreed to in writing, software
392
- * distributed under the License is distributed on an "AS IS" basis,
393
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
394
- * See the License for the specific language governing permissions and
395
- * limitations under the License.
396
- */
397
- class ProcessModule {
398
- }
399
- ProcessModule.decorators = [
400
- { type: NgModule, args: [{
401
- declarations: [ProcessDiagramComponent],
402
- imports: [
403
- CommonModule,
404
- ListModule,
405
- WidgetModule,
406
- TimelineModule,
407
- BpmnJsDiagramModule,
408
- CamundaFormModule,
409
- BrowserAnimationsModule,
410
- ToastrModule.forRoot({
411
- positionClass: 'toast-bottom-full-width',
412
- preventDuplicates: true,
413
- }),
414
- ],
415
- exports: [ProcessDiagramComponent],
416
- },] }
416
+ /*
417
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
418
+ *
419
+ * Licensed under EUPL, Version 1.2 (the "License");
420
+ * you may not use this file except in compliance with the License.
421
+ * You may obtain a copy of the License at
422
+ *
423
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
424
+ *
425
+ * Unless required by applicable law or agreed to in writing, software
426
+ * distributed under the License is distributed on an "AS IS" basis,
427
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
428
+ * See the License for the specific language governing permissions and
429
+ * limitations under the License.
430
+ */
431
+ class ProcessModule {
432
+ }
433
+ ProcessModule.decorators = [
434
+ { type: NgModule, args: [{
435
+ declarations: [ProcessDiagramComponent],
436
+ imports: [
437
+ CommonModule,
438
+ ListModule,
439
+ WidgetModule,
440
+ TimelineModule,
441
+ BpmnJsDiagramModule,
442
+ CamundaFormModule,
443
+ BrowserAnimationsModule,
444
+ ToastrModule.forRoot({
445
+ positionClass: 'toast-bottom-full-width',
446
+ preventDuplicates: true,
447
+ }),
448
+ ],
449
+ exports: [ProcessDiagramComponent],
450
+ },] }
417
451
  ];
418
452
 
419
- /*
420
- * Copyright 2015-2020 Ritense BV, the Netherlands.
421
- *
422
- * Licensed under EUPL, Version 1.2 (the "License");
423
- * you may not use this file except in compliance with the License.
424
- * You may obtain a copy of the License at
425
- *
426
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
427
- *
428
- * Unless required by applicable law or agreed to in writing, software
429
- * distributed under the License is distributed on an "AS IS" basis,
430
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
431
- * See the License for the specific language governing permissions and
432
- * limitations under the License.
453
+ /*
454
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
455
+ *
456
+ * Licensed under EUPL, Version 1.2 (the "License");
457
+ * you may not use this file except in compliance with the License.
458
+ * You may obtain a copy of the License at
459
+ *
460
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
461
+ *
462
+ * Unless required by applicable law or agreed to in writing, software
463
+ * distributed under the License is distributed on an "AS IS" basis,
464
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
465
+ * See the License for the specific language governing permissions and
466
+ * limitations under the License.
433
467
  */
434
468
 
435
- /**
436
- * Generated bundle index. Do not edit.
469
+ /**
470
+ * Generated bundle index. Do not edit.
437
471
  */
438
472
 
439
473
  export { ProcessDiagramComponent, ProcessModule, ProcessService };