node-red-contrib-mobius-flow-base 3.0.0-beta.17 → 3.0.0-beta.19

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.
@@ -62,6 +62,9 @@ function handleWebSocketMessage(message) {
62
62
  const callbacks = registeredCallbacks
63
63
  .filter((cb) => cb.topic === message.topic)
64
64
  .map((cb) => cb.callback);
65
+ if (!message.payload.timestamp) {
66
+ message.payload.timestamp = message.timestamp ? message.timestamp : new Date().toISOString();
67
+ }
65
68
  callbacks.forEach((cb) => cb(message.payload));
66
69
  }
67
70
  const reconnect = () => {
@@ -208,7 +208,7 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
208
208
  `mdiscover?mobius=${mobiusSrvc}&uri=${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`,
209
209
  (response) => {
210
210
  resList = response.data[0].resources;
211
- ress = ['#'];
211
+ ress = opts.removeWildcards ? [] : ['#'];
212
212
  for (let j = 0; j < resList.length; j++) {
213
213
  ress.push(`${resList[j].rid} - ${resList[j].name}`);
214
214
  }
@@ -234,7 +234,8 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
234
234
  * @param {string} pid - The chosen PID
235
235
  */
236
236
  function insSearch(objects, pid) {
237
- let inss = ['#', '+'];
237
+ $('#instance-search-rid').removeAttr("disabled");
238
+ let inss = opts.removeWildcards ? [] : ['#', '+'];
238
239
  for (let i = 0; i < objects.length; i++) {
239
240
  if (objects[i].pid === pid) {
240
241
  const name = objects[i].resources[1].pv;
@@ -256,6 +257,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
256
257
  $('#instance-search-ins').val($('#instance-search-ins').val().substring(0, 4));
257
258
  }
258
259
  searchObject.ins = $('#instance-search-ins').val();
260
+ if (searchObject.ins === '#') {
261
+ $('#instance-search-rid').attr("disabled", "disabled");
262
+ }
259
263
  },
260
264
  })
261
265
  .autocomplete('search', '');
@@ -266,8 +270,10 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
266
270
  * @param {object} objects - Response from call to Mobius, list of mobius objects
267
271
  */
268
272
  function pidsSearch(objects) {
273
+ $('#instance-search-ins').removeAttr("disabled");
274
+ $('#instance-search-rid').removeAttr("disabled");
269
275
  searchObject.objects = objects;
270
- let pids = ['#', '+'];
276
+ let pids = opts.removeWildcards ? [] : ['#', '+'];
271
277
  for (let i = 0; i < objects.length; i++) {
272
278
  pids.push(`${objects[i].pid} - ${objects[i].profileName}`);
273
279
  }
@@ -283,6 +289,10 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
283
289
  $('#instance-search-pid').val($('#instance-search-pid').val().substring(0, 4));
284
290
  }
285
291
  searchObject.pid = $('#instance-search-pid').val();
292
+ if (searchObject.pid === '#') {
293
+ $('#instance-search-ins').attr("disabled", "disabled");
294
+ $('#instance-search-rid').attr("disabled", "disabled");
295
+ }
286
296
  },
287
297
  })
288
298
  .autocomplete('search', '');
@@ -293,7 +303,10 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
293
303
  * @param {object} response - Response from call to Mobius
294
304
  */
295
305
  function serviceSearch(response) {
296
- let services = ['#', '+'];
306
+ $('#instance-search-pid').removeAttr("disabled");
307
+ $('#instance-search-ins').removeAttr("disabled");
308
+ $('#instance-search-rid').removeAttr("disabled");
309
+ let services = opts.removeWildcards ? [] : ['#', '+'];
297
310
  for (let i = 0; i < response.length; i++) {
298
311
  if (response[i].sid !== '009') {
299
312
  services.push(`${response[i].sid} - ${response[i].name}`);
@@ -310,8 +323,17 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
310
323
  $('#instance-search-sid').val($('#instance-search-sid').val().substring(0, 3));
311
324
  }
312
325
  searchObject.sid = $('#instance-search-sid').val();
326
+ if (searchObject.sid === '#') {
327
+ $('#instance-search-pid').attr("disabled", "disabled");
328
+ $('#instance-search-ins').attr("disabled", "disabled");
329
+ $('#instance-search-rid').attr("disabled", "disabled");
330
+ return;
331
+ };
313
332
  if (searchObject.sid === '+') {
314
333
  for (let i = 2; i < services.length; i++) {
334
+ if (services[i].substring(0, 3).length !== 3) {
335
+ return;
336
+ }
315
337
  $.getJSON(
316
338
  `mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${services[
317
339
  i
@@ -322,6 +344,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
322
344
  );
323
345
  }
324
346
  } else {
347
+ if (searchObject.sid.length !== 3) {
348
+ return;
349
+ }
325
350
  $.getJSON(
326
351
  `mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${searchObject.sid}`,
327
352
  (objects) => {
@@ -355,6 +380,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
355
380
  }
356
381
  }
357
382
 
383
+ // Used to temporarily store updated list items
384
+ let tempList = [];
385
+
358
386
  /**
359
387
  * Finish mobsearch, compile full URI and set value in host node
360
388
  */
@@ -368,7 +396,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
368
396
  uri = uri.substring(0, uri.indexOf('#') + 1);
369
397
  }
370
398
  if (listed) {
371
- opts.list[selectionIndex].uri = uri;
399
+ // opts.list[selectionIndex].uri = uri;
400
+ tempList = JSON.parse(JSON.stringify(opts.list));
401
+ tempList[selectionIndex].uri = uri;
372
402
  updateList();
373
403
  } else {
374
404
  $(`#${opts.uriFieldName}`).val(uri);
@@ -398,16 +428,16 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
398
428
  * Check state of all field to rid level, change state of accept button accordingly
399
429
  */
400
430
  function checkFieldsToRid() {
431
+ const wildcardPass = !opts.removeWildcards && ($('#instance-search-sid').val() === '#' ||
432
+ $('#instance-search-pid').val() === '#' ||
433
+ $('#instance-search-ins').val() === '#' ||
434
+ $('#instance-search-rid').val() === '#')
401
435
  if (
402
436
  ($('#instance-search-hid').val() !== '' &&
403
437
  $('#instance-search-sid').val() !== '' &&
404
438
  $('#instance-search-pid').val() !== '' &&
405
439
  $('#instance-search-ins').val() !== '' &&
406
- $('#instance-search-rid').val() !== '') ||
407
- $('#instance-search-sid').val() === '#' ||
408
- $('#instance-search-pid').val() === '#' ||
409
- $('#instance-search-ins').val() === '#' ||
410
- $('#instance-search-rid').val() === '#'
440
+ $('#instance-search-rid').val() !== '') || wildcardPass
411
441
  ) {
412
442
  $('#node-search-accept').css('color', '#555555');
413
443
  readyToAccept = true;
@@ -421,14 +451,14 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
421
451
  * Check state of all field to ins level, change state of accept button accordingly
422
452
  */
423
453
  function checkFieldsToIns() {
454
+ const wildcardPass = !opts.removeWildcards && ($('#instance-search-sid').val() === '#' ||
455
+ $('#instance-search-pid').val() === '#' ||
456
+ $('#instance-search-ins').val() === '#')
424
457
  if (
425
458
  ($('#instance-search-hid').val() !== '' &&
426
459
  $('#instance-search-sid').val() !== '' &&
427
460
  $('#instance-search-pid').val() !== '' &&
428
- $('#instance-search-ins').val() !== '') ||
429
- $('#instance-search-sid').val() === '#' ||
430
- $('#instance-search-pid').val() === '#' ||
431
- $('#instance-search-ins').val() === '#'
461
+ $('#instance-search-ins').val() !== '') || wildcardPass
432
462
  ) {
433
463
  $('#node-search-accept').css('color', '#555555');
434
464
  readyToAccept = true;
@@ -462,11 +492,11 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
462
492
  .each(function (i) {
463
493
  let item = $(this);
464
494
  let secondField = item.find(`.${opts.containerSecondFieldName}`).val();
465
- opts.list[i][Object.keys(opts.list[i])[1]] = secondField;
495
+ tempList[i][Object.keys(tempList[i])[1]] = secondField;
466
496
  });
467
497
  $(`#${opts.containerName}`).editableList('empty');
468
- for (let i = 0; i < opts.list.length; i++) {
469
- let item = opts.list[i];
498
+ for (let i = 0; i < tempList.length; i++) {
499
+ let item = tempList[i];
470
500
  $(`#${opts.containerName}`).editableList('addItem', item);
471
501
  }
472
502
  $(`#${opts.containerRowName}`).show();
@@ -549,6 +579,7 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
549
579
  $('#node-lookup-instance').removeClass('disabled');
550
580
  $('#instance-search-row').hide();
551
581
  $('#instance-row').show();
582
+ $(`#${opts.containerRowName}`).show();
552
583
  });
553
584
  $('#node-search-accept').click(function () {
554
585
  //Accept button clicked
@@ -679,7 +679,7 @@ module.exports = function (RED) {
679
679
  res.json(response);
680
680
  })
681
681
  .catch((err) => {
682
- RED.log.warn(`Get objects failed - ${err}`);
682
+ RED.log.warn(`Get objects failed on service ${req.query.sid} ${err ? ` - ${err}` : ''}`);
683
683
  });
684
684
  }
685
685
  });
@@ -135,6 +135,7 @@ POSSIBILITY OF SUCH DAMAGE.
135
135
  let subscription = node.subscriptions[i];
136
136
  $("#node-input-subs-container").editableList('addItem', subscription);
137
137
  }
138
+
138
139
  },
139
140
  oneditresize(size) {
140
141
  var rows = $("#dialog-form>div:not(.node-input-subs-container-row)");
@@ -112,7 +112,7 @@ module.exports = function (RED) {
112
112
  try {
113
113
  delete outObject.isFromConfig;
114
114
  outObject.timestamp = response.timestamp;
115
- outObject.changed = response.changed;
115
+ outObject.changed = response.additonalInformation.changed;
116
116
  outObject.resources = _.keyBy(outObject.resources, 'rid');
117
117
  } catch (err) {
118
118
  node.error(`Failed to handle injected COV: ${JSON.stringify(outObject)}`);
@@ -106,6 +106,7 @@ POSSIBILITY OF SUCH DAMAGE.
106
106
  htmlElementId: 'mobsearch',
107
107
  uriFieldName: 'node-input-mobject',
108
108
  inputRowId: 'input-row',
109
+ removeWildcards: true,
109
110
  };
110
111
  initMobsearch.toIns(mobiusSrvc, opts);
111
112
  },
@@ -114,6 +114,7 @@ POSSIBILITY OF SUCH DAMAGE.
114
114
  htmlElementId: 'mobsearch',
115
115
  uriFieldName: 'node-input-resource',
116
116
  inputRowId: 'input-row',
117
+ removeWildcards: true,
117
118
  };
118
119
  initMobsearch.toRid(mobiusSrvc, opts);
119
120
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-mobius-flow-base",
3
- "version": "3.0.0-beta.17",
3
+ "version": "3.0.0-beta.19",
4
4
  "description": "Node-RED base nodes for Mobius Flow",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",