node-red-contrib-mobius-flow-base 2.5.86-beta.24 → 2.5.86-beta.28

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
  };
@@ -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 });
@@ -221,7 +221,7 @@ module.exports = {
221
221
  connection,
222
222
  `${hid}/${sid}/${pids[i]}/${inss[j]}`
223
223
  );
224
- objectList.push(objResponse.value);
224
+ objectList.push(objResponse.value[0]);
225
225
  }
226
226
  }
227
227
  resolve(objectList);
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.24",
3
+ "version": "2.5.86-beta.28",
4
4
  "description": "Node-RED base nodes for Mobius Flow",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",