node-red-contrib-mobius-flow-base 2.5.86-beta.68 → 2.5.86-beta.69
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 +112 -27
- package/package.json +1 -1
|
@@ -1,33 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param mobiusSrvc - Connection to Mobius
|
|
4
|
+
* @param {object} opts - Options object, field explained below
|
|
5
|
+
|
|
6
|
+
OPTS OBJECT (opts.)
|
|
7
|
+
ALL CASES
|
|
8
|
+
htmlElementId - The id of the HTML element that mobsearch will inject into
|
|
9
|
+
NON-LISTED ONLY
|
|
10
|
+
uriFieldName - The id of the URI HTML field, mobsearch will set the value of this field to be the result
|
|
11
|
+
LISTED ONLY (Uses editable list)
|
|
12
|
+
containerRowName - The id of the row containing the HTML container
|
|
13
|
+
containerName - The id of the HTML container
|
|
14
|
+
containerSecondFieldName - The id of the secondary field (Not URI field) within HTML container
|
|
15
|
+
|
|
16
|
+
EXAMPLE OPTS OBJECT - context of getMultiResource
|
|
17
|
+
opts = {
|
|
18
|
+
htmlElementId: 'mobsearch',
|
|
19
|
+
list: node.resources,
|
|
20
|
+
containerRowName: 'node-input-resources-container-row',
|
|
21
|
+
containerName: 'node-input-resources-container',
|
|
22
|
+
containerSecondFieldName: 'node-input-resources-comment',
|
|
23
|
+
}
|
|
24
|
+
*
|
|
25
|
+
*
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
1
28
|
initMobsearch = {
|
|
29
|
+
// Standard mobsearch to rid level
|
|
2
30
|
toRid: (mobiusSrvc, opts) => {
|
|
3
31
|
getMobsearch(mobiusSrvc, true, false, opts);
|
|
4
32
|
},
|
|
33
|
+
// Standard mobsearch to ins level
|
|
5
34
|
toIns: (mobiusSrvc, opts) => {
|
|
6
35
|
getMobsearch(mobiusSrvc, false, false, opts);
|
|
7
36
|
},
|
|
37
|
+
// Mobsearch to rid level, for nodes using editable list
|
|
8
38
|
toRid_listed: (mobiusSrvc, opts) => {
|
|
9
39
|
getMobsearch(mobiusSrvc, true, true, opts);
|
|
10
40
|
},
|
|
41
|
+
// Mobsearch to ins level, for nodes using editable list
|
|
11
42
|
toIns_listed: (mobiusSrvc, opts) => {
|
|
12
43
|
getMobsearch(mobiusSrvc, false, true, opts);
|
|
13
44
|
},
|
|
14
45
|
};
|
|
15
46
|
|
|
16
|
-
//
|
|
17
|
-
// opts.htmlElementId
|
|
18
|
-
// opts.uriFieldName
|
|
19
|
-
// opts.selectionIndex
|
|
20
|
-
// opts.containerRowName
|
|
21
|
-
// opts.containerName
|
|
22
|
-
// opts.containerSecondFieldName
|
|
23
|
-
|
|
47
|
+
// Make / Reset global selectionIndex vairable (variable to allow setting of correct list field)
|
|
24
48
|
if (typeof selectionIndex === undefined) {
|
|
25
49
|
let selectionIndex = 0;
|
|
26
50
|
}
|
|
27
51
|
|
|
28
|
-
|
|
52
|
+
/**
|
|
53
|
+
* function to add search button functionality to list rows
|
|
54
|
+
* @param {*} field - The search field within a given list row
|
|
55
|
+
* @param {*} rowIndex - The list row index
|
|
56
|
+
* @param {*} opts - Mobsearch options object
|
|
57
|
+
*/
|
|
58
|
+
function addMobsearchListButton(field, rowIndex, opts) {
|
|
29
59
|
field.click(function () {
|
|
30
|
-
selectionIndex =
|
|
60
|
+
selectionIndex = rowIndex;
|
|
31
61
|
$(`#${opts.containerRowName}`).hide();
|
|
32
62
|
$('#instance-search-sid').val('');
|
|
33
63
|
$('#instance-search-pid').val('');
|
|
@@ -39,8 +69,22 @@ function addMobsearchListButton(field, i, opts) {
|
|
|
39
69
|
});
|
|
40
70
|
}
|
|
41
71
|
|
|
72
|
+
/**
|
|
73
|
+
*
|
|
74
|
+
* @param mobiusSrvc - Connection to Mobius
|
|
75
|
+
* @param {boolean} useRid - Flag for Mobsearch to include rid field
|
|
76
|
+
* @param {boolean} listed - Flag for Mobsearch work with nodes using editableLists
|
|
77
|
+
* @param {object} opts - Mobsearhc options object
|
|
78
|
+
*/
|
|
42
79
|
function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
43
80
|
selectionIndex = 0;
|
|
81
|
+
// Get current state of input field
|
|
82
|
+
let uriFieldValue = '';
|
|
83
|
+
if (!listed) {
|
|
84
|
+
uriFieldValue = $(`#${opts.uriFieldName}`).val();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// * HTML INJECTION * //
|
|
44
88
|
|
|
45
89
|
const resourceHtml = `
|
|
46
90
|
<input type="text" id="instance-search-hid" style="width:13%;" placeholder="HID">
|
|
@@ -57,12 +101,6 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
57
101
|
<input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
|
|
58
102
|
`;
|
|
59
103
|
|
|
60
|
-
// Get current state of input field
|
|
61
|
-
let uriFieldValue = '';
|
|
62
|
-
if (!listed) {
|
|
63
|
-
uriFieldValue = $(`#${opts.uriFieldName}`).val();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
104
|
//set level dependent html
|
|
67
105
|
let rows = useRid === true ? resourceHtml : instanceHtml;
|
|
68
106
|
let alertMsg = useRid === true ? `and/or RID ` : ``;
|
|
@@ -92,7 +130,10 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
92
130
|
`;
|
|
93
131
|
}
|
|
94
132
|
|
|
95
|
-
//
|
|
133
|
+
// * END HTML INJECTION * //
|
|
134
|
+
|
|
135
|
+
// * INIT SETUP * //
|
|
136
|
+
|
|
96
137
|
$('#instance-search-row').hide();
|
|
97
138
|
$('#wildcard-alert-row').hide();
|
|
98
139
|
$('#node-search-return').addClass('disabled');
|
|
@@ -122,9 +163,13 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
122
163
|
};
|
|
123
164
|
}
|
|
124
165
|
|
|
125
|
-
//
|
|
166
|
+
// * END INIT SETUP * //
|
|
126
167
|
|
|
127
|
-
|
|
168
|
+
/**
|
|
169
|
+
* Search for INSs present on selected PID
|
|
170
|
+
* @param {object} objects - Response from call to Mobiu, list of mobius objects
|
|
171
|
+
* @param {string} pid - The chosen PID
|
|
172
|
+
*/
|
|
128
173
|
function ridSearch(objects, ins) {
|
|
129
174
|
$.getJSON(
|
|
130
175
|
`mdiscover?mobius=${mobiusSrvc}&uri=${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`,
|
|
@@ -150,7 +195,11 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
150
195
|
);
|
|
151
196
|
}
|
|
152
197
|
|
|
153
|
-
|
|
198
|
+
/**
|
|
199
|
+
* Search for INSs present on selected PID
|
|
200
|
+
* @param {object} objects - Response from call to Mobius, list of mobius objects
|
|
201
|
+
* @param {string} pid - The chosen PID
|
|
202
|
+
*/
|
|
154
203
|
function insSearch(objects, pid) {
|
|
155
204
|
let inss = ['#', '+'];
|
|
156
205
|
for (let i = 0; i < objects.length; i++) {
|
|
@@ -179,7 +228,10 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
179
228
|
.autocomplete('search', '');
|
|
180
229
|
}
|
|
181
230
|
|
|
182
|
-
|
|
231
|
+
/**
|
|
232
|
+
* Search for PIDs present on selected service
|
|
233
|
+
* @param {object} objects - Response from call to Mobius, list of mobius objects
|
|
234
|
+
*/
|
|
183
235
|
function pidsSearch(objects) {
|
|
184
236
|
searchObject.objects = objects;
|
|
185
237
|
let pids = ['#', '+'];
|
|
@@ -203,7 +255,10 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
203
255
|
.autocomplete('search', '');
|
|
204
256
|
}
|
|
205
257
|
|
|
206
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Search for SIDs, and then fetch child objects based on selection
|
|
260
|
+
* @param {object} response - Response from call to Mobius
|
|
261
|
+
*/
|
|
207
262
|
function serviceSearch(response) {
|
|
208
263
|
let services = ['#', '+'];
|
|
209
264
|
for (let i = 0; i < response.length; i++) {
|
|
@@ -246,7 +301,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
246
301
|
.autocomplete('search', '');
|
|
247
302
|
}
|
|
248
303
|
|
|
249
|
-
|
|
304
|
+
/**
|
|
305
|
+
* Start mobsearch
|
|
306
|
+
*/
|
|
250
307
|
function startSearch() {
|
|
251
308
|
$('#wildcard-alert-row').hide();
|
|
252
309
|
$('#instance-search-sid').val('');
|
|
@@ -265,7 +322,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
265
322
|
}
|
|
266
323
|
}
|
|
267
324
|
|
|
268
|
-
|
|
325
|
+
/**
|
|
326
|
+
* Finish mobsearch, compile full URI and set value in host node
|
|
327
|
+
*/
|
|
269
328
|
function finishSearch() {
|
|
270
329
|
$('#wildcard-alert-row').hide();
|
|
271
330
|
let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`;
|
|
@@ -290,7 +349,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
290
349
|
$('#instance-row').show();
|
|
291
350
|
}
|
|
292
351
|
|
|
293
|
-
|
|
352
|
+
/**
|
|
353
|
+
* Update if accept button is grade out and functional, based on conditions of fields
|
|
354
|
+
*/
|
|
294
355
|
function acceptCheck() {
|
|
295
356
|
if (useRid) {
|
|
296
357
|
checkFieldsToRid();
|
|
@@ -300,6 +361,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
300
361
|
checkWildcards();
|
|
301
362
|
}
|
|
302
363
|
|
|
364
|
+
/**
|
|
365
|
+
* Check state of all field to rid level, change state of accept button accordingly
|
|
366
|
+
*/
|
|
303
367
|
function checkFieldsToRid() {
|
|
304
368
|
if (
|
|
305
369
|
($('#instance-search-hid').val() !== '' &&
|
|
@@ -320,6 +384,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
320
384
|
}
|
|
321
385
|
}
|
|
322
386
|
|
|
387
|
+
/**
|
|
388
|
+
* Check state of all field to ins level, change state of accept button accordingly
|
|
389
|
+
*/
|
|
323
390
|
function checkFieldsToIns() {
|
|
324
391
|
if (
|
|
325
392
|
($('#instance-search-hid').val() !== '' &&
|
|
@@ -338,6 +405,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
338
405
|
}
|
|
339
406
|
}
|
|
340
407
|
|
|
408
|
+
/**
|
|
409
|
+
* Checks if + wildcard values are present, shows / hides alert message accordingly
|
|
410
|
+
*/
|
|
341
411
|
function checkWildcards() {
|
|
342
412
|
if (
|
|
343
413
|
$('#instance-search-sid').val() !== '+' &&
|
|
@@ -350,6 +420,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
350
420
|
}
|
|
351
421
|
}
|
|
352
422
|
|
|
423
|
+
/**
|
|
424
|
+
* Update editable list with results from mobsearch
|
|
425
|
+
*/
|
|
353
426
|
function updateList() {
|
|
354
427
|
$(`#${opts.containerName}`)
|
|
355
428
|
.editableList('items')
|
|
@@ -366,7 +439,8 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
366
439
|
$(`#${opts.containerRowName}`).show();
|
|
367
440
|
}
|
|
368
441
|
|
|
369
|
-
//
|
|
442
|
+
// * CLICK RESPONSE * //
|
|
443
|
+
|
|
370
444
|
$('#node-lookup-instance').click(function () {
|
|
371
445
|
//When search button is clicked
|
|
372
446
|
$('#instance-search-sid').val('');
|
|
@@ -381,6 +455,7 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
381
455
|
$('#instance-row').hide();
|
|
382
456
|
$('#instance-search-row').show();
|
|
383
457
|
});
|
|
458
|
+
|
|
384
459
|
$('#instance-search-sid').click(function () {
|
|
385
460
|
//SID field clicked
|
|
386
461
|
$('#instance-search-pid').val('');
|
|
@@ -431,6 +506,7 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
431
506
|
}
|
|
432
507
|
});
|
|
433
508
|
}
|
|
509
|
+
|
|
434
510
|
$('#node-search-return').click(function () {
|
|
435
511
|
//Return/Back button clicked
|
|
436
512
|
$('#node-search-return').addClass('disabled');
|
|
@@ -446,7 +522,10 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
446
522
|
}
|
|
447
523
|
});
|
|
448
524
|
|
|
449
|
-
//
|
|
525
|
+
// * END CLICK RESPONSE * //
|
|
526
|
+
|
|
527
|
+
// * CHANGE RESPONSE * //
|
|
528
|
+
|
|
450
529
|
$('#instance-search-hid').change(function () {
|
|
451
530
|
acceptCheck();
|
|
452
531
|
$('#instance-search-sid').val('');
|
|
@@ -456,18 +535,22 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
456
535
|
$('#instance-search-rid').val('');
|
|
457
536
|
}
|
|
458
537
|
});
|
|
538
|
+
|
|
459
539
|
$('#instance-search-sid').change(function () {
|
|
460
540
|
searchObject.sid = $('#instance-search-sid').val();
|
|
461
541
|
acceptCheck();
|
|
462
542
|
});
|
|
543
|
+
|
|
463
544
|
$('#instance-search-pid').change(function () {
|
|
464
545
|
searchObject.pid = $('#instance-search-pid').val();
|
|
465
546
|
acceptCheck();
|
|
466
547
|
});
|
|
548
|
+
|
|
467
549
|
$('#instance-search-ins').change(function () {
|
|
468
550
|
searchObject.ins = $('#instance-search-ins').val();
|
|
469
551
|
acceptCheck();
|
|
470
552
|
});
|
|
553
|
+
|
|
471
554
|
if (useRid) {
|
|
472
555
|
$('#instance-search-rid').change(function () {
|
|
473
556
|
searchObject.rid = $('#instance-search-rid').val();
|
|
@@ -475,6 +558,8 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
475
558
|
});
|
|
476
559
|
}
|
|
477
560
|
|
|
561
|
+
// * END CHANGE RESPONSE * //
|
|
562
|
+
|
|
478
563
|
// reset input filed after init
|
|
479
564
|
if (!listed) {
|
|
480
565
|
$(`#${opts.uriFieldName}`).val(uriFieldValue);
|