@5minds/node-red-contrib-processcube 0.10.3-feature-e75e2f-lybzmwlq → 0.11.0-feature-1a3680-lyc1y00u
Sign up to get free protection for your applications and to get access to all the features.
@@ -39,6 +39,14 @@
|
|
39
39
|
"info": "",
|
40
40
|
"env": []
|
41
41
|
},
|
42
|
+
{
|
43
|
+
"id": "0825fee24edbf04b",
|
44
|
+
"type": "tab",
|
45
|
+
"label": "Wait for Usertask",
|
46
|
+
"disabled": false,
|
47
|
+
"info": "",
|
48
|
+
"env": []
|
49
|
+
},
|
42
50
|
{
|
43
51
|
"id": "09cdc14cfb8ad687",
|
44
52
|
"type": "group",
|
@@ -1528,6 +1536,7 @@
|
|
1528
1536
|
"id": "3e89be46a437d93c",
|
1529
1537
|
"type": "usertask-finished-listener",
|
1530
1538
|
"z": "fd3c725340de4f74",
|
1539
|
+
"d": true,
|
1531
1540
|
"g": "f29182f397cab86b",
|
1532
1541
|
"name": "",
|
1533
1542
|
"engine": "d042a4c68f51d6ab",
|
@@ -1563,6 +1572,7 @@
|
|
1563
1572
|
"id": "3011d9be5207350a",
|
1564
1573
|
"type": "usertask-new-listener",
|
1565
1574
|
"z": "fd3c725340de4f74",
|
1575
|
+
"d": true,
|
1566
1576
|
"g": "f29182f397cab86b",
|
1567
1577
|
"name": "",
|
1568
1578
|
"engine": "d042a4c68f51d6ab",
|
@@ -2766,5 +2776,92 @@
|
|
2766
2776
|
"x": 90,
|
2767
2777
|
"y": 260,
|
2768
2778
|
"wires": []
|
2779
|
+
},
|
2780
|
+
{
|
2781
|
+
"id": "22a41b4678ae316d",
|
2782
|
+
"type": "wait-for-usertask",
|
2783
|
+
"z": "0825fee24edbf04b",
|
2784
|
+
"name": "",
|
2785
|
+
"engine": "d042a4c68f51d6ab",
|
2786
|
+
"query": "{\"flowNodeId\":\"PlaceAnOrderUserTask\"}",
|
2787
|
+
"query_type": "json",
|
2788
|
+
"x": 350,
|
2789
|
+
"y": 160,
|
2790
|
+
"wires": [
|
2791
|
+
[
|
2792
|
+
"fdd00e4099ca2ff6",
|
2793
|
+
"f7c378cc51a6244d"
|
2794
|
+
]
|
2795
|
+
]
|
2796
|
+
},
|
2797
|
+
{
|
2798
|
+
"id": "d1336102e406b91c",
|
2799
|
+
"type": "inject",
|
2800
|
+
"z": "0825fee24edbf04b",
|
2801
|
+
"name": "",
|
2802
|
+
"props": [
|
2803
|
+
{
|
2804
|
+
"p": "payload"
|
2805
|
+
},
|
2806
|
+
{
|
2807
|
+
"p": "topic",
|
2808
|
+
"vt": "str"
|
2809
|
+
}
|
2810
|
+
],
|
2811
|
+
"repeat": "",
|
2812
|
+
"crontab": "",
|
2813
|
+
"once": false,
|
2814
|
+
"onceDelay": 0.1,
|
2815
|
+
"topic": "",
|
2816
|
+
"payload": "",
|
2817
|
+
"payloadType": "date",
|
2818
|
+
"x": 100,
|
2819
|
+
"y": 160,
|
2820
|
+
"wires": [
|
2821
|
+
[
|
2822
|
+
"22a41b4678ae316d"
|
2823
|
+
]
|
2824
|
+
]
|
2825
|
+
},
|
2826
|
+
{
|
2827
|
+
"id": "fdd00e4099ca2ff6",
|
2828
|
+
"type": "debug",
|
2829
|
+
"z": "0825fee24edbf04b",
|
2830
|
+
"name": "debug 28",
|
2831
|
+
"active": true,
|
2832
|
+
"tosidebar": true,
|
2833
|
+
"console": false,
|
2834
|
+
"tostatus": false,
|
2835
|
+
"complete": "false",
|
2836
|
+
"statusVal": "",
|
2837
|
+
"statusType": "auto",
|
2838
|
+
"x": 570,
|
2839
|
+
"y": 160,
|
2840
|
+
"wires": []
|
2841
|
+
},
|
2842
|
+
{
|
2843
|
+
"id": "f7c378cc51a6244d",
|
2844
|
+
"type": "delay",
|
2845
|
+
"z": "0825fee24edbf04b",
|
2846
|
+
"name": "",
|
2847
|
+
"pauseType": "delay",
|
2848
|
+
"timeout": "1",
|
2849
|
+
"timeoutUnits": "milliseconds",
|
2850
|
+
"rate": "1",
|
2851
|
+
"nbRateUnits": "1",
|
2852
|
+
"rateUnits": "second",
|
2853
|
+
"randomFirst": "1",
|
2854
|
+
"randomLast": "5",
|
2855
|
+
"randomUnits": "seconds",
|
2856
|
+
"drop": false,
|
2857
|
+
"allowrate": false,
|
2858
|
+
"outputs": 1,
|
2859
|
+
"x": 350,
|
2860
|
+
"y": 240,
|
2861
|
+
"wires": [
|
2862
|
+
[
|
2863
|
+
"22a41b4678ae316d"
|
2864
|
+
]
|
2865
|
+
]
|
2769
2866
|
}
|
2770
2867
|
]
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@5minds/node-red-contrib-processcube",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.11.0-feature-1a3680-lyc1y00u",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "Node-RED nodes for ProcessCube",
|
6
6
|
"authors": [
|
@@ -44,7 +44,8 @@
|
|
44
44
|
"UserTaskNewListener": "usertask-new-listener.js",
|
45
45
|
"UserTaskFinishedListener": "usertask-finished-listener.js",
|
46
46
|
"UserTaskInput": "usertask-input.js",
|
47
|
-
"UserTaskOutput": "usertask-output.js"
|
47
|
+
"UserTaskOutput": "usertask-output.js",
|
48
|
+
"WaitForUsertask": "wait_for_usertask.js"
|
48
49
|
}
|
49
50
|
},
|
50
51
|
"dependencies": {
|
package/usertask-input.js
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
RED.nodes.registerType('wait-for-usertask',{
|
3
|
+
category: 'ProcessCube',
|
4
|
+
color: '#02AFD6',
|
5
|
+
defaults: {
|
6
|
+
name: {value: ""},
|
7
|
+
engine: {value: "", type: "processcube-engine-config"},
|
8
|
+
query: {value: "payload"},
|
9
|
+
query_type: {value: "msg"}
|
10
|
+
},
|
11
|
+
inputs: 1,
|
12
|
+
outputs: 1,
|
13
|
+
icon: "font-awesome/fa-envelope-open",
|
14
|
+
label: function() {
|
15
|
+
return this.name || "wait-for-usertask";
|
16
|
+
},
|
17
|
+
oneditprepare: function() {
|
18
|
+
$("#node-input-query").typedInput({
|
19
|
+
default: 'msg',
|
20
|
+
types: ['msg', 'json']
|
21
|
+
});
|
22
|
+
|
23
|
+
$("#node-input-query").typedInput('value', this.query);
|
24
|
+
$("#node-input-query").typedInput('type', this.query_type);
|
25
|
+
},
|
26
|
+
oneditsave: function() {
|
27
|
+
this.query = $("#node-input-query").typedInput('value'),
|
28
|
+
this.query_type = $("#node-input-query").typedInput('type')
|
29
|
+
|
30
|
+
}
|
31
|
+
});
|
32
|
+
</script>
|
33
|
+
|
34
|
+
<script type="text/html" data-template-name="wait-for-usertask">
|
35
|
+
<div class="form-row">
|
36
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
37
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
38
|
+
</div>
|
39
|
+
<div class="form-row">
|
40
|
+
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
41
|
+
<input type="text" id="node-input-engine" placeholder="http://engine:8000">
|
42
|
+
</div>
|
43
|
+
<div class="form-row">
|
44
|
+
<label for="node-input-query"><i class="fa fa-tag"></i> Query</label>
|
45
|
+
<input type="text" id="node-input-query">
|
46
|
+
</div>
|
47
|
+
</script>
|
48
|
+
|
49
|
+
<script type="text/markdown" data-help-name="wait-for-usertask">
|
50
|
+
Waiting for Usertasks of the connected ProcessCube Engine.
|
51
|
+
|
52
|
+
### Inputs
|
53
|
+
|
54
|
+
: payload (json) : the query to filter the usertasks.
|
55
|
+
|
56
|
+
## Outputs
|
57
|
+
|
58
|
+
: payload.userTask (string) : The filtered UserTask
|
59
|
+
|
60
|
+
### Details
|
61
|
+
|
62
|
+
`msg.payload` or a constant json to filter the UserTasks for Waiting for
|
63
|
+
|
64
|
+
### References
|
65
|
+
|
66
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© Plattform
|
67
|
+
</script>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
const process = require('process');
|
2
|
+
|
3
|
+
const engine_client = require('@5minds/processcube_engine_client');
|
4
|
+
|
5
|
+
module.exports = function (RED) {
|
6
|
+
function WaitForUsertask(config) {
|
7
|
+
RED.nodes.createNode(this, config);
|
8
|
+
var node = this;
|
9
|
+
let client = null;
|
10
|
+
|
11
|
+
this.engine = this.server = RED.nodes.getNode(config.engine);
|
12
|
+
|
13
|
+
const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
|
14
|
+
|
15
|
+
node.on("close", async () => {
|
16
|
+
if (client != null) {
|
17
|
+
client.dispose();
|
18
|
+
client = null;
|
19
|
+
}
|
20
|
+
});
|
21
|
+
|
22
|
+
node.on('input', function (msg) {
|
23
|
+
|
24
|
+
const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg)
|
25
|
+
|
26
|
+
client = new engine_client.EngineClient(engineUrl);
|
27
|
+
client.userTasks.onUserTaskWaiting((userTaskWaitingNotification) => {
|
28
|
+
|
29
|
+
query['flowNodeInstanceId'] = userTaskWaitingNotification.flowNodeInstanceId;
|
30
|
+
|
31
|
+
client.userTasks.query(query).then((matchingFlowNodes) => {
|
32
|
+
|
33
|
+
if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
|
34
|
+
userTask = matchingFlowNodes.userTasks[0];
|
35
|
+
|
36
|
+
msg.payload = { userTask: userTask };
|
37
|
+
node.send(msg);
|
38
|
+
} else {
|
39
|
+
// do nothing, cause we are waiting for a specific user task
|
40
|
+
}
|
41
|
+
|
42
|
+
// dispose the client
|
43
|
+
if (client != null) {
|
44
|
+
client.dispose();
|
45
|
+
client = null;
|
46
|
+
}
|
47
|
+
});
|
48
|
+
});
|
49
|
+
});
|
50
|
+
}
|
51
|
+
RED.nodes.registerType("wait-for-usertask", WaitForUsertask);
|
52
|
+
}
|