node-red-contrib-mobius-flow-base 2.5.86-beta.67 → 2.5.86-beta.70
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 +115 -27
- package/dist/nodes/mobius-clear-resource.html +8 -273
- package/dist/nodes/mobius-clear-resource.js +21 -8
- package/dist/nodes/mobius-discover-object-list.html +12 -248
- package/dist/nodes/mobius-discover-object-list.js +71 -53
- package/dist/nodes/mobius-flow-inject.html +12 -248
- package/dist/nodes/mobius-flow-inject.js +23 -9
- package/dist/nodes/mobius-get-multi-object.html +12 -248
- package/dist/nodes/mobius-get-multi-object.js +17 -9
- package/dist/nodes/mobius-get-resource.html +0 -5
- package/dist/nodes/mobius-object-cov.html +8 -238
- package/dist/nodes/mobius-object-cov.js +8 -0
- package/dist/nodes/mobius-resource-cov.html +8 -273
- package/dist/nodes/mobius-resource-cov.js +13 -5
- package/dist/nodes/mobius-set-multi-resource.html +8 -238
- package/dist/nodes/mobius-set-multi-resource.js +8 -0
- package/dist/nodes/mobius-set-resource.html +9 -273
- package/dist/nodes/mobius-set-resource.js +31 -13
- package/package.json +1 -1
|
@@ -1,33 +1,64 @@
|
|
|
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
|
+
list - Array containing current list items in object form
|
|
13
|
+
containerRowName - The id of the row containing the HTML container
|
|
14
|
+
containerName - The id of the HTML container
|
|
15
|
+
containerSecondFieldName - The id of the secondary field (Not URI field) within HTML container
|
|
16
|
+
|
|
17
|
+
EXAMPLE OPTS OBJECT - context of getMultiResource
|
|
18
|
+
opts = {
|
|
19
|
+
htmlElementId: 'mobsearch',
|
|
20
|
+
list: node.resources,
|
|
21
|
+
containerRowName: 'node-input-resources-container-row',
|
|
22
|
+
containerName: 'node-input-resources-container',
|
|
23
|
+
containerSecondFieldName: 'node-input-resources-comment',
|
|
24
|
+
}
|
|
25
|
+
*
|
|
26
|
+
*
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
1
29
|
initMobsearch = {
|
|
30
|
+
// Standard mobsearch to rid level
|
|
2
31
|
toRid: (mobiusSrvc, opts) => {
|
|
3
32
|
getMobsearch(mobiusSrvc, true, false, opts);
|
|
4
33
|
},
|
|
34
|
+
// Standard mobsearch to ins level
|
|
5
35
|
toIns: (mobiusSrvc, opts) => {
|
|
6
36
|
getMobsearch(mobiusSrvc, false, false, opts);
|
|
7
37
|
},
|
|
38
|
+
// Mobsearch to rid level, for nodes using editable list
|
|
8
39
|
toRid_listed: (mobiusSrvc, opts) => {
|
|
9
40
|
getMobsearch(mobiusSrvc, true, true, opts);
|
|
10
41
|
},
|
|
42
|
+
// Mobsearch to ins level, for nodes using editable list
|
|
11
43
|
toIns_listed: (mobiusSrvc, opts) => {
|
|
12
44
|
getMobsearch(mobiusSrvc, false, true, opts);
|
|
13
45
|
},
|
|
14
46
|
};
|
|
15
47
|
|
|
16
|
-
//
|
|
17
|
-
// opts.htmlElementId
|
|
18
|
-
// opts.uriFieldName
|
|
19
|
-
// opts.selectionIndex
|
|
20
|
-
// opts.containerRowName
|
|
21
|
-
// opts.containerName
|
|
22
|
-
// opts.containerSecondFieldName
|
|
23
|
-
|
|
48
|
+
// Make / Reset global selectionIndex vairable (variable to allow setting of correct list field)
|
|
24
49
|
if (typeof selectionIndex === undefined) {
|
|
25
50
|
let selectionIndex = 0;
|
|
26
51
|
}
|
|
27
52
|
|
|
28
|
-
|
|
53
|
+
/**
|
|
54
|
+
* function to add search button functionality to list rows
|
|
55
|
+
* @param {object} field - The search field within a given list row
|
|
56
|
+
* @param {number} rowIndex - The list row index
|
|
57
|
+
* @param {object} opts - Mobsearch options object
|
|
58
|
+
*/
|
|
59
|
+
function addMobsearchListButton(field, rowIndex, opts) {
|
|
29
60
|
field.click(function () {
|
|
30
|
-
selectionIndex =
|
|
61
|
+
selectionIndex = rowIndex;
|
|
31
62
|
$(`#${opts.containerRowName}`).hide();
|
|
32
63
|
$('#instance-search-sid').val('');
|
|
33
64
|
$('#instance-search-pid').val('');
|
|
@@ -39,8 +70,22 @@ function addMobsearchListButton(field, i, opts) {
|
|
|
39
70
|
});
|
|
40
71
|
}
|
|
41
72
|
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @param mobiusSrvc - Connection to Mobius
|
|
76
|
+
* @param {boolean} useRid - Flag for Mobsearch to include rid field
|
|
77
|
+
* @param {boolean} listed - Flag for Mobsearch work with nodes using editableLists
|
|
78
|
+
* @param {object} opts - Mobsearhc options object
|
|
79
|
+
*/
|
|
42
80
|
function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
43
81
|
selectionIndex = 0;
|
|
82
|
+
// Get current state of input field
|
|
83
|
+
let uriFieldValue = '';
|
|
84
|
+
if (!listed) {
|
|
85
|
+
uriFieldValue = $(`#${opts.uriFieldName}`).val();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// * HTML INJECTION * //
|
|
44
89
|
|
|
45
90
|
const resourceHtml = `
|
|
46
91
|
<input type="text" id="instance-search-hid" style="width:13%;" placeholder="HID">
|
|
@@ -57,11 +102,6 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
57
102
|
<input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
|
|
58
103
|
`;
|
|
59
104
|
|
|
60
|
-
let uriFieldValue = '';
|
|
61
|
-
if (!listed) {
|
|
62
|
-
uriFieldValue = $(`#${opts.uriFieldName}`).val();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
105
|
//set level dependent html
|
|
66
106
|
let rows = useRid === true ? resourceHtml : instanceHtml;
|
|
67
107
|
let alertMsg = useRid === true ? `and/or RID ` : ``;
|
|
@@ -91,7 +131,10 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
91
131
|
`;
|
|
92
132
|
}
|
|
93
133
|
|
|
94
|
-
//
|
|
134
|
+
// * END HTML INJECTION * //
|
|
135
|
+
|
|
136
|
+
// * INIT SETUP * //
|
|
137
|
+
|
|
95
138
|
$('#instance-search-row').hide();
|
|
96
139
|
$('#wildcard-alert-row').hide();
|
|
97
140
|
$('#node-search-return').addClass('disabled');
|
|
@@ -121,9 +164,13 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
121
164
|
};
|
|
122
165
|
}
|
|
123
166
|
|
|
124
|
-
//
|
|
167
|
+
// * END INIT SETUP * //
|
|
125
168
|
|
|
126
|
-
|
|
169
|
+
/**
|
|
170
|
+
* Search for INSs present on selected PID
|
|
171
|
+
* @param {object} objects - Response from call to Mobiu, list of mobius objects
|
|
172
|
+
* @param {string} pid - The chosen PID
|
|
173
|
+
*/
|
|
127
174
|
function ridSearch(objects, ins) {
|
|
128
175
|
$.getJSON(
|
|
129
176
|
`mdiscover?mobius=${mobiusSrvc}&uri=${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`,
|
|
@@ -149,7 +196,11 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
149
196
|
);
|
|
150
197
|
}
|
|
151
198
|
|
|
152
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Search for INSs present on selected PID
|
|
201
|
+
* @param {object} objects - Response from call to Mobius, list of mobius objects
|
|
202
|
+
* @param {string} pid - The chosen PID
|
|
203
|
+
*/
|
|
153
204
|
function insSearch(objects, pid) {
|
|
154
205
|
let inss = ['#', '+'];
|
|
155
206
|
for (let i = 0; i < objects.length; i++) {
|
|
@@ -178,7 +229,10 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
178
229
|
.autocomplete('search', '');
|
|
179
230
|
}
|
|
180
231
|
|
|
181
|
-
|
|
232
|
+
/**
|
|
233
|
+
* Search for PIDs present on selected service
|
|
234
|
+
* @param {object} objects - Response from call to Mobius, list of mobius objects
|
|
235
|
+
*/
|
|
182
236
|
function pidsSearch(objects) {
|
|
183
237
|
searchObject.objects = objects;
|
|
184
238
|
let pids = ['#', '+'];
|
|
@@ -202,7 +256,10 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
202
256
|
.autocomplete('search', '');
|
|
203
257
|
}
|
|
204
258
|
|
|
205
|
-
|
|
259
|
+
/**
|
|
260
|
+
* Search for SIDs, and then fetch child objects based on selection
|
|
261
|
+
* @param {object} response - Response from call to Mobius
|
|
262
|
+
*/
|
|
206
263
|
function serviceSearch(response) {
|
|
207
264
|
let services = ['#', '+'];
|
|
208
265
|
for (let i = 0; i < response.length; i++) {
|
|
@@ -245,7 +302,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
245
302
|
.autocomplete('search', '');
|
|
246
303
|
}
|
|
247
304
|
|
|
248
|
-
|
|
305
|
+
/**
|
|
306
|
+
* Start mobsearch
|
|
307
|
+
*/
|
|
249
308
|
function startSearch() {
|
|
250
309
|
$('#wildcard-alert-row').hide();
|
|
251
310
|
$('#instance-search-sid').val('');
|
|
@@ -258,13 +317,15 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
258
317
|
if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
|
|
259
318
|
$.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch).fail(
|
|
260
319
|
(err) => {
|
|
261
|
-
console.log('
|
|
320
|
+
console.log('Mobsearch failed to contact Mobius');
|
|
262
321
|
}
|
|
263
322
|
);
|
|
264
323
|
}
|
|
265
324
|
}
|
|
266
325
|
|
|
267
|
-
|
|
326
|
+
/**
|
|
327
|
+
* Finish mobsearch, compile full URI and set value in host node
|
|
328
|
+
*/
|
|
268
329
|
function finishSearch() {
|
|
269
330
|
$('#wildcard-alert-row').hide();
|
|
270
331
|
let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`;
|
|
@@ -289,7 +350,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
289
350
|
$('#instance-row').show();
|
|
290
351
|
}
|
|
291
352
|
|
|
292
|
-
|
|
353
|
+
/**
|
|
354
|
+
* Update if accept button is grade out and functional, based on conditions of fields
|
|
355
|
+
*/
|
|
293
356
|
function acceptCheck() {
|
|
294
357
|
if (useRid) {
|
|
295
358
|
checkFieldsToRid();
|
|
@@ -299,6 +362,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
299
362
|
checkWildcards();
|
|
300
363
|
}
|
|
301
364
|
|
|
365
|
+
/**
|
|
366
|
+
* Check state of all field to rid level, change state of accept button accordingly
|
|
367
|
+
*/
|
|
302
368
|
function checkFieldsToRid() {
|
|
303
369
|
if (
|
|
304
370
|
($('#instance-search-hid').val() !== '' &&
|
|
@@ -319,6 +385,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
319
385
|
}
|
|
320
386
|
}
|
|
321
387
|
|
|
388
|
+
/**
|
|
389
|
+
* Check state of all field to ins level, change state of accept button accordingly
|
|
390
|
+
*/
|
|
322
391
|
function checkFieldsToIns() {
|
|
323
392
|
if (
|
|
324
393
|
($('#instance-search-hid').val() !== '' &&
|
|
@@ -337,6 +406,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
337
406
|
}
|
|
338
407
|
}
|
|
339
408
|
|
|
409
|
+
/**
|
|
410
|
+
* Checks if + wildcard values are present, shows / hides alert message accordingly
|
|
411
|
+
*/
|
|
340
412
|
function checkWildcards() {
|
|
341
413
|
if (
|
|
342
414
|
$('#instance-search-sid').val() !== '+' &&
|
|
@@ -349,6 +421,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
349
421
|
}
|
|
350
422
|
}
|
|
351
423
|
|
|
424
|
+
/**
|
|
425
|
+
* Update editable list with results from mobsearch
|
|
426
|
+
*/
|
|
352
427
|
function updateList() {
|
|
353
428
|
$(`#${opts.containerName}`)
|
|
354
429
|
.editableList('items')
|
|
@@ -365,7 +440,8 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
365
440
|
$(`#${opts.containerRowName}`).show();
|
|
366
441
|
}
|
|
367
442
|
|
|
368
|
-
//
|
|
443
|
+
// * CLICK RESPONSE * //
|
|
444
|
+
|
|
369
445
|
$('#node-lookup-instance').click(function () {
|
|
370
446
|
//When search button is clicked
|
|
371
447
|
$('#instance-search-sid').val('');
|
|
@@ -380,6 +456,7 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
380
456
|
$('#instance-row').hide();
|
|
381
457
|
$('#instance-search-row').show();
|
|
382
458
|
});
|
|
459
|
+
|
|
383
460
|
$('#instance-search-sid').click(function () {
|
|
384
461
|
//SID field clicked
|
|
385
462
|
$('#instance-search-pid').val('');
|
|
@@ -430,6 +507,7 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
430
507
|
}
|
|
431
508
|
});
|
|
432
509
|
}
|
|
510
|
+
|
|
433
511
|
$('#node-search-return').click(function () {
|
|
434
512
|
//Return/Back button clicked
|
|
435
513
|
$('#node-search-return').addClass('disabled');
|
|
@@ -445,7 +523,10 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
445
523
|
}
|
|
446
524
|
});
|
|
447
525
|
|
|
448
|
-
//
|
|
526
|
+
// * END CLICK RESPONSE * //
|
|
527
|
+
|
|
528
|
+
// * CHANGE RESPONSE * //
|
|
529
|
+
|
|
449
530
|
$('#instance-search-hid').change(function () {
|
|
450
531
|
acceptCheck();
|
|
451
532
|
$('#instance-search-sid').val('');
|
|
@@ -455,18 +536,22 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
455
536
|
$('#instance-search-rid').val('');
|
|
456
537
|
}
|
|
457
538
|
});
|
|
539
|
+
|
|
458
540
|
$('#instance-search-sid').change(function () {
|
|
459
541
|
searchObject.sid = $('#instance-search-sid').val();
|
|
460
542
|
acceptCheck();
|
|
461
543
|
});
|
|
544
|
+
|
|
462
545
|
$('#instance-search-pid').change(function () {
|
|
463
546
|
searchObject.pid = $('#instance-search-pid').val();
|
|
464
547
|
acceptCheck();
|
|
465
548
|
});
|
|
549
|
+
|
|
466
550
|
$('#instance-search-ins').change(function () {
|
|
467
551
|
searchObject.ins = $('#instance-search-ins').val();
|
|
468
552
|
acceptCheck();
|
|
469
553
|
});
|
|
554
|
+
|
|
470
555
|
if (useRid) {
|
|
471
556
|
$('#instance-search-rid').change(function () {
|
|
472
557
|
searchObject.rid = $('#instance-search-rid').val();
|
|
@@ -474,6 +559,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
|
474
559
|
});
|
|
475
560
|
}
|
|
476
561
|
|
|
562
|
+
// * END CHANGE RESPONSE * //
|
|
563
|
+
|
|
564
|
+
// reset input filed after init
|
|
477
565
|
if (!listed) {
|
|
478
566
|
$(`#${opts.uriFieldName}`).val(uriFieldValue);
|
|
479
567
|
}
|
|
@@ -39,24 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
39
39
|
<a id="node-lookup-instance" class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>
|
|
40
40
|
</div>
|
|
41
41
|
</div>
|
|
42
|
-
<div id="
|
|
43
|
-
<div class="form-row">
|
|
44
|
-
<label for="instance-search-sid"><i class="fa fa-tasks"></i> URI</label>
|
|
45
|
-
<input type="text" id="instance-search-hid" style="width:13%;" placeholder="HID">
|
|
46
|
-
<input type="text" id="instance-search-sid" style="width:8%;" 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
|
-
<input type="text" id="instance-search-rid" style="width:8%;" placeholder="RID">
|
|
50
|
-
<a id="node-search-return" class="searchbutton" style="vertical-align: middle"><i id="node-search-return-icon" class="fa fa-arrow-left"></i></a>
|
|
51
|
-
<a id="node-search-accept" class="searchbutton" style="vertical-align: middle; color: #CCCCCC"><i id="node-search-accept-icon" class="fa fa-check"></i></a>
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
<div id="wildcard-alert-row" class="form-row hidden" style="color:#555555" align="center">
|
|
55
|
-
<p>Please note: The selection of wildcard '+'
|
|
56
|
-
means a search for a specific instance or resource
|
|
57
|
-
cannot be performed. As such, enter the
|
|
58
|
-
INS and/or RID manually.</p>
|
|
59
|
-
</div>
|
|
42
|
+
<div id="mobsearch"></div>
|
|
60
43
|
|
|
61
44
|
<div class="form-row">
|
|
62
45
|
<label for="node-input-priority"><i class="fa fa-exclamation-triangle"></i> Priority</label>
|
|
@@ -74,6 +57,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
74
57
|
</div>
|
|
75
58
|
</script>
|
|
76
59
|
|
|
60
|
+
<script src="common/mobsearch.js"></script>
|
|
61
|
+
|
|
77
62
|
<script type="text/javascript">
|
|
78
63
|
RED.nodes.registerType('mobius clear resource',{
|
|
79
64
|
category: 'mobius',
|
|
@@ -119,261 +104,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
119
104
|
var node = this;
|
|
120
105
|
let mobiusSrvc = $("#node-input-connection").val();
|
|
121
106
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
$("#node-search-return").addClass('disabled');
|
|
128
|
-
$.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
|
|
129
|
-
$("#instance-search-hid").val(response);
|
|
130
|
-
})
|
|
131
|
-
let readyToAccept = false;
|
|
132
|
-
let searchObject = {
|
|
133
|
-
hid: $("#instance-search-hid").val(),
|
|
134
|
-
sid: $("#instance-search-sid").val(),
|
|
135
|
-
pid: $("#instance-search-pid").val(),
|
|
136
|
-
ins: $("#instance-search-ins").val(),
|
|
137
|
-
rid: $("#instance-search-rid").val(),
|
|
138
|
-
objects: []
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
//Function to search for RIDs
|
|
142
|
-
function ridSearch (objects, ins) {
|
|
143
|
-
$.getJSON(`mdiscover?mobius=${mobiusSrvc}&uri=${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`, (response) => {
|
|
144
|
-
resList = response.value[0].resources
|
|
145
|
-
ress = ['#'];
|
|
146
|
-
for (let j = 0; j < resList.length; j++) {
|
|
147
|
-
ress.push(`${resList[j].rid} - ${resList[j].name}`)
|
|
148
|
-
}
|
|
149
|
-
$("#instance-search-rid").autocomplete({
|
|
150
|
-
source: ress,
|
|
151
|
-
minLength: 0,
|
|
152
|
-
close: function (event, ui) {
|
|
153
|
-
acceptCheck();
|
|
154
|
-
$("#instance-search-rid").autocomplete('destroy');
|
|
155
|
-
$("#instance-search-rid").val($("#instance-search-rid").val().substring(0, 2));
|
|
156
|
-
searchObject.rid = $("#instance-search-rid").val();
|
|
157
|
-
}
|
|
158
|
-
}).autocomplete('search', '');
|
|
159
|
-
})
|
|
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
|
-
if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
|
|
255
|
-
$.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch)
|
|
256
|
-
.fail((err) => {
|
|
257
|
-
console.log('Some kind of html failure message on service discovery');
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
//Finish a search
|
|
263
|
-
function finishSearch() {
|
|
264
|
-
$("#wildcard-alert-row").hide();
|
|
265
|
-
let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}/${searchObject.rid}`
|
|
266
|
-
if (uri.includes('#')) {
|
|
267
|
-
uri = uri.substring(0,uri.indexOf('#') + 1)
|
|
268
|
-
}
|
|
269
|
-
$("#node-input-resource").val(uri);
|
|
270
|
-
$("#node-search-accept").css('color', '#CCCCCC');
|
|
271
|
-
readyToAccept = false;
|
|
272
|
-
$("#node-search-return").addClass('disabled');
|
|
273
|
-
$("#node-search-accept").addClass('disabled');
|
|
274
|
-
$("#node-lookup-instance").removeClass('disabled');
|
|
275
|
-
$("#instance-search-row").hide();
|
|
276
|
-
$("#instance-row").show();
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
//Function to update if accept button is grade out and functions based on conditions of fields
|
|
280
|
-
function acceptCheck() {
|
|
281
|
-
if (($("#instance-search-hid").val() !== '' && $("#instance-search-sid").val() !== '' && $("#instance-search-pid").val() !== '' && $("#instance-search-ins").val() !== '' && $("#instance-search-rid").val() !== '') ||
|
|
282
|
-
$("#instance-search-sid").val() === '#' || $("#instance-search-pid").val() === '#' || $("#instance-search-ins").val() === '#' || $("#instance-search-rid").val() === '#') {
|
|
283
|
-
$("#node-search-accept").css('color', '#555555');
|
|
284
|
-
readyToAccept = true;
|
|
285
|
-
} else {
|
|
286
|
-
$("#node-search-accept").css('color', '#CCCCCC');
|
|
287
|
-
readyToAccept = false;
|
|
288
|
-
}
|
|
289
|
-
if ($("#instance-search-sid").val() !== '+' && $("#instance-search-pid").val() !== '+' && $("#instance-search-ins").val() !== '+') {
|
|
290
|
-
$("#wildcard-alert-row").hide();
|
|
291
|
-
} else {
|
|
292
|
-
$("#wildcard-alert-row").show();
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// Respond to clicks
|
|
297
|
-
$("#node-lookup-instance").click(function () { //When search button is clicked
|
|
298
|
-
$("#instance-search-sid").val('');
|
|
299
|
-
$("#instance-search-pid").val('');
|
|
300
|
-
$("#instance-search-ins").val('');
|
|
301
|
-
$("#instance-search-rid").val('');
|
|
302
|
-
$("#node-lookup-instance").addClass('disabled');
|
|
303
|
-
$("#node-search-return").removeClass('disabled');
|
|
304
|
-
$("#node-search-accept").removeClass('disabled');
|
|
305
|
-
$("#instance-row").hide();
|
|
306
|
-
$("#instance-search-row").show();
|
|
307
|
-
});
|
|
308
|
-
$("#instance-search-sid").click(function () { //SID field clicked
|
|
309
|
-
$("#instance-search-pid").val('')
|
|
310
|
-
$("#instance-search-ins").val('')
|
|
311
|
-
searchObject.pid = '';
|
|
312
|
-
searchObject.ins = '';
|
|
313
|
-
searchObject.rid = '';
|
|
314
|
-
searchObject.objects = [];
|
|
315
|
-
startSearch();
|
|
316
|
-
})
|
|
317
|
-
$("#instance-search-pid").click(function () { //PID field clicked
|
|
318
|
-
$("#instance-search-ins").val('')
|
|
319
|
-
$("#instance-search-rid").val('')
|
|
320
|
-
searchObject.ins = '';
|
|
321
|
-
searchObject.rid = '';
|
|
322
|
-
if (searchObject.sid !== '') {
|
|
323
|
-
pidsSearch(searchObject.objects);
|
|
324
|
-
}
|
|
325
|
-
})
|
|
326
|
-
$("#instance-search-ins").click(function () { //INS field clicked
|
|
327
|
-
$("#instance-search-rid").val('')
|
|
328
|
-
searchObject.rid = '';
|
|
329
|
-
if (searchObject.pid !== '' && searchObject.pid !== '+' && searchObject.sid !== '+') {
|
|
330
|
-
insSearch(searchObject.objects, searchObject.pid);
|
|
331
|
-
}
|
|
332
|
-
})
|
|
333
|
-
$("#instance-search-rid").click(function () { //RID clicked
|
|
334
|
-
if (searchObject.ins !== '' && searchObject.ins !== '+' && searchObject.pid !== '+' && searchObject.sid !== '+') {
|
|
335
|
-
ridSearch(searchObject.objects, searchObject.ins);
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
$("#node-search-return").click(function () { //Return/Back button clicked
|
|
339
|
-
$("#node-search-return").addClass('disabled');
|
|
340
|
-
$("#node-search-accept").addClass('disabled');
|
|
341
|
-
$("#node-lookup-instance").removeClass('disabled');
|
|
342
|
-
$("#instance-search-row").hide();
|
|
343
|
-
$("#instance-row").show();
|
|
344
|
-
});
|
|
345
|
-
$("#node-search-accept").click(function () { //Accept button clicked
|
|
346
|
-
if (readyToAccept) {
|
|
347
|
-
finishSearch();
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
// Respond to search field changes
|
|
352
|
-
$("#instance-search-hid").change(function () {
|
|
353
|
-
acceptCheck();
|
|
354
|
-
$("#instance-search-sid").val('');
|
|
355
|
-
$("#instance-search-pid").val('');
|
|
356
|
-
$("#instance-search-ins").val('');
|
|
357
|
-
$("#instance-search-rid").val('');
|
|
358
|
-
});
|
|
359
|
-
$("#instance-search-sid").change(function () {
|
|
360
|
-
searchObject.sid = $("#instance-search-sid").val()
|
|
361
|
-
acceptCheck();
|
|
362
|
-
});
|
|
363
|
-
$("#instance-search-pid").change(function () {
|
|
364
|
-
searchObject.pid = $("#instance-search-pid").val()
|
|
365
|
-
acceptCheck();
|
|
366
|
-
});
|
|
367
|
-
$("#instance-search-ins").change(function () {
|
|
368
|
-
searchObject.ins = $("#instance-search-ins").val()
|
|
369
|
-
acceptCheck();
|
|
370
|
-
});
|
|
371
|
-
$("#instance-search-rid").change(function () {
|
|
372
|
-
searchObject.rid = $("#instance-search-rid").val()
|
|
373
|
-
acceptCheck();
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
// *** MOBSEARCH *** //
|
|
107
|
+
opts = {
|
|
108
|
+
htmlElementId: 'mobsearch',
|
|
109
|
+
uriFieldName: 'node-input-resource'
|
|
110
|
+
};
|
|
111
|
+
initMobsearch.toRid(mobiusSrvc, opts);
|
|
377
112
|
},
|
|
378
113
|
oneditsave: function() {
|
|
379
114
|
if($("#node-input-detailedOutput").prop('checked')) {
|