@5minds/node-red-contrib-processcube 1.1.4-develop-e31a04-m025nm40 → 1.1.4-feature-7fe78b-m04wj3x0
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 +2 -1
- package/process-new-listener.html +31 -0
- package/process-new-listener.js +71 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@5minds/node-red-contrib-processcube",
|
3
|
-
"version": "1.1.4-
|
3
|
+
"version": "1.1.4-feature-7fe78b-m04wj3x0",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "Node-RED nodes for ProcessCube",
|
6
6
|
"scripts": {
|
@@ -40,6 +40,7 @@
|
|
40
40
|
"externaltaskOutput": "externaltask-output.js",
|
41
41
|
"externaltaskError": "externaltask-error.js",
|
42
42
|
"processStart": "process-start.js",
|
43
|
+
"processNewListener": "process-new-listener.js",
|
43
44
|
"processcubeEngineConfig": "processcube-engine-config.js",
|
44
45
|
"ProcessinstanceQuery": "processinstance-query.js",
|
45
46
|
"ProcessdefinitionQuery": "processdefinition-query.js",
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
RED.nodes.registerType('process-new-listener', {
|
3
|
+
category: 'ProcessCube',
|
4
|
+
color: '#02AFD6',
|
5
|
+
defaults: {
|
6
|
+
name: { value: '' },
|
7
|
+
processmodel: { value: '', required: false },
|
8
|
+
},
|
9
|
+
inputs: 1,
|
10
|
+
outputs: 1,
|
11
|
+
icon: 'font-awesome/fa-sign-in',
|
12
|
+
label: function () {
|
13
|
+
return this.name || 'process-new-listener';
|
14
|
+
},
|
15
|
+
});
|
16
|
+
</script>
|
17
|
+
|
18
|
+
<script type="text/html" data-template-name="process-new-listener">
|
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-processmodel"><i class="fa fa-tag"></i> Processmodel</label>
|
25
|
+
<input type="text" id="node-input-processmodel" placeholder="ID of Processmodel" />
|
26
|
+
</div>
|
27
|
+
</script>
|
28
|
+
|
29
|
+
<script type="text/markdown" data-help-name="process-start">
|
30
|
+
Subscribe to process starts
|
31
|
+
</script>
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module.exports = function (RED) {
|
2
|
+
function ProcessNewListener(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.notifications.onProcessStarted(
|
21
|
+
(processNotification) => {
|
22
|
+
// node.send({
|
23
|
+
// payload: {
|
24
|
+
// flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
|
25
|
+
// userTaskEvent: userTaskWaitingNotification,
|
26
|
+
// action: 'new',
|
27
|
+
// type: 'usertask',
|
28
|
+
// },
|
29
|
+
// });
|
30
|
+
console.log(processNotification);
|
31
|
+
},
|
32
|
+
{ identity: currentIdentity }
|
33
|
+
);
|
34
|
+
}
|
35
|
+
|
36
|
+
node.engine.registerOnIdentityChanged(async (identity) => {
|
37
|
+
if (subscription) {
|
38
|
+
client.notifications.removeSubscription(subscription, currentIdentity);
|
39
|
+
}
|
40
|
+
|
41
|
+
currentIdentity = identity;
|
42
|
+
|
43
|
+
subscription = await client.notifications.onProcessStarted(
|
44
|
+
(processNotification) => {
|
45
|
+
// node.send({
|
46
|
+
// payload: {
|
47
|
+
// flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
|
48
|
+
// userTaskEvent: userTaskWaitingNotification,
|
49
|
+
// action: 'new',
|
50
|
+
// type: 'usertask',
|
51
|
+
// },
|
52
|
+
// });
|
53
|
+
console.log(processNotification);
|
54
|
+
},
|
55
|
+
{ identity: currentIdentity }
|
56
|
+
);
|
57
|
+
});
|
58
|
+
|
59
|
+
node.on('close', () => {
|
60
|
+
if (node.engine && node.engine.engineClient && client) {
|
61
|
+
client.notifications.removeSubscription(subscription, currentIdentity);
|
62
|
+
}
|
63
|
+
});
|
64
|
+
};
|
65
|
+
|
66
|
+
if (node.engine) {
|
67
|
+
register();
|
68
|
+
}
|
69
|
+
}
|
70
|
+
RED.nodes.registerType('process-new-listener', ProcessNewListener);
|
71
|
+
};
|