node-red-contrib-mobius-flow-base 2.5.86-beta.25 → 2.5.86-beta.29

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.
@@ -661,4 +661,14 @@ module.exports = function (RED) {
661
661
  });
662
662
  }
663
663
  });
664
+
665
+ RED.httpAdmin.get('/mgethid', RED.auth.needsPermission('serial.read'), function (req, res) {
666
+ let conn = RED.nodes.getNode(req.query.mobius);
667
+ if (conn === null || !conn.service.connected) {
668
+ RED.log.error('Get hid failed - could not to connect to MOBiUS hub.');
669
+ throw new Error('Get hid failed - could not to connect to MOBiUS hub.');
670
+ } else {
671
+ res.json(conn.service.srvcAPI.status.hubId);
672
+ }
673
+ });
664
674
  };
@@ -57,6 +57,25 @@ POSSIBILITY OF SUCH DAMAGE.
57
57
  <label for="node-input-subs-container" style="width:105px;float:left;"><i class="fa fa-bars"></i> Discover</label>
58
58
  <ol id="node-input-subs-container"></ol>
59
59
  </div>
60
+
61
+ <div id="instance-search-row">
62
+ <div class="form-row">
63
+ <label for="instance-search-sid"><i class="fa fa-tasks"></i> URI</label>
64
+ <input type="text" id="instance-search-hid" style="width:15%;" placeholder="HID">
65
+ <input type="text" id="instance-search-sid" style="width:10%;" placeholder="SID">
66
+ <input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
67
+ <input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
68
+ <a id="node-search-return" class="searchbutton" style="vertical-align: middle"><i id="node-search-return-icon" class="fa fa-arrow-left"></i></a>
69
+ <a id="node-search-accept" class="searchbutton" style="vertical-align: middle"><i id="node-search-accept-icon" class="fa fa-check"></i></a>
70
+ </div>
71
+ </div>
72
+ <div id="wildcard-alert-row" class="form-row hidden" style="color:#555555" align="center">
73
+ <p>Please note: The selection of wildcard '+'
74
+ means a search for a specific instance or resource
75
+ cannot be performed. As such, enter the
76
+ INS manually.</p>
77
+ </div>
78
+
60
79
  <div class="form-row">
61
80
  <label for="node-input-useRIDValueFiltering" style="width:178px;float:left;"><i class="fa fa-filter"></i> Filter by Resource Value</label>
62
81
  <input type="checkbox" id="node-input-useRIDValueFiltering" style="display: inline-block; width: auto; vertical-align: top;">
@@ -119,6 +138,215 @@ POSSIBILITY OF SUCH DAMAGE.
119
138
  },
120
139
  oneditprepare: function () {
121
140
  var node = this;
141
+ let mobiusSrvc = $("#node-input-connection").val();
142
+
143
+ // *** MOBSEARCH *** //
144
+
145
+ $("#instance-search-row").hide();
146
+ $("#wildcard-alert-row").hide();
147
+ $("#node-search-return").addClass('disabled');
148
+ $.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
149
+ $("#instance-search-hid").val(response);
150
+ })
151
+
152
+ let globalSubscriptionIndex = 0;
153
+
154
+ let searchObject = {
155
+ hid: '',
156
+ sid: '',
157
+ pid: '',
158
+ ins: '',
159
+ objects: []
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
+ searchObject.objects = [];
255
+ if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
256
+ $.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch)
257
+ .fail((err) => {
258
+ console.log('Some kind of html failure message on service discovery');
259
+ });
260
+ }
261
+ }
262
+
263
+ //Finish a search
264
+ function finishSearch() {
265
+ $("#wildcard-alert-row").hide();
266
+ let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`
267
+ if (uri.includes('#')) {
268
+ uri = uri.substring(0,uri.indexOf('#') + 1)
269
+ }
270
+ node.subscriptions[globalSubscriptionIndex].uri = uri;
271
+ updateList()
272
+ $("#node-search-accept").css('color', '#CCCCCC');
273
+ readyToAccept = false;
274
+ $("#node-search-return").addClass('disabled');
275
+ $("#node-search-accept").addClass('disabled');
276
+ $("#instance-search-row").hide();
277
+ $('#node-input-subs-container-row').show();
278
+ }
279
+
280
+ //Function to update if accept button is grade out and functions based on conditions of fields
281
+ function acceptCheck() {
282
+ if (($("#instance-search-hid").val() !== '' && $("#instance-search-sid").val() !== '' && $("#instance-search-pid").val() !== '' && $("#instance-search-ins").val() !== '') ||
283
+ $("#instance-search-sid").val() === '#' || $("#instance-search-pid").val() === '#' || $("#instance-search-ins").val() === '#') {
284
+ $("#node-search-accept").css('color', '#555555');
285
+ readyToAccept = true;
286
+ } else {
287
+ $("#node-search-accept").css('color', '#CCCCCC');
288
+ readyToAccept = false;
289
+ }
290
+ if ($("#instance-search-sid").val() !== '+' && $("#instance-search-pid").val() !== '+') {
291
+ $("#wildcard-alert-row").hide();
292
+ } else {
293
+ $("#wildcard-alert-row").show();
294
+ }
295
+ }
296
+
297
+ $("#instance-search-sid").click(function () { //SID field clicked
298
+ $("#instance-search-pid").val('')
299
+ $("#instance-search-ins").val('')
300
+ searchObject.pid = '';
301
+ searchObject.ins = '';
302
+ searchObject.objects = [];
303
+ startSearch();
304
+ })
305
+ $("#instance-search-pid").click(function () { //PID field clicked
306
+ $("#instance-search-ins").val('')
307
+ searchObject.ins = '';
308
+ if (searchObject.sid !== '') {
309
+ pidsSearch(searchObject.objects);
310
+ }
311
+ })
312
+ $("#instance-search-ins").click(function () { //INS field clicked
313
+ if (searchObject.pid !== '' && searchObject.pid !== '+' && searchObject.sid !== '+') {
314
+ insSearch(searchObject.objects, searchObject.pid);
315
+ }
316
+ })
317
+ $("#node-search-return").click(function () { //Return/Back button clicked
318
+ $("#node-search-return").addClass('disabled');
319
+ $("#node-search-accept").addClass('disabled');
320
+ $("#instance-search-row").hide();
321
+ $('#node-input-subs-container-row').show();
322
+ });
323
+ $("#node-search-accept").click(function () { //Accept button clicked
324
+ if (readyToAccept) {
325
+ finishSearch();
326
+ }
327
+ });
328
+
329
+ // Respond to search field changes
330
+ $("#instance-search-hid").change(function () {
331
+ acceptCheck();
332
+ $("#instance-search-sid").val('');
333
+ $("#instance-search-pid").val('');
334
+ $("#instance-search-ins").val('');
335
+ });
336
+ $("#instance-search-sid").change(function () {
337
+ searchObject.sid = $("#instance-search-sid").val()
338
+ acceptCheck();
339
+ });
340
+ $("#instance-search-pid").change(function () {
341
+ searchObject.pid = $("#instance-search-pid").val()
342
+ acceptCheck();
343
+ });
344
+ $("#instance-search-ins").change(function () {
345
+ searchObject.ins = $("#instance-search-ins").val()
346
+ acceptCheck();
347
+ });
348
+
349
+ // *** END MOBSEARCH *** //
122
350
 
123
351
  /** Create the subs container and populate it */
124
352
  $('#node-input-subs-container').css('min-height', '200px').css('min-width', '345px').editableList ({
@@ -138,6 +366,11 @@ POSSIBILITY OF SUCH DAMAGE.
138
366
 
139
367
  var row = $('<div>URI</div>').appendTo(container);
140
368
  var uriField = $('<input/>',{class: "node-input-sub-uri", type: "text", style: "width: 170px; margin-left: 5px; text-align: left;"}).appendTo(row);
369
+
370
+ // *** MOBSEARCH *** //
371
+ var searchField = $('<a class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
372
+ // *** END MOBSEARCH *** //
373
+
141
374
  var typeField = $('<select/>',{class: "node-input-sub-type", style: "width:auto; margin-left: 5px; text-align: center;"}).appendTo(row);
142
375
  typeField.append($("<option></option>").val('include').text('Include'));
143
376
  typeField.append($("<option></option>").val('exclude').text('Exclude'));
@@ -145,6 +378,25 @@ POSSIBILITY OF SUCH DAMAGE.
145
378
  // Populate the new stat
146
379
  uriField.val(subscription.uri);
147
380
  typeField.val(subscription.type);
381
+
382
+ // *** MOBSEARCH *** //
383
+
384
+ if (!node.subscriptions[i]) {
385
+ node.subscriptions[i] = {uri: '', type: 'include'}
386
+ }
387
+
388
+ searchField.click(function () {
389
+ globalSubscriptionIndex = i;
390
+ $('#node-input-subs-container-row').hide();
391
+ $("#instance-search-sid").val('');
392
+ $("#instance-search-pid").val('');
393
+ $("#instance-search-ins").val('');
394
+ $("#node-search-return").removeClass('disabled');
395
+ $("#node-search-accept").removeClass('disabled');
396
+ $("#instance-search-row").show();
397
+
398
+ });
399
+ // *** END MOBSEARCH *** //
148
400
  }
149
401
  });
150
402
 
@@ -154,11 +406,19 @@ POSSIBILITY OF SUCH DAMAGE.
154
406
  if (!node.subscriptions) {
155
407
  node.subscriptions = [subscription = {uri: '', type: 'include'}];
156
408
  }
157
- // Populate list with all saved filters
158
- for (let i = 0; i < node.subscriptions.length; i++) {
159
- let subscription = node.subscriptions[i];
160
- $("#node-input-subs-container").editableList('addItem', subscription);
409
+
410
+ // *** MOBSEARCH *** //
411
+
412
+ function updateList() {
413
+ $("#node-input-subs-container").editableList('empty');
414
+ for (let i = 0; i < node.subscriptions.length; i++) {
415
+ let subscription = node.subscriptions[i];
416
+ $("#node-input-subs-container").editableList('addItem', subscription);
417
+ }
161
418
  }
419
+ updateList()
420
+
421
+ // *** END MOBSEARCH *** //
162
422
 
163
423
  function showRIDFilterInputs() {
164
424
  if($("#node-input-useRIDValueFiltering").is(':checked')) {
@@ -29,9 +29,35 @@ 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-mobject"><i class="fa fa-tasks"></i> URI</label>
34
- <input type="text" id="node-input-mobject" placeholder="Object URI (hid/sid/pid/ins)">
32
+ <div id="instance-message-row" class="form-row hidden" style="color:#ff0000" align="center">
33
+ <p>To select a configured object from a drop-down list, <br/>
34
+ please create a MOBiUS connection, deploy the flow, and <br />
35
+ ensure that the node-red-connector service is running. <br />
36
+ Click the Confirm Deploy button if asked.</p>
37
+ </div>
38
+ <div id="instance-row">
39
+ <div class="form-row">
40
+ <label for="node-input-instance"><i class="fa fa-tasks"></i> URI</label>
41
+ <input type="text" id="node-input-instance" style="width:61%;" placeholder="HID/SID/PID/INS (optional name)">
42
+ <a id="node-lookup-instance" class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>
43
+ </div>
44
+ </div>
45
+ <div id="instance-search-row">
46
+ <div class="form-row">
47
+ <label for="instance-search-sid"><i class="fa fa-tasks"></i> URI</label>
48
+ <input type="text" id="instance-search-hid" style="width:15%;" placeholder="HID">
49
+ <input type="text" id="instance-search-sid" style="width:10%;" placeholder="SID">
50
+ <input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
51
+ <input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
52
+ <a id="node-search-return" class="searchbutton" style="vertical-align: middle"><i id="node-search-return-icon" class="fa fa-arrow-left"></i></a>
53
+ <a id="node-search-accept" class="searchbutton" style="vertical-align: middle"><i id="node-search-accept-icon" class="fa fa-check"></i></a>
54
+ </div>
55
+ </div>
56
+ <div id="wildcard-alert-row" class="form-row hidden" style="color:#555555" align="center">
57
+ <p>Please note: The selection of wildcard '+'
58
+ means a search for a specific instance or resource
59
+ cannot be performed. As such, enter the
60
+ INS manually.</p>
35
61
  </div>
36
62
  <div class="form-row">
37
63
  <label for="node-input-format"><i class="fa fa-bars"></i> Format</label>
@@ -60,7 +86,7 @@ POSSIBILITY OF SUCH DAMAGE.
60
86
  name: {value: ""},
61
87
  detailedOutput: {value:false},
62
88
  format: {value: "name", required: true},
63
- mobject: {value: "", validate:function(v) {
89
+ instance: {value: "", validate:function(v) {
64
90
  if(v === '') { return true; }
65
91
  let parts = v.split('/');
66
92
  for(let lp = 0; lp < parts.length; lp++) {
@@ -86,12 +112,251 @@ POSSIBILITY OF SUCH DAMAGE.
86
112
  if(this.name) {
87
113
  return this.name;
88
114
  } else {
89
- return this.mobject ? `Get - ${this.mobject}` : "get object";
115
+ return this.instance ? `Get - ${this.instance}` : "get object";
90
116
  }
91
117
  },
92
118
  labelStyle: function() {
93
119
  return this.name ? "node_label_italic":"";
94
120
  },
121
+ oneditprepare: function () {
122
+
123
+ var node = this;
124
+ let mobiusSrvc = $("#node-input-connection").val();
125
+
126
+ $("#instance-search-row").hide();
127
+
128
+ function doesMobiusServiceExist() {
129
+ let srvc = $("#node-input-mobius").val();
130
+ if (srvc === '_ADD_') {
131
+ $("#node-lookup-instance").hide();
132
+ $("#instance-message-row").show();
133
+ } else {
134
+ $("#instance-message-row").hide();
135
+ $("#node-lookup-instance").show();
136
+ }
137
+ }
138
+ doesMobiusServiceExist();
139
+
140
+ $("#node-search-return").addClass('disabled');
141
+
142
+ // *** MOBSEARCH *** //
143
+
144
+ //Inital setup
145
+ $("#instance-search-row").hide();
146
+ $("#wildcard-alert-row").hide();
147
+ $("#node-search-return").addClass('disabled');
148
+ $.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
149
+ $("#instance-search-hid").val(response);
150
+ })
151
+ let readyToAccept = false;
152
+ let searchObject = {
153
+ hid: $("#instance-search-hid").val(),
154
+ sid: $("#instance-search-sid").val(),
155
+ pid: $("#instance-search-pid").val(),
156
+ ins: $("#instance-search-ins").val(),
157
+ objects: []
158
+ }
159
+
160
+ //Function to search for INSs
161
+ function insSearch (objects, pid) {
162
+ let inss = ['#'];
163
+ for (let i = 0; i < objects.length; i++) {
164
+ if (objects[i].pid === pid) {
165
+ const name = objects[i].resources[1].pv;
166
+ if (name === '') {
167
+ inss.push(objects[i].ins);
168
+ } else {
169
+ inss.push(`${objects[i].ins} - ${name}`);
170
+ }
171
+ }
172
+ }
173
+ $("#instance-search-ins").autocomplete({
174
+ source: inss,
175
+ minLength: 0,
176
+ close: function (event, ui) {
177
+ acceptCheck();
178
+ $("#instance-search-ins").autocomplete('destroy');
179
+ if ($("#instance-search-ins").val().length > 4) {
180
+ $("#instance-search-ins").val($("#instance-search-ins").val().substring(0, 4))
181
+ }
182
+ searchObject.ins = $("#instance-search-ins").val();
183
+ }
184
+ }).autocomplete('search', '');
185
+ }
186
+
187
+ //Function to search for PIDs
188
+ function pidsSearch(objects) {
189
+ searchObject.objects = objects;
190
+ let pids = ['#', '+'];
191
+ for (let i = 0; i < objects.length; i++) {
192
+ pids.push(`${objects[i].pid} - ${objects[i].profileName}`);
193
+ }
194
+ pids = [...new Set(pids)];
195
+ $("#instance-search-pid").autocomplete({
196
+ source: pids,
197
+ minLength: 0,
198
+ close: function (event, ui) {
199
+ acceptCheck();
200
+ $("#instance-search-pid").autocomplete('destroy');
201
+ if ($("#instance-search-pid").val().length > 4) {
202
+ $("#instance-search-pid").val($("#instance-search-pid").val().substring(0, 4))
203
+ }
204
+ searchObject.pid = $("#instance-search-pid").val();
205
+ }
206
+ }).autocomplete('search', '');
207
+ }
208
+
209
+ //Function to search for SIDs, and then fetch child objects based on selection
210
+ function serviceSearch(response) {
211
+ let services = ['#', '+'];
212
+ for (let i = 0; i < response.length; i++) {
213
+ if (response[i].sid !== '009') {
214
+ services.push(`${response[i].sid} - ${response[i].name}`);
215
+ }
216
+ }
217
+ $("#instance-search-sid").autocomplete({
218
+ source: services,
219
+ minLength: 0,
220
+ close: function (event, ui) {
221
+ acceptCheck();
222
+ $("#instance-search-sid").autocomplete('destroy');
223
+ if ($("#instance-search-sid").val().length > 3) {
224
+ $("#instance-search-sid").val($("#instance-search-sid").val().substring(0, 3))
225
+ }
226
+ searchObject.sid = $("#instance-search-sid").val();
227
+ if (searchObject.sid === '+') {
228
+ for (let i = 2; i < services.length; i++) {
229
+ $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${services[i].substring(0, 3)}`, (objects) => {
230
+ searchObject.objects = searchObject.objects.concat(objects);
231
+ })
232
+ }
233
+ } else {
234
+ $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${searchObject.sid}`, (objects) => {
235
+ searchObject.objects = objects;
236
+ })
237
+ }
238
+ }
239
+ }).autocomplete('search', '');
240
+ }
241
+
242
+ //Start a new search
243
+ function startSearch() {
244
+ $("#wildcard-alert-row").hide();
245
+ $("#instance-search-sid").val('');
246
+ $("#instance-search-pid").val('');
247
+ $("#instance-search-ins").val('');
248
+ searchObject.hid = $("#instance-search-hid").val()
249
+ searchObject.sid = '';
250
+ searchObject.pid = '';
251
+ searchObject.ins = '';
252
+ if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
253
+ $.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch)
254
+ .fail((err) => {
255
+ console.log('Some kind of html failure message on service discovery');
256
+ });
257
+ }
258
+ }
259
+
260
+ //Finish a search
261
+ function finishSearch() {
262
+ $("#wildcard-alert-row").hide();
263
+ let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`
264
+ if (uri.includes('#')) {
265
+ uri = uri.substring(0,uri.indexOf('#') + 1)
266
+ }
267
+ $("#node-input-instance").val(uri);
268
+ $("#node-search-accept").css('color', '#CCCCCC');
269
+ readyToAccept = false;
270
+ $("#node-search-return").addClass('disabled');
271
+ $("#node-search-accept").addClass('disabled');
272
+ $("#node-lookup-instance").removeClass('disabled');
273
+ $("#instance-search-row").hide();
274
+ $("#instance-row").show();
275
+ }
276
+
277
+ //Function to update if accept button is grade out and functions based on conditions of fields
278
+ function acceptCheck() {
279
+ if (($("#instance-search-hid").val() !== '' && $("#instance-search-sid").val() !== '' && $("#instance-search-pid").val() !== '' && $("#instance-search-ins").val() !== '') ||
280
+ $("#instance-search-sid").val() === '#' || $("#instance-search-pid").val() === '#' || $("#instance-search-ins").val() === '#') {
281
+ $("#node-search-accept").css('color', '#555555');
282
+ readyToAccept = true;
283
+ } else {
284
+ $("#node-search-accept").css('color', '#CCCCCC');
285
+ readyToAccept = false;
286
+ }
287
+ if ($("#instance-search-sid").val() !== '+' && $("#instance-search-pid").val() !== '+') {
288
+ $("#wildcard-alert-row").hide();
289
+ } else {
290
+ $("#wildcard-alert-row").show();
291
+ }
292
+ }
293
+
294
+ // Respond to clicks
295
+ $("#node-lookup-instance").click(function () { //When search button is clicked
296
+ $("#instance-search-sid").val('');
297
+ $("#instance-search-pid").val('');
298
+ $("#instance-search-ins").val('');
299
+ $("#node-lookup-instance").addClass('disabled');
300
+ $("#node-search-return").removeClass('disabled');
301
+ $("#node-search-accept").removeClass('disabled');
302
+ $("#instance-row").hide();
303
+ $("#instance-search-row").show();
304
+ });
305
+ $("#instance-search-sid").click(function () { //SID field clicked
306
+ $("#instance-search-pid").val('')
307
+ $("#instance-search-ins").val('')
308
+ searchObject.pid = '';
309
+ searchObject.ins = '';
310
+ searchObject.objects = [];
311
+ startSearch();
312
+ })
313
+ $("#instance-search-pid").click(function () { //PID field clicked
314
+ $("#instance-search-ins").val('')
315
+ searchObject.ins = '';
316
+ if (searchObject.sid !== '') {
317
+ pidsSearch(searchObject.objects);
318
+ }
319
+ })
320
+ $("#instance-search-ins").click(function () { //INS field clicked
321
+ if (searchObject.pid !== '' && searchObject.pid !== '+' && searchObject.sid !== '+') {
322
+ insSearch(searchObject.objects, searchObject.pid);
323
+ }
324
+ })
325
+ $("#node-search-return").click(function () { //Return/Back button clicked
326
+ $("#node-search-return").addClass('disabled');
327
+ $("#node-search-accept").addClass('disabled');
328
+ $("#node-lookup-instance").removeClass('disabled');
329
+ $("#instance-search-row").hide();
330
+ $("#instance-row").show();
331
+ });
332
+ $("#node-search-accept").click(function () { //Accept button clicked
333
+ if (readyToAccept) {
334
+ finishSearch();
335
+ }
336
+ });
337
+
338
+ // Respond to search field changes
339
+ $("#instance-search-hid").change(function () {
340
+ acceptCheck();
341
+ $("#instance-search-sid").val('');
342
+ $("#instance-search-pid").val('');
343
+ $("#instance-search-ins").val('');
344
+ });
345
+ $("#instance-search-sid").change(function () {
346
+ searchObject.sid = $("#instance-search-sid").val()
347
+ acceptCheck();
348
+ });
349
+ $("#instance-search-pid").change(function () {
350
+ searchObject.pid = $("#instance-search-pid").val()
351
+ acceptCheck();
352
+ });
353
+ $("#instance-search-ins").change(function () {
354
+ searchObject.ins = $("#instance-search-ins").val()
355
+ acceptCheck();
356
+ });
357
+
358
+ // *** MOBSEARCH *** //
359
+ },
95
360
  oneditsave: function() {
96
361
  if($("#node-input-detailedOutput").prop('checked')) {
97
362
  this.outputs = 3;
@@ -30,11 +30,11 @@
30
30
  const _ = require('lodash');
31
31
 
32
32
  module.exports = function (RED) {
33
- function MobiusGetObjectNode (n) {
33
+ function MobiusGetObjectNode(n) {
34
34
  RED.nodes.createNode(this, n);
35
35
  this.detailedOutput = n.detailedOutput;
36
36
  this.format = n.format;
37
- this.mobject = n.mobject;
37
+ this.instance = n.instance;
38
38
  this.serviceConn = RED.nodes.getNode(n.connection);
39
39
  var node = this;
40
40
 
@@ -42,11 +42,11 @@ module.exports = function (RED) {
42
42
  node.status({
43
43
  fill: 'red',
44
44
  shape: 'ring',
45
- text: 'Disconnected'
45
+ text: 'Disconnected',
46
46
  });
47
47
 
48
48
  node.on('input', function (msg) {
49
- let uri = node.mobject;
49
+ let uri = node.instance;
50
50
  if (msg.hasOwnProperty('topic') && require('./validateURI')(msg.topic, 4)) {
51
51
  uri = msg.topic;
52
52
  }
@@ -54,32 +54,35 @@ module.exports = function (RED) {
54
54
  node.status({
55
55
  fill: 'green',
56
56
  shape: 'ring',
57
- text: 'Busy'
57
+ text: 'Busy',
58
58
  });
59
59
  node.serviceConn.readObject(uri, (err, response) => {
60
60
  if (err) {
61
61
  node.status({
62
62
  fill: 'yellow',
63
63
  shape: 'dot',
64
- text: 'Error: ' + JSON.stringify(err.code)
64
+ text: 'Error: ' + JSON.stringify(err.code),
65
65
  });
66
66
  node.error('Mobius error reading object ' + JSON.stringify(err));
67
67
  if (node.detailedOutput === true) {
68
- node.send([null, null, {topic: uri, payload: { error: true, response: err }}]);
68
+ node.send([null, null, { topic: uri, payload: { error: true, response: err } }]);
69
69
  }
70
70
  } else {
71
71
  node.status({
72
72
  fill: 'green',
73
73
  shape: 'dot',
74
- text: JSON.stringify(response.uri)
74
+ text: JSON.stringify(response.uri),
75
75
  });
76
76
 
77
- let allResources = _.keyBy(response.value.resources, node.format === 'name' ? 'name' : 'rid');
77
+ let allResources = _.keyBy(
78
+ response.value.resources,
79
+ node.format === 'name' ? 'name' : 'rid'
80
+ );
78
81
  if (node.detailedOutput === true) {
79
82
  node.send([
80
83
  { topic: uri, payload: allResources },
81
84
  { topic: uri, payload: response.value },
82
- { topic: uri, payload: { error: false, response: response } }
85
+ { topic: uri, payload: { error: false, response: response } },
83
86
  ]);
84
87
  } else {
85
88
  node.send({ topic: uri, payload: allResources });
@@ -29,9 +29,35 @@ 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-object"><i class="fa fa-tasks"></i> URI</label>
34
- <input type="text" id="node-input-object" placeholder="Object URI (hid/sid/pid/ins)">
32
+ <div id="instance-message-row" class="form-row hidden" style="color:#ff0000" align="center">
33
+ <p>To select a configured object from a drop-down list, <br/>
34
+ please create a MOBiUS connection, deploy the flow, and <br />
35
+ ensure that the node-red-connector service is running. <br />
36
+ Click the Confirm Deploy button if asked.</p>
37
+ </div>
38
+ <div id="instance-row">
39
+ <div class="form-row">
40
+ <label for="node-input-instance"><i class="fa fa-tasks"></i> URI</label>
41
+ <input type="text" id="node-input-instance" style="width:61%;" placeholder="HID/SID/PID/INS (optional name)">
42
+ <a id="node-lookup-instance" class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>
43
+ </div>
44
+ </div>
45
+ <div id="instance-search-row">
46
+ <div class="form-row">
47
+ <label for="instance-search-sid"><i class="fa fa-tasks"></i> URI</label>
48
+ <input type="text" id="instance-search-hid" style="width:15%;" placeholder="HID">
49
+ <input type="text" id="instance-search-sid" style="width:10%;" placeholder="SID">
50
+ <input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
51
+ <input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
52
+ <a id="node-search-return" class="searchbutton" style="vertical-align: middle"><i id="node-search-return-icon" class="fa fa-arrow-left"></i></a>
53
+ <a id="node-search-accept" class="searchbutton" style="vertical-align: middle"><i id="node-search-accept-icon" class="fa fa-check"></i></a>
54
+ </div>
55
+ </div>
56
+ <div id="wildcard-alert-row" class="form-row hidden" style="color:#555555" align="center">
57
+ <p>Please note: The selection of wildcard '+'
58
+ means a search for a specific instance or resource
59
+ cannot be performed. As such, enter the
60
+ INS manually.</p>
35
61
  </div>
36
62
  <div class="form-row">
37
63
  <label for="node-input-include"><i class="fa fa-bars"></i> Include</label>
@@ -67,7 +93,7 @@ POSSIBILITY OF SUCH DAMAGE.
67
93
  detailedOutput: {value:false},
68
94
  format: {value: "name", required: true},
69
95
  include: {value: "changed", required: true},
70
- object: {value:"", validate:function(v) {
96
+ instance: {value:"", validate:function(v) {
71
97
  if(v === '') { return true; }
72
98
  let parts = v.split('/');
73
99
  for(let lp = 0; lp < parts.length; lp++) {
@@ -94,12 +120,251 @@ POSSIBILITY OF SUCH DAMAGE.
94
120
  if(this.name) {
95
121
  return this.name;
96
122
  } else {
97
- return this.object ? `ObjCOV - ${this.object}` : "object cov";
123
+ return this.instance ? `ObjCOV - ${this.instance}` : "object cov";
98
124
  }
99
125
  },
100
126
  labelStyle: function() {
101
127
  return this.name ? "node_label_italic":"";
102
128
  },
129
+ oneditprepare: function () {
130
+
131
+ var node = this;
132
+ let mobiusSrvc = $("#node-input-connection").val();
133
+
134
+ $("#instance-search-row").hide();
135
+
136
+ function doesMobiusServiceExist() {
137
+ let srvc = $("#node-input-mobius").val();
138
+ if (srvc === '_ADD_') {
139
+ $("#node-lookup-instance").hide();
140
+ $("#instance-message-row").show();
141
+ } else {
142
+ $("#instance-message-row").hide();
143
+ $("#node-lookup-instance").show();
144
+ }
145
+ }
146
+ doesMobiusServiceExist();
147
+
148
+ $("#node-search-return").addClass('disabled');
149
+
150
+ // *** MOBSEARCH *** //
151
+
152
+ //Inital setup
153
+ $("#instance-search-row").hide();
154
+ $("#wildcard-alert-row").hide();
155
+ $("#node-search-return").addClass('disabled');
156
+ $.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
157
+ $("#instance-search-hid").val(response);
158
+ })
159
+ let readyToAccept = false;
160
+ let searchObject = {
161
+ hid: $("#instance-search-hid").val(),
162
+ sid: $("#instance-search-sid").val(),
163
+ pid: $("#instance-search-pid").val(),
164
+ ins: $("#instance-search-ins").val(),
165
+ objects: []
166
+ }
167
+
168
+ //Function to search for INSs
169
+ function insSearch (objects, pid) {
170
+ let inss = ['#'];
171
+ for (let i = 0; i < objects.length; i++) {
172
+ if (objects[i].pid === pid) {
173
+ const name = objects[i].resources[1].pv;
174
+ if (name === '') {
175
+ inss.push(objects[i].ins);
176
+ } else {
177
+ inss.push(`${objects[i].ins} - ${name}`);
178
+ }
179
+ }
180
+ }
181
+ $("#instance-search-ins").autocomplete({
182
+ source: inss,
183
+ minLength: 0,
184
+ close: function (event, ui) {
185
+ acceptCheck();
186
+ $("#instance-search-ins").autocomplete('destroy');
187
+ if ($("#instance-search-ins").val().length > 4) {
188
+ $("#instance-search-ins").val($("#instance-search-ins").val().substring(0, 4))
189
+ }
190
+ searchObject.ins = $("#instance-search-ins").val();
191
+ }
192
+ }).autocomplete('search', '');
193
+ }
194
+
195
+ //Function to search for PIDs
196
+ function pidsSearch(objects) {
197
+ searchObject.objects = objects;
198
+ let pids = ['#', '+'];
199
+ for (let i = 0; i < objects.length; i++) {
200
+ pids.push(`${objects[i].pid} - ${objects[i].profileName}`);
201
+ }
202
+ pids = [...new Set(pids)];
203
+ $("#instance-search-pid").autocomplete({
204
+ source: pids,
205
+ minLength: 0,
206
+ close: function (event, ui) {
207
+ acceptCheck();
208
+ $("#instance-search-pid").autocomplete('destroy');
209
+ if ($("#instance-search-pid").val().length > 4) {
210
+ $("#instance-search-pid").val($("#instance-search-pid").val().substring(0, 4))
211
+ }
212
+ searchObject.pid = $("#instance-search-pid").val();
213
+ }
214
+ }).autocomplete('search', '');
215
+ }
216
+
217
+ //Function to search for SIDs, and then fetch child objects based on selection
218
+ function serviceSearch(response) {
219
+ let services = ['#', '+'];
220
+ for (let i = 0; i < response.length; i++) {
221
+ if (response[i].sid !== '009') {
222
+ services.push(`${response[i].sid} - ${response[i].name}`);
223
+ }
224
+ }
225
+ $("#instance-search-sid").autocomplete({
226
+ source: services,
227
+ minLength: 0,
228
+ close: function (event, ui) {
229
+ acceptCheck();
230
+ $("#instance-search-sid").autocomplete('destroy');
231
+ if ($("#instance-search-sid").val().length > 3) {
232
+ $("#instance-search-sid").val($("#instance-search-sid").val().substring(0, 3))
233
+ }
234
+ searchObject.sid = $("#instance-search-sid").val();
235
+ if (searchObject.sid === '+') {
236
+ for (let i = 2; i < services.length; i++) {
237
+ $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${services[i].substring(0, 3)}`, (objects) => {
238
+ searchObject.objects = searchObject.objects.concat(objects);
239
+ })
240
+ }
241
+ } else {
242
+ $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${searchObject.sid}`, (objects) => {
243
+ searchObject.objects = objects;
244
+ })
245
+ }
246
+ }
247
+ }).autocomplete('search', '');
248
+ }
249
+
250
+ //Start a new search
251
+ function startSearch() {
252
+ $("#wildcard-alert-row").hide();
253
+ $("#instance-search-sid").val('');
254
+ $("#instance-search-pid").val('');
255
+ $("#instance-search-ins").val('');
256
+ searchObject.hid = $("#instance-search-hid").val()
257
+ searchObject.sid = '';
258
+ searchObject.pid = '';
259
+ searchObject.ins = '';
260
+ if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
261
+ $.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch)
262
+ .fail((err) => {
263
+ console.log('Some kind of html failure message on service discovery');
264
+ });
265
+ }
266
+ }
267
+
268
+ //Finish a search
269
+ function finishSearch() {
270
+ $("#wildcard-alert-row").hide();
271
+ let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`
272
+ if (uri.includes('#')) {
273
+ uri = uri.substring(0,uri.indexOf('#') + 1)
274
+ }
275
+ $("#node-input-instance").val(uri);
276
+ $("#node-search-accept").css('color', '#CCCCCC');
277
+ readyToAccept = false;
278
+ $("#node-search-return").addClass('disabled');
279
+ $("#node-search-accept").addClass('disabled');
280
+ $("#node-lookup-instance").removeClass('disabled');
281
+ $("#instance-search-row").hide();
282
+ $("#instance-row").show();
283
+ }
284
+
285
+ //Function to update if accept button is grade out and functions based on conditions of fields
286
+ function acceptCheck() {
287
+ if (($("#instance-search-hid").val() !== '' && $("#instance-search-sid").val() !== '' && $("#instance-search-pid").val() !== '' && $("#instance-search-ins").val() !== '') ||
288
+ $("#instance-search-sid").val() === '#' || $("#instance-search-pid").val() === '#' || $("#instance-search-ins").val() === '#') {
289
+ $("#node-search-accept").css('color', '#555555');
290
+ readyToAccept = true;
291
+ } else {
292
+ $("#node-search-accept").css('color', '#CCCCCC');
293
+ readyToAccept = false;
294
+ }
295
+ if ($("#instance-search-sid").val() !== '+' && $("#instance-search-pid").val() !== '+') {
296
+ $("#wildcard-alert-row").hide();
297
+ } else {
298
+ $("#wildcard-alert-row").show();
299
+ }
300
+ }
301
+
302
+ // Respond to clicks
303
+ $("#node-lookup-instance").click(function () { //When search button is clicked
304
+ $("#instance-search-sid").val('');
305
+ $("#instance-search-pid").val('');
306
+ $("#instance-search-ins").val('');
307
+ $("#node-lookup-instance").addClass('disabled');
308
+ $("#node-search-return").removeClass('disabled');
309
+ $("#node-search-accept").removeClass('disabled');
310
+ $("#instance-row").hide();
311
+ $("#instance-search-row").show();
312
+ });
313
+ $("#instance-search-sid").click(function () { //SID field clicked
314
+ $("#instance-search-pid").val('')
315
+ $("#instance-search-ins").val('')
316
+ searchObject.pid = '';
317
+ searchObject.ins = '';
318
+ searchObject.objects = [];
319
+ startSearch();
320
+ })
321
+ $("#instance-search-pid").click(function () { //PID field clicked
322
+ $("#instance-search-ins").val('')
323
+ searchObject.ins = '';
324
+ if (searchObject.sid !== '') {
325
+ pidsSearch(searchObject.objects);
326
+ }
327
+ })
328
+ $("#instance-search-ins").click(function () { //INS field clicked
329
+ if (searchObject.pid !== '' && searchObject.pid !== '+' && searchObject.sid !== '+') {
330
+ insSearch(searchObject.objects, searchObject.pid);
331
+ }
332
+ })
333
+ $("#node-search-return").click(function () { //Return/Back button clicked
334
+ $("#node-search-return").addClass('disabled');
335
+ $("#node-search-accept").addClass('disabled');
336
+ $("#node-lookup-instance").removeClass('disabled');
337
+ $("#instance-search-row").hide();
338
+ $("#instance-row").show();
339
+ });
340
+ $("#node-search-accept").click(function () { //Accept button clicked
341
+ if (readyToAccept) {
342
+ finishSearch();
343
+ }
344
+ });
345
+
346
+ // Respond to search field changes
347
+ $("#instance-search-hid").change(function () {
348
+ acceptCheck();
349
+ $("#instance-search-sid").val('');
350
+ $("#instance-search-pid").val('');
351
+ $("#instance-search-ins").val('');
352
+ });
353
+ $("#instance-search-sid").change(function () {
354
+ searchObject.sid = $("#instance-search-sid").val()
355
+ acceptCheck();
356
+ });
357
+ $("#instance-search-pid").change(function () {
358
+ searchObject.pid = $("#instance-search-pid").val()
359
+ acceptCheck();
360
+ });
361
+ $("#instance-search-ins").change(function () {
362
+ searchObject.ins = $("#instance-search-ins").val()
363
+ acceptCheck();
364
+ });
365
+
366
+ // *** MOBSEARCH *** //
367
+ },
103
368
  oneditsave: function() {
104
369
  if($("#node-input-detailedOutput").prop('checked')) {
105
370
  this.outputs = 3;
@@ -29,10 +29,10 @@
29
29
  var _ = require('lodash');
30
30
 
31
31
  module.exports = function (RED) {
32
- function MobiusObjectCovNode (n) {
32
+ function MobiusObjectCovNode(n) {
33
33
  RED.nodes.createNode(this, n);
34
34
  this.detailedOutput = n.detailedOutput;
35
- this.object = n.object;
35
+ this.instance = n.instance;
36
36
  this.format = n.format;
37
37
  this.include = n.include;
38
38
  this.serviceConn = RED.nodes.getNode(n.connection);
@@ -42,16 +42,19 @@ module.exports = function (RED) {
42
42
  node.status({
43
43
  fill: 'red',
44
44
  shape: 'ring',
45
- text: 'Disconnected'
45
+ text: 'Disconnected',
46
46
  });
47
47
 
48
- node.serviceConn.subscribeToObjectCOV(node.object, this.id, (response) => {
48
+ node.serviceConn.subscribeToObjectCOV(node.instance, this.id, (response) => {
49
49
  node.status({
50
50
  fill: 'green',
51
51
  shape: 'dot',
52
- text: JSON.stringify(response.uri)
52
+ text: JSON.stringify(response.uri),
53
53
  });
54
- let allResources = _.keyBy(response.value.resources, node.format === 'name' ? 'name' : 'rid');
54
+ let allResources = _.keyBy(
55
+ response.value.resources,
56
+ node.format === 'name' ? 'name' : 'rid'
57
+ );
55
58
  if (node.include === 'changed') {
56
59
  allResources = _.pickBy(allResources, (res) => {
57
60
  return response.changed.includes(res.rid);
@@ -61,7 +64,7 @@ module.exports = function (RED) {
61
64
  node.send([
62
65
  { topic: response.uri, payload: allResources },
63
66
  { topic: response.uri, payload: response.value },
64
- { topic: response.uri, payload: { response: response } }
67
+ { topic: response.uri, payload: { response: response } },
65
68
  ]);
66
69
  } else {
67
70
  node.send({ topic: response.uri, payload: allResources });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-mobius-flow-base",
3
- "version": "2.5.86-beta.25",
3
+ "version": "2.5.86-beta.29",
4
4
  "description": "Node-RED base nodes for Mobius Flow",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",