@gotillit/tillit-node-red 1.2.3 → 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.
@@ -0,0 +1 @@
1
+ export declare const buildRoutes: (RED: any) => void;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.buildRoutes = void 0;
43
+ var utils_1 = require("../shared/utils");
44
+ var got_1 = __importDefault(require("got"));
45
+ var buildRoutes = function (RED) {
46
+ var apiRoot = "/tillit";
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 () {
49
+ var conn, entity, broker, environment, tenant, username, password, ops, url, response;
50
+ return __generator(this, function (_a) {
51
+ switch (_a.label) {
52
+ case 0:
53
+ conn = req.params.conn;
54
+ entity = req.params.entity;
55
+ broker = RED.nodes.getNode(conn).broker;
56
+ environment = broker.environment, tenant = broker.tenant, username = broker.username, password = broker.password;
57
+ ops = {
58
+ method: 'GET',
59
+ username: username,
60
+ password: password
61
+ };
62
+ url = (0, utils_1.hostname)(environment, tenant) + "/api/core/".concat(entity, "?size=2000");
63
+ return [4 /*yield*/, (0, got_1.default)(url, ops)];
64
+ case 1:
65
+ response = _a.sent();
66
+ res.json(response.body);
67
+ return [2 /*return*/];
68
+ }
69
+ });
70
+ }); });
71
+ };
72
+ exports.buildRoutes = buildRoutes;
73
+ //# sourceMappingURL=node-routes.js.map
@@ -0,0 +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;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"}
@@ -0,0 +1 @@
1
+ export declare const buildPlugin: (RED: any) => void;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildPlugin = void 0;
4
+ var apiRoot = "/tillit";
5
+ var buildPlugin = function (RED) {
6
+ console.log('Registring plugin js');
7
+ RED.plugins.registerPlugin("node-red-tillit", {
8
+ settings: undefined,
9
+ type: '',
10
+ onadd: function () {
11
+ debugger;
12
+ RED.httpAdmin.get("".concat(apiRoot, "/event-types"), function (_, res) {
13
+ res.json([{ 'id': 1 }]);
14
+ });
15
+ }
16
+ });
17
+ };
18
+ exports.buildPlugin = buildPlugin;
19
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/nodes/plugin.ts"],"names":[],"mappings":";;;AAAA,IAAM,OAAO,GAAG,SAAS,CAAC;AAEnB,IAAM,WAAW,GAAG,UAAC,GAAQ;IAChC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;IACnC,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,iBAAiB,EAAE;QAC1C,QAAQ,EAAE,SAAS;QACnB,IAAI,EAAE,EAAE;QACR,KAAK,EAAE;YACH,QAAQ,CAAA;YACR,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,UAAG,OAAO,iBAAc,EAAE,UAAC,CAAM,EAAE,GAAQ;gBACzD,GAAG,CAAC,IAAI,CAAC,CAAC,EAAC,IAAI,EAAE,CAAC,EAAC,CAAC,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;QACP,CAAC;KACJ,CAAC,CAAA;AACN,CAAC,CAAC;AAZW,QAAA,WAAW,eAYtB"}
@@ -1,54 +1,82 @@
1
+ <script type="text/javascript">
2
+
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
+
28
+ </script>
1
29
 
2
30
  <script type="text/x-red" data-template-name="tillit-node-connection">
3
- <div class="form-row">
4
- <label for="node-config-input-name"><i class="fa fa-globe"></i>Name</label>
5
- <input type="text" id="node-config-input-name" placeholder="Name">
6
- </div>
7
- <div class="form-row">
8
- <label for="node-config-input-thingId"><i class="fa fa-tag"></i> Thing ID</label>
9
- <input type="text" id="node-config-input-thingId" placeholder="Thing ID">
10
- </div>
11
- <div class="form-row">
12
- <label for="node-config-input-environment"><i class="fa fa-tag"></i> Environment</label>
13
- <input type="text" id="node-config-input-environment" placeholder="TilliT Environment">
14
- </div>
15
- <div class="form-row">
16
- <label for="node-config-input-endpoint"><i class="fa fa-tag"></i> Tenant</label>
17
- <input type="text" id="node-config-input-tenant" placeholder="Tenant name">
18
- </div>
19
- <div class="form-row">
20
- <label for="node-config-input-privKey"><i class="fa fa-tag"></i> Private key</label>
21
- <input type="text" id="node-config-input-privKey"></input>
22
- </div>
23
-
24
- <div class="form-row">
25
- <label for="node-config-input-thingCert"><i class="fa fa-tag"></i> Thing cert</label>
26
- <input type="text" id="node-config-input-thingCert"></input>
27
- </div>
28
-
29
- <div class="form-row">
30
- <label for="node-config-input-rootCa"><i class="fa fa-tag"></i> Root CA</label>
31
- <input type="text" id="node-config-input-rootCa"></input>
32
- </div>
33
-
34
-
35
- <div class="form-row">
36
- <label for="node-config-input-username"><i class="fa fa-tag"></i> Username</label>
37
- <input type="text" id="node-config-input-username"></input>
38
- </div>
39
-
40
- <div class="form-row">
41
- <label for="node-config-input-password"><i class="fa fa-tag"></i> Password</label>
42
- <input type="password" id="node-config-input-password"></input>
43
- </div>
44
-
45
- <div class="form-tips">
46
- <p><b>Secret:</b> Using environment variables:</p>
47
- <p>
48
- You can override any of these settings using environment variables. Recommended for production deployment.
49
- Use: USERNAME, PASSWORD, TENANT, ENVIRONMENT, THING_CERT, PRIV_KEY, ROOT_CA
50
- </p>
51
- </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>
52
80
  </script>
53
81
 
54
82
  <!-- MQTT Broker Configuration -->
@@ -96,32 +124,32 @@
96
124
  </script>
97
125
 
98
126
  <script type="text/x-red" data-template-name="tillit-out">
99
- <div class="form-row">
100
- <label for="node-input-name"><i class="fa fa-globe"></i> Name</label>
101
- <input type="text" id="node-input-name">
102
- </div>
103
- <div class="form-row">
104
- <label for="node-input-device"><i class="fa fa-globe"></i> Connection</label>
105
- <input type="text" id="node-input-device">
106
- </div>
107
- <div class="form-row">
108
- <label for="node-input-topic"><i class="fa fa-globe"></i> Topic</label>
109
- <input type="text" id="node-input-topic">
110
- </div>
111
- <div class="form-row">
112
- <label for="node-input-qos"><i class="fa fa-empire"></i> <span> QoS</span></label>
113
- <select id="node-input-qos" style="width:125px !important">
114
- <option value="0">0</option>
115
- <option value="1">1</option>
116
- </select>
117
- </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>
118
146
  </script>
119
147
 
120
148
  <script type="text/x-red" data-help-name="tillit-out">
121
- <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>
122
- <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>
123
- <p>If <b>msg.payload</b> contains an object it will be stringified before being sent.</p>
124
- <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>
125
153
  </script>
126
154
 
127
155
  <script type="text/javascript">
@@ -160,27 +188,27 @@
160
188
  </script>
161
189
 
162
190
  <script type="text/x-red" data-template-name="tillit-in">
163
- <div class="form-row">
164
- <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
165
- <input type="text" id="node-input-device">
166
- </div>
167
-
168
- <div class="form-row">
169
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
170
- <input type="text" id="node-input-name" placeholder="Name">
171
- </div>
172
- <div class="form-row">
173
- <label for="node-input-topic"><i class="fa fa-tag"></i> Topic</label>
174
- <input type="text" id="node-input-topic" placeholder="Topic">
175
- </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>
176
204
  </script>
177
205
 
178
206
  <script type="text/x-red" data-help-name="tillit-in">
179
- <p>TillliT MQTT input node. Connects to a broker and subscribes to the specified topic. The topic may contain MQTT wildcards.</p>
180
- <p>Topic needs to start with your tenant. To subscribe to all messages from your account, do {tenant}/#</p>
181
- <p>Outputs an object called <b>msg</b> containing <b>msg.topic, msg.payload, msg.qos</b> and <b>msg.retain</b>.</p>
182
- <p><b>msg.payload</b> is usually a string, but can also be a binary buffer.</p>
183
- <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>
184
212
  </script>
185
213
 
186
214
  <script type="text/javascript">
@@ -215,41 +243,39 @@
215
243
  </script>
216
244
 
217
245
 
218
-
219
-
220
246
  <script type="text/x-red" data-template-name="tillit-api">
221
- <div class="form-row">
222
- <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
223
- <input type="text" id="node-input-device">
224
- </div>
225
-
226
- <div class="form-row">
227
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
228
- <input type="text" id="node-input-name" placeholder="Name">
229
- </div>
230
- <div class="form-row">
231
- <label for="node-input-endpoint"><i class="fa fa-tag"></i> Endpoint</label>
232
- <input type="text" id="node-input-endpoint" placeholder="Endpoint">
233
- </div>
234
- <div class="form-row">
235
- <label for="node-input-method"><i class="fa fa-empire"></i> <span> Method</span></label>
236
- <select id="node-input-method" style="width:125px !important">
237
- <option value="GET">GET</option>
238
- <option value="POST">POST</option>
239
- <option value="PUT">PUT</option>
240
- <option value="DELETE">DELETE</option>
241
- </select>
242
- </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>
243
269
  </script>
244
270
 
245
271
  <script type="text/x-red" data-help-name="tillit-api">
246
- <p>An easy way for you to use the TilliT API from Node-red</p>
247
- <p>Set your endpoint and method here.</p>
248
- <p>Endpoint can be substituted by msg.endpoint</p>
249
- <p><b>msg.payload</b> is expected to be a json and will be the body on POST and PUT calls</p>
250
- <p><b>output 1</b> is the return of the call in case of success</p>
251
- <p><b>output 2</b> is the error body in case of failure</p>
252
- <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>
253
279
  </script>
254
280
 
255
281
  <script type="text/javascript">
@@ -288,42 +314,46 @@
288
314
 
289
315
 
290
316
  <script type="text/x-red" data-help-name="tillit-pv">
291
- <p>Publishes <b>msg.payload</b> to update the value of a process variable</p>
292
- <p>msg.payload will be used as the value, respecting the data type selected</p>
293
- <p>msg.topic will be used as assetId if you leave the configuration blank</p>
294
- <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>
295
321
 
296
322
  </script>
297
323
 
298
324
 
299
325
  <script type="text/x-red" data-template-name="tillit-pv">
300
- <div class="form-row">
301
- <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
302
- <input type="text" id="node-input-device">
303
- </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>
304
330
 
305
- <div class="form-row">
306
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
307
- <input type="text" id="node-input-name" placeholder="Name">
308
- </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>
309
335
 
310
- <div class="form-row">
311
- <label for="node-input-assetId"><i class="fa fa-tag"></i> Asset Id</label>
312
- <input type="text" id="node-input-assetId" placeholder="will use msg.topic if blank">
313
- </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>
314
342
 
315
- <div class="form-row">
316
- <label for="node-input-processVariableId"><i class="fa fa-tag"></i> Process Variable Id</label>
317
- <input type="text" id="node-input-processVariableId" placeholder="">
318
- </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>
319
349
 
320
- <div class="form-row">
321
- <label for="node-input-dataType"><i class="fa fa-tag"></i>Data Type</label>
322
- <select id="node-input-dataType" style="width:125px !important">
323
- <option value="number">NUMBER</option>
324
- <option value="string">STRING</option>
325
- <option value="boolean">BOOLEAN</option>
326
- </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>
327
357
  </div>
328
358
 
329
359
 
@@ -358,55 +388,77 @@
358
388
  },
359
389
  labelStyle: function () {
360
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
+
361
411
  }
362
412
  });
363
413
  </script>
364
414
 
365
415
 
366
-
367
-
368
416
  <script type="text/x-red" data-help-name="tillit-event">
369
- <p>Publishes <b>msg.payload</b> to raise an event</p>
370
- <p>msg.topic can be used as assetId if you leave the node blank</p>
371
- <p>msg.payload should be like the following example:</p>
372
- <code>
373
- {
374
- assetId: number, //ID of the asset
375
- timestamp: string, //Timestamp of the event
376
- eventTypeId: number, //ID of the event to raise
377
- orderId: number //The id of the order to raise event on (Optional)
378
- orderNumber: string //The order number of the order to raise event on (Optional)
379
- status: string //ACTIVE | SCHEDULED | COMPLETED (Optional)
380
- 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)
381
429
  }
382
- </code>
383
- This node will merge the settings from the node with the payload.
384
- <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>
385
433
 
386
434
  </script>
387
435
 
388
436
 
389
437
  <script type="text/x-red" data-template-name="tillit-event">
390
- <div class="form-row">
391
- <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
392
- <input type="text" id="node-input-device">
393
- </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>
394
442
 
395
443
 
396
- <div class="form-row">
397
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
398
- <input type="text" id="node-input-name" placeholder="Name">
399
- </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>
400
448
 
401
- <div class="form-row">
402
- <label for="node-input-assetId"><i class="fa fa-tag"></i> Asset Id</label>
403
- <input type="text" id="node-input-assetId" placeholder="Leave null and will use msg.topic or msg.payload.assetId">
404
- </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>
405
455
 
406
- <div class="form-row">
407
- <label for="node-input-processVariableId"><i class="fa fa-tag"></i> Event Type Id</label>
408
- <input type="text" id="node-input-eventTypeId" placeholder="Leave null and will use msg.payload.eventTypeId">
409
- </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>
410
462
 
411
463
 
412
464
  </script>
@@ -438,57 +490,78 @@
438
490
  },
439
491
  labelStyle: function () {
440
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
+
441
513
  }
442
514
  });
443
- </script>
444
-
445
515
 
516
+ </script>
446
517
 
447
518
 
448
519
  <script type="text/x-red" data-help-name="tillit-progress">
449
- <p>Publishes <b>msg.payload</b> to update the asset progress</p>
450
- <code>
451
- [{
452
- assetId: number,
453
- orderId: number, //Is optional, if not supplied then the current running order is used.
454
- timestamp: string,
455
- totalCount: number,
456
- rejectCount: number,
457
- EQUIPMENT_STATUS_READY: boolean,
458
- EQUIPMENT_STATUS_RUNNING: boolean,
459
- EQUIPMENT_STATUS_STOPPED: boolean,
460
- EQUIPMENT_STATUS_COMPLETE: boolean,
461
- EQUIPMENT_STATUS_SUSPENDED: boolean,
462
- EQUIPMENT_STATUS_ABORTED: boolean,
463
- EQUIPMENT_STATUS_STARVED: boolean,
464
- EQUIPMENT_STATUS_BLOCKED: boolean,
465
- EQUIPMENT_STATUS_FAULTED: boolean,
466
- downtimeReason: string,
467
- reasonGroupId: number
468
- }]
469
- </code>
470
- <p>msg.topic will be used as assetId if you leave the configuration blank</p>
471
- <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>
472
543
 
473
544
  </script>
474
545
 
475
546
 
476
547
  <script type="text/x-red" data-template-name="tillit-progress">
477
- <div class="form-row">
478
- <label for="node-input-device"><i class="fa fa-device"></i> Connection</label>
479
- <input type="text" id="node-input-device">
480
- </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>
481
552
 
482
553
 
483
- <div class="form-row">
484
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
485
- <input type="text" id="node-input-name" placeholder="Name">
486
- </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>
487
558
 
488
- <div class="form-row">
489
- <label for="node-input-assetId"><i class="fa fa-tag"></i> Asset Id</label>
490
- <input type="text" id="node-input-assetId" placeholder="will use msg.topic if blank">
491
- </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>
492
565
 
493
566
  </script>
494
567
 
@@ -517,6 +590,25 @@
517
590
  },
518
591
  labelStyle: function () {
519
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
+
520
612
  }
521
613
  });
522
614
  </script>
@@ -7,6 +7,7 @@ var node_broker_1 = require("./nodes/node-broker");
7
7
  var node_pv_1 = require("./nodes/node-pv");
8
8
  var node_event_1 = require("./nodes/node-event");
9
9
  var node_progress_1 = require("./nodes/node-progress");
10
+ var node_routes_1 = require("./nodes/node-routes");
10
11
  module.exports = function (RED) {
11
12
  RED.nodes.registerType("tillit-node-connection", (0, node_broker_1.buildNodeBrokerFunction)(RED));
12
13
  RED.nodes.registerType("tillit-api", (0, node_api_1.buildApiFunction)(RED));
@@ -15,5 +16,6 @@ module.exports = function (RED) {
15
16
  RED.nodes.registerType("tillit-progress", (0, node_progress_1.buildNodeProgressFunction)(RED));
16
17
  RED.nodes.registerType("tillit-in", (0, node_in_1.buildNodeInFunction)(RED));
17
18
  RED.nodes.registerType("tillit-event", (0, node_event_1.buildEventFunction)(RED));
19
+ (0, node_routes_1.buildRoutes)(RED);
18
20
  };
19
21
  //# sourceMappingURL=tillit-node.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tillit-node.js","sourceRoot":"","sources":["../src/tillit-node.ts"],"names":[],"mappings":";;AAAA,6CAAkD;AAClD,6CAAsD;AACtD,2CAAoD;AACpD,mDAA4D;AAC5D,2CAAoD;AACpD,iDAAsD;AACtD,uDAAgE;AAEhE,MAAM,CAAC,OAAO,GAAG,UAAU,GAAQ;IAG/B,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,wBAAwB,EAAE,IAAA,qCAAuB,EAAC,GAAG,CAAC,CAAC,CAAC;IAC/E,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,IAAA,2BAAgB,EAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,IAAA,+BAAoB,EAAC,GAAG,CAAC,CAAC,CAAC;IAChE,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE,IAAA,6BAAmB,EAAC,GAAG,CAAC,CAAC,CAAC;IAC9D,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,iBAAiB,EAAE,IAAA,yCAAyB,EAAC,GAAG,CAAC,CAAC,CAAC;IAC1E,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE,IAAA,6BAAmB,EAAC,GAAG,CAAC,CAAC,CAAC;IAC9D,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,cAAc,EAAE,IAAA,+BAAkB,EAAC,GAAG,CAAC,CAAC,CAAC;AAGpE,CAAC,CAAC"}
1
+ {"version":3,"file":"tillit-node.js","sourceRoot":"","sources":["../src/tillit-node.ts"],"names":[],"mappings":";;AAAA,6CAAkD;AAClD,6CAAsD;AACtD,2CAAoD;AACpD,mDAA4D;AAC5D,2CAAoD;AACpD,iDAAsD;AACtD,uDAAgE;AAChE,mDAAgD;AAEhD,MAAM,CAAC,OAAO,GAAG,UAAU,GAAQ;IAI/B,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,wBAAwB,EAAE,IAAA,qCAAuB,EAAC,GAAG,CAAC,CAAC,CAAC;IAC/E,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,IAAA,2BAAgB,EAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,IAAA,+BAAoB,EAAC,GAAG,CAAC,CAAC,CAAC;IAChE,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE,IAAA,6BAAmB,EAAC,GAAG,CAAC,CAAC,CAAC;IAC9D,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,iBAAiB,EAAE,IAAA,yCAAyB,EAAC,GAAG,CAAC,CAAC,CAAC;IAC1E,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE,IAAA,6BAAmB,EAAC,GAAG,CAAC,CAAC,CAAC;IAC9D,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,cAAc,EAAE,IAAA,+BAAkB,EAAC,GAAG,CAAC,CAAC,CAAC;IAEhE,IAAA,yBAAW,EAAC,GAAG,CAAC,CAAC;AAErB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gotillit/tillit-node-red",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "A TilliT node for Node-RED",
5
5
  "main": "./dist/index.js",
6
6
  "dependencies": {