@gotillit/tillit-node-red 1.2.4 → 1.2.5

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.
@@ -44,7 +44,8 @@ var utils_1 = require("../shared/utils");
44
44
  var got_1 = __importDefault(require("got"));
45
45
  var buildRoutes = function (RED) {
46
46
  var apiRoot = "/tillit";
47
- RED.httpAdmin.get("".concat(apiRoot, "/:conn/:entity"), function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
47
+ var routeAuthHandler = RED.auth.needsPermission("tillit.write");
48
+ RED.httpAdmin.get("".concat(apiRoot, "/:conn/:entity"), routeAuthHandler, function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
48
49
  var conn, entity, broker, environment, tenant, username, password, ops, url, response;
49
50
  return __generator(this, function (_a) {
50
51
  switch (_a.label) {
@@ -1 +1 @@
1
- {"version":3,"file":"node-routes.js","sourceRoot":"","sources":["../../src/nodes/node-routes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAyC;AACzC,4CAAsB;AAEf,IAAM,WAAW,GAAG,UAAC,GAAQ;IAChC,IAAM,OAAO,GAAG,SAAS,CAAC;IAE1B,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,UAAG,OAAO,mBAAgB,EAAE,UAAO,GAAQ,EAAE,GAAQ;;;;;oBAC7D,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA;oBACtB,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC;oBAC3B,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;oBACvC,WAAW,GAAgC,MAAM,YAAtC,EAAE,MAAM,GAAwB,MAAM,OAA9B,EAAE,QAAQ,GAAc,MAAM,SAApB,EAAE,QAAQ,GAAI,MAAM,SAAV,CAAW;oBACrD,GAAG,GAAQ;wBACX,MAAM,EAAE,KAAK;wBACb,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAE,QAAQ;qBACrB,CAAA;oBACK,GAAG,GAAG,IAAA,gBAAQ,EAAC,WAAW,EAAE,MAAM,CAAC,GAAG,oBAAa,MAAM,eAAY,CAAC;oBAC3D,qBAAM,IAAA,aAAG,EAAC,GAAG,EAAE,GAAG,CAAC,EAAA;;oBAA9B,QAAQ,GAAG,SAAmB;oBACpC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;;;;SAC3B,CAAC,CAAC;AACP,CAAC,CAAA;AAjBY,QAAA,WAAW,eAiBvB"}
1
+ {"version":3,"file":"node-routes.js","sourceRoot":"","sources":["../../src/nodes/node-routes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAyC;AACzC,4CAAsB;AAEf,IAAM,WAAW,GAAG,UAAC,GAAQ;IAChC,IAAM,OAAO,GAAG,SAAS,CAAC;IAC1B,IAAM,gBAAgB,GAAG,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IAElE,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,UAAG,OAAO,mBAAgB,EAAE,gBAAgB,EAAE,UAAO,GAAQ,EAAE,GAAQ;;;;;oBAC/E,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA;oBACtB,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC;oBAC3B,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;oBACvC,WAAW,GAAgC,MAAM,YAAtC,EAAE,MAAM,GAAwB,MAAM,OAA9B,EAAE,QAAQ,GAAc,MAAM,SAApB,EAAE,QAAQ,GAAI,MAAM,SAAV,CAAW;oBACrD,GAAG,GAAQ;wBACX,MAAM,EAAE,KAAK;wBACb,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAE,QAAQ;qBACrB,CAAA;oBACK,GAAG,GAAG,IAAA,gBAAQ,EAAC,WAAW,EAAE,MAAM,CAAC,GAAG,oBAAa,MAAM,eAAY,CAAC;oBAC3D,qBAAM,IAAA,aAAG,EAAC,GAAG,EAAE,GAAG,CAAC,EAAA;;oBAA9B,QAAQ,GAAG,SAAmB;oBACpC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;;;;SAC3B,CAAC,CAAC;AACP,CAAC,CAAA;AAlBY,QAAA,WAAW,eAkBvB"}
@@ -1,62 +1,82 @@
1
-
2
1
  <script type="text/javascript">
3
- console.log('Registring plugin html')
4
- RED.plugins.registerPlugin("node-red-tillit", {
5
- onadd: function() {
6
2
 
7
- }})
3
+ function populateDropdown(deviceId, elementId, entity, selectedId) {
4
+ const domElement = document.getElementById(elementId);
5
+
6
+ fetch(`/tillit/${deviceId}/${entity}`)
7
+ .then(function (response) {
8
+ return response.json();
9
+ })
10
+ .then(function (data) {
11
+ // Populate the select element with returned data
12
+ const items = JSON.parse(data);
13
+ console.log(selectedId)
14
+ items.sort((a, b) => a.name < b.name ? -1 : 1).forEach(function (item) {
15
+ const option = document.createElement('option');
16
+ option.value = item.id;
17
+ option.text = item.name;
18
+ option.selected = item.id == selectedId
19
+ console.log(option.selected)
20
+ domElement.appendChild(option);
21
+ });
22
+ })
23
+ .catch(function (error) {
24
+ console.error(error);
25
+ });
26
+ }
27
+
8
28
  </script>
9
29
 
10
30
  <script type="text/x-red" data-template-name="tillit-node-connection">
11
- <div class="form-row">
12
- <label for="node-config-input-name"><i class="fa fa-globe"></i>Name</label>
13
- <input type="text" id="node-config-input-name" placeholder="Name">
14
- </div>
15
- <div class="form-row">
16
- <label for="node-config-input-thingId"><i class="fa fa-tag"></i> Thing ID</label>
17
- <input type="text" id="node-config-input-thingId" placeholder="Thing ID">
18
- </div>
19
- <div class="form-row">
20
- <label for="node-config-input-environment"><i class="fa fa-tag"></i> Environment</label>
21
- <input type="text" id="node-config-input-environment" placeholder="TilliT Environment">
22
- </div>
23
- <div class="form-row">
24
- <label for="node-config-input-endpoint"><i class="fa fa-tag"></i> Tenant</label>
25
- <input type="text" id="node-config-input-tenant" placeholder="Tenant name">
26
- </div>
27
- <div class="form-row">
28
- <label for="node-config-input-privKey"><i class="fa fa-tag"></i> Private key</label>
29
- <input type="text" id="node-config-input-privKey"></input>
30
- </div>
31
-
32
- <div class="form-row">
33
- <label for="node-config-input-thingCert"><i class="fa fa-tag"></i> Thing cert</label>
34
- <input type="text" id="node-config-input-thingCert"></input>
35
- </div>
36
-
37
- <div class="form-row">
38
- <label for="node-config-input-rootCa"><i class="fa fa-tag"></i> Root CA</label>
39
- <input type="text" id="node-config-input-rootCa"></input>
40
- </div>
41
-
42
-
43
- <div class="form-row">
44
- <label for="node-config-input-username"><i class="fa fa-tag"></i> Username</label>
45
- <input type="text" id="node-config-input-username"></input>
46
- </div>
47
-
48
- <div class="form-row">
49
- <label for="node-config-input-password"><i class="fa fa-tag"></i> Password</label>
50
- <input type="password" id="node-config-input-password"></input>
51
- </div>
52
-
53
- <div class="form-tips">
54
- <p><b>Secret:</b> Using environment variables:</p>
55
- <p>
56
- You can override any of these settings using environment variables. Recommended for production deployment.
57
- Use: USERNAME, PASSWORD, TENANT, ENVIRONMENT, THING_CERT, PRIV_KEY, ROOT_CA
58
- </p>
59
- </div>
31
+ <div class="form-row">
32
+ <label for="node-config-input-name"><i class="fa fa-globe"></i>Name</label>
33
+ <input type="text" id="node-config-input-name" placeholder="Name">
34
+ </div>
35
+ <div class="form-row">
36
+ <label for="node-config-input-thingId"><i class="fa fa-tag"></i> Thing ID</label>
37
+ <input type="text" id="node-config-input-thingId" placeholder="Thing ID">
38
+ </div>
39
+ <div class="form-row">
40
+ <label for="node-config-input-environment"><i class="fa fa-tag"></i> Environment</label>
41
+ <input type="text" id="node-config-input-environment" placeholder="TilliT Environment">
42
+ </div>
43
+ <div class="form-row">
44
+ <label for="node-config-input-endpoint"><i class="fa fa-tag"></i> Tenant</label>
45
+ <input type="text" id="node-config-input-tenant" placeholder="Tenant name">
46
+ </div>
47
+ <div class="form-row">
48
+ <label for="node-config-input-privKey"><i class="fa fa-tag"></i> Private key</label>
49
+ <input type="text" id="node-config-input-privKey"></input>
50
+ </div>
51
+
52
+ <div class="form-row">
53
+ <label for="node-config-input-thingCert"><i class="fa fa-tag"></i> Thing cert</label>
54
+ <input type="text" id="node-config-input-thingCert"></input>
55
+ </div>
56
+
57
+ <div class="form-row">
58
+ <label for="node-config-input-rootCa"><i class="fa fa-tag"></i> Root CA</label>
59
+ <input type="text" id="node-config-input-rootCa"></input>
60
+ </div>
61
+
62
+
63
+ <div class="form-row">
64
+ <label for="node-config-input-username"><i class="fa fa-tag"></i> Username</label>
65
+ <input type="text" id="node-config-input-username"></input>
66
+ </div>
67
+
68
+ <div class="form-row">
69
+ <label for="node-config-input-password"><i class="fa fa-tag"></i> Password</label>
70
+ <input type="password" id="node-config-input-password"></input>
71
+ </div>
72
+
73
+ <div class="form-tips">
74
+ <p><b>Secret:</b> Using environment variables:</p>
75
+ <p>
76
+ You can override any of these settings using environment variables. Recommended for production deployment.
77
+ Use: USERNAME, PASSWORD, TENANT, ENVIRONMENT, THING_CERT, PRIV_KEY, ROOT_CA
78
+ </p>
79
+ </div>
60
80
  </script>
61
81
 
62
82
  <!-- MQTT Broker Configuration -->
@@ -104,32 +124,32 @@
104
124
  </script>
105
125
 
106
126
  <script type="text/x-red" data-template-name="tillit-out">
107
- <div class="form-row">
108
- <label for="node-input-name"><i class="fa fa-globe"></i> Name</label>
109
- <input type="text" id="node-input-name">
110
- </div>
111
- <div class="form-row">
112
- <label for="node-input-device"><i class="fa fa-globe"></i> Connection</label>
113
- <input type="text" id="node-input-device">
114
- </div>
115
- <div class="form-row">
116
- <label for="node-input-topic"><i class="fa fa-globe"></i> Topic</label>
117
- <input type="text" id="node-input-topic">
118
- </div>
119
- <div class="form-row">
120
- <label for="node-input-qos"><i class="fa fa-empire"></i> <span> QoS</span></label>
121
- <select id="node-input-qos" style="width:125px !important">
122
- <option value="0">0</option>
123
- <option value="1">1</option>
124
- </select>
125
- </div>
127
+ <div class="form-row">
128
+ <label for="node-input-name"><i class="fa fa-globe"></i> Name</label>
129
+ <input type="text" id="node-input-name">
130
+ </div>
131
+ <div class="form-row">
132
+ <label for="node-input-device"><i class="fa fa-globe"></i> Connection</label>
133
+ <input type="text" id="node-input-device">
134
+ </div>
135
+ <div class="form-row">
136
+ <label for="node-input-topic"><i class="fa fa-globe"></i> Topic</label>
137
+ <input type="text" id="node-input-topic">
138
+ </div>
139
+ <div class="form-row">
140
+ <label for="node-input-qos"><i class="fa fa-empire"></i> <span> QoS</span></label>
141
+ <select id="node-input-qos" style="width:125px !important">
142
+ <option value="0">0</option>
143
+ <option value="1">1</option>
144
+ </select>
145
+ </div>
126
146
  </script>
127
147
 
128
148
  <script type="text/x-red" data-help-name="tillit-out">
129
- <p>Connects to a TilliT's MQTT broker and publishes <b>msg.payload</b> either to the <b>msg.topic</b> or to the topic specified in the edit window. The value in the edit window has precedence.</p>
130
- <p>Likewise QoS and/or retain values in the edit panel will overwrite any <b>msg.qos</b> and <b>msg.retain</b> properties. If nothing is set they default to <i>0</i> and <i>false</i> respectively.</p>
131
- <p>If <b>msg.payload</b> contains an object it will be stringified before being sent.</p>
132
- <p>For more information visit our help documentation: <a href="https://help.tillit.cloud/tillit/knowledge-base/setting-up-tillit/connecting-to-tillit/mqtt" target="blank">Open</a>
149
+ <p>Connects to a TilliT's MQTT broker and publishes <b>msg.payload</b> either to the <b>msg.topic</b> or to the topic specified in the edit window. The value in the edit window has precedence.</p>
150
+ <p>Likewise QoS and/or retain values in the edit panel will overwrite any <b>msg.qos</b> and <b>msg.retain</b> properties. If nothing is set they default to <i>0</i> and <i>false</i> respectively.</p>
151
+ <p>If <b>msg.payload</b> contains an object it will be stringified before being sent.</p>
152
+ <p>For more information visit our help documentation: <a href="https://help.tillit.cloud/tillit/knowledge-base/setting-up-tillit/connecting-to-tillit/mqtt" target="blank">Open</a>
133
153
  </script>
134
154
 
135
155
  <script type="text/javascript">
@@ -168,27 +188,27 @@
168
188
  </script>
169
189
 
170
190
  <script type="text/x-red" data-template-name="tillit-in">
171
- <div class="form-row">
172
- <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
173
- <input type="text" id="node-input-device">
174
- </div>
175
-
176
- <div class="form-row">
177
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
178
- <input type="text" id="node-input-name" placeholder="Name">
179
- </div>
180
- <div class="form-row">
181
- <label for="node-input-topic"><i class="fa fa-tag"></i> Topic</label>
182
- <input type="text" id="node-input-topic" placeholder="Topic">
183
- </div>
191
+ <div class="form-row">
192
+ <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
193
+ <input type="text" id="node-input-device">
194
+ </div>
195
+
196
+ <div class="form-row">
197
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
198
+ <input type="text" id="node-input-name" placeholder="Name">
199
+ </div>
200
+ <div class="form-row">
201
+ <label for="node-input-topic"><i class="fa fa-tag"></i> Topic</label>
202
+ <input type="text" id="node-input-topic" placeholder="Topic">
203
+ </div>
184
204
  </script>
185
205
 
186
206
  <script type="text/x-red" data-help-name="tillit-in">
187
- <p>TillliT MQTT input node. Connects to a broker and subscribes to the specified topic. The topic may contain MQTT wildcards.</p>
188
- <p>Topic needs to start with your tenant. To subscribe to all messages from your account, do {tenant}/#</p>
189
- <p>Outputs an object called <b>msg</b> containing <b>msg.topic, msg.payload, msg.qos</b> and <b>msg.retain</b>.</p>
190
- <p><b>msg.payload</b> is usually a string, but can also be a binary buffer.</p>
191
- <p>For more information visit our help documentation: <a href="https://help.tillit.cloud/tillit/knowledge-base/setting-up-tillit/connecting-to-tillit/mqtt" target="blank">Open</a>
207
+ <p>TillliT MQTT input node. Connects to a broker and subscribes to the specified topic. The topic may contain MQTT wildcards.</p>
208
+ <p>Topic needs to start with your tenant. To subscribe to all messages from your account, do {tenant}/#</p>
209
+ <p>Outputs an object called <b>msg</b> containing <b>msg.topic, msg.payload, msg.qos</b> and <b>msg.retain</b>.</p>
210
+ <p><b>msg.payload</b> is usually a string, but can also be a binary buffer.</p>
211
+ <p>For more information visit our help documentation: <a href="https://help.tillit.cloud/tillit/knowledge-base/setting-up-tillit/connecting-to-tillit/mqtt" target="blank">Open</a>
192
212
  </script>
193
213
 
194
214
  <script type="text/javascript">
@@ -223,41 +243,39 @@
223
243
  </script>
224
244
 
225
245
 
226
-
227
-
228
246
  <script type="text/x-red" data-template-name="tillit-api">
229
- <div class="form-row">
230
- <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
231
- <input type="text" id="node-input-device">
232
- </div>
233
-
234
- <div class="form-row">
235
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
236
- <input type="text" id="node-input-name" placeholder="Name">
237
- </div>
238
- <div class="form-row">
239
- <label for="node-input-endpoint"><i class="fa fa-tag"></i> Endpoint</label>
240
- <input type="text" id="node-input-endpoint" placeholder="Endpoint">
241
- </div>
242
- <div class="form-row">
243
- <label for="node-input-method"><i class="fa fa-empire"></i> <span> Method</span></label>
244
- <select id="node-input-method" style="width:125px !important">
245
- <option value="GET">GET</option>
246
- <option value="POST">POST</option>
247
- <option value="PUT">PUT</option>
248
- <option value="DELETE">DELETE</option>
249
- </select>
250
- </div>
247
+ <div class="form-row">
248
+ <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
249
+ <input type="text" id="node-input-device">
250
+ </div>
251
+
252
+ <div class="form-row">
253
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
254
+ <input type="text" id="node-input-name" placeholder="Name">
255
+ </div>
256
+ <div class="form-row">
257
+ <label for="node-input-endpoint"><i class="fa fa-tag"></i> Endpoint</label>
258
+ <input type="text" id="node-input-endpoint" placeholder="Endpoint">
259
+ </div>
260
+ <div class="form-row">
261
+ <label for="node-input-method"><i class="fa fa-empire"></i> <span> Method</span></label>
262
+ <select id="node-input-method" style="width:125px !important">
263
+ <option value="GET">GET</option>
264
+ <option value="POST">POST</option>
265
+ <option value="PUT">PUT</option>
266
+ <option value="DELETE">DELETE</option>
267
+ </select>
268
+ </div>
251
269
  </script>
252
270
 
253
271
  <script type="text/x-red" data-help-name="tillit-api">
254
- <p>An easy way for you to use the TilliT API from Node-red</p>
255
- <p>Set your endpoint and method here.</p>
256
- <p>Endpoint can be substituted by msg.endpoint</p>
257
- <p><b>msg.payload</b> is expected to be a json and will be the body on POST and PUT calls</p>
258
- <p><b>output 1</b> is the return of the call in case of success</p>
259
- <p><b>output 2</b> is the error body in case of failure</p>
260
- <p>For more information visit our help documentation: <a href="https://help.tillit.cloud/api/api/overview" target="blank">Open</a>
272
+ <p>An easy way for you to use the TilliT API from Node-red</p>
273
+ <p>Set your endpoint and method here.</p>
274
+ <p>Endpoint can be substituted by msg.endpoint</p>
275
+ <p><b>msg.payload</b> is expected to be a json and will be the body on POST and PUT calls</p>
276
+ <p><b>output 1</b> is the return of the call in case of success</p>
277
+ <p><b>output 2</b> is the error body in case of failure</p>
278
+ <p>For more information visit our help documentation: <a href="https://help.tillit.cloud/api/api/overview" target="blank">Open</a>
261
279
  </script>
262
280
 
263
281
  <script type="text/javascript">
@@ -296,42 +314,46 @@
296
314
 
297
315
 
298
316
  <script type="text/x-red" data-help-name="tillit-pv">
299
- <p>Publishes <b>msg.payload</b> to update the value of a process variable</p>
300
- <p>msg.payload will be used as the value, respecting the data type selected</p>
301
- <p>msg.topic will be used as assetId if you leave the configuration blank</p>
302
- <p>For more information visit our help documentation: <a href="https://help.tillit.cloud/tillit/knowledge-base/setting-up-tillit/connecting-to-tillit/mqtt/publish-timeseries" target="blank">Open</a>
317
+ <p>Publishes <b>msg.payload</b> to update the value of a process variable</p>
318
+ <p>msg.payload will be used as the value, respecting the data type selected</p>
319
+ <p>msg.topic will be used as assetId if you leave the configuration blank</p>
320
+ <p>For more information visit our help documentation: <a href="https://help.tillit.cloud/tillit/knowledge-base/setting-up-tillit/connecting-to-tillit/mqtt/publish-timeseries" target="blank">Open</a>
303
321
 
304
322
  </script>
305
323
 
306
324
 
307
325
  <script type="text/x-red" data-template-name="tillit-pv">
308
- <div class="form-row">
309
- <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
310
- <input type="text" id="node-input-device">
311
- </div>
326
+ <div class="form-row">
327
+ <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
328
+ <input type="text" id="node-input-device">
329
+ </div>
312
330
 
313
- <div class="form-row">
314
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
315
- <input type="text" id="node-input-name" placeholder="Name">
316
- </div>
331
+ <div class="form-row">
332
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
333
+ <input type="text" id="node-input-name" placeholder="Name">
334
+ </div>
317
335
 
318
- <div class="form-row">
319
- <label for="node-input-assetId"><i class="fa fa-tag"></i> Asset Id</label>
320
- <input type="text" id="node-input-assetId" placeholder="will use msg.topic if blank">
321
- </div>
336
+ <div class="form-row">
337
+ <label for="node-input-assetId"><i class="fa fa-tag"></i> Asset </label>
338
+ <select id="node-input-assetId" placeholder="will use msg.topic if blank">
339
+ <option></option>
340
+ </select>
341
+ </div>
322
342
 
323
- <div class="form-row">
324
- <label for="node-input-processVariableId"><i class="fa fa-tag"></i> Process Variable Id</label>
325
- <input type="text" id="node-input-processVariableId" placeholder="">
326
- </div>
343
+ <div class="form-row">
344
+ <label for="node-input-processVariableId"><i class="fa fa-tag"></i> Process Variable </label>
345
+ <select id="node-input-processVariableId" placeholder="">
346
+ <option></option>
347
+ </select>
348
+ </div>
327
349
 
328
- <div class="form-row">
329
- <label for="node-input-dataType"><i class="fa fa-tag"></i>Data Type</label>
330
- <select id="node-input-dataType" style="width:125px !important">
331
- <option value="number">NUMBER</option>
332
- <option value="string">STRING</option>
333
- <option value="boolean">BOOLEAN</option>
334
- </select>
350
+ <div class="form-row">
351
+ <label for="node-input-dataType"><i class="fa fa-tag"></i>Data Type</label>
352
+ <select id="node-input-dataType" style="width:125px !important">
353
+ <option value="number">NUMBER</option>
354
+ <option value="string">STRING</option>
355
+ <option value="boolean">BOOLEAN</option>
356
+ </select>
335
357
  </div>
336
358
 
337
359
 
@@ -366,55 +388,77 @@
366
388
  },
367
389
  labelStyle: function () {
368
390
  return this.name ? "node_label_italic" : "";
391
+ }, oneditprepare: function () {
392
+ const self = this;
393
+
394
+ function prepareForm() {
395
+ populateDropdown(self.device, 'node-input-assetId', 'assets', self.assetId);
396
+ populateDropdown(self.device, 'node-input-processVariableId', 'process-variables', self.assetId);
397
+ }
398
+
399
+ console.log('oneditprepare')
400
+ $('#node-input-device').change(function () {
401
+ // handle change event here
402
+ prepareForm();
403
+ });
404
+ setTimeout(() => {
405
+ if (!$('#node-input-device').val()) {
406
+ return
407
+ }
408
+ prepareForm();
409
+ }, 100)
410
+
369
411
  }
370
412
  });
371
413
  </script>
372
414
 
373
415
 
374
-
375
-
376
416
  <script type="text/x-red" data-help-name="tillit-event">
377
- <p>Publishes <b>msg.payload</b> to raise an event</p>
378
- <p>msg.topic can be used as assetId if you leave the node blank</p>
379
- <p>msg.payload should be like the following example:</p>
380
- <code>
381
- {
382
- assetId: number, //ID of the asset
383
- timestamp: string, //Timestamp of the event
384
- eventTypeId: number, //ID of the event to raise
385
- orderId: number //The id of the order to raise event on (Optional)
386
- orderNumber: string //The order number of the order to raise event on (Optional)
387
- status: string //ACTIVE | SCHEDULED | COMPLETED (Optional)
388
- subtitle: string //Set a description for the event (Optional)
417
+ <p>Publishes <b>msg.payload</b> to raise an event</p>
418
+ <p>msg.topic can be used as assetId if you leave the node blank</p>
419
+ <p>msg.payload should be like the following example:</p>
420
+ <code>
421
+ {
422
+ assetId: number, //ID of the asset
423
+ timestamp: string, //Timestamp of the event
424
+ eventTypeId: number, //ID of the event to raise
425
+ orderId: number //The id of the order to raise event on (Optional)
426
+ orderNumber: string //The order number of the order to raise event on (Optional)
427
+ status: string //ACTIVE | SCHEDULED | COMPLETED (Optional)
428
+ subtitle: string //Set a description for the event (Optional)
389
429
  }
390
- </code>
391
- This node will merge the settings from the node with the payload.
392
- <p>For more information visit our help documentation: <a href="https://help.tillit.cloud/api/examples/raise-an-event-in-tillit" target="blank">Open</a>
430
+ </code>
431
+ This node will merge the settings from the node with the payload.
432
+ <p>For more information visit our help documentation: <a href="https://help.tillit.cloud/api/examples/raise-an-event-in-tillit" target="blank">Open</a>
393
433
 
394
434
  </script>
395
435
 
396
436
 
397
437
  <script type="text/x-red" data-template-name="tillit-event">
398
- <div class="form-row">
399
- <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
400
- <input type="text" id="node-input-device">
401
- </div>
438
+ <div class="form-row">
439
+ <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
440
+ <input type="text" id="node-input-device">
441
+ </div>
402
442
 
403
443
 
404
- <div class="form-row">
405
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
406
- <input type="text" id="node-input-name" placeholder="Name">
407
- </div>
444
+ <div class="form-row">
445
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
446
+ <input type="text" id="node-input-name" placeholder="Name">
447
+ </div>
408
448
 
409
- <div class="form-row">
410
- <label for="node-input-assetId"><i class="fa fa-tag"></i> Asset Id</label>
411
- <input type="text" id="node-input-assetId" placeholder="Leave null and will use msg.topic or msg.payload.assetId">
412
- </div>
449
+ <div class="form-row">
450
+ <label for="node-input-assetId"><i class="fa fa-tag"></i>Asset</label>
451
+ <select id="node-input-assetId" placeholder="Leave null and will use msg.topic or msg.payload.assetId">
452
+ <option></option>
453
+ </select>
454
+ </div>
413
455
 
414
- <div class="form-row">
415
- <label for="node-input-processVariableId"><i class="fa fa-tag"></i> Event Type Id</label>
416
- <input type="text" id="node-input-eventTypeId" placeholder="Leave null and will use msg.payload.eventTypeId">
417
- </div>
456
+ <div class="form-row">
457
+ <label for="node-input-processVariableId"><i class="fa fa-tag"></i> Event Type</label>
458
+ <select id="node-input-eventTypeId" placeholder="Leave null and will use msg.payload.eventTypeId">
459
+ <option></option>
460
+ </select>
461
+ </div>
418
462
 
419
463
 
420
464
  </script>
@@ -446,57 +490,78 @@
446
490
  },
447
491
  labelStyle: function () {
448
492
  return this.name ? "node_label_italic" : "";
493
+ }, oneditprepare: function () {
494
+ const self = this;
495
+
496
+ function prepareForm() {
497
+ populateDropdown(self.device, 'node-input-assetId', 'assets', self.assetId);
498
+ populateDropdown(self.device, 'node-input-eventTypeId', 'event-types', self.eventTypeId);
499
+ }
500
+
501
+ console.log('oneditprepare')
502
+ $('#node-input-device').change(function () {
503
+ // handle change event here
504
+ prepareForm();
505
+ });
506
+ setTimeout(() => {
507
+ if (!$('#node-input-device').val()) {
508
+ return
509
+ }
510
+ prepareForm();
511
+ }, 100)
512
+
449
513
  }
450
514
  });
451
- </script>
452
-
453
515
 
516
+ </script>
454
517
 
455
518
 
456
519
  <script type="text/x-red" data-help-name="tillit-progress">
457
- <p>Publishes <b>msg.payload</b> to update the asset progress</p>
458
- <code>
459
- [{
460
- assetId: number,
461
- orderId: number, //Is optional, if not supplied then the current running order is used.
462
- timestamp: string,
463
- totalCount: number,
464
- rejectCount: number,
465
- EQUIPMENT_STATUS_READY: boolean,
466
- EQUIPMENT_STATUS_RUNNING: boolean,
467
- EQUIPMENT_STATUS_STOPPED: boolean,
468
- EQUIPMENT_STATUS_COMPLETE: boolean,
469
- EQUIPMENT_STATUS_SUSPENDED: boolean,
470
- EQUIPMENT_STATUS_ABORTED: boolean,
471
- EQUIPMENT_STATUS_STARVED: boolean,
472
- EQUIPMENT_STATUS_BLOCKED: boolean,
473
- EQUIPMENT_STATUS_FAULTED: boolean,
474
- downtimeReason: string,
475
- reasonGroupId: number
476
- }]
477
- </code>
478
- <p>msg.topic will be used as assetId if you leave the configuration blank</p>
479
- <p>For more information visit our help documentation: <a href="https://help.tillit.cloud/tillit/knowledge-base/setting-up-tillit/connecting-to-tillit/mqtt/publish-timeseries" target="blank">Open</a>
520
+ <p>Publishes <b>msg.payload</b> to update the asset progress</p>
521
+ <code>
522
+ [{
523
+ assetId: number,
524
+ orderId: number, //Is optional, if not supplied then the current running order is used.
525
+ timestamp: string,
526
+ totalCount: number,
527
+ rejectCount: number,
528
+ EQUIPMENT_STATUS_READY: boolean,
529
+ EQUIPMENT_STATUS_RUNNING: boolean,
530
+ EQUIPMENT_STATUS_STOPPED: boolean,
531
+ EQUIPMENT_STATUS_COMPLETE: boolean,
532
+ EQUIPMENT_STATUS_SUSPENDED: boolean,
533
+ EQUIPMENT_STATUS_ABORTED: boolean,
534
+ EQUIPMENT_STATUS_STARVED: boolean,
535
+ EQUIPMENT_STATUS_BLOCKED: boolean,
536
+ EQUIPMENT_STATUS_FAULTED: boolean,
537
+ downtimeReason: string,
538
+ reasonGroupId: number
539
+ }]
540
+ </code>
541
+ <p>msg.topic will be used as assetId if you leave the configuration blank</p>
542
+ <p>For more information visit our help documentation: <a href="https://help.tillit.cloud/tillit/knowledge-base/setting-up-tillit/connecting-to-tillit/mqtt/publish-timeseries" target="blank">Open</a>
480
543
 
481
544
  </script>
482
545
 
483
546
 
484
547
  <script type="text/x-red" data-template-name="tillit-progress">
485
- <div class="form-row">
486
- <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
487
- <input type="text" id="node-input-device">
488
- </div>
548
+ <div class="form-row">
549
+ <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
550
+ <input type="text" id="node-input-device">
551
+ </div>
489
552
 
490
553
 
491
- <div class="form-row">
492
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
493
- <input type="text" id="node-input-name" placeholder="Name">
494
- </div>
554
+ <div class="form-row">
555
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
556
+ <input type="text" id="node-input-name" placeholder="Name">
557
+ </div>
495
558
 
496
- <div class="form-row">
497
- <label for="node-input-assetId"><i class="fa fa-tag"></i> Asset Id</label>
498
- <input type="text" id="node-input-assetId" placeholder="will use msg.topic if blank">
499
- </div>
559
+ <div class="form-row">
560
+ <label for="node-input-assetId"><i class="fa fa-tag"></i> Asset</label>
561
+ <select id="node-input-assetId" placeholder="will use msg.topic if blank">
562
+ <option></option>
563
+ </select>
564
+ </div>
500
565
 
501
566
  </script>
502
567
 
@@ -525,6 +590,25 @@
525
590
  },
526
591
  labelStyle: function () {
527
592
  return this.name ? "node_label_italic" : "";
593
+ }, oneditprepare: function () {
594
+ const self = this;
595
+
596
+ function prepareForm() {
597
+ populateDropdown(self.device, 'node-input-assetId', 'assets', self.assetId);
598
+ }
599
+
600
+ console.log('oneditprepare')
601
+ $('#node-input-device').change(function () {
602
+ // handle change event here
603
+ prepareForm();
604
+ });
605
+ setTimeout(() => {
606
+ if (!$('#node-input-device').val()) {
607
+ return
608
+ }
609
+ prepareForm();
610
+ }, 100)
611
+
528
612
  }
529
613
  });
530
614
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gotillit/tillit-node-red",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "A TilliT node for Node-RED",
5
5
  "main": "./dist/index.js",
6
6
  "dependencies": {