@gotillit/tillit-node-red 1.2.41 → 1.2.52

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