node-red-contrib-mobius-flow-base 2.5.86-beta.7 → 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.
@@ -0,0 +1,568 @@
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
+ */
29
+ initMobsearch = {
30
+ // Standard mobsearch to rid level
31
+ toRid: (mobiusSrvc, opts) => {
32
+ getMobsearch(mobiusSrvc, true, false, opts);
33
+ },
34
+ // Standard mobsearch to ins level
35
+ toIns: (mobiusSrvc, opts) => {
36
+ getMobsearch(mobiusSrvc, false, false, opts);
37
+ },
38
+ // Mobsearch to rid level, for nodes using editable list
39
+ toRid_listed: (mobiusSrvc, opts) => {
40
+ getMobsearch(mobiusSrvc, true, true, opts);
41
+ },
42
+ // Mobsearch to ins level, for nodes using editable list
43
+ toIns_listed: (mobiusSrvc, opts) => {
44
+ getMobsearch(mobiusSrvc, false, true, opts);
45
+ },
46
+ };
47
+
48
+ // Make / Reset global selectionIndex vairable (variable to allow setting of correct list field)
49
+ if (typeof selectionIndex === undefined) {
50
+ let selectionIndex = 0;
51
+ }
52
+
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) {
60
+ field.click(function () {
61
+ selectionIndex = rowIndex;
62
+ $(`#${opts.containerRowName}`).hide();
63
+ $('#instance-search-sid').val('');
64
+ $('#instance-search-pid').val('');
65
+ $('#instance-search-ins').val('');
66
+ $('#instance-search-rid').val('');
67
+ $('#node-search-return').removeClass('disabled');
68
+ $('#node-search-accept').removeClass('disabled');
69
+ $('#instance-search-row').show();
70
+ });
71
+ }
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
+ */
80
+ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
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 * //
89
+
90
+ const resourceHtml = `
91
+ <input type="text" id="instance-search-hid" style="width:13%;" placeholder="HID">
92
+ <input type="text" id="instance-search-sid" style="width:8%;" placeholder="SID">
93
+ <input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
94
+ <input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
95
+ <input type="text" id="instance-search-rid" style="width:8%;" placeholder="RID">
96
+ `;
97
+
98
+ const instanceHtml = `
99
+ <input type="text" id="instance-search-hid" style="width:15%;" placeholder="HID">
100
+ <input type="text" id="instance-search-sid" style="width:10%;" placeholder="SID">
101
+ <input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
102
+ <input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
103
+ `;
104
+
105
+ //set level dependent html
106
+ let rows = useRid === true ? resourceHtml : instanceHtml;
107
+ let alertMsg = useRid === true ? `and/or RID ` : ``;
108
+
109
+ //Inject new html
110
+ document.getElementById(opts.htmlElementId).innerHTML += `
111
+ <div id="instance-search-row">
112
+ <div class="form-row">
113
+ <label for="instance-search-sid"><i class="fa fa-tasks"></i> URI</label>
114
+ ${rows}
115
+ <a id="node-search-return" class="searchbutton" style="vertical-align: middle"><i id="node-search-return-icon" class="fa fa-arrow-left"></i></a>
116
+ <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>
117
+ </div>
118
+ </div>
119
+ <div id="wildcard-alert-row" class="form-row hidden" style="color:#555555" align="center">
120
+ <p>Please note: The selection of wildcard '+'
121
+ means a search for a specific instance or resource
122
+ cannot be performed. As such, enter the
123
+ INS ${alertMsg}manually.</p>
124
+ </div>
125
+ `;
126
+
127
+ if (!listed) {
128
+ //Add search button
129
+ document.getElementById('input-row').innerHTML += `
130
+ <a id="node-lookup-instance" class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>
131
+ `;
132
+ }
133
+
134
+ // * END HTML INJECTION * //
135
+
136
+ // * INIT SETUP * //
137
+
138
+ $('#instance-search-row').hide();
139
+ $('#wildcard-alert-row').hide();
140
+ $('#node-search-return').addClass('disabled');
141
+ $.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
142
+ $('#instance-search-hid').val(response);
143
+ });
144
+ let readyToAccept = false;
145
+
146
+ let searchObject = {};
147
+ if (listed) {
148
+ searchObject = {
149
+ hid: '',
150
+ sid: '',
151
+ pid: '',
152
+ ins: '',
153
+ rid: '',
154
+ objects: [],
155
+ };
156
+ } else {
157
+ searchObject = {
158
+ hid: $('#instance-search-hid').val(),
159
+ sid: $('#instance-search-sid').val(),
160
+ pid: $('#instance-search-pid').val(),
161
+ ins: $('#instance-search-ins').val(),
162
+ rid: $('#instance-search-rid').val(),
163
+ objects: [],
164
+ };
165
+ }
166
+
167
+ // * END INIT SETUP * //
168
+
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
+ */
174
+ function ridSearch(objects, ins) {
175
+ $.getJSON(
176
+ `mdiscover?mobius=${mobiusSrvc}&uri=${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`,
177
+ (response) => {
178
+ resList = response.value[0].resources;
179
+ ress = ['#'];
180
+ for (let j = 0; j < resList.length; j++) {
181
+ ress.push(`${resList[j].rid} - ${resList[j].name}`);
182
+ }
183
+ $('#instance-search-rid')
184
+ .autocomplete({
185
+ source: ress,
186
+ minLength: 0,
187
+ close: function (event, ui) {
188
+ acceptCheck();
189
+ $('#instance-search-rid').autocomplete('destroy');
190
+ $('#instance-search-rid').val($('#instance-search-rid').val().substring(0, 2));
191
+ searchObject.rid = $('#instance-search-rid').val();
192
+ },
193
+ })
194
+ .autocomplete('search', '');
195
+ }
196
+ );
197
+ }
198
+
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
+ */
204
+ function insSearch(objects, pid) {
205
+ let inss = ['#', '+'];
206
+ for (let i = 0; i < objects.length; i++) {
207
+ if (objects[i].pid === pid) {
208
+ const name = objects[i].resources[1].pv;
209
+ if (name === '') {
210
+ inss.push(objects[i].ins);
211
+ } else {
212
+ inss.push(`${objects[i].ins} - ${name}`);
213
+ }
214
+ }
215
+ }
216
+ $('#instance-search-ins')
217
+ .autocomplete({
218
+ source: inss,
219
+ minLength: 0,
220
+ close: function (event, ui) {
221
+ acceptCheck();
222
+ $('#instance-search-ins').autocomplete('destroy');
223
+ if ($('#instance-search-ins').val().length > 4) {
224
+ $('#instance-search-ins').val($('#instance-search-ins').val().substring(0, 4));
225
+ }
226
+ searchObject.ins = $('#instance-search-ins').val();
227
+ },
228
+ })
229
+ .autocomplete('search', '');
230
+ }
231
+
232
+ /**
233
+ * Search for PIDs present on selected service
234
+ * @param {object} objects - Response from call to Mobius, list of mobius objects
235
+ */
236
+ function pidsSearch(objects) {
237
+ searchObject.objects = objects;
238
+ let pids = ['#', '+'];
239
+ for (let i = 0; i < objects.length; i++) {
240
+ pids.push(`${objects[i].pid} - ${objects[i].profileName}`);
241
+ }
242
+ pids = [...new Set(pids)];
243
+ $('#instance-search-pid')
244
+ .autocomplete({
245
+ source: pids,
246
+ minLength: 0,
247
+ close: function (event, ui) {
248
+ acceptCheck();
249
+ $('#instance-search-pid').autocomplete('destroy');
250
+ if ($('#instance-search-pid').val().length > 4) {
251
+ $('#instance-search-pid').val($('#instance-search-pid').val().substring(0, 4));
252
+ }
253
+ searchObject.pid = $('#instance-search-pid').val();
254
+ },
255
+ })
256
+ .autocomplete('search', '');
257
+ }
258
+
259
+ /**
260
+ * Search for SIDs, and then fetch child objects based on selection
261
+ * @param {object} response - Response from call to Mobius
262
+ */
263
+ function serviceSearch(response) {
264
+ let services = ['#', '+'];
265
+ for (let i = 0; i < response.length; i++) {
266
+ if (response[i].sid !== '009') {
267
+ services.push(`${response[i].sid} - ${response[i].name}`);
268
+ }
269
+ }
270
+ $('#instance-search-sid')
271
+ .autocomplete({
272
+ source: services,
273
+ minLength: 0,
274
+ close: function (event, ui) {
275
+ acceptCheck();
276
+ $('#instance-search-sid').autocomplete('destroy');
277
+ if ($('#instance-search-sid').val().length > 3) {
278
+ $('#instance-search-sid').val($('#instance-search-sid').val().substring(0, 3));
279
+ }
280
+ searchObject.sid = $('#instance-search-sid').val();
281
+ if (searchObject.sid === '+') {
282
+ for (let i = 2; i < services.length; i++) {
283
+ $.getJSON(
284
+ `mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${services[
285
+ i
286
+ ].substring(0, 3)}`,
287
+ (objects) => {
288
+ searchObject.objects = searchObject.objects.concat(objects);
289
+ }
290
+ );
291
+ }
292
+ } else {
293
+ $.getJSON(
294
+ `mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${searchObject.sid}`,
295
+ (objects) => {
296
+ searchObject.objects = objects;
297
+ }
298
+ );
299
+ }
300
+ },
301
+ })
302
+ .autocomplete('search', '');
303
+ }
304
+
305
+ /**
306
+ * Start mobsearch
307
+ */
308
+ function startSearch() {
309
+ $('#wildcard-alert-row').hide();
310
+ $('#instance-search-sid').val('');
311
+ $('#instance-search-pid').val('');
312
+ $('#instance-search-ins').val('');
313
+ searchObject.hid = $('#instance-search-hid').val();
314
+ searchObject.sid = '';
315
+ searchObject.pid = '';
316
+ searchObject.ins = '';
317
+ if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
318
+ $.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch).fail(
319
+ (err) => {
320
+ console.log('Mobsearch failed to contact Mobius');
321
+ }
322
+ );
323
+ }
324
+ }
325
+
326
+ /**
327
+ * Finish mobsearch, compile full URI and set value in host node
328
+ */
329
+ function finishSearch() {
330
+ $('#wildcard-alert-row').hide();
331
+ let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`;
332
+ if (useRid) {
333
+ uri = uri + `/${searchObject.rid}`;
334
+ }
335
+ if (uri.includes('#')) {
336
+ uri = uri.substring(0, uri.indexOf('#') + 1);
337
+ }
338
+ if (listed) {
339
+ opts.list[selectionIndex].uri = uri;
340
+ updateList();
341
+ } else {
342
+ $(`#${opts.uriFieldName}`).val(uri);
343
+ }
344
+ $('#node-search-accept').css('color', '#CCCCCC');
345
+ readyToAccept = false;
346
+ $('#node-search-return').addClass('disabled');
347
+ $('#node-search-accept').addClass('disabled');
348
+ $('#node-lookup-instance').removeClass('disabled');
349
+ $('#instance-search-row').hide();
350
+ $('#instance-row').show();
351
+ }
352
+
353
+ /**
354
+ * Update if accept button is grade out and functional, based on conditions of fields
355
+ */
356
+ function acceptCheck() {
357
+ if (useRid) {
358
+ checkFieldsToRid();
359
+ } else {
360
+ checkFieldsToIns();
361
+ }
362
+ checkWildcards();
363
+ }
364
+
365
+ /**
366
+ * Check state of all field to rid level, change state of accept button accordingly
367
+ */
368
+ function checkFieldsToRid() {
369
+ if (
370
+ ($('#instance-search-hid').val() !== '' &&
371
+ $('#instance-search-sid').val() !== '' &&
372
+ $('#instance-search-pid').val() !== '' &&
373
+ $('#instance-search-ins').val() !== '' &&
374
+ $('#instance-search-rid').val() !== '') ||
375
+ $('#instance-search-sid').val() === '#' ||
376
+ $('#instance-search-pid').val() === '#' ||
377
+ $('#instance-search-ins').val() === '#' ||
378
+ $('#instance-search-rid').val() === '#'
379
+ ) {
380
+ $('#node-search-accept').css('color', '#555555');
381
+ readyToAccept = true;
382
+ } else {
383
+ $('#node-search-accept').css('color', '#CCCCCC');
384
+ readyToAccept = false;
385
+ }
386
+ }
387
+
388
+ /**
389
+ * Check state of all field to ins level, change state of accept button accordingly
390
+ */
391
+ function checkFieldsToIns() {
392
+ if (
393
+ ($('#instance-search-hid').val() !== '' &&
394
+ $('#instance-search-sid').val() !== '' &&
395
+ $('#instance-search-pid').val() !== '' &&
396
+ $('#instance-search-ins').val() !== '') ||
397
+ $('#instance-search-sid').val() === '#' ||
398
+ $('#instance-search-pid').val() === '#' ||
399
+ $('#instance-search-ins').val() === '#'
400
+ ) {
401
+ $('#node-search-accept').css('color', '#555555');
402
+ readyToAccept = true;
403
+ } else {
404
+ $('#node-search-accept').css('color', '#CCCCCC');
405
+ readyToAccept = false;
406
+ }
407
+ }
408
+
409
+ /**
410
+ * Checks if + wildcard values are present, shows / hides alert message accordingly
411
+ */
412
+ function checkWildcards() {
413
+ if (
414
+ $('#instance-search-sid').val() !== '+' &&
415
+ $('#instance-search-pid').val() !== '+' &&
416
+ $('#instance-search-ins').val() !== '+'
417
+ ) {
418
+ $('#wildcard-alert-row').hide();
419
+ } else {
420
+ $('#wildcard-alert-row').show();
421
+ }
422
+ }
423
+
424
+ /**
425
+ * Update editable list with results from mobsearch
426
+ */
427
+ function updateList() {
428
+ $(`#${opts.containerName}`)
429
+ .editableList('items')
430
+ .each(function (i) {
431
+ let item = $(this);
432
+ let secondField = item.find(`.${opts.containerSecondFieldName}`).val();
433
+ opts.list[i][Object.keys(opts.list[i])[1]] = secondField;
434
+ });
435
+ $(`#${opts.containerName}`).editableList('empty');
436
+ for (let i = 0; i < opts.list.length; i++) {
437
+ let item = opts.list[i];
438
+ $(`#${opts.containerName}`).editableList('addItem', item);
439
+ }
440
+ $(`#${opts.containerRowName}`).show();
441
+ }
442
+
443
+ // * CLICK RESPONSE * //
444
+
445
+ $('#node-lookup-instance').click(function () {
446
+ //When search button is clicked
447
+ $('#instance-search-sid').val('');
448
+ $('#instance-search-pid').val('');
449
+ $('#instance-search-ins').val('');
450
+ if (useRid) {
451
+ $('#instance-search-rid').val('');
452
+ }
453
+ $('#node-lookup-instance').addClass('disabled');
454
+ $('#node-search-return').removeClass('disabled');
455
+ $('#node-search-accept').removeClass('disabled');
456
+ $('#instance-row').hide();
457
+ $('#instance-search-row').show();
458
+ });
459
+
460
+ $('#instance-search-sid').click(function () {
461
+ //SID field clicked
462
+ $('#instance-search-pid').val('');
463
+ $('#instance-search-ins').val('');
464
+ searchObject.pid = '';
465
+ searchObject.ins = '';
466
+ if (useRid) {
467
+ searchObject.rid = '';
468
+ }
469
+ searchObject.objects = [];
470
+ startSearch();
471
+ });
472
+ $('#instance-search-pid').click(function () {
473
+ //PID field clicked
474
+ $('#instance-search-ins').val('');
475
+
476
+ searchObject.ins = '';
477
+
478
+ if (useRid) {
479
+ $('#instance-search-rid').val('');
480
+ searchObject.rid = '';
481
+ }
482
+ if (searchObject.sid !== '') {
483
+ pidsSearch(searchObject.objects);
484
+ }
485
+ });
486
+ $('#instance-search-ins').click(function () {
487
+ //INS field clicked
488
+ if (useRid) {
489
+ $('#instance-search-rid').val('');
490
+ searchObject.rid = '';
491
+ }
492
+ if (searchObject.pid !== '' && searchObject.pid !== '+' && searchObject.sid !== '+') {
493
+ insSearch(searchObject.objects, searchObject.pid);
494
+ }
495
+ });
496
+
497
+ if (useRid) {
498
+ $('#instance-search-rid').click(function () {
499
+ //RID clicked
500
+ if (
501
+ searchObject.ins !== '' &&
502
+ searchObject.ins !== '+' &&
503
+ searchObject.pid !== '+' &&
504
+ searchObject.sid !== '+'
505
+ ) {
506
+ ridSearch(searchObject.objects, searchObject.ins);
507
+ }
508
+ });
509
+ }
510
+
511
+ $('#node-search-return').click(function () {
512
+ //Return/Back button clicked
513
+ $('#node-search-return').addClass('disabled');
514
+ $('#node-search-accept').addClass('disabled');
515
+ $('#node-lookup-instance').removeClass('disabled');
516
+ $('#instance-search-row').hide();
517
+ $('#instance-row').show();
518
+ });
519
+ $('#node-search-accept').click(function () {
520
+ //Accept button clicked
521
+ if (readyToAccept) {
522
+ finishSearch();
523
+ }
524
+ });
525
+
526
+ // * END CLICK RESPONSE * //
527
+
528
+ // * CHANGE RESPONSE * //
529
+
530
+ $('#instance-search-hid').change(function () {
531
+ acceptCheck();
532
+ $('#instance-search-sid').val('');
533
+ $('#instance-search-pid').val('');
534
+ $('#instance-search-ins').val('');
535
+ if (useRid) {
536
+ $('#instance-search-rid').val('');
537
+ }
538
+ });
539
+
540
+ $('#instance-search-sid').change(function () {
541
+ searchObject.sid = $('#instance-search-sid').val();
542
+ acceptCheck();
543
+ });
544
+
545
+ $('#instance-search-pid').change(function () {
546
+ searchObject.pid = $('#instance-search-pid').val();
547
+ acceptCheck();
548
+ });
549
+
550
+ $('#instance-search-ins').change(function () {
551
+ searchObject.ins = $('#instance-search-ins').val();
552
+ acceptCheck();
553
+ });
554
+
555
+ if (useRid) {
556
+ $('#instance-search-rid').change(function () {
557
+ searchObject.rid = $('#instance-search-rid').val();
558
+ acceptCheck();
559
+ });
560
+ }
561
+
562
+ // * END CHANGE RESPONSE * //
563
+
564
+ // reset input filed after init
565
+ if (!listed) {
566
+ $(`#${opts.uriFieldName}`).val(uriFieldValue);
567
+ }
568
+ }
@@ -29,10 +29,18 @@ POSSIBILITY OF SUCH DAMAGE.
29
29
  <label for="node-input-connection"><i class="fa fa-globe"></i> MOBiUS</label>
30
30
  <input type="text" id="node-input-connection">
31
31
  </div>
32
- <div class="form-row">
33
- <label for="node-input-resource"><i class="fa fa-tasks"></i> URI</label>
34
- <input type="text" id="node-input-resource" placeholder="Resource URI (hid/sid/pid/ins/rid)">
32
+
33
+ <hr>
34
+
35
+ <div id="instance-row">
36
+ <div class="form-row">
37
+ <label for="node-input-resource"><i class="fa fa-tasks"></i> URI</label>
38
+ <input type="text" id="node-input-resource" style="width:61%;" placeholder="HID/SID/PID/INS/RID">
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
+ </div>
35
41
  </div>
42
+ <div id="mobsearch"></div>
43
+
36
44
  <div class="form-row">
37
45
  <label for="node-input-priority"><i class="fa fa-exclamation-triangle"></i> Priority</label>
38
46
  <input type="text" id="node-input-priority" placeholder="Priotity to clear">
@@ -49,6 +57,8 @@ POSSIBILITY OF SUCH DAMAGE.
49
57
  </div>
50
58
  </script>
51
59
 
60
+ <script src="common/mobsearch.js"></script>
61
+
52
62
  <script type="text/javascript">
53
63
  RED.nodes.registerType('mobius clear resource',{
54
64
  category: 'mobius',
@@ -90,6 +100,16 @@ POSSIBILITY OF SUCH DAMAGE.
90
100
  labelStyle: function() {
91
101
  return this.name ? "node_label_italic":"";
92
102
  },
103
+ oneditprepare: function () {
104
+ var node = this;
105
+ let mobiusSrvc = $("#node-input-connection").val();
106
+
107
+ opts = {
108
+ htmlElementId: 'mobsearch',
109
+ uriFieldName: 'node-input-resource'
110
+ };
111
+ initMobsearch.toRid(mobiusSrvc, opts);
112
+ },
93
113
  oneditsave: function() {
94
114
  if($("#node-input-detailedOutput").prop('checked')) {
95
115
  this.outputs = 4;
@@ -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
  };