@5minds/node-red-contrib-processcube 1.5.10-feature-e89b67-m4jqa6qs → 1.5.10-feature-79d9a9-m4k1xjd3
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/package.json +1 -1
- package/processinstance-delete.html +7 -7
- package/processinstance-delete.js +25 -10
package/package.json
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
name: { value: '' },
|
7
7
|
engine: { value: '', type: 'processcube-engine-config' },
|
8
8
|
modelid: { value: '' },
|
9
|
-
|
10
|
-
|
9
|
+
time: { value: '', type: 'number' },
|
10
|
+
time_type: { value: 'hours' },
|
11
11
|
},
|
12
12
|
inputs: 1,
|
13
13
|
outputs: 1,
|
@@ -32,12 +32,12 @@
|
|
32
32
|
<input type="text" id="node-input-modelid" />
|
33
33
|
</div>
|
34
34
|
<div class="form-row">
|
35
|
-
<label for="node-input-
|
35
|
+
<label for="node-input-time"><i class="fa fa-tag"></i> Duration</label>
|
36
36
|
<input type="text" id="node-input-time" />
|
37
37
|
</div>
|
38
38
|
<div class="form-row">
|
39
|
-
<label for="node-input-
|
40
|
-
<select id="node-input-
|
39
|
+
<label for="node-input-time_type"><i class="fa fa-sliders"></i> Time Unit</label>
|
40
|
+
<select id="node-input-time_type" style="width: 70%;">
|
41
41
|
<option value="hours">Hours</option>
|
42
42
|
<option value="days">Days</option>
|
43
43
|
</select>
|
@@ -49,8 +49,8 @@ Delete old instances of a process model in the ProcessCube.
|
|
49
49
|
|
50
50
|
## Inputs
|
51
51
|
|
52
|
-
: payload.
|
53
|
-
: payload.
|
52
|
+
: payload.time (number): The number of given time periods.
|
53
|
+
: payload.time_type ('hours' | 'days'): The type of time period to use.
|
54
54
|
|
55
55
|
## Outputs
|
56
56
|
|
@@ -11,14 +11,15 @@ module.exports = function (RED) {
|
|
11
11
|
node.error('No engine configured.');
|
12
12
|
return;
|
13
13
|
}
|
14
|
+
|
14
15
|
let timeMultiplier;
|
15
|
-
if (msg.payload.
|
16
|
-
timeMultiplier = msg.payload.
|
16
|
+
if (msg.payload.time_type) {
|
17
|
+
timeMultiplier = msg.payload.time_type == 'hours' ? 1 : 24;
|
17
18
|
} else {
|
18
|
-
timeMultiplier = config.
|
19
|
+
timeMultiplier = config.time_type == 'hours' ? 1 : 24;
|
19
20
|
}
|
20
21
|
|
21
|
-
const timeToUse = msg.payload.
|
22
|
+
const timeToUse = msg.payload.time ? msg.payload.time : config.time;
|
22
23
|
const modelId = msg.payload.processModelId
|
23
24
|
? msg.payload.processModelId != ''
|
24
25
|
? msg.payload.processModelId
|
@@ -32,7 +33,7 @@ module.exports = function (RED) {
|
|
32
33
|
processModelId: modelId
|
33
34
|
}, { identity: engine.identity });
|
34
35
|
|
35
|
-
let allInstances = result.processInstances.filter((instance) => instance.state != 'suspended');
|
36
|
+
let allInstances = result.processInstances.filter((instance) => instance.state != 'suspended' && instance.state != 'running');
|
36
37
|
|
37
38
|
const today = new Date();
|
38
39
|
|
@@ -43,15 +44,29 @@ module.exports = function (RED) {
|
|
43
44
|
});
|
44
45
|
|
45
46
|
const ids = oldTasks.map((obj) => obj.processInstanceId);
|
46
|
-
msg.payload = ids;
|
47
47
|
|
48
|
-
|
48
|
+
// Änderungen: Fehler beim Löschen abfangen
|
49
|
+
msg.payload = {
|
50
|
+
successfulDeletions: [],
|
51
|
+
failedDeletions: []
|
52
|
+
};
|
53
|
+
|
54
|
+
for (const id of ids) {
|
55
|
+
try {
|
56
|
+
await client.processInstances.deleteProcessInstances([id], true, engine.identity);
|
57
|
+
msg.payload.successfulDeletions.push(id); // Erfolgreiche IDs hinzufügen
|
58
|
+
} catch (deleteError) {
|
59
|
+
msg.payload.failedDeletions.push({ id, error: deleteError.message }); // Fehler protokollieren
|
60
|
+
node.warn(`Failed to delete process instance ID: ${id}. Error: ${deleteError.message}`);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
49
64
|
node.send(msg);
|
50
|
-
} catch (
|
51
|
-
node.error(
|
65
|
+
} catch (queryError) {
|
66
|
+
node.error(`Failed to query process instances: ${queryError.message}`);
|
52
67
|
}
|
53
68
|
});
|
54
69
|
}
|
55
70
|
|
56
71
|
RED.nodes.registerType('processinstance-delete', ProcessInstanceDelete);
|
57
|
-
};
|
72
|
+
};
|