node-red-contrib-mobius-flow-base 2.5.86-beta.40 → 2.5.86-beta.45

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.
@@ -29,10 +29,39 @@ 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
+
33
+ <hr>
34
+ <div id="instance-message-row" class="form-row hidden" style="color:#ff0000" align="center">
35
+ <p>To select a configured object from a drop-down list, <br/>
36
+ please create a MOBiUS connection, deploy the flow, and <br />
37
+ ensure that the node-red-connector service is running. <br />
38
+ Click the Confirm Deploy button if asked.</p>
39
+ </div>
40
+ <div id="instance-row">
41
+ <div class="form-row">
42
+ <label for="node-input-instance"><i class="fa fa-tasks"></i> URI</label>
43
+ <input type="text" id="node-input-instance" style="width:61%;" placeholder="HID/SID/PID/INS (optional name)">
44
+ <a id="node-lookup-instance" class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>
45
+ </div>
46
+ </div>
47
+ <div id="instance-search-row">
48
+ <div class="form-row">
49
+ <label for="instance-search-sid"><i class="fa fa-tasks"></i> URI</label>
50
+ <input type="text" id="instance-search-hid" style="width:15%;" placeholder="HID">
51
+ <input type="text" id="instance-search-sid" style="width:10%;" placeholder="SID">
52
+ <input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
53
+ <input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
54
+ <a id="node-search-return" class="searchbutton" style="vertical-align: middle"><i id="node-search-return-icon" class="fa fa-arrow-left"></i></a>
55
+ <a id="node-search-accept" class="searchbutton" style="vertical-align: middle"><i id="node-search-accept-icon" class="fa fa-check"></i></a>
56
+ </div>
57
+ </div>
58
+ <div id="wildcard-alert-row" class="form-row hidden" style="color:#555555" align="center">
59
+ <p>Please note: The selection of wildcard '+'
60
+ means a search for a specific instance or resource
61
+ cannot be performed. As such, enter the
62
+ INS manually.</p>
35
63
  </div>
64
+
36
65
  <div class="form-row">
37
66
  <label>&nbsp;</label>
38
67
  <input type="checkbox" id="node-input-detailedOutput" style="display: inline-block; width: auto; vertical-align: top;">
@@ -51,7 +80,7 @@ POSSIBILITY OF SUCH DAMAGE.
51
80
  defaults: {
52
81
  name: {value:""},
53
82
  detailedOutput: {value:false},
54
- mobject: {value: "", validate:function(v) {
83
+ instance: {value: "", validate:function(v) {
55
84
  if(v === '') { return true; }
56
85
  let parts = v.split('/');
57
86
  for(let lp = 0; lp < parts.length; lp++) {
@@ -82,6 +111,244 @@ POSSIBILITY OF SUCH DAMAGE.
82
111
  labelStyle: function() {
83
112
  return this.name ? "node_label_italic":"";
84
113
  },
114
+ oneditprepare: function () {
115
+ var node = this;
116
+ let mobiusSrvc = $("#node-input-connection").val();
117
+
118
+ $("#instance-search-row").hide();
119
+
120
+ function doesMobiusServiceExist() {
121
+ let srvc = $("#node-input-mobius").val();
122
+ if (srvc === '_ADD_') {
123
+ $("#node-lookup-instance").hide();
124
+ $("#instance-message-row").show();
125
+ } else {
126
+ $("#instance-message-row").hide();
127
+ $("#node-lookup-instance").show();
128
+ }
129
+ }
130
+ doesMobiusServiceExist();
131
+
132
+ $("#node-search-return").addClass('disabled');
133
+
134
+ // *** MOBSEARCH *** //
135
+
136
+ //Inital setup
137
+ $("#instance-search-row").hide();
138
+ $("#wildcard-alert-row").hide();
139
+ $("#node-search-return").addClass('disabled');
140
+ $.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
141
+ $("#instance-search-hid").val(response);
142
+ })
143
+ let readyToAccept = false;
144
+ let searchObject = {
145
+ hid: $("#instance-search-hid").val(),
146
+ sid: $("#instance-search-sid").val(),
147
+ pid: $("#instance-search-pid").val(),
148
+ ins: $("#instance-search-ins").val(),
149
+ objects: []
150
+ }
151
+
152
+ //Function to search for INSs
153
+ function insSearch (objects, pid) {
154
+ let inss = ['#'];
155
+ for (let i = 0; i < objects.length; i++) {
156
+ if (objects[i].pid === pid) {
157
+ const name = objects[i].resources[1].pv;
158
+ if (name === '') {
159
+ inss.push(objects[i].ins);
160
+ } else {
161
+ inss.push(`${objects[i].ins} - ${name}`);
162
+ }
163
+ }
164
+ }
165
+ $("#instance-search-ins").autocomplete({
166
+ source: inss,
167
+ minLength: 0,
168
+ close: function (event, ui) {
169
+ acceptCheck();
170
+ $("#instance-search-ins").autocomplete('destroy');
171
+ if ($("#instance-search-ins").val().length > 4) {
172
+ $("#instance-search-ins").val($("#instance-search-ins").val().substring(0, 4))
173
+ }
174
+ searchObject.ins = $("#instance-search-ins").val();
175
+ }
176
+ }).autocomplete('search', '');
177
+ }
178
+
179
+ //Function to search for PIDs
180
+ function pidsSearch(objects) {
181
+ searchObject.objects = objects;
182
+ let pids = ['#', '+'];
183
+ for (let i = 0; i < objects.length; i++) {
184
+ pids.push(`${objects[i].pid} - ${objects[i].profileName}`);
185
+ }
186
+ pids = [...new Set(pids)];
187
+ $("#instance-search-pid").autocomplete({
188
+ source: pids,
189
+ minLength: 0,
190
+ close: function (event, ui) {
191
+ acceptCheck();
192
+ $("#instance-search-pid").autocomplete('destroy');
193
+ if ($("#instance-search-pid").val().length > 4) {
194
+ $("#instance-search-pid").val($("#instance-search-pid").val().substring(0, 4))
195
+ }
196
+ searchObject.pid = $("#instance-search-pid").val();
197
+ }
198
+ }).autocomplete('search', '');
199
+ }
200
+
201
+ //Function to search for SIDs, and then fetch child objects based on selection
202
+ function serviceSearch(response) {
203
+ let services = ['#', '+'];
204
+ for (let i = 0; i < response.length; i++) {
205
+ if (response[i].sid !== '009') {
206
+ services.push(`${response[i].sid} - ${response[i].name}`);
207
+ }
208
+ }
209
+ $("#instance-search-sid").autocomplete({
210
+ source: services,
211
+ minLength: 0,
212
+ close: function (event, ui) {
213
+ acceptCheck();
214
+ $("#instance-search-sid").autocomplete('destroy');
215
+ if ($("#instance-search-sid").val().length > 3) {
216
+ $("#instance-search-sid").val($("#instance-search-sid").val().substring(0, 3))
217
+ }
218
+ searchObject.sid = $("#instance-search-sid").val();
219
+ if (searchObject.sid === '+') {
220
+ for (let i = 2; i < services.length; i++) {
221
+ $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${services[i].substring(0, 3)}`, (objects) => {
222
+ searchObject.objects = searchObject.objects.concat(objects);
223
+ })
224
+ }
225
+ } else {
226
+ $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${searchObject.sid}`, (objects) => {
227
+ searchObject.objects = objects;
228
+ })
229
+ }
230
+ }
231
+ }).autocomplete('search', '');
232
+ }
233
+
234
+ //Start a new search
235
+ function startSearch() {
236
+ $("#wildcard-alert-row").hide();
237
+ $("#instance-search-sid").val('');
238
+ $("#instance-search-pid").val('');
239
+ $("#instance-search-ins").val('');
240
+ searchObject.hid = $("#instance-search-hid").val()
241
+ searchObject.sid = '';
242
+ searchObject.pid = '';
243
+ searchObject.ins = '';
244
+ if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
245
+ $.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch)
246
+ .fail((err) => {
247
+ console.log('Some kind of html failure message on service discovery');
248
+ });
249
+ }
250
+ }
251
+
252
+ //Finish a search
253
+ function finishSearch() {
254
+ $("#wildcard-alert-row").hide();
255
+ let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`
256
+ if (uri.includes('#')) {
257
+ uri = uri.substring(0,uri.indexOf('#') + 1)
258
+ }
259
+ $("#node-input-instance").val(uri);
260
+ $("#node-search-accept").css('color', '#CCCCCC');
261
+ readyToAccept = false;
262
+ $("#node-search-return").addClass('disabled');
263
+ $("#node-search-accept").addClass('disabled');
264
+ $("#node-lookup-instance").removeClass('disabled');
265
+ $("#instance-search-row").hide();
266
+ $("#instance-row").show();
267
+ }
268
+
269
+ //Function to update if accept button is grade out and functions based on conditions of fields
270
+ function acceptCheck() {
271
+ if (($("#instance-search-hid").val() !== '' && $("#instance-search-sid").val() !== '' && $("#instance-search-pid").val() !== '' && $("#instance-search-ins").val() !== '') ||
272
+ $("#instance-search-sid").val() === '#' || $("#instance-search-pid").val() === '#' || $("#instance-search-ins").val() === '#') {
273
+ $("#node-search-accept").css('color', '#555555');
274
+ readyToAccept = true;
275
+ } else {
276
+ $("#node-search-accept").css('color', '#CCCCCC');
277
+ readyToAccept = false;
278
+ }
279
+ if ($("#instance-search-sid").val() !== '+' && $("#instance-search-pid").val() !== '+') {
280
+ $("#wildcard-alert-row").hide();
281
+ } else {
282
+ $("#wildcard-alert-row").show();
283
+ }
284
+ }
285
+
286
+ // Respond to clicks
287
+ $("#node-lookup-instance").click(function () { //When search button is clicked
288
+ $("#instance-search-sid").val('');
289
+ $("#instance-search-pid").val('');
290
+ $("#instance-search-ins").val('');
291
+ $("#node-lookup-instance").addClass('disabled');
292
+ $("#node-search-return").removeClass('disabled');
293
+ $("#node-search-accept").removeClass('disabled');
294
+ $("#instance-row").hide();
295
+ $("#instance-search-row").show();
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
+ $("#node-lookup-instance").removeClass('disabled');
321
+ $("#instance-search-row").hide();
322
+ $("#instance-row").show();
323
+ });
324
+ $("#node-search-accept").click(function () { //Accept button clicked
325
+ if (readyToAccept) {
326
+ finishSearch();
327
+ }
328
+ });
329
+
330
+ // Respond to search field changes
331
+ $("#instance-search-hid").change(function () {
332
+ acceptCheck();
333
+ $("#instance-search-sid").val('');
334
+ $("#instance-search-pid").val('');
335
+ $("#instance-search-ins").val('');
336
+ });
337
+ $("#instance-search-sid").change(function () {
338
+ searchObject.sid = $("#instance-search-sid").val()
339
+ acceptCheck();
340
+ });
341
+ $("#instance-search-pid").change(function () {
342
+ searchObject.pid = $("#instance-search-pid").val()
343
+ acceptCheck();
344
+ });
345
+ $("#instance-search-ins").change(function () {
346
+ searchObject.ins = $("#instance-search-ins").val()
347
+ acceptCheck();
348
+ });
349
+
350
+ // *** MOBSEARCH *** //
351
+ },
85
352
  oneditsave: function() {
86
353
  if($("#node-input-detailedOutput").prop('checked')) {
87
354
  this.outputs = 2;
@@ -28,10 +28,10 @@
28
28
  'use strict';
29
29
 
30
30
  module.exports = function (RED) {
31
- function MobiusSetMultiResourceNode (n) {
31
+ function MobiusSetMultiResourceNode(n) {
32
32
  RED.nodes.createNode(this, n);
33
33
  this.detailedOutput = n.detailedOutput;
34
- this.mobject = n.mobject;
34
+ this.instance = n.instance;
35
35
  this.serviceConn = RED.nodes.getNode(n.connection);
36
36
  var node = this;
37
37
 
@@ -39,11 +39,11 @@ module.exports = function (RED) {
39
39
  node.status({
40
40
  fill: 'red',
41
41
  shape: 'ring',
42
- text: 'Disconnected'
42
+ text: 'Disconnected',
43
43
  });
44
44
 
45
45
  node.on('input', function (msg) {
46
- let uri = node.mobject;
46
+ let uri = node.instance;
47
47
  let value = null;
48
48
  if (msg.hasOwnProperty('topic') && require('./validateURI')(msg.topic, 4)) {
49
49
  uri = msg.topic;
@@ -55,7 +55,7 @@ module.exports = function (RED) {
55
55
  node.status({
56
56
  fill: 'green',
57
57
  shape: 'ring',
58
- text: 'Busy'
58
+ text: 'Busy',
59
59
  });
60
60
 
61
61
  node.serviceConn.multiWriteResourceValue(uri, value, (err, response) => {
@@ -63,27 +63,25 @@ module.exports = function (RED) {
63
63
  node.status({
64
64
  fill: 'yellow',
65
65
  shape: 'dot',
66
- text: 'Error: ' + JSON.stringify(err.code)
66
+ text: 'Error: ' + JSON.stringify(err.code),
67
67
  });
68
68
  node.error('Mobius error writing multiple resources ' + JSON.stringify(err));
69
69
  if (node.detailedOutput === true) {
70
- node.send([null, {topic: uri, payload: { error: true, response: err }}]);
70
+ node.send([null, { topic: uri, payload: { error: true, response: err } }]);
71
71
  }
72
72
  } else {
73
73
  node.status({
74
74
  fill: 'green',
75
75
  shape: 'dot',
76
- text: 'OK'
76
+ text: 'OK',
77
77
  });
78
78
  if (node.detailedOutput === true) {
79
79
  node.send([
80
80
  { topic: uri, payload: response.value },
81
- { topic: uri, payload: { error: false, response: response } }
81
+ { topic: uri, payload: { error: false, response: response } },
82
82
  ]);
83
83
  } else {
84
- node.send([
85
- { topic: uri, payload: response.value }
86
- ]);
84
+ node.send([{ topic: uri, payload: response.value }]);
87
85
  }
88
86
  }
89
87
  });