node-red-contrib-mobius-flow-base 2.5.86-beta.4 → 2.5.86-beta.40
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/mobius-connection.js +72 -0
- package/dist/nodes/mobius-discover-object-list.html +266 -6
- package/dist/nodes/mobius-get-multi-object.html +278 -7
- package/dist/nodes/mobius-get-object.html +270 -5
- package/dist/nodes/mobius-get-object.js +13 -10
- package/dist/nodes/mobius-object-cov.html +270 -5
- package/dist/nodes/mobius-object-cov.js +10 -7
- package/dist/nodes/node-red-ui-discover-devices.js +136 -6
- package/package.json +1 -1
|
@@ -520,6 +520,30 @@ module.exports = function (RED) {
|
|
|
520
520
|
node.updateObjectInServiceConfig = function (hid, sid, pid, ins, config, callback) {
|
|
521
521
|
node.service.srvcAPI.updateObjectInServiceConfig(hid, sid, pid, ins, config, callback);
|
|
522
522
|
};
|
|
523
|
+
|
|
524
|
+
node.getNodeConfig = function (hid) {
|
|
525
|
+
return new Promise((resolve, reject) => {
|
|
526
|
+
node.service.srvcAPI.getNodeConfig(hid, (err, response) => {
|
|
527
|
+
if (!err) {
|
|
528
|
+
resolve(response);
|
|
529
|
+
} else {
|
|
530
|
+
reject(err);
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
node.getServiceConfigProm = function (hid, sid) {
|
|
537
|
+
return new Promise((resolve, reject) => {
|
|
538
|
+
node.service.srvcAPI.getServiceConfig(hid, sid, (err, response) => {
|
|
539
|
+
if (!err) {
|
|
540
|
+
resolve(response);
|
|
541
|
+
} else {
|
|
542
|
+
reject(err);
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
});
|
|
546
|
+
};
|
|
523
547
|
}
|
|
524
548
|
|
|
525
549
|
RED.nodes.registerType('mobius connection', MobiusConnectionNode);
|
|
@@ -599,4 +623,52 @@ module.exports = function (RED) {
|
|
|
599
623
|
});
|
|
600
624
|
}
|
|
601
625
|
});
|
|
626
|
+
|
|
627
|
+
// Register the endpoint for node-red mobius discovery in node-red node config pages
|
|
628
|
+
RED.httpAdmin.get('/mgetservices', RED.auth.needsPermission('serial.read'), function (req, res) {
|
|
629
|
+
let conn = RED.nodes.getNode(req.query.mobius);
|
|
630
|
+
let hid = req.query.hid;
|
|
631
|
+
if (conn === null || !conn.service.connected) {
|
|
632
|
+
RED.log.error('Get services failed - could not to connect to MOBiUS hub.');
|
|
633
|
+
throw new Error('Get services failed - could not to connect to MOBiUS hub.');
|
|
634
|
+
} else {
|
|
635
|
+
uiDeviceDiscovery
|
|
636
|
+
.getServiceList(conn, hid)
|
|
637
|
+
.then((response) => {
|
|
638
|
+
res.json(response);
|
|
639
|
+
})
|
|
640
|
+
.catch((err) => {
|
|
641
|
+
RED.log.warn(`Get services failed - ${err}`);
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
RED.httpAdmin.get('/mgetobjects', RED.auth.needsPermission('serial.read'), function (req, res) {
|
|
647
|
+
let conn = RED.nodes.getNode(req.query.mobius);
|
|
648
|
+
let hid = req.query.hid;
|
|
649
|
+
let sid = req.query.sid;
|
|
650
|
+
if (conn === null || !conn.service.connected) {
|
|
651
|
+
RED.log.error('Get objects failed - could not to connect to MOBiUS hub.');
|
|
652
|
+
throw new Error('Get objects failed - could not to connect to MOBiUS hub.');
|
|
653
|
+
} else {
|
|
654
|
+
uiDeviceDiscovery
|
|
655
|
+
.getObjectList(conn, hid, sid)
|
|
656
|
+
.then((response) => {
|
|
657
|
+
res.json(response);
|
|
658
|
+
})
|
|
659
|
+
.catch((err) => {
|
|
660
|
+
RED.log.warn(`Get objects failed - ${err}`);
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
RED.httpAdmin.get('/mgethid', RED.auth.needsPermission('serial.read'), function (req, res) {
|
|
666
|
+
let conn = RED.nodes.getNode(req.query.mobius);
|
|
667
|
+
if (conn === null || !conn.service.connected) {
|
|
668
|
+
RED.log.error('Get hid failed - could not to connect to MOBiUS hub.');
|
|
669
|
+
throw new Error('Get hid failed - could not to connect to MOBiUS hub.');
|
|
670
|
+
} else {
|
|
671
|
+
res.json(conn.service.srvcAPI.status.hubId);
|
|
672
|
+
}
|
|
673
|
+
});
|
|
602
674
|
};
|
|
@@ -53,10 +53,29 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
53
53
|
<option value="array">Array of Items</option>
|
|
54
54
|
</select>
|
|
55
55
|
</div>
|
|
56
|
-
<div class="form-row node-input-subs-container-row">
|
|
56
|
+
<div id="node-input-subs-container-row" class="form-row node-input-subs-container-row">
|
|
57
57
|
<label for="node-input-subs-container" style="width:105px;float:left;"><i class="fa fa-bars"></i> Discover</label>
|
|
58
58
|
<ol id="node-input-subs-container"></ol>
|
|
59
59
|
</div>
|
|
60
|
+
|
|
61
|
+
<div id="instance-search-row">
|
|
62
|
+
<div class="form-row">
|
|
63
|
+
<label for="instance-search-sid"><i class="fa fa-search"></i> Search</label>
|
|
64
|
+
<input type="text" id="instance-search-hid" style="width:15%;" placeholder="HID">
|
|
65
|
+
<input type="text" id="instance-search-sid" style="width:10%;" placeholder="SID">
|
|
66
|
+
<input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
|
|
67
|
+
<input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
|
|
68
|
+
<a id="node-search-return" class="searchbutton" style="vertical-align: middle"><i id="node-search-return-icon" class="fa fa-arrow-left"></i></a>
|
|
69
|
+
<a id="node-search-accept" class="searchbutton" style="vertical-align: middle"><i id="node-search-accept-icon" class="fa fa-check"></i></a>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
<div id="wildcard-alert-row" class="form-row hidden" style="color:#555555" align="center">
|
|
73
|
+
<p>Please note: The selection of wildcard '+'
|
|
74
|
+
means a search for a specific instance or resource
|
|
75
|
+
cannot be performed. As such, enter the
|
|
76
|
+
INS manually.</p>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
60
79
|
<div class="form-row">
|
|
61
80
|
<label for="node-input-useRIDValueFiltering" style="width:178px;float:left;"><i class="fa fa-filter"></i> Filter by Resource Value</label>
|
|
62
81
|
<input type="checkbox" id="node-input-useRIDValueFiltering" style="display: inline-block; width: auto; vertical-align: top;">
|
|
@@ -119,6 +138,215 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
119
138
|
},
|
|
120
139
|
oneditprepare: function () {
|
|
121
140
|
var node = this;
|
|
141
|
+
let mobiusSrvc = $("#node-input-connection").val();
|
|
142
|
+
|
|
143
|
+
// *** MOBSEARCH *** //
|
|
144
|
+
|
|
145
|
+
$("#instance-search-row").hide();
|
|
146
|
+
$("#wildcard-alert-row").hide();
|
|
147
|
+
$("#node-search-return").addClass('disabled');
|
|
148
|
+
$.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
|
|
149
|
+
$("#instance-search-hid").val(response);
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
let globalSubscriptionIndex = 0;
|
|
153
|
+
|
|
154
|
+
let searchObject = {
|
|
155
|
+
hid: '',
|
|
156
|
+
sid: '',
|
|
157
|
+
pid: '',
|
|
158
|
+
ins: '',
|
|
159
|
+
objects: []
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//Function to search for INSs
|
|
163
|
+
function insSearch (objects, pid) {
|
|
164
|
+
let inss = ['#'];
|
|
165
|
+
for (let i = 0; i < objects.length; i++) {
|
|
166
|
+
if (objects[i].pid === pid) {
|
|
167
|
+
const name = objects[i].resources[1].pv;
|
|
168
|
+
if (name === '') {
|
|
169
|
+
inss.push(objects[i].ins);
|
|
170
|
+
} else {
|
|
171
|
+
inss.push(`${objects[i].ins} - ${name}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
$("#instance-search-ins").autocomplete({
|
|
176
|
+
source: inss,
|
|
177
|
+
minLength: 0,
|
|
178
|
+
close: function (event, ui) {
|
|
179
|
+
acceptCheck();
|
|
180
|
+
$("#instance-search-ins").autocomplete('destroy');
|
|
181
|
+
if ($("#instance-search-ins").val().length > 4) {
|
|
182
|
+
$("#instance-search-ins").val($("#instance-search-ins").val().substring(0, 4))
|
|
183
|
+
}
|
|
184
|
+
searchObject.ins = $("#instance-search-ins").val();
|
|
185
|
+
}
|
|
186
|
+
}).autocomplete('search', '');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
//Function to search for PIDs
|
|
190
|
+
function pidsSearch(objects) {
|
|
191
|
+
searchObject.objects = objects;
|
|
192
|
+
let pids = ['#', '+'];
|
|
193
|
+
for (let i = 0; i < objects.length; i++) {
|
|
194
|
+
pids.push(`${objects[i].pid} - ${objects[i].profileName}`);
|
|
195
|
+
}
|
|
196
|
+
pids = [...new Set(pids)];
|
|
197
|
+
$("#instance-search-pid").autocomplete({
|
|
198
|
+
source: pids,
|
|
199
|
+
minLength: 0,
|
|
200
|
+
close: function (event, ui) {
|
|
201
|
+
acceptCheck();
|
|
202
|
+
$("#instance-search-pid").autocomplete('destroy');
|
|
203
|
+
if ($("#instance-search-pid").val().length > 4) {
|
|
204
|
+
$("#instance-search-pid").val($("#instance-search-pid").val().substring(0, 4))
|
|
205
|
+
}
|
|
206
|
+
searchObject.pid = $("#instance-search-pid").val();
|
|
207
|
+
}
|
|
208
|
+
}).autocomplete('search', '');
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
//Function to search for SIDs, and then fetch child objects based on selection
|
|
212
|
+
function serviceSearch(response) {
|
|
213
|
+
let services = ['#', '+'];
|
|
214
|
+
for (let i = 0; i < response.length; i++) {
|
|
215
|
+
if (response[i].sid !== '009') {
|
|
216
|
+
services.push(`${response[i].sid} - ${response[i].name}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
$("#instance-search-sid").autocomplete({
|
|
220
|
+
source: services,
|
|
221
|
+
minLength: 0,
|
|
222
|
+
close: function (event, ui) {
|
|
223
|
+
acceptCheck();
|
|
224
|
+
$("#instance-search-sid").autocomplete('destroy');
|
|
225
|
+
if ($("#instance-search-sid").val().length > 3) {
|
|
226
|
+
$("#instance-search-sid").val($("#instance-search-sid").val().substring(0, 3))
|
|
227
|
+
}
|
|
228
|
+
searchObject.sid = $("#instance-search-sid").val();
|
|
229
|
+
if (searchObject.sid === '+') {
|
|
230
|
+
for (let i = 2; i < services.length; i++) {
|
|
231
|
+
$.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${services[i].substring(0, 3)}`, (objects) => {
|
|
232
|
+
searchObject.objects = searchObject.objects.concat(objects);
|
|
233
|
+
})
|
|
234
|
+
}
|
|
235
|
+
} else {
|
|
236
|
+
$.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${searchObject.sid}`, (objects) => {
|
|
237
|
+
searchObject.objects = objects;
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}).autocomplete('search', '');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
//Start a new search
|
|
245
|
+
function startSearch() {
|
|
246
|
+
$("#wildcard-alert-row").hide();
|
|
247
|
+
$("#instance-search-sid").val('');
|
|
248
|
+
$("#instance-search-pid").val('');
|
|
249
|
+
$("#instance-search-ins").val('');
|
|
250
|
+
searchObject.hid = $("#instance-search-hid").val()
|
|
251
|
+
searchObject.sid = '';
|
|
252
|
+
searchObject.pid = '';
|
|
253
|
+
searchObject.ins = '';
|
|
254
|
+
searchObject.objects = [];
|
|
255
|
+
if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
|
|
256
|
+
$.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch)
|
|
257
|
+
.fail((err) => {
|
|
258
|
+
console.log('Some kind of html failure message on service discovery');
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
//Finish a search
|
|
264
|
+
function finishSearch() {
|
|
265
|
+
$("#wildcard-alert-row").hide();
|
|
266
|
+
let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`
|
|
267
|
+
if (uri.includes('#')) {
|
|
268
|
+
uri = uri.substring(0,uri.indexOf('#') + 1)
|
|
269
|
+
}
|
|
270
|
+
node.subscriptions[globalSubscriptionIndex].uri = uri;
|
|
271
|
+
updateList()
|
|
272
|
+
$("#node-search-accept").css('color', '#CCCCCC');
|
|
273
|
+
readyToAccept = false;
|
|
274
|
+
$("#node-search-return").addClass('disabled');
|
|
275
|
+
$("#node-search-accept").addClass('disabled');
|
|
276
|
+
$("#instance-search-row").hide();
|
|
277
|
+
$('#node-input-subs-container-row').show();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
//Function to update if accept button is grade out and functions based on conditions of fields
|
|
281
|
+
function acceptCheck() {
|
|
282
|
+
if (($("#instance-search-hid").val() !== '' && $("#instance-search-sid").val() !== '' && $("#instance-search-pid").val() !== '' && $("#instance-search-ins").val() !== '') ||
|
|
283
|
+
$("#instance-search-sid").val() === '#' || $("#instance-search-pid").val() === '#' || $("#instance-search-ins").val() === '#') {
|
|
284
|
+
$("#node-search-accept").css('color', '#555555');
|
|
285
|
+
readyToAccept = true;
|
|
286
|
+
} else {
|
|
287
|
+
$("#node-search-accept").css('color', '#CCCCCC');
|
|
288
|
+
readyToAccept = false;
|
|
289
|
+
}
|
|
290
|
+
if ($("#instance-search-sid").val() !== '+' && $("#instance-search-pid").val() !== '+') {
|
|
291
|
+
$("#wildcard-alert-row").hide();
|
|
292
|
+
} else {
|
|
293
|
+
$("#wildcard-alert-row").show();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
$("#instance-search-sid").click(function () { //SID field clicked
|
|
298
|
+
$("#instance-search-pid").val('')
|
|
299
|
+
$("#instance-search-ins").val('')
|
|
300
|
+
searchObject.pid = '';
|
|
301
|
+
searchObject.ins = '';
|
|
302
|
+
searchObject.objects = [];
|
|
303
|
+
startSearch();
|
|
304
|
+
})
|
|
305
|
+
$("#instance-search-pid").click(function () { //PID field clicked
|
|
306
|
+
$("#instance-search-ins").val('')
|
|
307
|
+
searchObject.ins = '';
|
|
308
|
+
if (searchObject.sid !== '') {
|
|
309
|
+
pidsSearch(searchObject.objects);
|
|
310
|
+
}
|
|
311
|
+
})
|
|
312
|
+
$("#instance-search-ins").click(function () { //INS field clicked
|
|
313
|
+
if (searchObject.pid !== '' && searchObject.pid !== '+' && searchObject.sid !== '+') {
|
|
314
|
+
insSearch(searchObject.objects, searchObject.pid);
|
|
315
|
+
}
|
|
316
|
+
})
|
|
317
|
+
$("#node-search-return").click(function () { //Return/Back button clicked
|
|
318
|
+
$("#node-search-return").addClass('disabled');
|
|
319
|
+
$("#node-search-accept").addClass('disabled');
|
|
320
|
+
$("#instance-search-row").hide();
|
|
321
|
+
$('#node-input-subs-container-row').show();
|
|
322
|
+
});
|
|
323
|
+
$("#node-search-accept").click(function () { //Accept button clicked
|
|
324
|
+
if (readyToAccept) {
|
|
325
|
+
finishSearch();
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
// Respond to search field changes
|
|
330
|
+
$("#instance-search-hid").change(function () {
|
|
331
|
+
acceptCheck();
|
|
332
|
+
$("#instance-search-sid").val('');
|
|
333
|
+
$("#instance-search-pid").val('');
|
|
334
|
+
$("#instance-search-ins").val('');
|
|
335
|
+
});
|
|
336
|
+
$("#instance-search-sid").change(function () {
|
|
337
|
+
searchObject.sid = $("#instance-search-sid").val()
|
|
338
|
+
acceptCheck();
|
|
339
|
+
});
|
|
340
|
+
$("#instance-search-pid").change(function () {
|
|
341
|
+
searchObject.pid = $("#instance-search-pid").val()
|
|
342
|
+
acceptCheck();
|
|
343
|
+
});
|
|
344
|
+
$("#instance-search-ins").change(function () {
|
|
345
|
+
searchObject.ins = $("#instance-search-ins").val()
|
|
346
|
+
acceptCheck();
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
// *** END MOBSEARCH *** //
|
|
122
350
|
|
|
123
351
|
/** Create the subs container and populate it */
|
|
124
352
|
$('#node-input-subs-container').css('min-height', '200px').css('min-width', '345px').editableList ({
|
|
@@ -137,7 +365,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
137
365
|
}
|
|
138
366
|
|
|
139
367
|
var row = $('<div>URI</div>').appendTo(container);
|
|
140
|
-
var uriField = $('<input/>',{class: "node-input-sub-uri", type: "text", style: "width:
|
|
368
|
+
var uriField = $('<input/>',{class: "node-input-sub-uri", type: "text", style: "width: 150px; margin-left: 5px; text-align: left;"}).appendTo(row);
|
|
369
|
+
|
|
370
|
+
// *** MOBSEARCH *** //
|
|
371
|
+
var searchField = $('<a class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
|
|
372
|
+
// *** END MOBSEARCH *** //
|
|
373
|
+
|
|
141
374
|
var typeField = $('<select/>',{class: "node-input-sub-type", style: "width:auto; margin-left: 5px; text-align: center;"}).appendTo(row);
|
|
142
375
|
typeField.append($("<option></option>").val('include').text('Include'));
|
|
143
376
|
typeField.append($("<option></option>").val('exclude').text('Exclude'));
|
|
@@ -145,6 +378,25 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
145
378
|
// Populate the new stat
|
|
146
379
|
uriField.val(subscription.uri);
|
|
147
380
|
typeField.val(subscription.type);
|
|
381
|
+
|
|
382
|
+
// *** MOBSEARCH *** //
|
|
383
|
+
|
|
384
|
+
if (!node.subscriptions[i]) {
|
|
385
|
+
node.subscriptions[i] = {uri: '', type: 'include'}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
searchField.click(function () {
|
|
389
|
+
globalSubscriptionIndex = i;
|
|
390
|
+
$('#node-input-subs-container-row').hide();
|
|
391
|
+
$("#instance-search-sid").val('');
|
|
392
|
+
$("#instance-search-pid").val('');
|
|
393
|
+
$("#instance-search-ins").val('');
|
|
394
|
+
$("#node-search-return").removeClass('disabled');
|
|
395
|
+
$("#node-search-accept").removeClass('disabled');
|
|
396
|
+
$("#instance-search-row").show();
|
|
397
|
+
|
|
398
|
+
});
|
|
399
|
+
// *** END MOBSEARCH *** //
|
|
148
400
|
}
|
|
149
401
|
});
|
|
150
402
|
|
|
@@ -154,11 +406,19 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
154
406
|
if (!node.subscriptions) {
|
|
155
407
|
node.subscriptions = [subscription = {uri: '', type: 'include'}];
|
|
156
408
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
409
|
+
|
|
410
|
+
// *** MOBSEARCH *** //
|
|
411
|
+
|
|
412
|
+
function updateList() {
|
|
413
|
+
$("#node-input-subs-container").editableList('empty');
|
|
414
|
+
for (let i = 0; i < node.subscriptions.length; i++) {
|
|
415
|
+
let subscription = node.subscriptions[i];
|
|
416
|
+
$("#node-input-subs-container").editableList('addItem', subscription);
|
|
417
|
+
}
|
|
161
418
|
}
|
|
419
|
+
updateList()
|
|
420
|
+
|
|
421
|
+
// *** END MOBSEARCH *** //
|
|
162
422
|
|
|
163
423
|
function showRIDFilterInputs() {
|
|
164
424
|
if($("#node-input-useRIDValueFiltering").is(':checked')) {
|