@valtimo/process 4.15.2-next-main.15 → 4.15.3-next-main.16

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,434 +8,432 @@ 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`, { 'params': params });
105
- }
106
- deployProcess(processXml) {
107
- const formData = new FormData;
108
- formData.append('file', new File([processXml], 'process.bpmn'));
109
- formData.append('deployment-name', 'valtimoConsoleApp');
110
- formData.append('deployment-source', 'process application');
111
- return this.http.post(`${this.valtimoEndpointUri}camunda-rest/engine/default/deployment/create`, formData);
112
- }
113
- migrateProcess(processDefinition1Id, processDefinition2Id, params) {
114
- return this.http.post(`${this.valtimoEndpointUri}process/definition/${processDefinition1Id}/${processDefinition2Id}/migrate`, params);
115
- }
116
- }
117
- ProcessService.ɵprov = ɵɵdefineInjectable({ factory: function ProcessService_Factory() { return new ProcessService(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: ProcessService, providedIn: "root" });
118
- ProcessService.decorators = [
119
- { type: Injectable, args: [{
120
- providedIn: 'root'
121
- },] }
122
- ];
123
- ProcessService.ctorParameters = () => [
124
- { type: HttpClient },
125
- { 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
+ 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 }
126
128
  ];
127
129
 
128
- /*
129
- * Copyright 2015-2020 Ritense BV, the Netherlands.
130
- *
131
- * Licensed under EUPL, Version 1.2 (the "License");
132
- * you may not use this file except in compliance with the License.
133
- * You may obtain a copy of the License at
134
- *
135
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
136
- *
137
- * Unless required by applicable law or agreed to in writing, software
138
- * distributed under the License is distributed on an "AS IS" basis,
139
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
140
- * See the License for the specific language governing permissions and
141
- * limitations under the License.
142
- */
143
- class ProcessDiagramComponent {
144
- constructor(processService) {
145
- this.processService = processService;
146
- this.importDone = new EventEmitter();
147
- this.enumHeatmapOptions = ['count', 'duration'];
148
- }
149
- ngOnInit() {
150
- if (this.processDefinitionKey) {
151
- this.loadProcessDefinitionFromKey(this.processDefinitionKey);
152
- }
153
- if (this.processInstanceId) {
154
- this.loadProcessInstanceXml(this.processInstanceId);
155
- }
156
- this.bpmnJS = new BpmnJS();
157
- this.bpmnJS.on('import.done', ({ error }) => {
158
- if (!error) {
159
- const canvas = this.bpmnJS.get('canvas'), eventBus = this.bpmnJS.get('eventBus');
160
- if (this.processDiagram.historicActivityInstances) {
161
- this.processDiagram.historicActivityInstances.forEach(instance => {
162
- // exclude multiInstanceBody
163
- if (instance.activityType !== 'multiInstanceBody') {
164
- canvas.addMarker(instance.activityId, instance.endTime ? 'highlight-overlay-past' : 'highlight-overlay-current');
165
- }
166
- });
167
- }
168
- canvas.zoom('fit-viewport', 'auto');
169
- if (this.processDefinitionVersions) {
170
- eventBus.on('canvas.init', () => {
171
- if (this.showHeatmap) {
172
- this.clearHeatmap();
173
- }
174
- this.loadHeatmapData();
175
- });
176
- eventBus.on('canvas.viewbox.changing', () => {
177
- if (this.showHeatmap) {
178
- this.clearHeatmap();
179
- }
180
- });
181
- eventBus.on('canvas.viewbox.changed', () => {
182
- this.loadHeatmapData();
183
- });
184
- }
185
- }
186
- });
187
- }
188
- ngOnChanges() {
189
- if (this.processDefinitionKey) {
190
- this.loadProcessDefinitionFromKey(this.processDefinitionKey);
191
- }
192
- else if (this.processInstanceId) {
193
- this.loadProcessInstanceXml(this.processInstanceId);
194
- }
195
- }
196
- ngOnDestroy() {
197
- if (this.bpmnJS) {
198
- this.bpmnJS.destroy();
199
- }
200
- }
201
- loadProcessDefinition(processDefinitionKey) {
202
- this.processService.getProcessDefinition(processDefinitionKey).subscribe(response => {
203
- this.heatmapOption = this.enumHeatmapOptions[0];
204
- this.version = response.version;
205
- this.loadProcessDefinitionXml(response.id);
206
- });
207
- }
208
- loadProcessDefinitionVersions(processDefinitionKey) {
209
- this.processService.getProcessDefinitionVersions(processDefinitionKey).subscribe(response => {
210
- this.processDefinitionVersions = response;
211
- });
212
- }
213
- loadProcessDefinitionFromKey(processDefinitionKey) {
214
- this.loadProcessDefinitionVersions(processDefinitionKey);
215
- this.loadProcessDefinition(processDefinitionKey);
216
- }
217
- loadProcessDefinitionXml(processDefinitionId) {
218
- this.processService.getProcessDefinitionXml(processDefinitionId).subscribe(response => {
219
- this.processDiagram = response;
220
- this.bpmnJS.importXML(this.processDiagram.bpmn20Xml);
221
- this.bpmnJS.attachTo(this.el.nativeElement);
222
- });
223
- }
224
- loadProcessInstanceXml(processInstanceId) {
225
- this.processService.getProcessXml(processInstanceId).subscribe(response => {
226
- this.processDiagram = response;
227
- this.bpmnJS.importXML(this.processDiagram.bpmn20Xml);
228
- this.bpmnJS.attachTo(this.el.nativeElement);
229
- });
230
- }
231
- loadProcessDefinitionHeatmapCount(processDefinition) {
232
- this.processService.getProcessHeatmapCount(processDefinition).subscribe(response => {
233
- this.inputData = response;
234
- this.valueKey = 'totalCount';
235
- this.heatPoints = { data: [] };
236
- this.min = 0;
237
- this.max = 0;
238
- Object.keys(this.inputData).forEach(key => {
239
- const diagramContainer = this.el.nativeElement.querySelector('svg')
240
- .getBoundingClientRect(), diagramElm = this.el.nativeElement.querySelector(`g[data-element-id=${key}]`)
241
- .getBoundingClientRect();
242
- this.setMax(key);
243
- this.heatPoints.data.push({
244
- x: Math.round(diagramElm.x - diagramContainer.x + diagramElm.width / 2),
245
- y: Math.round(diagramElm.y - diagramContainer.y + diagramElm.height / 2),
246
- value: this.inputData[key][this.valueKey],
247
- radius: diagramElm.width / 2
248
- });
249
- this.addCounterActiveOverlays(key, this.inputData);
250
- });
251
- this.clearHeatmap();
252
- if (this.showHeatmap) {
253
- this.loadHeatmap();
254
- }
255
- });
256
- }
257
- onWindowResize() {
258
- const oldCanvas = this.el.nativeElement.querySelector('canvas[class=heatmap-canvas]');
259
- if (oldCanvas) {
260
- oldCanvas.remove();
261
- this.heatMapInstance = null;
262
- }
263
- if (this.showHeatmap) {
264
- this.loadHeatmap();
265
- }
266
- }
267
- loadProcessDefinitionHeatmapDuration(processDefinition) {
268
- this.processService.getProcessHeatmapDuration(processDefinition).subscribe(response => {
269
- this.inputData = response;
270
- this.valueKey = 'averageDurationInMilliseconds';
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')
276
- .getBoundingClientRect(), diagramElm = this.el.nativeElement.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
- setProcessDefinitionKey(processDefinitionKey) {
294
- this.processDefinitionKey = processDefinitionKey;
295
- this.loadProcessDefinitionFromKey(this.processDefinitionKey);
296
- }
297
- setProcessDefinitionVersion(version) {
298
- this.version = +version;
299
- this.loadHeatmapData();
300
- }
301
- setHeatmapOption(heatmapOption) {
302
- this.heatmapOption = heatmapOption;
303
- this.loadHeatmapData();
304
- }
305
- toggleShowHeatmap() {
306
- this.showHeatmap = !this.showHeatmap;
307
- this.loadHeatmapData();
308
- }
309
- loadHeatmap() {
310
- if (!this.heatMapInstance) {
311
- this.heatMapInstance = create({
312
- radius: 54,
313
- blur: .70,
314
- maxOpacity: .4,
315
- minOpacity: 0,
316
- container: this.el.nativeElement
317
- });
318
- }
319
- this.heatMapInstance.setData({
320
- min: this.min,
321
- max: this.max,
322
- data: this.heatPoints.data
323
- });
324
- }
325
- clearHeatmap() {
326
- if (this.heatMapInstance) {
327
- this.heatMapInstance.setData({ data: [] });
328
- }
329
- }
330
- loadHeatmapData() {
331
- this.processDefinition = this.processDefinitionVersions.find(definition => definition.version === this.version);
332
- if (this.heatmapOption === 'count') {
333
- this.loadProcessDefinitionHeatmapCount(this.processDefinition);
334
- }
335
- if (this.heatmapOption === 'duration') {
336
- this.loadProcessDefinitionHeatmapDuration(this.processDefinition);
337
- }
338
- }
339
- setMax(key) {
340
- if (this.heatmapDuration) {
341
- this.max = Math.max(this.heatmapDuration[key].averageDurationInMilliseconds, this.max);
342
- }
343
- else if (this.heatmapCount) {
344
- this.max = Math.max(this.heatmapCount[key].totalCount + this.heatmapCount[key].count, this.max);
345
- }
346
- }
347
- addCounterActiveOverlays(key, inputData) {
348
- const overlays = this.bpmnJS.get('overlays');
349
- overlays.add(key, {
350
- position: {
351
- bottom: 13,
352
- left: -12
353
- },
354
- show: {
355
- minZoom: 0,
356
- maxZoom: 5.0
357
- },
358
- html: `<span class="badge badge-pill badge-primary">${inputData[key].count}</span>`
359
- });
360
- }
361
- }
362
- ProcessDiagramComponent.decorators = [
363
- { type: Component, args: [{
364
- selector: 'valtimo-process-diagram',
365
- 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><br />\n <select class=\"form-control\" (change)=\"setProcessDefinitionVersion($event.target.value)\">\n <option *ngFor=\"let processDefinitionVersion of processDefinitionVersions\"\n [value]=\"processDefinitionVersion.version\"\n [selected]=\"processDefinitionVersion.version === version\">\n {{ processDefinitionVersion.version }}\n </option>\n </select>\n </div>\n <div class=\"col-4\">\n <label><strong>Heatmap type</strong></label><br />\n <select class=\"form-control\" (change)=\"setHeatmapOption($event.target.value)\">\n <option *ngFor=\"let option of enumHeatmapOptions\"\n [value]=\"option\"\n [selected]=\"option === heatmapOption\" >\n {{ option }}\n </option>\n </select>\n </div>\n <div class=\"col-4 text-right\">\n <label><strong>Show heatmap</strong></label><br />\n <div class=\"text-left switch-button switch-button-sm switch-button-success\">\n <input type=\"checkbox\" id=\"toggleHeatmap\" [checked]=\"showHeatmap\" (click)=\"toggleShowHeatmap()\"><span>\n <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><div class=\"legenda highlight-overlay-past\"></div> Executed tasks</span>\n <span class=\"ml-3\"><div class=\"legenda highlight-overlay-current\"></div> Current tasks</span>\n </div>\n\n <div *ngIf=\"processDefinitionKey\" class=\"p-4 text-center legenda-holder\">\n <span><span class=\"badge badge-pill badge-primary\">N</span>&nbsp;&nbsp;Amount of currently active instances of this task.</span>\n <span>&nbsp;&nbsp;|&nbsp;&nbsp;Red/yellow/green orbs: The amount of times the task is executed in comparison to the other tasks.</span>\n </div>\n</div>\n",
366
- encapsulation: ViewEncapsulation.None,
367
- 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}"]
368
- },] }
369
- ];
370
- ProcessDiagramComponent.ctorParameters = () => [
371
- { type: ProcessService }
372
- ];
373
- ProcessDiagramComponent.propDecorators = {
374
- el: [{ type: ViewChild, args: ['ref', { static: true },] }],
375
- importDone: [{ type: Output }],
376
- processDefinitionKey: [{ type: Input }],
377
- processInstanceId: [{ type: Input }]
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 }]
378
380
  };
379
381
 
380
- /*
381
- * Copyright 2015-2020 Ritense BV, the Netherlands.
382
- *
383
- * Licensed under EUPL, Version 1.2 (the "License");
384
- * you may not use this file except in compliance with the License.
385
- * You may obtain a copy of the License at
386
- *
387
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
388
- *
389
- * Unless required by applicable law or agreed to in writing, software
390
- * distributed under the License is distributed on an "AS IS" basis,
391
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
392
- * See the License for the specific language governing permissions and
393
- * limitations under the License.
394
- */
395
- class ProcessModule {
396
- }
397
- ProcessModule.decorators = [
398
- { type: NgModule, args: [{
399
- declarations: [
400
- ProcessDiagramComponent
401
- ],
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: [
416
- ProcessDiagramComponent
417
- ],
418
- },] }
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
+ },] }
419
417
  ];
420
418
 
421
- /*
422
- * Copyright 2015-2020 Ritense BV, the Netherlands.
423
- *
424
- * Licensed under EUPL, Version 1.2 (the "License");
425
- * you may not use this file except in compliance with the License.
426
- * You may obtain a copy of the License at
427
- *
428
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
429
- *
430
- * Unless required by applicable law or agreed to in writing, software
431
- * distributed under the License is distributed on an "AS IS" basis,
432
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
433
- * See the License for the specific language governing permissions and
434
- * limitations under the License.
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.
435
433
  */
436
434
 
437
- /**
438
- * Generated bundle index. Do not edit.
435
+ /**
436
+ * Generated bundle index. Do not edit.
439
437
  */
440
438
 
441
439
  export { ProcessDiagramComponent, ProcessModule, ProcessService };