node-red-contrib-mobius-flow-base 2.5.86-beta.68 → 2.5.86-beta.71

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.
@@ -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
- // RID ONLY
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
- function addMobsearchListButton(field, i, opts) {
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 = i;
61
+ selectionIndex = rowIndex;
31
62
  $(`#${opts.containerRowName}`).hide();
32
63
  $('#instance-search-sid').val('');
33
64
  $('#instance-search-pid').val('');
@@ -39,8 +70,24 @@ 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
+ console.log(opts.htmlElementId);
89
+
90
+ // * HTML INJECTION * //
44
91
 
45
92
  const resourceHtml = `
46
93
  <input type="text" id="instance-search-hid" style="width:13%;" placeholder="HID">
@@ -57,12 +104,6 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
57
104
  <input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
58
105
  `;
59
106
 
60
- // Get current state of input field
61
- let uriFieldValue = '';
62
- if (!listed) {
63
- uriFieldValue = $(`#${opts.uriFieldName}`).val();
64
- }
65
-
66
107
  //set level dependent html
67
108
  let rows = useRid === true ? resourceHtml : instanceHtml;
68
109
  let alertMsg = useRid === true ? `and/or RID ` : ``;
@@ -92,7 +133,10 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
92
133
  `;
93
134
  }
94
135
 
95
- //Inital setup
136
+ // * END HTML INJECTION * //
137
+
138
+ // * INIT SETUP * //
139
+
96
140
  $('#instance-search-row').hide();
97
141
  $('#wildcard-alert-row').hide();
98
142
  $('#node-search-return').addClass('disabled');
@@ -122,9 +166,13 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
122
166
  };
123
167
  }
124
168
 
125
- //End init setup
169
+ // * END INIT SETUP * //
126
170
 
127
- //Function to search for RIDs
171
+ /**
172
+ * Search for INSs present on selected PID
173
+ * @param {object} objects - Response from call to Mobiu, list of mobius objects
174
+ * @param {string} pid - The chosen PID
175
+ */
128
176
  function ridSearch(objects, ins) {
129
177
  $.getJSON(
130
178
  `mdiscover?mobius=${mobiusSrvc}&uri=${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`,
@@ -150,7 +198,11 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
150
198
  );
151
199
  }
152
200
 
153
- //Function to search for INSs
201
+ /**
202
+ * Search for INSs present on selected PID
203
+ * @param {object} objects - Response from call to Mobius, list of mobius objects
204
+ * @param {string} pid - The chosen PID
205
+ */
154
206
  function insSearch(objects, pid) {
155
207
  let inss = ['#', '+'];
156
208
  for (let i = 0; i < objects.length; i++) {
@@ -179,7 +231,10 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
179
231
  .autocomplete('search', '');
180
232
  }
181
233
 
182
- //Function to search for PIDs
234
+ /**
235
+ * Search for PIDs present on selected service
236
+ * @param {object} objects - Response from call to Mobius, list of mobius objects
237
+ */
183
238
  function pidsSearch(objects) {
184
239
  searchObject.objects = objects;
185
240
  let pids = ['#', '+'];
@@ -203,7 +258,10 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
203
258
  .autocomplete('search', '');
204
259
  }
205
260
 
206
- //Function to search for SIDs, and then fetch child objects based on selection
261
+ /**
262
+ * Search for SIDs, and then fetch child objects based on selection
263
+ * @param {object} response - Response from call to Mobius
264
+ */
207
265
  function serviceSearch(response) {
208
266
  let services = ['#', '+'];
209
267
  for (let i = 0; i < response.length; i++) {
@@ -246,7 +304,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
246
304
  .autocomplete('search', '');
247
305
  }
248
306
 
249
- //Start a new search
307
+ /**
308
+ * Start mobsearch
309
+ */
250
310
  function startSearch() {
251
311
  $('#wildcard-alert-row').hide();
252
312
  $('#instance-search-sid').val('');
@@ -265,7 +325,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
265
325
  }
266
326
  }
267
327
 
268
- //Finish a search
328
+ /**
329
+ * Finish mobsearch, compile full URI and set value in host node
330
+ */
269
331
  function finishSearch() {
270
332
  $('#wildcard-alert-row').hide();
271
333
  let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`;
@@ -290,7 +352,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
290
352
  $('#instance-row').show();
291
353
  }
292
354
 
293
- //Function to update if accept button is grade out and functions based on conditions of fields
355
+ /**
356
+ * Update if accept button is grade out and functional, based on conditions of fields
357
+ */
294
358
  function acceptCheck() {
295
359
  if (useRid) {
296
360
  checkFieldsToRid();
@@ -300,6 +364,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
300
364
  checkWildcards();
301
365
  }
302
366
 
367
+ /**
368
+ * Check state of all field to rid level, change state of accept button accordingly
369
+ */
303
370
  function checkFieldsToRid() {
304
371
  if (
305
372
  ($('#instance-search-hid').val() !== '' &&
@@ -320,6 +387,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
320
387
  }
321
388
  }
322
389
 
390
+ /**
391
+ * Check state of all field to ins level, change state of accept button accordingly
392
+ */
323
393
  function checkFieldsToIns() {
324
394
  if (
325
395
  ($('#instance-search-hid').val() !== '' &&
@@ -338,6 +408,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
338
408
  }
339
409
  }
340
410
 
411
+ /**
412
+ * Checks if + wildcard values are present, shows / hides alert message accordingly
413
+ */
341
414
  function checkWildcards() {
342
415
  if (
343
416
  $('#instance-search-sid').val() !== '+' &&
@@ -350,6 +423,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
350
423
  }
351
424
  }
352
425
 
426
+ /**
427
+ * Update editable list with results from mobsearch
428
+ */
353
429
  function updateList() {
354
430
  $(`#${opts.containerName}`)
355
431
  .editableList('items')
@@ -366,7 +442,8 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
366
442
  $(`#${opts.containerRowName}`).show();
367
443
  }
368
444
 
369
- // Respond to clicks
445
+ // * CLICK RESPONSE * //
446
+
370
447
  $('#node-lookup-instance').click(function () {
371
448
  //When search button is clicked
372
449
  $('#instance-search-sid').val('');
@@ -381,6 +458,7 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
381
458
  $('#instance-row').hide();
382
459
  $('#instance-search-row').show();
383
460
  });
461
+
384
462
  $('#instance-search-sid').click(function () {
385
463
  //SID field clicked
386
464
  $('#instance-search-pid').val('');
@@ -431,6 +509,7 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
431
509
  }
432
510
  });
433
511
  }
512
+
434
513
  $('#node-search-return').click(function () {
435
514
  //Return/Back button clicked
436
515
  $('#node-search-return').addClass('disabled');
@@ -446,7 +525,10 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
446
525
  }
447
526
  });
448
527
 
449
- // Respond to search field changes
528
+ // * END CLICK RESPONSE * //
529
+
530
+ // * CHANGE RESPONSE * //
531
+
450
532
  $('#instance-search-hid').change(function () {
451
533
  acceptCheck();
452
534
  $('#instance-search-sid').val('');
@@ -456,18 +538,22 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
456
538
  $('#instance-search-rid').val('');
457
539
  }
458
540
  });
541
+
459
542
  $('#instance-search-sid').change(function () {
460
543
  searchObject.sid = $('#instance-search-sid').val();
461
544
  acceptCheck();
462
545
  });
546
+
463
547
  $('#instance-search-pid').change(function () {
464
548
  searchObject.pid = $('#instance-search-pid').val();
465
549
  acceptCheck();
466
550
  });
551
+
467
552
  $('#instance-search-ins').change(function () {
468
553
  searchObject.ins = $('#instance-search-ins').val();
469
554
  acceptCheck();
470
555
  });
556
+
471
557
  if (useRid) {
472
558
  $('#instance-search-rid').change(function () {
473
559
  searchObject.rid = $('#instance-search-rid').val();
@@ -475,6 +561,8 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
475
561
  });
476
562
  }
477
563
 
564
+ // * END CHANGE RESPONSE * //
565
+
478
566
  // reset input filed after init
479
567
  if (!listed) {
480
568
  $(`#${opts.uriFieldName}`).val(uriFieldValue);
@@ -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="instance-search-row">
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
- // *** MOBSEARCH *** //
123
-
124
- //Inital setup
125
- $("#instance-search-row").hide();
126
- $("#wildcard-alert-row").hide();
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')) {
@@ -28,7 +28,7 @@
28
28
  'use strict';
29
29
 
30
30
  module.exports = function (RED) {
31
- function MobiusClearResourceNode (n) {
31
+ function MobiusClearResourceNode(n) {
32
32
  RED.nodes.createNode(this, n);
33
33
  this.detailedOutput = n.detailedOutput;
34
34
  this.resource = n.resource;
@@ -40,7 +40,7 @@ module.exports = function (RED) {
40
40
  node.status({
41
41
  fill: 'red',
42
42
  shape: 'ring',
43
- text: 'Disconnected'
43
+ text: 'Disconnected',
44
44
  });
45
45
 
46
46
  node.on('input', function (msg) {
@@ -57,7 +57,7 @@ module.exports = function (RED) {
57
57
  node.status({
58
58
  fill: 'green',
59
59
  shape: 'ring',
60
- text: 'Busy'
60
+ text: 'Busy',
61
61
  });
62
62
 
63
63
  node.serviceConn.clearResourcePriority(uri, pri, (err, response) => {
@@ -65,29 +65,34 @@ module.exports = function (RED) {
65
65
  node.status({
66
66
  fill: 'yellow',
67
67
  shape: 'dot',
68
- text: 'Error: ' + JSON.stringify(err.code)
68
+ text: 'Error: ' + JSON.stringify(err.code),
69
69
  });
70
70
  node.error('Mobius error clearing resource priority ' + JSON.stringify(err));
71
71
  if (node.detailedOutput === true) {
72
- node.send([null, null, null, {topic: uri, payload: { error: true, response: err }}]);
72
+ node.send([
73
+ null,
74
+ null,
75
+ null,
76
+ { topic: uri, payload: { error: true, response: err } },
77
+ ]);
73
78
  }
74
79
  } else {
75
80
  node.status({
76
81
  fill: 'green',
77
82
  shape: 'dot',
78
- text: JSON.stringify(response.value.pv)
83
+ text: JSON.stringify(response.value.pv),
79
84
  });
80
85
  if (node.detailedOutput === true) {
81
86
  node.send([
82
87
  { topic: uri, payload: response.value.pv },
83
88
  { topic: uri, payload: { pv: response.value.pv, name: response.value.name } },
84
89
  { topic: uri, payload: response.value },
85
- { topic: uri, payload: { error: false, response: response } }
90
+ { topic: uri, payload: { error: false, response: response } },
86
91
  ]);
87
92
  } else {
88
93
  node.send([
89
94
  { topic: uri, payload: response.value.pv },
90
- { topic: uri, payload: { pv: response.value.pv, name: response.value.name } }
95
+ { topic: uri, payload: { pv: response.value.pv, name: response.value.name } },
91
96
  ]);
92
97
  }
93
98
  }
@@ -106,4 +111,12 @@ module.exports = function (RED) {
106
111
  }
107
112
 
108
113
  RED.nodes.registerType('mobius clear resource', MobiusClearResourceNode);
114
+
115
+ RED.httpAdmin.get('/common/*', function (req, res) {
116
+ var options = {
117
+ root: __dirname + '/common/',
118
+ dotfiles: 'deny',
119
+ };
120
+ res.sendFile(req.params[0], options);
121
+ });
109
122
  };