@5minds/node-red-contrib-processcube 1.1.4-feature-e9faa8-m04zlkr3 → 1.1.4-feature-271ccb-m0509jqp
Sign up to get free protection for your applications and to get access to all the features.
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-271ccb-m0509jqp",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "Node-RED nodes for ProcessCube",
|
6
6
|
"scripts": {
|
@@ -40,7 +40,8 @@
|
|
40
40
|
"externaltaskOutput": "externaltask-output.js",
|
41
41
|
"externaltaskError": "externaltask-error.js",
|
42
42
|
"processStart": "process-start.js",
|
43
|
-
"
|
43
|
+
"processStartedListener": "process-started-listener.js",
|
44
|
+
"processFinishedListener": "process-finished-listener.js",
|
44
45
|
"processcubeEngineConfig": "processcube-engine-config.js",
|
45
46
|
"ProcessinstanceQuery": "processinstance-query.js",
|
46
47
|
"ProcessdefinitionQuery": "processdefinition-query.js",
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
RED.nodes.registerType('process-finished-listener', {
|
3
|
+
category: 'ProcessCube',
|
4
|
+
color: '#02AFD6',
|
5
|
+
defaults: {
|
6
|
+
name: { value: '' },
|
7
|
+
engine: { value: '', type: 'processcube-engine-config' },
|
8
|
+
processmodel: { value: '', required: false },
|
9
|
+
},
|
10
|
+
inputs: 0,
|
11
|
+
outputs: 1,
|
12
|
+
icon: 'font-awesome/fa-sign-in',
|
13
|
+
label: function () {
|
14
|
+
return this.name || 'process-finished-listener';
|
15
|
+
},
|
16
|
+
});
|
17
|
+
</script>
|
18
|
+
|
19
|
+
<script type="text/html" data-template-name="process-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
|
+
<div class="form-row">
|
29
|
+
<label for="node-input-processmodel"><i class="fa fa-tag"></i> Processmodel</label>
|
30
|
+
<input type="text" id="node-input-processmodel" placeholder="ID of Processmodel" />
|
31
|
+
</div>
|
32
|
+
</script>
|
33
|
+
|
34
|
+
<script type="text/markdown" data-help-name="process-start">
|
35
|
+
Subscribe to process endings
|
36
|
+
</script>
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module.exports = function (RED) {
|
2
|
+
function ProcessFinishedListener(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.notification.onProcessEnded(
|
21
|
+
(processNotification) => {
|
22
|
+
console.log(processNotification);
|
23
|
+
if (config.processmodel != processNotification.processModelId) return;
|
24
|
+
node.send({
|
25
|
+
payload: {
|
26
|
+
processInstanceId: processNotification.processInstanceId,
|
27
|
+
flowNodeId: processNotification.flowNodeId,
|
28
|
+
token: processNotification.currentToken,
|
29
|
+
action: 'started',
|
30
|
+
type: 'processInstance',
|
31
|
+
},
|
32
|
+
});
|
33
|
+
},
|
34
|
+
{ identity: currentIdentity }
|
35
|
+
);
|
36
|
+
}
|
37
|
+
|
38
|
+
node.engine.registerOnIdentityChanged(async (identity) => {
|
39
|
+
if (subscription) {
|
40
|
+
client.notification.removeSubscription(subscription, currentIdentity);
|
41
|
+
}
|
42
|
+
|
43
|
+
currentIdentity = identity;
|
44
|
+
|
45
|
+
subscription = await client.notification.onProcessEnded(
|
46
|
+
(processNotification) => {
|
47
|
+
if (config.processmodel != processNotification.processModelId) return;
|
48
|
+
node.send({
|
49
|
+
payload: {
|
50
|
+
processInstanceId: processNotification.processInstanceId,
|
51
|
+
flowNodeId: processNotification.flowNodeId,
|
52
|
+
token: processNotification.currentToken,
|
53
|
+
action: 'ended',
|
54
|
+
type: 'processInstance',
|
55
|
+
},
|
56
|
+
});
|
57
|
+
},
|
58
|
+
{ identity: currentIdentity }
|
59
|
+
);
|
60
|
+
});
|
61
|
+
|
62
|
+
node.on('close', () => {
|
63
|
+
if (node.engine && node.engine.engineClient && client) {
|
64
|
+
client.notification.removeSubscription(subscription, currentIdentity);
|
65
|
+
}
|
66
|
+
});
|
67
|
+
};
|
68
|
+
|
69
|
+
if (node.engine) {
|
70
|
+
register();
|
71
|
+
}
|
72
|
+
}
|
73
|
+
RED.nodes.registerType('process-ended-listener', ProcessEndedListener);
|
74
|
+
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<script type="text/javascript">
|
2
|
-
RED.nodes.registerType('process-
|
2
|
+
RED.nodes.registerType('process-started-listener', {
|
3
3
|
category: 'ProcessCube',
|
4
4
|
color: '#02AFD6',
|
5
5
|
defaults: {
|
@@ -11,12 +11,12 @@
|
|
11
11
|
outputs: 1,
|
12
12
|
icon: 'font-awesome/fa-sign-in',
|
13
13
|
label: function () {
|
14
|
-
return this.name || 'process-
|
14
|
+
return this.name || 'process-started-listener';
|
15
15
|
},
|
16
16
|
});
|
17
17
|
</script>
|
18
18
|
|
19
|
-
<script type="text/html" data-template-name="process-
|
19
|
+
<script type="text/html" data-template-name="process-started-listener">
|
20
20
|
<div class="form-row">
|
21
21
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
22
22
|
<input type="text" id="node-input-name" placeholder="Name" />
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module.exports = function (RED) {
|
2
|
-
function
|
2
|
+
function ProcessStartedListener(config) {
|
3
3
|
RED.nodes.createNode(this, config);
|
4
4
|
var node = this;
|
5
5
|
node.engine = RED.nodes.getNode(config.engine);
|
@@ -69,5 +69,5 @@ module.exports = function (RED) {
|
|
69
69
|
register();
|
70
70
|
}
|
71
71
|
}
|
72
|
-
RED.nodes.registerType('process-
|
72
|
+
RED.nodes.registerType('process-started-listener', ProcessStartedListener);
|
73
73
|
};
|