node-red-contrib-mobius-flow-base 2.5.86-beta.4 → 2.5.86-beta.44

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-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
+
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 for="node-input-include"><i class="fa fa-bars"></i> Include</label>
38
67
  <select type="text" id="node-input-include" style="display: inline-block; width: auto; vertical-align: center;">
@@ -67,7 +96,7 @@ POSSIBILITY OF SUCH DAMAGE.
67
96
  detailedOutput: {value:false},
68
97
  format: {value: "name", required: true},
69
98
  include: {value: "changed", required: true},
70
- object: {value:"", validate:function(v) {
99
+ instance: {value:"", validate:function(v) {
71
100
  if(v === '') { return true; }
72
101
  let parts = v.split('/');
73
102
  for(let lp = 0; lp < parts.length; lp++) {
@@ -94,12 +123,251 @@ POSSIBILITY OF SUCH DAMAGE.
94
123
  if(this.name) {
95
124
  return this.name;
96
125
  } else {
97
- return this.object ? `ObjCOV - ${this.object}` : "object cov";
126
+ return this.instance ? `ObjCOV - ${this.instance}` : "object cov";
98
127
  }
99
128
  },
100
129
  labelStyle: function() {
101
130
  return this.name ? "node_label_italic":"";
102
131
  },
132
+ oneditprepare: function () {
133
+
134
+ var node = this;
135
+ let mobiusSrvc = $("#node-input-connection").val();
136
+
137
+ $("#instance-search-row").hide();
138
+
139
+ function doesMobiusServiceExist() {
140
+ let srvc = $("#node-input-mobius").val();
141
+ if (srvc === '_ADD_') {
142
+ $("#node-lookup-instance").hide();
143
+ $("#instance-message-row").show();
144
+ } else {
145
+ $("#instance-message-row").hide();
146
+ $("#node-lookup-instance").show();
147
+ }
148
+ }
149
+ doesMobiusServiceExist();
150
+
151
+ $("#node-search-return").addClass('disabled');
152
+
153
+ // *** MOBSEARCH *** //
154
+
155
+ //Inital setup
156
+ $("#instance-search-row").hide();
157
+ $("#wildcard-alert-row").hide();
158
+ $("#node-search-return").addClass('disabled');
159
+ $.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
160
+ $("#instance-search-hid").val(response);
161
+ })
162
+ let readyToAccept = false;
163
+ let searchObject = {
164
+ hid: $("#instance-search-hid").val(),
165
+ sid: $("#instance-search-sid").val(),
166
+ pid: $("#instance-search-pid").val(),
167
+ ins: $("#instance-search-ins").val(),
168
+ objects: []
169
+ }
170
+
171
+ //Function to search for INSs
172
+ function insSearch (objects, pid) {
173
+ let inss = ['#'];
174
+ for (let i = 0; i < objects.length; i++) {
175
+ if (objects[i].pid === pid) {
176
+ const name = objects[i].resources[1].pv;
177
+ if (name === '') {
178
+ inss.push(objects[i].ins);
179
+ } else {
180
+ inss.push(`${objects[i].ins} - ${name}`);
181
+ }
182
+ }
183
+ }
184
+ $("#instance-search-ins").autocomplete({
185
+ source: inss,
186
+ minLength: 0,
187
+ close: function (event, ui) {
188
+ acceptCheck();
189
+ $("#instance-search-ins").autocomplete('destroy');
190
+ if ($("#instance-search-ins").val().length > 4) {
191
+ $("#instance-search-ins").val($("#instance-search-ins").val().substring(0, 4))
192
+ }
193
+ searchObject.ins = $("#instance-search-ins").val();
194
+ }
195
+ }).autocomplete('search', '');
196
+ }
197
+
198
+ //Function to search for PIDs
199
+ function pidsSearch(objects) {
200
+ searchObject.objects = objects;
201
+ let pids = ['#', '+'];
202
+ for (let i = 0; i < objects.length; i++) {
203
+ pids.push(`${objects[i].pid} - ${objects[i].profileName}`);
204
+ }
205
+ pids = [...new Set(pids)];
206
+ $("#instance-search-pid").autocomplete({
207
+ source: pids,
208
+ minLength: 0,
209
+ close: function (event, ui) {
210
+ acceptCheck();
211
+ $("#instance-search-pid").autocomplete('destroy');
212
+ if ($("#instance-search-pid").val().length > 4) {
213
+ $("#instance-search-pid").val($("#instance-search-pid").val().substring(0, 4))
214
+ }
215
+ searchObject.pid = $("#instance-search-pid").val();
216
+ }
217
+ }).autocomplete('search', '');
218
+ }
219
+
220
+ //Function to search for SIDs, and then fetch child objects based on selection
221
+ function serviceSearch(response) {
222
+ let services = ['#', '+'];
223
+ for (let i = 0; i < response.length; i++) {
224
+ if (response[i].sid !== '009') {
225
+ services.push(`${response[i].sid} - ${response[i].name}`);
226
+ }
227
+ }
228
+ $("#instance-search-sid").autocomplete({
229
+ source: services,
230
+ minLength: 0,
231
+ close: function (event, ui) {
232
+ acceptCheck();
233
+ $("#instance-search-sid").autocomplete('destroy');
234
+ if ($("#instance-search-sid").val().length > 3) {
235
+ $("#instance-search-sid").val($("#instance-search-sid").val().substring(0, 3))
236
+ }
237
+ searchObject.sid = $("#instance-search-sid").val();
238
+ if (searchObject.sid === '+') {
239
+ for (let i = 2; i < services.length; i++) {
240
+ $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${services[i].substring(0, 3)}`, (objects) => {
241
+ searchObject.objects = searchObject.objects.concat(objects);
242
+ })
243
+ }
244
+ } else {
245
+ $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${searchObject.sid}`, (objects) => {
246
+ searchObject.objects = objects;
247
+ })
248
+ }
249
+ }
250
+ }).autocomplete('search', '');
251
+ }
252
+
253
+ //Start a new search
254
+ function startSearch() {
255
+ $("#wildcard-alert-row").hide();
256
+ $("#instance-search-sid").val('');
257
+ $("#instance-search-pid").val('');
258
+ $("#instance-search-ins").val('');
259
+ searchObject.hid = $("#instance-search-hid").val()
260
+ searchObject.sid = '';
261
+ searchObject.pid = '';
262
+ searchObject.ins = '';
263
+ if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
264
+ $.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch)
265
+ .fail((err) => {
266
+ console.log('Some kind of html failure message on service discovery');
267
+ });
268
+ }
269
+ }
270
+
271
+ //Finish a search
272
+ function finishSearch() {
273
+ $("#wildcard-alert-row").hide();
274
+ let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`
275
+ if (uri.includes('#')) {
276
+ uri = uri.substring(0,uri.indexOf('#') + 1)
277
+ }
278
+ $("#node-input-instance").val(uri);
279
+ $("#node-search-accept").css('color', '#CCCCCC');
280
+ readyToAccept = false;
281
+ $("#node-search-return").addClass('disabled');
282
+ $("#node-search-accept").addClass('disabled');
283
+ $("#node-lookup-instance").removeClass('disabled');
284
+ $("#instance-search-row").hide();
285
+ $("#instance-row").show();
286
+ }
287
+
288
+ //Function to update if accept button is grade out and functions based on conditions of fields
289
+ function acceptCheck() {
290
+ if (($("#instance-search-hid").val() !== '' && $("#instance-search-sid").val() !== '' && $("#instance-search-pid").val() !== '' && $("#instance-search-ins").val() !== '') ||
291
+ $("#instance-search-sid").val() === '#' || $("#instance-search-pid").val() === '#' || $("#instance-search-ins").val() === '#') {
292
+ $("#node-search-accept").css('color', '#555555');
293
+ readyToAccept = true;
294
+ } else {
295
+ $("#node-search-accept").css('color', '#CCCCCC');
296
+ readyToAccept = false;
297
+ }
298
+ if ($("#instance-search-sid").val() !== '+' && $("#instance-search-pid").val() !== '+') {
299
+ $("#wildcard-alert-row").hide();
300
+ } else {
301
+ $("#wildcard-alert-row").show();
302
+ }
303
+ }
304
+
305
+ // Respond to clicks
306
+ $("#node-lookup-instance").click(function () { //When search button is clicked
307
+ $("#instance-search-sid").val('');
308
+ $("#instance-search-pid").val('');
309
+ $("#instance-search-ins").val('');
310
+ $("#node-lookup-instance").addClass('disabled');
311
+ $("#node-search-return").removeClass('disabled');
312
+ $("#node-search-accept").removeClass('disabled');
313
+ $("#instance-row").hide();
314
+ $("#instance-search-row").show();
315
+ });
316
+ $("#instance-search-sid").click(function () { //SID field clicked
317
+ $("#instance-search-pid").val('')
318
+ $("#instance-search-ins").val('')
319
+ searchObject.pid = '';
320
+ searchObject.ins = '';
321
+ searchObject.objects = [];
322
+ startSearch();
323
+ })
324
+ $("#instance-search-pid").click(function () { //PID field clicked
325
+ $("#instance-search-ins").val('')
326
+ searchObject.ins = '';
327
+ if (searchObject.sid !== '') {
328
+ pidsSearch(searchObject.objects);
329
+ }
330
+ })
331
+ $("#instance-search-ins").click(function () { //INS field clicked
332
+ if (searchObject.pid !== '' && searchObject.pid !== '+' && searchObject.sid !== '+') {
333
+ insSearch(searchObject.objects, searchObject.pid);
334
+ }
335
+ })
336
+ $("#node-search-return").click(function () { //Return/Back button clicked
337
+ $("#node-search-return").addClass('disabled');
338
+ $("#node-search-accept").addClass('disabled');
339
+ $("#node-lookup-instance").removeClass('disabled');
340
+ $("#instance-search-row").hide();
341
+ $("#instance-row").show();
342
+ });
343
+ $("#node-search-accept").click(function () { //Accept button clicked
344
+ if (readyToAccept) {
345
+ finishSearch();
346
+ }
347
+ });
348
+
349
+ // Respond to search field changes
350
+ $("#instance-search-hid").change(function () {
351
+ acceptCheck();
352
+ $("#instance-search-sid").val('');
353
+ $("#instance-search-pid").val('');
354
+ $("#instance-search-ins").val('');
355
+ });
356
+ $("#instance-search-sid").change(function () {
357
+ searchObject.sid = $("#instance-search-sid").val()
358
+ acceptCheck();
359
+ });
360
+ $("#instance-search-pid").change(function () {
361
+ searchObject.pid = $("#instance-search-pid").val()
362
+ acceptCheck();
363
+ });
364
+ $("#instance-search-ins").change(function () {
365
+ searchObject.ins = $("#instance-search-ins").val()
366
+ acceptCheck();
367
+ });
368
+
369
+ // *** MOBSEARCH *** //
370
+ },
103
371
  oneditsave: function() {
104
372
  if($("#node-input-detailedOutput").prop('checked')) {
105
373
  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 });