node-red-contrib-mobius-flow-base 2.5.86-beta.5 → 2.5.86-beta.53
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/common/mobsearch.js +382 -0
- package/dist/nodes/mobius-clear-resource.html +288 -3
- package/dist/nodes/mobius-connection.js +30 -1
- package/dist/nodes/mobius-discover-object-list.html +272 -3
- package/dist/nodes/mobius-flow-inject.html +270 -2
- package/dist/nodes/mobius-get-multi-object.html +276 -7
- package/dist/nodes/mobius-get-multi-resource.html +328 -7
- package/dist/nodes/mobius-get-object.html +254 -5
- package/dist/nodes/mobius-get-object.js +13 -10
- package/dist/nodes/mobius-get-resource.html +18 -3
- package/dist/nodes/mobius-get-resource.js +21 -8
- package/dist/nodes/mobius-object-cov.html +256 -5
- package/dist/nodes/mobius-object-cov.js +10 -7
- package/dist/nodes/mobius-resource-cov.html +290 -4
- package/dist/nodes/mobius-set-multi-resource.html +254 -4
- package/dist/nodes/mobius-set-multi-resource.js +10 -12
- package/dist/nodes/mobius-set-resource.html +288 -3
- package/dist/nodes/node-red-ui-discover-devices.js +64 -37
- package/package.json +2 -2
|
@@ -533,7 +533,7 @@ module.exports = function (RED) {
|
|
|
533
533
|
});
|
|
534
534
|
};
|
|
535
535
|
|
|
536
|
-
node.
|
|
536
|
+
node.getServiceConfigProm = function (hid, sid) {
|
|
537
537
|
return new Promise((resolve, reject) => {
|
|
538
538
|
node.service.srvcAPI.getServiceConfig(hid, sid, (err, response) => {
|
|
539
539
|
if (!err) {
|
|
@@ -642,4 +642,33 @@ module.exports = function (RED) {
|
|
|
642
642
|
});
|
|
643
643
|
}
|
|
644
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
|
+
});
|
|
645
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,7 +406,24 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
154
406
|
if (!node.subscriptions) {
|
|
155
407
|
node.subscriptions = [subscription = {uri: '', type: 'include'}];
|
|
156
408
|
}
|
|
157
|
-
|
|
409
|
+
|
|
410
|
+
// *** MOBSEARCH *** //
|
|
411
|
+
|
|
412
|
+
function updateList() {
|
|
413
|
+
$("#node-input-subs-container").editableList('items').each(function (i) {
|
|
414
|
+
let sub = $(this);
|
|
415
|
+
let type = sub.find(".node-input-sub-type").val();
|
|
416
|
+
node.subscriptions[i].type = type;
|
|
417
|
+
})
|
|
418
|
+
$("#node-input-subs-container").editableList('empty');
|
|
419
|
+
for (let i = 0; i < node.subscriptions.length; i++) {
|
|
420
|
+
let subscription = node.subscriptions[i];
|
|
421
|
+
$("#node-input-subs-container").editableList('addItem', subscription);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// *** END MOBSEARCH *** //
|
|
426
|
+
|
|
158
427
|
for (let i = 0; i < node.subscriptions.length; i++) {
|
|
159
428
|
let subscription = node.subscriptions[i];
|
|
160
429
|
$("#node-input-subs-container").editableList('addItem', subscription);
|
|
@@ -34,10 +34,28 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
34
34
|
<label for="node-input-connection"><i class="fa fa-globe"></i> MOBiUS</label>
|
|
35
35
|
<input type="text" id="node-input-connection">
|
|
36
36
|
</div>
|
|
37
|
-
<div class="form-row node-input-subs-container-row">
|
|
37
|
+
<div id="node-input-subs-container-row" class="form-row node-input-subs-container-row">
|
|
38
38
|
<label for="node-input-subs-container"><i class="fa fa-bars"></i> Subscriptions</label>
|
|
39
39
|
<ol id="node-input-subs-container"></ol>
|
|
40
40
|
</div>
|
|
41
|
+
|
|
42
|
+
<div id="instance-search-row">
|
|
43
|
+
<div class="form-row">
|
|
44
|
+
<label for="instance-search-sid"><i class="fa fa-search"></i> Search</label>
|
|
45
|
+
<input type="text" id="instance-search-hid" style="width:15%;" placeholder="HID">
|
|
46
|
+
<input type="text" id="instance-search-sid" style="width:10%;" placeholder="SID">
|
|
47
|
+
<input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
|
|
48
|
+
<input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
|
|
49
|
+
<a id="node-search-return" class="searchbutton" style="vertical-align: middle"><i id="node-search-return-icon" class="fa fa-arrow-left"></i></a>
|
|
50
|
+
<a id="node-search-accept" class="searchbutton" style="vertical-align: middle"><i id="node-search-accept-icon" class="fa fa-check"></i></a>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
<div id="wildcard-alert-row" class="form-row hidden" style="color:#555555" align="center">
|
|
54
|
+
<p>Please note: The selection of wildcard '+'
|
|
55
|
+
means a search for a specific instance or resource
|
|
56
|
+
cannot be performed. As such, enter the
|
|
57
|
+
INS manually.</p>
|
|
58
|
+
</div>
|
|
41
59
|
</script>
|
|
42
60
|
|
|
43
61
|
<script type="text/javascript">
|
|
@@ -67,6 +85,215 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
67
85
|
},
|
|
68
86
|
oneditprepare: function () {
|
|
69
87
|
var node = this;
|
|
88
|
+
let mobiusSrvc = $("#node-input-connection").val();
|
|
89
|
+
|
|
90
|
+
// *** MOBSEARCH *** //
|
|
91
|
+
|
|
92
|
+
$("#instance-search-row").hide();
|
|
93
|
+
$("#wildcard-alert-row").hide();
|
|
94
|
+
$("#node-search-return").addClass('disabled');
|
|
95
|
+
$.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
|
|
96
|
+
$("#instance-search-hid").val(response);
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
let globalSubscriptionIndex = 0;
|
|
100
|
+
|
|
101
|
+
let searchObject = {
|
|
102
|
+
hid: '',
|
|
103
|
+
sid: '',
|
|
104
|
+
pid: '',
|
|
105
|
+
ins: '',
|
|
106
|
+
objects: []
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//Function to search for INSs
|
|
110
|
+
function insSearch (objects, pid) {
|
|
111
|
+
let inss = ['#'];
|
|
112
|
+
for (let i = 0; i < objects.length; i++) {
|
|
113
|
+
if (objects[i].pid === pid) {
|
|
114
|
+
const name = objects[i].resources[1].pv;
|
|
115
|
+
if (name === '') {
|
|
116
|
+
inss.push(objects[i].ins);
|
|
117
|
+
} else {
|
|
118
|
+
inss.push(`${objects[i].ins} - ${name}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
$("#instance-search-ins").autocomplete({
|
|
123
|
+
source: inss,
|
|
124
|
+
minLength: 0,
|
|
125
|
+
close: function (event, ui) {
|
|
126
|
+
acceptCheck();
|
|
127
|
+
$("#instance-search-ins").autocomplete('destroy');
|
|
128
|
+
if ($("#instance-search-ins").val().length > 4) {
|
|
129
|
+
$("#instance-search-ins").val($("#instance-search-ins").val().substring(0, 4))
|
|
130
|
+
}
|
|
131
|
+
searchObject.ins = $("#instance-search-ins").val();
|
|
132
|
+
}
|
|
133
|
+
}).autocomplete('search', '');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
//Function to search for PIDs
|
|
137
|
+
function pidsSearch(objects) {
|
|
138
|
+
searchObject.objects = objects;
|
|
139
|
+
let pids = ['#', '+'];
|
|
140
|
+
for (let i = 0; i < objects.length; i++) {
|
|
141
|
+
pids.push(`${objects[i].pid} - ${objects[i].profileName}`);
|
|
142
|
+
}
|
|
143
|
+
pids = [...new Set(pids)];
|
|
144
|
+
$("#instance-search-pid").autocomplete({
|
|
145
|
+
source: pids,
|
|
146
|
+
minLength: 0,
|
|
147
|
+
close: function (event, ui) {
|
|
148
|
+
acceptCheck();
|
|
149
|
+
$("#instance-search-pid").autocomplete('destroy');
|
|
150
|
+
if ($("#instance-search-pid").val().length > 4) {
|
|
151
|
+
$("#instance-search-pid").val($("#instance-search-pid").val().substring(0, 4))
|
|
152
|
+
}
|
|
153
|
+
searchObject.pid = $("#instance-search-pid").val();
|
|
154
|
+
}
|
|
155
|
+
}).autocomplete('search', '');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
//Function to search for SIDs, and then fetch child objects based on selection
|
|
159
|
+
function serviceSearch(response) {
|
|
160
|
+
let services = ['#', '+'];
|
|
161
|
+
for (let i = 0; i < response.length; i++) {
|
|
162
|
+
if (response[i].sid !== '009') {
|
|
163
|
+
services.push(`${response[i].sid} - ${response[i].name}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
$("#instance-search-sid").autocomplete({
|
|
167
|
+
source: services,
|
|
168
|
+
minLength: 0,
|
|
169
|
+
close: function (event, ui) {
|
|
170
|
+
acceptCheck();
|
|
171
|
+
$("#instance-search-sid").autocomplete('destroy');
|
|
172
|
+
if ($("#instance-search-sid").val().length > 3) {
|
|
173
|
+
$("#instance-search-sid").val($("#instance-search-sid").val().substring(0, 3))
|
|
174
|
+
}
|
|
175
|
+
searchObject.sid = $("#instance-search-sid").val();
|
|
176
|
+
if (searchObject.sid === '+') {
|
|
177
|
+
for (let i = 2; i < services.length; i++) {
|
|
178
|
+
$.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${services[i].substring(0, 3)}`, (objects) => {
|
|
179
|
+
searchObject.objects = searchObject.objects.concat(objects);
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
$.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${searchObject.sid}`, (objects) => {
|
|
184
|
+
searchObject.objects = objects;
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}).autocomplete('search', '');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
//Start a new search
|
|
192
|
+
function startSearch() {
|
|
193
|
+
$("#wildcard-alert-row").hide();
|
|
194
|
+
$("#instance-search-sid").val('');
|
|
195
|
+
$("#instance-search-pid").val('');
|
|
196
|
+
$("#instance-search-ins").val('');
|
|
197
|
+
searchObject.hid = $("#instance-search-hid").val()
|
|
198
|
+
searchObject.sid = '';
|
|
199
|
+
searchObject.pid = '';
|
|
200
|
+
searchObject.ins = '';
|
|
201
|
+
searchObject.objects = [];
|
|
202
|
+
if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
|
|
203
|
+
$.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch)
|
|
204
|
+
.fail((err) => {
|
|
205
|
+
console.log('Some kind of html failure message on service discovery');
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
//Finish a search
|
|
211
|
+
function finishSearch() {
|
|
212
|
+
$("#wildcard-alert-row").hide();
|
|
213
|
+
let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`
|
|
214
|
+
if (uri.includes('#')) {
|
|
215
|
+
uri = uri.substring(0,uri.indexOf('#') + 1)
|
|
216
|
+
}
|
|
217
|
+
node.subscriptions[globalSubscriptionIndex].uri = uri;
|
|
218
|
+
updateList()
|
|
219
|
+
$("#node-search-accept").css('color', '#CCCCCC');
|
|
220
|
+
readyToAccept = false;
|
|
221
|
+
$("#node-search-return").addClass('disabled');
|
|
222
|
+
$("#node-search-accept").addClass('disabled');
|
|
223
|
+
$("#instance-search-row").hide();
|
|
224
|
+
$('#node-input-subs-container-row').show();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
//Function to update if accept button is grade out and functions based on conditions of fields
|
|
228
|
+
function acceptCheck() {
|
|
229
|
+
if (($("#instance-search-hid").val() !== '' && $("#instance-search-sid").val() !== '' && $("#instance-search-pid").val() !== '' && $("#instance-search-ins").val() !== '') ||
|
|
230
|
+
$("#instance-search-sid").val() === '#' || $("#instance-search-pid").val() === '#' || $("#instance-search-ins").val() === '#') {
|
|
231
|
+
$("#node-search-accept").css('color', '#555555');
|
|
232
|
+
readyToAccept = true;
|
|
233
|
+
} else {
|
|
234
|
+
$("#node-search-accept").css('color', '#CCCCCC');
|
|
235
|
+
readyToAccept = false;
|
|
236
|
+
}
|
|
237
|
+
if ($("#instance-search-sid").val() !== '+' && $("#instance-search-pid").val() !== '+') {
|
|
238
|
+
$("#wildcard-alert-row").hide();
|
|
239
|
+
} else {
|
|
240
|
+
$("#wildcard-alert-row").show();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
$("#instance-search-sid").click(function () { //SID field clicked
|
|
245
|
+
$("#instance-search-pid").val('')
|
|
246
|
+
$("#instance-search-ins").val('')
|
|
247
|
+
searchObject.pid = '';
|
|
248
|
+
searchObject.ins = '';
|
|
249
|
+
searchObject.objects = [];
|
|
250
|
+
startSearch();
|
|
251
|
+
})
|
|
252
|
+
$("#instance-search-pid").click(function () { //PID field clicked
|
|
253
|
+
$("#instance-search-ins").val('')
|
|
254
|
+
searchObject.ins = '';
|
|
255
|
+
if (searchObject.sid !== '') {
|
|
256
|
+
pidsSearch(searchObject.objects);
|
|
257
|
+
}
|
|
258
|
+
})
|
|
259
|
+
$("#instance-search-ins").click(function () { //INS field clicked
|
|
260
|
+
if (searchObject.pid !== '' && searchObject.pid !== '+' && searchObject.sid !== '+') {
|
|
261
|
+
insSearch(searchObject.objects, searchObject.pid);
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
$("#node-search-return").click(function () { //Return/Back button clicked
|
|
265
|
+
$("#node-search-return").addClass('disabled');
|
|
266
|
+
$("#node-search-accept").addClass('disabled');
|
|
267
|
+
$("#instance-search-row").hide();
|
|
268
|
+
$('#node-input-subs-container-row').show();
|
|
269
|
+
});
|
|
270
|
+
$("#node-search-accept").click(function () { //Accept button clicked
|
|
271
|
+
if (readyToAccept) {
|
|
272
|
+
finishSearch();
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// Respond to search field changes
|
|
277
|
+
$("#instance-search-hid").change(function () {
|
|
278
|
+
acceptCheck();
|
|
279
|
+
$("#instance-search-sid").val('');
|
|
280
|
+
$("#instance-search-pid").val('');
|
|
281
|
+
$("#instance-search-ins").val('');
|
|
282
|
+
});
|
|
283
|
+
$("#instance-search-sid").change(function () {
|
|
284
|
+
searchObject.sid = $("#instance-search-sid").val()
|
|
285
|
+
acceptCheck();
|
|
286
|
+
});
|
|
287
|
+
$("#instance-search-pid").change(function () {
|
|
288
|
+
searchObject.pid = $("#instance-search-pid").val()
|
|
289
|
+
acceptCheck();
|
|
290
|
+
});
|
|
291
|
+
$("#instance-search-ins").change(function () {
|
|
292
|
+
searchObject.ins = $("#instance-search-ins").val()
|
|
293
|
+
acceptCheck();
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// *** END MOBSEARCH *** //
|
|
70
297
|
|
|
71
298
|
/** Create the subs container and populate it */
|
|
72
299
|
$('#node-input-subs-container').css('min-height', '300px').css('min-width', '450px').editableList ({
|
|
@@ -86,6 +313,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
86
313
|
|
|
87
314
|
var row = $('<div>URI</div>').appendTo(container);
|
|
88
315
|
var uriField = $('<input/>',{class: "node-input-sub-uri", type: "text", style: "width: 200px; margin-left: 5px; text-align: left;"}).appendTo(row);
|
|
316
|
+
|
|
317
|
+
// *** MOBSEARCH *** //
|
|
318
|
+
var searchField = $('<a class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
|
|
319
|
+
// *** END MOBSEARCH *** //
|
|
320
|
+
|
|
89
321
|
var typeField = $('<select/>',{class: "node-input-sub-type", style: "width:auto; margin-left: 5px; text-align: center;"}).appendTo(row);
|
|
90
322
|
typeField.append($("<option></option>").val('include').text('Include'));
|
|
91
323
|
typeField.append($("<option></option>").val('exclude').text('Exclude'));
|
|
@@ -93,6 +325,25 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
93
325
|
// Populate the new stat
|
|
94
326
|
uriField.val(subscription.uri);
|
|
95
327
|
typeField.val(subscription.type);
|
|
328
|
+
|
|
329
|
+
// *** MOBSEARCH *** //
|
|
330
|
+
|
|
331
|
+
if (!node.subscriptions[i]) {
|
|
332
|
+
node.subscriptions[i] = {uri: '', type: 'include'}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
searchField.click(function () {
|
|
336
|
+
globalSubscriptionIndex = i;
|
|
337
|
+
$('#node-input-subs-container-row').hide();
|
|
338
|
+
$("#instance-search-sid").val('');
|
|
339
|
+
$("#instance-search-pid").val('');
|
|
340
|
+
$("#instance-search-ins").val('');
|
|
341
|
+
$("#node-search-return").removeClass('disabled');
|
|
342
|
+
$("#node-search-accept").removeClass('disabled');
|
|
343
|
+
$("#instance-search-row").show();
|
|
344
|
+
|
|
345
|
+
});
|
|
346
|
+
// *** END MOBSEARCH *** //
|
|
96
347
|
}
|
|
97
348
|
});
|
|
98
349
|
|
|
@@ -100,7 +351,24 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
100
351
|
if (!node.subscriptions) {
|
|
101
352
|
node.subscriptions = [subscription = {uri: '', type: 'include'}];
|
|
102
353
|
}
|
|
103
|
-
|
|
354
|
+
|
|
355
|
+
// *** MOBSEARCH *** //
|
|
356
|
+
|
|
357
|
+
function updateList() {
|
|
358
|
+
$("#node-input-subs-container").editableList('items').each(function (i) {
|
|
359
|
+
let sub = $(this);
|
|
360
|
+
let type = sub.find(".node-input-sub-type").val();
|
|
361
|
+
node.subscriptions[i].type = type;
|
|
362
|
+
})
|
|
363
|
+
$("#node-input-subs-container").editableList('empty');
|
|
364
|
+
for (let i = 0; i < node.subscriptions.length; i++) {
|
|
365
|
+
let subscription = node.subscriptions[i];
|
|
366
|
+
$("#node-input-subs-container").editableList('addItem', subscription);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// *** END MOBSEARCH *** //
|
|
371
|
+
|
|
104
372
|
for (let i = 0; i < node.subscriptions.length; i++) {
|
|
105
373
|
let subscription = node.subscriptions[i];
|
|
106
374
|
$("#node-input-subs-container").editableList('addItem', subscription);
|