@gotillit/tillit-node-red 1.2.41 → 1.2.51

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.
Files changed (2) hide show
  1. package/dist/tillit-node.html +308 -223
  2. package/package.json +1 -1
@@ -1,62 +1,83 @@
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
+ $.ajax({
7
+ url: `/tillit/${deviceId}/${entity}`,
8
+ type: "GET",
9
+ success: function (data) {
10
+ console.log(data)
11
+ const items = JSON.parse(data);
12
+ console.log(selectedId)
13
+ items.sort((a, b) => a.name < b.name ? -1 : 1).forEach(function (item) {
14
+ const option = document.createElement('option');
15
+ option.value = item.id;
16
+ option.text = item.name;
17
+ option.selected = item.id == selectedId
18
+ console.log(option.selected)
19
+ domElement.appendChild(option);
20
+ });
21
+ },
22
+ error: function (jqXHR, textStatus, errorThrown) {
23
+ console.log(jqXHR, textStatus, errorThrown);
24
+ }
25
+ });
26
+ }
27
+
28
+
8
29
  </script>
9
30
 
10
31
  <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>
32
+ <div class="form-row">
33
+ <label for="node-config-input-name"><i class="fa fa-globe"></i>Name</label>
34
+ <input type="text" id="node-config-input-name" placeholder="Name">
35
+ </div>
36
+ <div class="form-row">
37
+ <label for="node-config-input-thingId"><i class="fa fa-tag"></i> Thing ID</label>
38
+ <input type="text" id="node-config-input-thingId" placeholder="Thing ID">
39
+ </div>
40
+ <div class="form-row">
41
+ <label for="node-config-input-environment"><i class="fa fa-tag"></i> Environment</label>
42
+ <input type="text" id="node-config-input-environment" placeholder="TilliT Environment">
43
+ </div>
44
+ <div class="form-row">
45
+ <label for="node-config-input-endpoint"><i class="fa fa-tag"></i> Tenant</label>
46
+ <input type="text" id="node-config-input-tenant" placeholder="Tenant name">
47
+ </div>
48
+ <div class="form-row">
49
+ <label for="node-config-input-privKey"><i class="fa fa-tag"></i> Private key</label>
50
+ <input type="text" id="node-config-input-privKey"></input>
51
+ </div>
52
+
53
+ <div class="form-row">
54
+ <label for="node-config-input-thingCert"><i class="fa fa-tag"></i> Thing cert</label>
55
+ <input type="text" id="node-config-input-thingCert"></input>
56
+ </div>
57
+
58
+ <div class="form-row">
59
+ <label for="node-config-input-rootCa"><i class="fa fa-tag"></i> Root CA</label>
60
+ <input type="text" id="node-config-input-rootCa"></input>
61
+ </div>
62
+
63
+
64
+ <div class="form-row">
65
+ <label for="node-config-input-username"><i class="fa fa-tag"></i> Username</label>
66
+ <input type="text" id="node-config-input-username"></input>
67
+ </div>
68
+
69
+ <div class="form-row">
70
+ <label for="node-config-input-password"><i class="fa fa-tag"></i> Password</label>
71
+ <input type="password" id="node-config-input-password"></input>
72
+ </div>
73
+
74
+ <div class="form-tips">
75
+ <p><b>Secret:</b> Using environment variables:</p>
76
+ <p>
77
+ You can override any of these settings using environment variables. Recommended for production deployment.
78
+ Use: USERNAME, PASSWORD, TENANT, ENVIRONMENT, THING_CERT, PRIV_KEY, ROOT_CA
79
+ </p>
80
+ </div>
60
81
  </script>
61
82
 
62
83
  <!-- MQTT Broker Configuration -->
@@ -104,32 +125,32 @@
104
125
  </script>
105
126
 
106
127
  <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>
128
+ <div class="form-row">
129
+ <label for="node-input-name"><i class="fa fa-globe"></i> Name</label>
130
+ <input type="text" id="node-input-name">
131
+ </div>
132
+ <div class="form-row">
133
+ <label for="node-input-device"><i class="fa fa-globe"></i> Connection</label>
134
+ <input type="text" id="node-input-device">
135
+ </div>
136
+ <div class="form-row">
137
+ <label for="node-input-topic"><i class="fa fa-globe"></i> Topic</label>
138
+ <input type="text" id="node-input-topic">
139
+ </div>
140
+ <div class="form-row">
141
+ <label for="node-input-qos"><i class="fa fa-empire"></i> <span> QoS</span></label>
142
+ <select id="node-input-qos" style="width:125px !important">
143
+ <option value="0">0</option>
144
+ <option value="1">1</option>
145
+ </select>
146
+ </div>
126
147
  </script>
127
148
 
128
149
  <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>
150
+ <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>
151
+ <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>
152
+ <p>If <b>msg.payload</b> contains an object it will be stringified before being sent.</p>
153
+ <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
154
  </script>
134
155
 
135
156
  <script type="text/javascript">
@@ -168,27 +189,27 @@
168
189
  </script>
169
190
 
170
191
  <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>
192
+ <div class="form-row">
193
+ <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
194
+ <input type="text" id="node-input-device">
195
+ </div>
196
+
197
+ <div class="form-row">
198
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
199
+ <input type="text" id="node-input-name" placeholder="Name">
200
+ </div>
201
+ <div class="form-row">
202
+ <label for="node-input-topic"><i class="fa fa-tag"></i> Topic</label>
203
+ <input type="text" id="node-input-topic" placeholder="Topic">
204
+ </div>
184
205
  </script>
185
206
 
186
207
  <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>
208
+ <p>TillliT MQTT input node. Connects to a broker and subscribes to the specified topic. The topic may contain MQTT wildcards.</p>
209
+ <p>Topic needs to start with your tenant. To subscribe to all messages from your account, do {tenant}/#</p>
210
+ <p>Outputs an object called <b>msg</b> containing <b>msg.topic, msg.payload, msg.qos</b> and <b>msg.retain</b>.</p>
211
+ <p><b>msg.payload</b> is usually a string, but can also be a binary buffer.</p>
212
+ <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
213
  </script>
193
214
 
194
215
  <script type="text/javascript">
@@ -223,41 +244,39 @@
223
244
  </script>
224
245
 
225
246
 
226
-
227
-
228
247
  <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>
248
+ <div class="form-row">
249
+ <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
250
+ <input type="text" id="node-input-device">
251
+ </div>
252
+
253
+ <div class="form-row">
254
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
255
+ <input type="text" id="node-input-name" placeholder="Name">
256
+ </div>
257
+ <div class="form-row">
258
+ <label for="node-input-endpoint"><i class="fa fa-tag"></i> Endpoint</label>
259
+ <input type="text" id="node-input-endpoint" placeholder="Endpoint">
260
+ </div>
261
+ <div class="form-row">
262
+ <label for="node-input-method"><i class="fa fa-empire"></i> <span> Method</span></label>
263
+ <select id="node-input-method" style="width:125px !important">
264
+ <option value="GET">GET</option>
265
+ <option value="POST">POST</option>
266
+ <option value="PUT">PUT</option>
267
+ <option value="DELETE">DELETE</option>
268
+ </select>
269
+ </div>
251
270
  </script>
252
271
 
253
272
  <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>
273
+ <p>An easy way for you to use the TilliT API from Node-red</p>
274
+ <p>Set your endpoint and method here.</p>
275
+ <p>Endpoint can be substituted by msg.endpoint</p>
276
+ <p><b>msg.payload</b> is expected to be a json and will be the body on POST and PUT calls</p>
277
+ <p><b>output 1</b> is the return of the call in case of success</p>
278
+ <p><b>output 2</b> is the error body in case of failure</p>
279
+ <p>For more information visit our help documentation: <a href="https://help.tillit.cloud/api/api/overview" target="blank">Open</a>
261
280
  </script>
262
281
 
263
282
  <script type="text/javascript">
@@ -296,42 +315,46 @@
296
315
 
297
316
 
298
317
  <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>
318
+ <p>Publishes <b>msg.payload</b> to update the value of a process variable</p>
319
+ <p>msg.payload will be used as the value, respecting the data type selected</p>
320
+ <p>msg.topic will be used as assetId if you leave the configuration blank</p>
321
+ <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
322
 
304
323
  </script>
305
324
 
306
325
 
307
326
  <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>
327
+ <div class="form-row">
328
+ <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
329
+ <input type="text" id="node-input-device">
330
+ </div>
312
331
 
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>
332
+ <div class="form-row">
333
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
334
+ <input type="text" id="node-input-name" placeholder="Name">
335
+ </div>
317
336
 
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>
337
+ <div class="form-row">
338
+ <label for="node-input-assetId"><i class="fa fa-tag"></i> Asset </label>
339
+ <select id="node-input-assetId" placeholder="will use msg.topic if blank">
340
+ <option></option>
341
+ </select>
342
+ </div>
322
343
 
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>
344
+ <div class="form-row">
345
+ <label for="node-input-processVariableId"><i class="fa fa-tag"></i> Process Variable </label>
346
+ <select id="node-input-processVariableId" placeholder="">
347
+ <option></option>
348
+ </select>
349
+ </div>
327
350
 
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>
351
+ <div class="form-row">
352
+ <label for="node-input-dataType"><i class="fa fa-tag"></i>Data Type</label>
353
+ <select id="node-input-dataType" style="width:125px !important">
354
+ <option value="number">NUMBER</option>
355
+ <option value="string">STRING</option>
356
+ <option value="boolean">BOOLEAN</option>
357
+ </select>
335
358
  </div>
336
359
 
337
360
 
@@ -366,55 +389,77 @@
366
389
  },
367
390
  labelStyle: function () {
368
391
  return this.name ? "node_label_italic" : "";
392
+ }, oneditprepare: function () {
393
+ const self = this;
394
+
395
+ function prepareForm() {
396
+ populateDropdown(self.device, 'node-input-assetId', 'assets', self.assetId);
397
+ populateDropdown(self.device, 'node-input-processVariableId', 'process-variables', self.assetId);
398
+ }
399
+
400
+ console.log('oneditprepare')
401
+ $('#node-input-device').change(function () {
402
+ // handle change event here
403
+ prepareForm();
404
+ });
405
+ setTimeout(() => {
406
+ if (!$('#node-input-device').val()) {
407
+ return
408
+ }
409
+ prepareForm();
410
+ }, 100)
411
+
369
412
  }
370
413
  });
371
414
  </script>
372
415
 
373
416
 
374
-
375
-
376
417
  <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)
418
+ <p>Publishes <b>msg.payload</b> to raise an event</p>
419
+ <p>msg.topic can be used as assetId if you leave the node blank</p>
420
+ <p>msg.payload should be like the following example:</p>
421
+ <code>
422
+ {
423
+ assetId: number, //ID of the asset
424
+ timestamp: string, //Timestamp of the event
425
+ eventTypeId: number, //ID of the event to raise
426
+ orderId: number //The id of the order to raise event on (Optional)
427
+ orderNumber: string //The order number of the order to raise event on (Optional)
428
+ status: string //ACTIVE | SCHEDULED | COMPLETED (Optional)
429
+ subtitle: string //Set a description for the event (Optional)
389
430
  }
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>
431
+ </code>
432
+ This node will merge the settings from the node with the payload.
433
+ <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
434
 
394
435
  </script>
395
436
 
396
437
 
397
438
  <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>
439
+ <div class="form-row">
440
+ <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
441
+ <input type="text" id="node-input-device">
442
+ </div>
402
443
 
403
444
 
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>
445
+ <div class="form-row">
446
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
447
+ <input type="text" id="node-input-name" placeholder="Name">
448
+ </div>
408
449
 
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>
450
+ <div class="form-row">
451
+ <label for="node-input-assetId"><i class="fa fa-tag"></i>Asset</label>
452
+ <select id="node-input-assetId" placeholder="Leave null and will use msg.topic or msg.payload.assetId">
453
+ <option></option>
454
+ </select>
455
+ </div>
413
456
 
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>
457
+ <div class="form-row">
458
+ <label for="node-input-processVariableId"><i class="fa fa-tag"></i> Event Type</label>
459
+ <select id="node-input-eventTypeId" placeholder="Leave null and will use msg.payload.eventTypeId">
460
+ <option></option>
461
+ </select>
462
+ </div>
418
463
 
419
464
 
420
465
  </script>
@@ -446,57 +491,78 @@
446
491
  },
447
492
  labelStyle: function () {
448
493
  return this.name ? "node_label_italic" : "";
494
+ }, oneditprepare: function () {
495
+ const self = this;
496
+
497
+ function prepareForm() {
498
+ populateDropdown(self.device, 'node-input-assetId', 'assets', self.assetId);
499
+ populateDropdown(self.device, 'node-input-eventTypeId', 'event-types', self.eventTypeId);
500
+ }
501
+
502
+ console.log('oneditprepare')
503
+ $('#node-input-device').change(function () {
504
+ // handle change event here
505
+ prepareForm();
506
+ });
507
+ setTimeout(() => {
508
+ if (!$('#node-input-device').val()) {
509
+ return
510
+ }
511
+ prepareForm();
512
+ }, 100)
513
+
449
514
  }
450
515
  });
451
- </script>
452
-
453
516
 
517
+ </script>
454
518
 
455
519
 
456
520
  <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>
521
+ <p>Publishes <b>msg.payload</b> to update the asset progress</p>
522
+ <code>
523
+ [{
524
+ assetId: number,
525
+ orderId: number, //Is optional, if not supplied then the current running order is used.
526
+ timestamp: string,
527
+ totalCount: number,
528
+ rejectCount: number,
529
+ EQUIPMENT_STATUS_READY: boolean,
530
+ EQUIPMENT_STATUS_RUNNING: boolean,
531
+ EQUIPMENT_STATUS_STOPPED: boolean,
532
+ EQUIPMENT_STATUS_COMPLETE: boolean,
533
+ EQUIPMENT_STATUS_SUSPENDED: boolean,
534
+ EQUIPMENT_STATUS_ABORTED: boolean,
535
+ EQUIPMENT_STATUS_STARVED: boolean,
536
+ EQUIPMENT_STATUS_BLOCKED: boolean,
537
+ EQUIPMENT_STATUS_FAULTED: boolean,
538
+ downtimeReason: string,
539
+ reasonGroupId: number
540
+ }]
541
+ </code>
542
+ <p>msg.topic will be used as assetId if you leave the configuration blank</p>
543
+ <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
544
 
481
545
  </script>
482
546
 
483
547
 
484
548
  <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>
549
+ <div class="form-row">
550
+ <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
551
+ <input type="text" id="node-input-device">
552
+ </div>
489
553
 
490
554
 
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>
555
+ <div class="form-row">
556
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
557
+ <input type="text" id="node-input-name" placeholder="Name">
558
+ </div>
495
559
 
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>
560
+ <div class="form-row">
561
+ <label for="node-input-assetId"><i class="fa fa-tag"></i> Asset</label>
562
+ <select id="node-input-assetId" placeholder="will use msg.topic if blank">
563
+ <option></option>
564
+ </select>
565
+ </div>
500
566
 
501
567
  </script>
502
568
 
@@ -525,6 +591,25 @@
525
591
  },
526
592
  labelStyle: function () {
527
593
  return this.name ? "node_label_italic" : "";
594
+ }, oneditprepare: function () {
595
+ const self = this;
596
+
597
+ function prepareForm() {
598
+ populateDropdown(self.device, 'node-input-assetId', 'assets', self.assetId);
599
+ }
600
+
601
+ console.log('oneditprepare')
602
+ $('#node-input-device').change(function () {
603
+ // handle change event here
604
+ prepareForm();
605
+ });
606
+ setTimeout(() => {
607
+ if (!$('#node-input-device').val()) {
608
+ return
609
+ }
610
+ prepareForm();
611
+ }, 100)
612
+
528
613
  }
529
614
  });
530
615
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gotillit/tillit-node-red",
3
- "version": "1.2.41",
3
+ "version": "1.2.51",
4
4
  "description": "A TilliT node for Node-RED",
5
5
  "main": "./dist/index.js",
6
6
  "dependencies": {