@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.
- package/dist/nodes/node-routes.d.ts +1 -0
- package/dist/nodes/node-routes.js +73 -0
- package/dist/nodes/node-routes.js.map +1 -0
- package/dist/nodes/plugin.d.ts +1 -0
- package/dist/nodes/plugin.js +19 -0
- package/dist/nodes/plugin.js.map +1 -0
- package/dist/tillit-node.html +310 -218
- package/dist/tillit-node.js +2 -0
- package/dist/tillit-node.js.map +1 -1
- package/package.json +1 -1
|
@@ -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"}
|
package/dist/tillit-node.html
CHANGED
|
@@ -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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
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
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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
|
-
|
|
383
|
-
|
|
384
|
-
|
|
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
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
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
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
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
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
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
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
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
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
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
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
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
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
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>
|
package/dist/tillit-node.js
CHANGED
|
@@ -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
|
package/dist/tillit-node.js.map
CHANGED
|
@@ -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;
|
|
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"}
|