@5minds/node-red-contrib-processcube 0.5.7 → 0.6.0-develop-a016f3-lxu6osmc

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@
7
7
  error: {value:""}
8
8
  },
9
9
  inputs: 1,
10
- outputs: 0,
10
+ outputs: 1,
11
11
  icon: "font-awesome/fa-exclamation-triangle",
12
12
  label: function() {
13
13
  return this.name || "externaltask-error";
@@ -26,6 +26,8 @@ module.exports = function(RED) {
26
26
  };
27
27
 
28
28
  eventEmitter.emit(`error-${externalTaskId}`, msg.payload);
29
+
30
+ node.send(msg);
29
31
  });
30
32
  }
31
33
  RED.nodes.registerType("externaltask-error", ExternalTaskError);
@@ -11,6 +11,16 @@ function showStatus(node, msgCounter) {
11
11
  }
12
12
  }
13
13
 
14
+ function decrCounter(msgCounter) {
15
+ msgCounter--;
16
+
17
+ if (msgCounter < 0) {
18
+ msgCounter = 0;
19
+ }
20
+
21
+ return msgCounter;
22
+ }
23
+
14
24
  module.exports = function(RED) {
15
25
  function ExternalTaskInput(config) {
16
26
  RED.nodes.createNode(this,config);
@@ -46,13 +56,14 @@ module.exports = function(RED) {
46
56
 
47
57
  // TODO: once ist 2x gebunden
48
58
  eventEmitter.once(`finish-${externalTask.flowNodeInstanceId}`, (result) => {
49
- msgCounter--;
59
+ msgCounter = decrCounter(msgCounter);
60
+
50
61
  showStatus(node, msgCounter);
51
62
  resolve(result);
52
63
  });
53
64
 
54
65
  eventEmitter.once(`error-${externalTask.flowNodeInstanceId}`, (msg) => {
55
- msgCounter--;
66
+ msgCounter = decrCounter(msgCounter);
56
67
  showStatus(node, msgCounter);
57
68
 
58
69
  var result = msg.payload ? msg.payload : msg;
@@ -106,7 +106,6 @@
106
106
  "1497b762d2ac1723",
107
107
  "493500b42d8d0f5b",
108
108
  "34984ae3f4e83b0b",
109
- "8e2a2f993ee7156a",
110
109
  "eee38d2764bac337",
111
110
  "a4d741804929ba73",
112
111
  "915816cdb895af14",
@@ -161,12 +160,15 @@
161
160
  "5cc47f646e818d1e",
162
161
  "66b90cf83a531a75",
163
162
  "e002a108a6c7df75",
164
- "2851b83de5fb070d"
163
+ "2851b83de5fb070d",
164
+ "a547ad5dcdd4613f",
165
+ "e98eecc53e433cfe",
166
+ "ed3c805cc0dc276c"
165
167
  ],
166
168
  "x": 34,
167
169
  "y": 559,
168
- "w": 712,
169
- "h": 142
170
+ "w": 952,
171
+ "h": 182
170
172
  },
171
173
  {
172
174
  "id": "02fef81e2129ea71",
@@ -379,6 +381,33 @@
379
381
  "visible": "true",
380
382
  "disabled": "false"
381
383
  },
384
+ {
385
+ "id": "973fe345c23a83a4",
386
+ "type": "ui-page",
387
+ "name": "DynamicTable",
388
+ "ui": "26a45d43c064bdb6",
389
+ "path": "/page4",
390
+ "icon": "home",
391
+ "layout": "grid",
392
+ "theme": "7175f012d8e51857",
393
+ "order": -1,
394
+ "className": "",
395
+ "visible": "true",
396
+ "disabled": "false"
397
+ },
398
+ {
399
+ "id": "99fb2417816969fd",
400
+ "type": "ui-group",
401
+ "name": "Table",
402
+ "page": "973fe345c23a83a4",
403
+ "width": "12",
404
+ "height": "1",
405
+ "order": -1,
406
+ "showTitle": true,
407
+ "className": "",
408
+ "visible": "true",
409
+ "disabled": "false"
410
+ },
382
411
  {
383
412
  "id": "84f18cf9bf25b858",
384
413
  "type": "openApi-red",
@@ -1450,6 +1479,8 @@
1450
1479
  "g": "405f8c703368777c",
1451
1480
  "name": "",
1452
1481
  "engine": "42e6796dddd9d4db",
1482
+ "query": "payload",
1483
+ "force_send_array": true,
1453
1484
  "multisend": false,
1454
1485
  "x": 540,
1455
1486
  "y": 140,
@@ -1506,6 +1537,8 @@
1506
1537
  "g": "405f8c703368777c",
1507
1538
  "name": "",
1508
1539
  "engine": "d042a4c68f51d6ab",
1540
+ "result": "payload",
1541
+ "result_type": "msg",
1509
1542
  "x": 1020,
1510
1543
  "y": 140,
1511
1544
  "wires": [
@@ -1710,10 +1743,10 @@
1710
1743
  "once": false,
1711
1744
  "onceDelay": 0.1,
1712
1745
  "topic": "",
1713
- "payload": "{\t \"state\": \"suspended\"\t}",
1714
- "payloadType": "jsonata",
1746
+ "payload": "{\"flowNodeInstanceId\":\"a84dfgh2b416-58f7-443f-bd38-c10ddcd776cb\"}",
1747
+ "payloadType": "json",
1715
1748
  "x": 160,
1716
- "y": 660,
1749
+ "y": 700,
1717
1750
  "wires": [
1718
1751
  [
1719
1752
  "66b90cf83a531a75"
@@ -1727,12 +1760,16 @@
1727
1760
  "g": "b60e94a5f1ee2790",
1728
1761
  "name": "",
1729
1762
  "engine": "d042a4c68f51d6ab",
1763
+ "query": "payload",
1764
+ "query_type": "msg",
1765
+ "force_send_array": false,
1730
1766
  "multisend": false,
1731
1767
  "x": 400,
1732
- "y": 660,
1768
+ "y": 700,
1733
1769
  "wires": [
1734
1770
  [
1735
- "e002a108a6c7df75"
1771
+ "e002a108a6c7df75",
1772
+ "a547ad5dcdd4613f"
1736
1773
  ]
1737
1774
  ]
1738
1775
  },
@@ -1750,7 +1787,7 @@
1750
1787
  "statusVal": "",
1751
1788
  "statusType": "auto",
1752
1789
  "x": 640,
1753
- "y": 660,
1790
+ "y": 700,
1754
1791
  "wires": []
1755
1792
  },
1756
1793
  {
@@ -1761,9 +1798,201 @@
1761
1798
  "name": "Abfragen von UserTasks",
1762
1799
  "info": "",
1763
1800
  "x": 170,
1801
+ "y": 640,
1802
+ "wires": []
1803
+ },
1804
+ {
1805
+ "id": "a547ad5dcdd4613f",
1806
+ "type": "dynamic-form",
1807
+ "z": "fd3c725340de4f74",
1808
+ "g": "b60e94a5f1ee2790",
1809
+ "name": "",
1810
+ "group": "5403f00c961584ab",
1811
+ "order": 0,
1812
+ "options": [
1813
+ {
1814
+ "label": "jljlkj"
1815
+ },
1816
+ {
1817
+ "label": "another"
1818
+ },
1819
+ {
1820
+ "label": "dsfjklsdj"
1821
+ }
1822
+ ],
1823
+ "waiting_title": "Warten auf den Usertask...",
1824
+ "waiting_info": "Der Usertask wird automatisch angezeigt, wenn ein entsprechender Task vorhanden ist.",
1825
+ "width": 0,
1826
+ "height": 0,
1827
+ "outputs": 3,
1828
+ "x": 640,
1829
+ "y": 640,
1830
+ "wires": [
1831
+ [
1832
+ "e98eecc53e433cfe"
1833
+ ],
1834
+ [
1835
+ "ed3c805cc0dc276c"
1836
+ ],
1837
+ [
1838
+ "ed3c805cc0dc276c"
1839
+ ]
1840
+ ]
1841
+ },
1842
+ {
1843
+ "id": "e98eecc53e433cfe",
1844
+ "type": "debug",
1845
+ "z": "fd3c725340de4f74",
1846
+ "g": "b60e94a5f1ee2790",
1847
+ "name": "debug 25",
1848
+ "active": true,
1849
+ "tosidebar": true,
1850
+ "console": false,
1851
+ "tostatus": false,
1852
+ "complete": "false",
1853
+ "statusVal": "",
1854
+ "statusType": "auto",
1855
+ "x": 860,
1764
1856
  "y": 600,
1765
1857
  "wires": []
1766
1858
  },
1859
+ {
1860
+ "id": "ed3c805cc0dc276c",
1861
+ "type": "debug",
1862
+ "z": "fd3c725340de4f74",
1863
+ "g": "b60e94a5f1ee2790",
1864
+ "name": "debug 26",
1865
+ "active": true,
1866
+ "tosidebar": true,
1867
+ "console": false,
1868
+ "tostatus": false,
1869
+ "complete": "false",
1870
+ "statusVal": "",
1871
+ "statusType": "auto",
1872
+ "x": 880,
1873
+ "y": 640,
1874
+ "wires": []
1875
+ },
1876
+ {
1877
+ "id": "a80d2f28ea46f22f",
1878
+ "type": "inject",
1879
+ "z": "fd3c725340de4f74",
1880
+ "name": "",
1881
+ "props": [
1882
+ {
1883
+ "p": "payload"
1884
+ },
1885
+ {
1886
+ "p": "topic",
1887
+ "vt": "str"
1888
+ }
1889
+ ],
1890
+ "repeat": "",
1891
+ "crontab": "",
1892
+ "once": false,
1893
+ "onceDelay": 0.1,
1894
+ "topic": "",
1895
+ "payload": "",
1896
+ "payloadType": "date",
1897
+ "x": 140,
1898
+ "y": 840,
1899
+ "wires": [
1900
+ [
1901
+ "e283d772578fb6d2"
1902
+ ]
1903
+ ]
1904
+ },
1905
+ {
1906
+ "id": "09a463e42d3ce5b8",
1907
+ "type": "dynamic-table",
1908
+ "z": "fd3c725340de4f74",
1909
+ "name": "",
1910
+ "tableName": "",
1911
+ "group": "99fb2417816969fd",
1912
+ "order": 0,
1913
+ "data": "payload.userTasks",
1914
+ "data_type": "msg",
1915
+ "options": [
1916
+ {
1917
+ "label": "action",
1918
+ "condition": ""
1919
+ },
1920
+ {
1921
+ "label": "another",
1922
+ "condition": ""
1923
+ }
1924
+ ],
1925
+ "columns": [
1926
+ {
1927
+ "label": "State",
1928
+ "value": "state",
1929
+ "type": "str"
1930
+ }
1931
+ ],
1932
+ "width": 0,
1933
+ "height": 0,
1934
+ "outputs": 2,
1935
+ "x": 560,
1936
+ "y": 840,
1937
+ "wires": [
1938
+ [
1939
+ "8c5309ae86d0cb66"
1940
+ ],
1941
+ [
1942
+ "45208778372636d3"
1943
+ ]
1944
+ ]
1945
+ },
1946
+ {
1947
+ "id": "e283d772578fb6d2",
1948
+ "type": "usertask-input",
1949
+ "z": "fd3c725340de4f74",
1950
+ "name": "",
1951
+ "engine": "d042a4c68f51d6ab",
1952
+ "query": "{\"state\":\"suspended\"}",
1953
+ "query_type": "json",
1954
+ "force_send_array": true,
1955
+ "multisend": false,
1956
+ "x": 340,
1957
+ "y": 840,
1958
+ "wires": [
1959
+ [
1960
+ "09a463e42d3ce5b8"
1961
+ ]
1962
+ ]
1963
+ },
1964
+ {
1965
+ "id": "8c5309ae86d0cb66",
1966
+ "type": "debug",
1967
+ "z": "fd3c725340de4f74",
1968
+ "name": "debug 27",
1969
+ "active": true,
1970
+ "tosidebar": true,
1971
+ "console": false,
1972
+ "tostatus": false,
1973
+ "complete": "false",
1974
+ "statusVal": "",
1975
+ "statusType": "auto",
1976
+ "x": 740,
1977
+ "y": 780,
1978
+ "wires": []
1979
+ },
1980
+ {
1981
+ "id": "45208778372636d3",
1982
+ "type": "debug",
1983
+ "z": "fd3c725340de4f74",
1984
+ "name": "debug 28",
1985
+ "active": true,
1986
+ "tosidebar": true,
1987
+ "console": false,
1988
+ "tostatus": false,
1989
+ "complete": "false",
1990
+ "statusVal": "",
1991
+ "statusType": "auto",
1992
+ "x": 780,
1993
+ "y": 880,
1994
+ "wires": []
1995
+ },
1767
1996
  {
1768
1997
  "id": "0f5978f327b01bfb",
1769
1998
  "type": "ui-table",
@@ -2118,29 +2347,6 @@
2118
2347
  ]
2119
2348
  ]
2120
2349
  },
2121
- {
2122
- "id": "8e2a2f993ee7156a",
2123
- "type": "dynamic-form",
2124
- "z": "b195bc3ca2e1a665",
2125
- "g": "ec36901abb138306",
2126
- "name": "",
2127
- "group": "5403f00c961584ab",
2128
- "order": 0,
2129
- "waiting_title": "Waiting for Warten auf den Usertask...",
2130
- "waiting_info": "Der Usertask wird automatisch angezeigt, wenn ein entsprechender Task vorhanden ist.",
2131
- "submit_title": "Submit your task",
2132
- "cancel_title": "Cancel your task",
2133
- "width": 0,
2134
- "height": 0,
2135
- "x": 820,
2136
- "y": 520,
2137
- "wires": [
2138
- [
2139
- "915816cdb895af14",
2140
- "5399c05e8fea3679"
2141
- ]
2142
- ]
2143
- },
2144
2350
  {
2145
2351
  "id": "eee38d2764bac337",
2146
2352
  "type": "usertask-input",
@@ -2152,9 +2358,7 @@
2152
2358
  "x": 560,
2153
2359
  "y": 580,
2154
2360
  "wires": [
2155
- [
2156
- "8e2a2f993ee7156a"
2157
- ]
2361
+ []
2158
2362
  ]
2159
2363
  },
2160
2364
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube",
3
- "version": "0.5.7",
3
+ "version": "0.6.0-develop-a016f3-lxu6osmc",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "authors": [
@@ -5,6 +5,8 @@
5
5
  defaults: {
6
6
  name: {value: ""},
7
7
  engine: {value: "", type: "processcube-engine-config"},
8
+ query: {value: "payload"},
9
+ query_type: {value: "msg"},
8
10
  force_send_array: {value: false},
9
11
  multisend: {value: false}
10
12
  },
@@ -13,6 +15,20 @@
13
15
  icon: "font-awesome/fa-envelope-open",
14
16
  label: function() {
15
17
  return this.name || "usertask-input";
18
+ },
19
+ oneditprepare: function() {
20
+ $("#node-input-query").typedInput({
21
+ default: 'msg',
22
+ types: ['msg', 'json']
23
+ });
24
+
25
+ $("#node-input-query").typedInput('value', this.query);
26
+ $("#node-input-query").typedInput('type', this.query_type);
27
+ },
28
+ oneditsave: function() {
29
+ this.query = $("#node-input-query").typedInput('value'),
30
+ this.query_type = $("#node-input-query").typedInput('type')
31
+
16
32
  }
17
33
  });
18
34
  </script>
@@ -26,6 +42,10 @@
26
42
  <label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
27
43
  <input type="text" id="node-input-engine" placeholder="http://engine:8000">
28
44
  </div>
45
+ <div class="form-row">
46
+ <label for="node-input-query"><i class="fa fa-tag"></i> Query</label>
47
+ <input type="text" id="node-input-query">
48
+ </div>
29
49
  <div class="form-row" style="display:flex; margin-bottom: 3px;">
30
50
  <label for="node-input-force_send_array" style="vertical-align:top"><i class="fa fa-list-alt"></i> Force send payload as array</label>
31
51
  <div>
@@ -44,4 +64,4 @@
44
64
 
45
65
  <script type="text/html" data-help-name="usertask-input">
46
66
  <p>A node which subscribes to an User Task of https://processcube.io</p>
47
- </script>
67
+ </script>
package/usertask-input.js CHANGED
@@ -28,7 +28,7 @@ module.exports = function(RED) {
28
28
  if (!client) {
29
29
  nodeContext.set('client', new engine_client.EngineClient(engineUrl));
30
30
  client = nodeContext.get('client');
31
- }
31
+ }
32
32
 
33
33
  var eventEmitter = flowContext.get('emitter');
34
34
 
@@ -42,15 +42,14 @@ module.exports = function(RED) {
42
42
  client = null;
43
43
  });
44
44
 
45
- node.on('input', async function(msg) {
46
- console.log(`UserTaskInput received message: ${JSON.stringify(msg.payload)}`);
47
-
48
- let query = msg.payload;
45
+ node.on('input', function(msg) {
46
+ const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg)
47
+ console.log(query)
49
48
 
50
49
  client.userTasks.query(query).then((matchingFlowNodes) => {
51
50
 
52
51
  console.log(`UserTaskInput query result: ${JSON.stringify(matchingFlowNodes)}`);
53
-
52
+
54
53
  if (!config.force_send_array && matchingFlowNodes && matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
55
54
  userTask = matchingFlowNodes.userTasks[0];
56
55
 
@@ -72,4 +71,4 @@ module.exports = function(RED) {
72
71
  });
73
72
  }
74
73
  RED.nodes.registerType("usertask-input", UserTaskInput);
75
- }
74
+ }
@@ -4,14 +4,30 @@
4
4
  color: '#00aed7',
5
5
  defaults: {
6
6
  name: {value: ""},
7
- engine: {value: "", type: "processcube-engine-config"}
7
+ engine: {value: "", type: "processcube-engine-config"},
8
+ result: {value: "payload"},
9
+ result_type: {value: "msg"}
8
10
  },
9
11
  inputs: 1,
10
12
  outputs: 1,
11
13
  icon: "font-awesome/fa-envelope",
12
14
  label: function() {
13
15
  return this.name || "usertask-output";
14
- }
16
+ },
17
+ oneditprepare: function() {
18
+ $("#node-input-result").typedInput({
19
+ default: 'msg',
20
+ types: ['msg', 'json']
21
+ });
22
+
23
+ $("#node-input-result").typedInput('value', this.result);
24
+ $("#node-input-result").typedInput('type', this.result_type);
25
+ },
26
+ oneditsave: function() {
27
+ this.result = $("#node-input-result").typedInput('value'),
28
+ this.result_type = $("#node-input-result").typedInput('type')
29
+
30
+ }
15
31
  });
16
32
  </script>
17
33
 
@@ -24,8 +40,12 @@
24
40
  <label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
25
41
  <input type="text" id="node-input-engine" placeholder="http://engine:8000">
26
42
  </div>
43
+ <div class="form-row">
44
+ <label for="node-input-result"><i class="fa fa-tag"></i> Result</label>
45
+ <input type="text" id="node-input-result">
46
+ </div>
27
47
  </script>
28
48
 
29
49
  <script type="text/html" data-help-name="usertask-output">
30
50
  <p>A node which send the result to an User Task of https://processcube.io</p>
31
- </script>
51
+ </script>
@@ -21,7 +21,7 @@ module.exports = function(RED) {
21
21
  if (!client) {
22
22
  nodeContext.set('client', new engine_client.EngineClient(engineUrl));
23
23
  client = nodeContext.get('client');
24
- }
24
+ }
25
25
 
26
26
  var eventEmitter = flowContext.get('emitter');
27
27
 
@@ -35,7 +35,8 @@ module.exports = function(RED) {
35
35
  console.log(`Try to finsih UserTask with id ${msg.payload.userTask.flowNodeInstanceId}.`);
36
36
 
37
37
  const flowNodeInstanceId = msg.payload.userTask.flowNodeInstanceId;
38
- const userTaskResult = msg.payload.formData || {};
38
+
39
+ const userTaskResult = RED.util.evaluateNodeProperty(config.result, config.result_type, node, msg);
39
40
 
40
41
  client.userTasks.finishUserTask(flowNodeInstanceId, userTaskResult).then(() => {
41
42
  console.log(`UserTask with id ${flowNodeInstanceId} finished.`);
@@ -47,8 +48,8 @@ module.exports = function(RED) {
47
48
  } else {
48
49
  console.log(`No UserTask found in message: ${JSON.stringify(msg.payload)}`);
49
50
  }
50
- });
51
+ });
51
52
  }
52
53
 
53
54
  RED.nodes.registerType("usertask-output", UserTaskOutput);
54
- }
55
+ }