node-red-contrib-mobius-flow-base 2.5.86-beta.7 → 2.5.86-beta.73

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