@5minds/node-red-contrib-processcube 1.1.4-feature-80090b-m06aaj19 → 1.1.4-feature-f15f2e-m06hsqhu
Sign up to get free protection for your applications and to get access to all the features.
- package/externaltask-event-listener.html +52 -0
- package/externaltask-event-listener.js +108 -0
- package/package.json +3 -2
- package/usertask-event-listener.html +53 -0
- package/usertask-event-listener.js +111 -0
- package/process-terminate.html +0 -37
- package/process-terminate.js +0 -27
- package/usertask-finished-listener.html +0 -45
- package/usertask-finished-listener.js +0 -68
- package/usertask-new-listener.html +0 -45
- package/usertask-new-listener.js +0 -69
@@ -0,0 +1,52 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
RED.nodes.registerType('externaltask-event-listener', {
|
3
|
+
category: 'ProcessCube Events',
|
4
|
+
color: '#02AFD6',
|
5
|
+
defaults: {
|
6
|
+
name: { value: '' },
|
7
|
+
engine: { value: '', type: 'processcube-engine-config' },
|
8
|
+
externaltask: { value: '', required: false },
|
9
|
+
eventtype: { value: '', required: true },
|
10
|
+
},
|
11
|
+
inputs: 0,
|
12
|
+
outputs: 1,
|
13
|
+
icon: 'font-awesome/fa-sign-in',
|
14
|
+
label: function () {
|
15
|
+
return this.name || 'externaltask-event-listener';
|
16
|
+
},
|
17
|
+
});
|
18
|
+
</script>
|
19
|
+
|
20
|
+
<script type="text/html" data-template-name="externaltask-event-listener">
|
21
|
+
<div class="form-row">
|
22
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
23
|
+
<input type="text" id="node-input-name" placeholder="Name" />
|
24
|
+
</div>
|
25
|
+
<div class="form-row">
|
26
|
+
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
27
|
+
<input type="text" id="node-input-engine" placeholder="http://engine:8000" />
|
28
|
+
</div>
|
29
|
+
<div class="form-row">
|
30
|
+
<label for="node-input-externaltask"><i class="fa fa-tag"></i> Externaltask</label>
|
31
|
+
<input type="text" id="node-input-externaltask" placeholder="ID of Externaltask" />
|
32
|
+
</div>
|
33
|
+
<div class="form-row">
|
34
|
+
<label for="node-input-eventtype"><i class="fa fa-sliders"></i> Event</label>
|
35
|
+
<select id="node-input-eventtype" style="width: 70%;">
|
36
|
+
<option value="created">created</option>
|
37
|
+
<option value="locked">locked</option>
|
38
|
+
<option value="unlocked">unlocked</option>
|
39
|
+
</select>
|
40
|
+
</div>
|
41
|
+
</script>
|
42
|
+
|
43
|
+
<script type="text/markdown" data-help-name="externaltask-event-listener">
|
44
|
+
A node which listens for events triggered by externaltasks
|
45
|
+
|
46
|
+
## Outputs
|
47
|
+
|
48
|
+
### References
|
49
|
+
|
50
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
51
|
+
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
52
|
+
</script>
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module.exports = function (RED) {
|
2
|
+
function ExternalTaskEventListener(config) {
|
3
|
+
RED.nodes.createNode(this, config);
|
4
|
+
var node = this;
|
5
|
+
node.engine = RED.nodes.getNode(config.engine);
|
6
|
+
|
7
|
+
const register = async () => {
|
8
|
+
let currentIdentity = node.engine.identity;
|
9
|
+
|
10
|
+
const client = node.engine.engineClient;
|
11
|
+
|
12
|
+
if (!client) {
|
13
|
+
node.error('No engine configured.');
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
|
17
|
+
let subscription;
|
18
|
+
|
19
|
+
async function subscribe() {
|
20
|
+
switch (config.eventtype) {
|
21
|
+
case 'created':
|
22
|
+
return await client.notification.onExternalTaskCreated(
|
23
|
+
(externalTaskNotification) => {
|
24
|
+
if (
|
25
|
+
config.externaltask != '' &&
|
26
|
+
config.externaltask != externalTaskNotification.flowNodeId
|
27
|
+
)
|
28
|
+
return;
|
29
|
+
node.send({
|
30
|
+
payload: {
|
31
|
+
flowNodeInstanceId: externalTaskNotification.flowNodeInstanceId,
|
32
|
+
externalTaskEvent: externalTaskNotification,
|
33
|
+
action: 'created',
|
34
|
+
type: 'externaltask',
|
35
|
+
},
|
36
|
+
});
|
37
|
+
},
|
38
|
+
{ identity: currentIdentity }
|
39
|
+
);
|
40
|
+
case 'locked':
|
41
|
+
return await client.notification.onExternalTaskLocked(
|
42
|
+
(externalTaskNotification) => {
|
43
|
+
if (
|
44
|
+
config.externaltask != '' &&
|
45
|
+
config.externaltask != externalTaskNotification.flowNodeId
|
46
|
+
)
|
47
|
+
return;
|
48
|
+
node.send({
|
49
|
+
payload: {
|
50
|
+
flowNodeInstanceId: externalTaskNotification.flowNodeInstanceId,
|
51
|
+
externalTaskEvent: externalTaskNotification,
|
52
|
+
action: 'locked',
|
53
|
+
type: 'externaltask',
|
54
|
+
},
|
55
|
+
});
|
56
|
+
},
|
57
|
+
{ identity: currentIdentity }
|
58
|
+
);
|
59
|
+
case 'unlocked':
|
60
|
+
return await client.notification.onExternalTaskUnlocked(
|
61
|
+
(externalTaskNotification) => {
|
62
|
+
if (
|
63
|
+
config.externaltask != '' &&
|
64
|
+
config.externaltask != externalTaskNotification.flowNodeId
|
65
|
+
)
|
66
|
+
return;
|
67
|
+
node.send({
|
68
|
+
payload: {
|
69
|
+
flowNodeInstanceId: externalTaskNotification.flowNodeInstanceId,
|
70
|
+
externalTaskEvent: externalTaskNotification,
|
71
|
+
action: 'unlocked',
|
72
|
+
type: 'externaltask',
|
73
|
+
},
|
74
|
+
});
|
75
|
+
},
|
76
|
+
{ identity: currentIdentity }
|
77
|
+
);
|
78
|
+
default:
|
79
|
+
console.error('no such event: ' + config.eventtype);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
if (node.engine.isIdentityReady()) {
|
84
|
+
subscription = subscribe();
|
85
|
+
}
|
86
|
+
|
87
|
+
node.engine.registerOnIdentityChanged(async (identity) => {
|
88
|
+
if (subscription) {
|
89
|
+
client.notification.removeSubscription(subscription, currentIdentity);
|
90
|
+
}
|
91
|
+
currentIdentity = identity;
|
92
|
+
|
93
|
+
subscription = subscribe();
|
94
|
+
});
|
95
|
+
|
96
|
+
node.on('close', async () => {
|
97
|
+
if (node.engine && node.engine.engineClient && client) {
|
98
|
+
client.notification.removeSubscription(subscription, currentIdentity);
|
99
|
+
}
|
100
|
+
});
|
101
|
+
};
|
102
|
+
|
103
|
+
if (node.engine) {
|
104
|
+
register();
|
105
|
+
}
|
106
|
+
}
|
107
|
+
RED.nodes.registerType('externaltask-event-listener', ExternalTaskEventListener);
|
108
|
+
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@5minds/node-red-contrib-processcube",
|
3
|
-
"version": "1.1.4-feature-
|
3
|
+
"version": "1.1.4-feature-f15f2e-m06hsqhu",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "Node-RED nodes for ProcessCube",
|
6
6
|
"scripts": {
|
@@ -39,14 +39,15 @@
|
|
39
39
|
"externaltaskInput": "externaltask-input.js",
|
40
40
|
"externaltaskOutput": "externaltask-output.js",
|
41
41
|
"externaltaskError": "externaltask-error.js",
|
42
|
+
"externaltaskEventListener": "externaltask-event-listener.js",
|
42
43
|
"processStart": "process-start.js",
|
43
|
-
"processTerminate": "process-terminate.js",
|
44
44
|
"processEventListener": "process-event-listener.js",
|
45
45
|
"processcubeEngineConfig": "processcube-engine-config.js",
|
46
46
|
"ProcessinstanceQuery": "processinstance-query.js",
|
47
47
|
"ProcessdefinitionQuery": "processdefinition-query.js",
|
48
48
|
"messageEventTrigger": "message-event-trigger.js",
|
49
49
|
"signalEventTrigger": "signal-event-trigger.js",
|
50
|
+
"userTaskEventListener": "usertask-event-listener.js",
|
50
51
|
"UserTaskNewListener": "usertask-new-listener.js",
|
51
52
|
"UserTaskFinishedListener": "usertask-finished-listener.js",
|
52
53
|
"UserTaskInput": "usertask-input.js",
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
RED.nodes.registerType('usertask-event-listener', {
|
3
|
+
category: 'ProcessCube Events',
|
4
|
+
color: '#02AFD6',
|
5
|
+
defaults: {
|
6
|
+
name: { value: '' },
|
7
|
+
engine: { value: '', type: 'processcube-engine-config' },
|
8
|
+
usertask: { value: '', required: false },
|
9
|
+
eventtype: { value: '', required: true },
|
10
|
+
},
|
11
|
+
inputs: 0,
|
12
|
+
outputs: 1,
|
13
|
+
icon: 'font-awesome/fa-sign-in',
|
14
|
+
label: function () {
|
15
|
+
return this.name || 'usertask-event-listener';
|
16
|
+
},
|
17
|
+
});
|
18
|
+
</script>
|
19
|
+
|
20
|
+
<script type="text/html" data-template-name="usertask-event-listener">
|
21
|
+
<div class="form-row">
|
22
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
23
|
+
<input type="text" id="node-input-name" placeholder="Name" />
|
24
|
+
</div>
|
25
|
+
<div class="form-row">
|
26
|
+
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
27
|
+
<input type="text" id="node-input-engine" placeholder="http://engine:8000" />
|
28
|
+
</div>
|
29
|
+
<div class="form-row">
|
30
|
+
<label for="node-input-usertask"><i class="fa fa-tag"></i> Usertask</label>
|
31
|
+
<input type="text" id="node-input-usertask" placeholder="ID of Usertask" />
|
32
|
+
</div>
|
33
|
+
<div class="form-row">
|
34
|
+
<label for="node-input-eventtype"><i class="fa fa-sliders"></i> Event</label>
|
35
|
+
<select id="node-input-eventtype" style="width: 70%;">
|
36
|
+
<option value="new">new</option>
|
37
|
+
<option value="finished">finished</option>
|
38
|
+
<option value="reserved">reserved</option>
|
39
|
+
<option value="reservation-canceled">reservation-canceled</option>
|
40
|
+
</select>
|
41
|
+
</div>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
<script type="text/markdown" data-help-name="usertask-event-listener">
|
45
|
+
A node which listens for events triggered by usertasks
|
46
|
+
|
47
|
+
## Outputs
|
48
|
+
|
49
|
+
### References
|
50
|
+
|
51
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
52
|
+
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
53
|
+
</script>
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module.exports = function (RED) {
|
2
|
+
function UserTaskEventListener(config) {
|
3
|
+
RED.nodes.createNode(this, config);
|
4
|
+
var node = this;
|
5
|
+
node.engine = RED.nodes.getNode(config.engine);
|
6
|
+
|
7
|
+
const register = async () => {
|
8
|
+
let currentIdentity = node.engine.identity;
|
9
|
+
|
10
|
+
const client = node.engine.engineClient;
|
11
|
+
|
12
|
+
if (!client) {
|
13
|
+
node.error('No engine configured.');
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
|
17
|
+
let subscription;
|
18
|
+
|
19
|
+
async function subscribe() {
|
20
|
+
switch (config.eventtype) {
|
21
|
+
case 'new':
|
22
|
+
return await client.userTasks.onUserTaskWaiting(
|
23
|
+
(userTaskNotification) => {
|
24
|
+
if (config.usertask != '' && config.usertask != userTaskNotification.flowNodeId) return;
|
25
|
+
node.send({
|
26
|
+
payload: {
|
27
|
+
flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
|
28
|
+
userTaskEvent: userTaskNotification,
|
29
|
+
action: 'new',
|
30
|
+
type: 'usertask',
|
31
|
+
},
|
32
|
+
});
|
33
|
+
},
|
34
|
+
{ identity: currentIdentity }
|
35
|
+
);
|
36
|
+
case 'finished':
|
37
|
+
return await client.userTasks.onUserTaskFinished(
|
38
|
+
(userTaskNotification) => {
|
39
|
+
if (config.usertask != '' && config.usertask != userTaskNotification.flowNodeId) return;
|
40
|
+
node.send({
|
41
|
+
payload: {
|
42
|
+
flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
|
43
|
+
userTaskEvent: userTaskNotification,
|
44
|
+
action: 'finished',
|
45
|
+
type: 'usertask',
|
46
|
+
},
|
47
|
+
});
|
48
|
+
},
|
49
|
+
{ identity: currentIdentity }
|
50
|
+
);
|
51
|
+
case 'reserved':
|
52
|
+
return await client.userTasks.onUserTaskReserved(
|
53
|
+
(userTaskNotification) => {
|
54
|
+
if (config.usertask != '' && config.usertask != userTaskNotification.flowNodeId) return;
|
55
|
+
node.send({
|
56
|
+
payload: {
|
57
|
+
flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
|
58
|
+
userTaskEvent: userTaskNotification,
|
59
|
+
action: 'reserved',
|
60
|
+
type: 'usertask',
|
61
|
+
},
|
62
|
+
});
|
63
|
+
},
|
64
|
+
{ identity: currentIdentity }
|
65
|
+
);
|
66
|
+
case 'reservation-canceled':
|
67
|
+
return await client.userTasks.onUserTaskReservationCanceled(
|
68
|
+
(userTaskNotification) => {
|
69
|
+
if (config.usertask != '' && config.usertask != userTaskNotification.flowNodeId) return;
|
70
|
+
node.send({
|
71
|
+
payload: {
|
72
|
+
flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
|
73
|
+
userTaskEvent: userTaskNotification,
|
74
|
+
action: 'reservation-canceled',
|
75
|
+
type: 'usertask',
|
76
|
+
},
|
77
|
+
});
|
78
|
+
},
|
79
|
+
{ identity: currentIdentity }
|
80
|
+
);
|
81
|
+
default:
|
82
|
+
console.error('no such event: ' + config.eventtype);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
if (node.engine.isIdentityReady()) {
|
87
|
+
subscription = subscribe();
|
88
|
+
}
|
89
|
+
|
90
|
+
node.engine.registerOnIdentityChanged(async (identity) => {
|
91
|
+
if (subscription) {
|
92
|
+
client.userTasks.removeSubscription(subscription, currentIdentity);
|
93
|
+
}
|
94
|
+
currentIdentity = identity;
|
95
|
+
|
96
|
+
subscription = subscribe();
|
97
|
+
});
|
98
|
+
|
99
|
+
node.on('close', async () => {
|
100
|
+
if (node.engine && node.engine.engineClient && client) {
|
101
|
+
client.userTasks.removeSubscription(subscription, currentIdentity);
|
102
|
+
}
|
103
|
+
});
|
104
|
+
};
|
105
|
+
|
106
|
+
if (node.engine) {
|
107
|
+
register();
|
108
|
+
}
|
109
|
+
}
|
110
|
+
RED.nodes.registerType('usertask-event-listener', UserTaskEventListener);
|
111
|
+
};
|
package/process-terminate.html
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
<script type="text/javascript">
|
2
|
-
RED.nodes.registerType('process-terminate', {
|
3
|
-
category: 'ProcessCube',
|
4
|
-
color: '#02AFD6',
|
5
|
-
defaults: {
|
6
|
-
name: { value: '' },
|
7
|
-
engine: { value: '', type: 'processcube-engine-config' },
|
8
|
-
},
|
9
|
-
inputs: 1,
|
10
|
-
outputs: 1,
|
11
|
-
icon: 'font-awesome/fa-sign-in',
|
12
|
-
label: function () {
|
13
|
-
return this.name || 'process-terminate';
|
14
|
-
},
|
15
|
-
});
|
16
|
-
</script>
|
17
|
-
|
18
|
-
<script type="text/html" data-template-name="process-terminate">
|
19
|
-
<div class="form-row">
|
20
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
21
|
-
<input type="text" id="node-input-name" placeholder="Name" />
|
22
|
-
</div>
|
23
|
-
<div class="form-row">
|
24
|
-
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
25
|
-
<input type="text" id="node-input-engine" placeholder="Engine-URL" />
|
26
|
-
</div>
|
27
|
-
</script>
|
28
|
-
|
29
|
-
<script type="text/markdown" data-help-name="process-terminate">
|
30
|
-
Terminate an instance of a process model in the ProcessCube.
|
31
|
-
|
32
|
-
### References
|
33
|
-
|
34
|
-
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
35
|
-
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
36
|
-
|
37
|
-
</script>
|
package/process-terminate.js
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
module.exports = function (RED) {
|
2
|
-
function ProcessTerminate(config) {
|
3
|
-
RED.nodes.createNode(this, config);
|
4
|
-
var node = this;
|
5
|
-
|
6
|
-
node.on('input', function (msg) {
|
7
|
-
const engine = RED.nodes.getNode(config.engine);
|
8
|
-
const client = engine.engineClient;
|
9
|
-
|
10
|
-
if (!client) {
|
11
|
-
node.error('No engine configured.');
|
12
|
-
return;
|
13
|
-
}
|
14
|
-
|
15
|
-
client.processInstances
|
16
|
-
.terminateProcessInstance(msg.payload, engine.identity)
|
17
|
-
.then(() => {
|
18
|
-
node.send(msg);
|
19
|
-
})
|
20
|
-
.catch((error) => {
|
21
|
-
node.error(error);
|
22
|
-
});
|
23
|
-
});
|
24
|
-
}
|
25
|
-
|
26
|
-
RED.nodes.registerType('process-terminate', ProcessTerminate);
|
27
|
-
};
|
@@ -1,45 +0,0 @@
|
|
1
|
-
<script type="text/javascript">
|
2
|
-
RED.nodes.registerType('usertask-finished-listener', {
|
3
|
-
category: 'ProcessCube Events',
|
4
|
-
color: '#02AFD6',
|
5
|
-
defaults: {
|
6
|
-
name: { value: '' },
|
7
|
-
engine: { value: '', type: 'processcube-engine-config' },
|
8
|
-
multisend: { value: false },
|
9
|
-
},
|
10
|
-
inputs: 0,
|
11
|
-
outputs: 1,
|
12
|
-
icon: 'font-awesome/fa-envelope',
|
13
|
-
label: function () {
|
14
|
-
return this.name || 'usertask-finished-listener';
|
15
|
-
},
|
16
|
-
});
|
17
|
-
</script>
|
18
|
-
|
19
|
-
<script type="text/html" data-template-name="usertask-finished-listener">
|
20
|
-
<div class="form-row">
|
21
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
22
|
-
<input type="text" id="node-input-name" placeholder="Name" />
|
23
|
-
</div>
|
24
|
-
<div class="form-row">
|
25
|
-
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
26
|
-
<input type="text" id="node-input-engine" placeholder="http://engine:8000" />
|
27
|
-
</div>
|
28
|
-
</script>
|
29
|
-
|
30
|
-
<script type="text/markdown" data-help-name="usertask-finished-listener">
|
31
|
-
A node which listens for finished usertasks in the ProcessCube.
|
32
|
-
|
33
|
-
## Outputs
|
34
|
-
|
35
|
-
: flowNodeInstanceId (string): The flow node instance id of the finished usertask.
|
36
|
-
: userTaskEvent (object): The user task event object.
|
37
|
-
: action (string): The action of the event.
|
38
|
-
: type (string): The type of the event.
|
39
|
-
|
40
|
-
### References
|
41
|
-
|
42
|
-
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
43
|
-
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
44
|
-
|
45
|
-
</script>
|
@@ -1,68 +0,0 @@
|
|
1
|
-
module.exports = function (RED) {
|
2
|
-
function UserTaskFinishedListener(config) {
|
3
|
-
RED.nodes.createNode(this, config);
|
4
|
-
var node = this;
|
5
|
-
node.engine = RED.nodes.getNode(config.engine);
|
6
|
-
|
7
|
-
const register = async () => {
|
8
|
-
let currentIdentity = node.engine.identity;
|
9
|
-
|
10
|
-
const client = node.engine.engineClient;
|
11
|
-
|
12
|
-
if (!client) {
|
13
|
-
node.error('No engine configured.');
|
14
|
-
return;
|
15
|
-
}
|
16
|
-
|
17
|
-
let subscription;
|
18
|
-
|
19
|
-
if (node.engine.isIdentityReady()) {
|
20
|
-
subscription = await client.userTasks.onUserTaskFinished(
|
21
|
-
(userTaskFinishedNotification) => {
|
22
|
-
node.send({
|
23
|
-
payload: {
|
24
|
-
flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId,
|
25
|
-
userTaskEvent: userTaskFinishedNotification,
|
26
|
-
action: 'finished',
|
27
|
-
type: 'usertask',
|
28
|
-
},
|
29
|
-
});
|
30
|
-
},
|
31
|
-
{ identity: currentIdentity },
|
32
|
-
);
|
33
|
-
}
|
34
|
-
|
35
|
-
node.engine.registerOnIdentityChanged(async (identity) => {
|
36
|
-
if (subscription) {
|
37
|
-
client.userTasks.removeSubscription(subscription, currentIdentity);
|
38
|
-
}
|
39
|
-
currentIdentity = identity;
|
40
|
-
|
41
|
-
subscription = await client.userTasks.onUserTaskFinished(
|
42
|
-
(userTaskFinishedNotification) => {
|
43
|
-
node.send({
|
44
|
-
payload: {
|
45
|
-
flowNodeInstanceId: userTaskFinishedNotification.flowNodeInstanceId,
|
46
|
-
userTaskEvent: userTaskFinishedNotification,
|
47
|
-
action: 'finished',
|
48
|
-
type: 'usertask',
|
49
|
-
},
|
50
|
-
});
|
51
|
-
},
|
52
|
-
{ identity: currentIdentity },
|
53
|
-
);
|
54
|
-
});
|
55
|
-
|
56
|
-
node.on('close', async () => {
|
57
|
-
if (node.engine && node.engine.engineClient && client) {
|
58
|
-
client.userTasks.removeSubscription(subscription, currentIdentity);
|
59
|
-
}
|
60
|
-
});
|
61
|
-
};
|
62
|
-
|
63
|
-
if (node.engine) {
|
64
|
-
register();
|
65
|
-
}
|
66
|
-
}
|
67
|
-
RED.nodes.registerType('usertask-finished-listener', UserTaskFinishedListener);
|
68
|
-
};
|
@@ -1,45 +0,0 @@
|
|
1
|
-
<script type="text/javascript">
|
2
|
-
RED.nodes.registerType('usertask-new-listener', {
|
3
|
-
category: 'ProcessCube Events',
|
4
|
-
color: '#02AFD6',
|
5
|
-
defaults: {
|
6
|
-
name: { value: '' },
|
7
|
-
engine: { value: '', type: 'processcube-engine-config' },
|
8
|
-
multisend: { value: false },
|
9
|
-
},
|
10
|
-
inputs: 0,
|
11
|
-
outputs: 1,
|
12
|
-
icon: 'font-awesome/fa-envelope-open',
|
13
|
-
label: function () {
|
14
|
-
return this.name || 'usertask-new-listener';
|
15
|
-
},
|
16
|
-
});
|
17
|
-
</script>
|
18
|
-
|
19
|
-
<script type="text/html" data-template-name="usertask-new-listener">
|
20
|
-
<div class="form-row">
|
21
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
22
|
-
<input type="text" id="node-input-name" placeholder="Name" />
|
23
|
-
</div>
|
24
|
-
<div class="form-row">
|
25
|
-
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
26
|
-
<input type="text" id="node-input-engine" placeholder="http://engine:8000" />
|
27
|
-
</div>
|
28
|
-
</script>
|
29
|
-
|
30
|
-
<script type="text/markdown" data-help-name="usertask-new-listener">
|
31
|
-
A node which listens for new usertasks in the ProcessCube.
|
32
|
-
|
33
|
-
## Outputs
|
34
|
-
|
35
|
-
: flowNodeInstanceId (string): The flow node instance id of the new usertask.
|
36
|
-
: userTaskEvent (string) : The user task event object.
|
37
|
-
: action (string) : The action of the event.
|
38
|
-
: type (string) : The type of the event.
|
39
|
-
|
40
|
-
### References
|
41
|
-
|
42
|
-
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
43
|
-
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
44
|
-
|
45
|
-
</script>
|
package/usertask-new-listener.js
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
module.exports = function (RED) {
|
2
|
-
function UserTaskNewListener(config) {
|
3
|
-
RED.nodes.createNode(this, config);
|
4
|
-
var node = this;
|
5
|
-
node.engine = RED.nodes.getNode(config.engine);
|
6
|
-
|
7
|
-
const register = async () => {
|
8
|
-
const client = node.engine.engineClient;
|
9
|
-
|
10
|
-
if (!client) {
|
11
|
-
node.error('No engine configured.');
|
12
|
-
return;
|
13
|
-
}
|
14
|
-
|
15
|
-
let currentIdentity = node.engine.identity;
|
16
|
-
|
17
|
-
let subscription;
|
18
|
-
|
19
|
-
if (node.engine.isIdentityReady()) {
|
20
|
-
subscription = await client.userTasks.onUserTaskWaiting(
|
21
|
-
(userTaskWaitingNotification) => {
|
22
|
-
node.send({
|
23
|
-
payload: {
|
24
|
-
flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
|
25
|
-
userTaskEvent: userTaskWaitingNotification,
|
26
|
-
action: 'new',
|
27
|
-
type: 'usertask',
|
28
|
-
},
|
29
|
-
});
|
30
|
-
},
|
31
|
-
{ identity: currentIdentity },
|
32
|
-
);
|
33
|
-
}
|
34
|
-
|
35
|
-
node.engine.registerOnIdentityChanged(async (identity) => {
|
36
|
-
if (subscription) {
|
37
|
-
client.userTasks.removeSubscription(subscription, currentIdentity);
|
38
|
-
}
|
39
|
-
|
40
|
-
currentIdentity = identity;
|
41
|
-
|
42
|
-
subscription = await client.userTasks.onUserTaskWaiting(
|
43
|
-
(userTaskWaitingNotification) => {
|
44
|
-
node.send({
|
45
|
-
payload: {
|
46
|
-
flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
|
47
|
-
userTaskEvent: userTaskWaitingNotification,
|
48
|
-
action: 'new',
|
49
|
-
type: 'usertask',
|
50
|
-
},
|
51
|
-
});
|
52
|
-
},
|
53
|
-
{ identity: currentIdentity },
|
54
|
-
);
|
55
|
-
});
|
56
|
-
|
57
|
-
node.on('close', () => {
|
58
|
-
if (node.engine && node.engine.engineClient && client) {
|
59
|
-
client.userTasks.removeSubscription(subscription, currentIdentity);
|
60
|
-
}
|
61
|
-
});
|
62
|
-
};
|
63
|
-
|
64
|
-
if (node.engine) {
|
65
|
-
register();
|
66
|
-
}
|
67
|
-
}
|
68
|
-
RED.nodes.registerType('usertask-new-listener', UserTaskNewListener);
|
69
|
-
};
|