node-red-contrib-mobius-flow-base 2.5.86-beta.69 → 2.5.86-beta.72

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.
@@ -28,7 +28,7 @@
28
28
  'use strict';
29
29
 
30
30
  module.exports = function (RED) {
31
- function MobiusFlowNode (n) {
31
+ function MobiusFlowNode(n) {
32
32
  RED.nodes.createNode(this, n);
33
33
  this.mobjects = n.mobjects;
34
34
  this.serviceConn = RED.nodes.getNode(n.connection);
@@ -38,7 +38,7 @@ module.exports = function (RED) {
38
38
  node.status({
39
39
  fill: 'red',
40
40
  shape: 'ring',
41
- text: 'Disconnected'
41
+ text: 'Disconnected',
42
42
  });
43
43
 
44
44
  node.serviceConn.register(node);
@@ -47,7 +47,7 @@ module.exports = function (RED) {
47
47
  node.status({
48
48
  fill: 'green',
49
49
  shape: 'ring',
50
- text: 'Busy'
50
+ text: 'Busy',
51
51
  });
52
52
 
53
53
  for (const mobject of node.mobjects) {
@@ -55,7 +55,7 @@ module.exports = function (RED) {
55
55
  node.status({
56
56
  fill: 'yellow',
57
57
  shape: 'dot',
58
- text: 'URIs not Valid'
58
+ text: 'URIs not Valid',
59
59
  });
60
60
  if (done) {
61
61
  return done();
@@ -71,15 +71,15 @@ module.exports = function (RED) {
71
71
  node.status({
72
72
  fill: 'green',
73
73
  shape: 'dot',
74
- text: 'Done'
74
+ text: 'Done',
75
75
  });
76
- node.send({topic: msg.topic, payload: values});
76
+ node.send({ topic: msg.topic, payload: values });
77
77
  })
78
78
  .catch((err) => {
79
79
  node.status({
80
80
  fill: 'yellow',
81
81
  shape: 'dot',
82
- text: 'Error: ' + JSON.stringify(err.code)
82
+ text: 'Error: ' + JSON.stringify(err.code),
83
83
  });
84
84
  node.error('Mobius error reading object ' + JSON.stringify(err));
85
85
  })
@@ -98,7 +98,7 @@ module.exports = function (RED) {
98
98
  }
99
99
  }
100
100
 
101
- function validateResourceURI (uri) {
101
+ function validateResourceURI(uri) {
102
102
  let parts = uri.split('/');
103
103
  for (let lp = 0; lp < parts.length; lp++) {
104
104
  if (parts[lp] === null || parts[lp] === '') {
@@ -111,7 +111,7 @@ module.exports = function (RED) {
111
111
  return false;
112
112
  }
113
113
 
114
- function readObject (node, uri) {
114
+ function readObject(node, uri) {
115
115
  return new Promise((resolve, reject) => {
116
116
  node.serviceConn.readObject(uri, (err, response) => {
117
117
  if (err) {
@@ -124,4 +124,12 @@ module.exports = function (RED) {
124
124
  }
125
125
 
126
126
  RED.nodes.registerType('mobius get multi-object', MobiusFlowNode);
127
+
128
+ RED.httpAdmin.get('/common/*', function (req, res) {
129
+ var options = {
130
+ root: __dirname + '/common/',
131
+ dotfiles: 'deny',
132
+ };
133
+ res.sendFile(req.params[0], options);
134
+ });
127
135
  };
@@ -108,7 +108,8 @@ POSSIBILITY OF SUCH DAMAGE.
108
108
 
109
109
  opts = {
110
110
  htmlElementId: 'mobsearch',
111
- uriFieldName: 'node-input-instance '
111
+ uriFieldName: 'node-input-instance ',
112
+ inputRowId: 'input-row',
112
113
  };
113
114
  initMobsearch.toIns(mobiusSrvc, opts);
114
115
  },
@@ -101,7 +101,8 @@ POSSIBILITY OF SUCH DAMAGE.
101
101
 
102
102
  opts = {
103
103
  htmlElementId: 'mobsearch',
104
- uriFieldName: 'node-input-resource'
104
+ uriFieldName: 'node-input-resource',
105
+ inputRowId: 'input-row',
105
106
  };
106
107
  initMobsearch.toRid(mobiusSrvc, opts);
107
108
 
@@ -33,29 +33,13 @@ POSSIBILITY OF SUCH DAMAGE.
33
33
  <hr>
34
34
 
35
35
  <div id="instance-row">
36
- <div class="form-row">
36
+ <div class="form-row" id="input-row">
37
37
  <label for="node-input-instance"><i class="fa fa-tasks"></i> URI</label>
38
38
  <input type="text" id="node-input-instance" style="width:61%;" placeholder="HID/SID/PID/INS (optional name)">
39
39
  <a id="node-lookup-instance" class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>
40
40
  </div>
41
41
  </div>
42
- <div id="instance-search-row">
43
- <div class="form-row">
44
- <label for="instance-search-sid"><i class="fa fa-tasks"></i> URI</label>
45
- <input type="text" id="instance-search-hid" style="width:15%;" placeholder="HID">
46
- <input type="text" id="instance-search-sid" style="width:10%;" placeholder="SID">
47
- <input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
48
- <input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
49
- <a id="node-search-return" class="searchbutton" style="vertical-align: middle"><i id="node-search-return-icon" class="fa fa-arrow-left"></i></a>
50
- <a id="node-search-accept" class="searchbutton" style="vertical-align: middle"><i id="node-search-accept-icon" class="fa fa-check"></i></a>
51
- </div>
52
- </div>
53
- <div id="wildcard-alert-row" class="form-row hidden" style="color:#555555" align="center">
54
- <p>Please note: The selection of wildcard '+'
55
- means a search for a specific instance or resource
56
- cannot be performed. As such, enter the
57
- INS manually.</p>
58
- </div>
42
+ <div id="mobsearch"></div>
59
43
 
60
44
  <div class="form-row">
61
45
  <label for="node-input-include"><i class="fa fa-bars"></i> Include</label>
@@ -83,6 +67,8 @@ POSSIBILITY OF SUCH DAMAGE.
83
67
  </div>
84
68
  </script>
85
69
 
70
+ <script src="common/mobsearch.js"></script>
71
+
86
72
  <script type="text/javascript">
87
73
  RED.nodes.registerType('mobius object cov', {
88
74
  category: 'mobius',
@@ -129,227 +115,12 @@ POSSIBILITY OF SUCH DAMAGE.
129
115
  var node = this;
130
116
  let mobiusSrvc = $("#node-input-connection").val();
131
117
 
132
- $("#instance-search-row").hide();
133
-
134
- $("#node-search-return").addClass('disabled');
135
-
136
- // *** MOBSEARCH *** //
137
-
138
- //Inital setup
139
- $("#instance-search-row").hide();
140
- $("#wildcard-alert-row").hide();
141
- $("#node-search-return").addClass('disabled');
142
- $.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
143
- $("#instance-search-hid").val(response);
144
- })
145
- let readyToAccept = false;
146
- let searchObject = {
147
- hid: $("#instance-search-hid").val(),
148
- sid: $("#instance-search-sid").val(),
149
- pid: $("#instance-search-pid").val(),
150
- ins: $("#instance-search-ins").val(),
151
- objects: []
152
- }
153
-
154
- //Function to search for INSs
155
- function insSearch (objects, pid) {
156
- let inss = ['#'];
157
- for (let i = 0; i < objects.length; i++) {
158
- if (objects[i].pid === pid) {
159
- const name = objects[i].resources[1].pv;
160
- if (name === '') {
161
- inss.push(objects[i].ins);
162
- } else {
163
- inss.push(`${objects[i].ins} - ${name}`);
164
- }
165
- }
166
- }
167
- $("#instance-search-ins").autocomplete({
168
- source: inss,
169
- minLength: 0,
170
- close: function (event, ui) {
171
- acceptCheck();
172
- $("#instance-search-ins").autocomplete('destroy');
173
- if ($("#instance-search-ins").val().length > 4) {
174
- $("#instance-search-ins").val($("#instance-search-ins").val().substring(0, 4))
175
- }
176
- searchObject.ins = $("#instance-search-ins").val();
177
- }
178
- }).autocomplete('search', '');
179
- }
180
-
181
- //Function to search for PIDs
182
- function pidsSearch(objects) {
183
- searchObject.objects = objects;
184
- let pids = ['#', '+'];
185
- for (let i = 0; i < objects.length; i++) {
186
- pids.push(`${objects[i].pid} - ${objects[i].profileName}`);
187
- }
188
- pids = [...new Set(pids)];
189
- $("#instance-search-pid").autocomplete({
190
- source: pids,
191
- minLength: 0,
192
- close: function (event, ui) {
193
- acceptCheck();
194
- $("#instance-search-pid").autocomplete('destroy');
195
- if ($("#instance-search-pid").val().length > 4) {
196
- $("#instance-search-pid").val($("#instance-search-pid").val().substring(0, 4))
197
- }
198
- searchObject.pid = $("#instance-search-pid").val();
199
- }
200
- }).autocomplete('search', '');
201
- }
202
-
203
- //Function to search for SIDs, and then fetch child objects based on selection
204
- function serviceSearch(response) {
205
- let services = ['#', '+'];
206
- for (let i = 0; i < response.length; i++) {
207
- if (response[i].sid !== '009') {
208
- services.push(`${response[i].sid} - ${response[i].name}`);
209
- }
210
- }
211
- $("#instance-search-sid").autocomplete({
212
- source: services,
213
- minLength: 0,
214
- close: function (event, ui) {
215
- acceptCheck();
216
- $("#instance-search-sid").autocomplete('destroy');
217
- if ($("#instance-search-sid").val().length > 3) {
218
- $("#instance-search-sid").val($("#instance-search-sid").val().substring(0, 3))
219
- }
220
- searchObject.sid = $("#instance-search-sid").val();
221
- if (searchObject.sid === '+') {
222
- for (let i = 2; i < services.length; i++) {
223
- $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${services[i].substring(0, 3)}`, (objects) => {
224
- searchObject.objects = searchObject.objects.concat(objects);
225
- })
226
- }
227
- } else {
228
- $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${searchObject.sid}`, (objects) => {
229
- searchObject.objects = objects;
230
- })
231
- }
232
- }
233
- }).autocomplete('search', '');
234
- }
235
-
236
- //Start a new search
237
- function startSearch() {
238
- $("#wildcard-alert-row").hide();
239
- $("#instance-search-sid").val('');
240
- $("#instance-search-pid").val('');
241
- $("#instance-search-ins").val('');
242
- searchObject.hid = $("#instance-search-hid").val()
243
- searchObject.sid = '';
244
- searchObject.pid = '';
245
- searchObject.ins = '';
246
- if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
247
- $.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch)
248
- .fail((err) => {
249
- console.log('Some kind of html failure message on service discovery');
250
- });
251
- }
252
- }
253
-
254
- //Finish a search
255
- function finishSearch() {
256
- $("#wildcard-alert-row").hide();
257
- let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`
258
- if (uri.includes('#')) {
259
- uri = uri.substring(0,uri.indexOf('#') + 1)
260
- }
261
- $("#node-input-instance").val(uri);
262
- $("#node-search-accept").css('color', '#CCCCCC');
263
- readyToAccept = false;
264
- $("#node-search-return").addClass('disabled');
265
- $("#node-search-accept").addClass('disabled');
266
- $("#node-lookup-instance").removeClass('disabled');
267
- $("#instance-search-row").hide();
268
- $("#instance-row").show();
269
- }
270
-
271
- //Function to update if accept button is grade out and functions based on conditions of fields
272
- function acceptCheck() {
273
- if (($("#instance-search-hid").val() !== '' && $("#instance-search-sid").val() !== '' && $("#instance-search-pid").val() !== '' && $("#instance-search-ins").val() !== '') ||
274
- $("#instance-search-sid").val() === '#' || $("#instance-search-pid").val() === '#' || $("#instance-search-ins").val() === '#') {
275
- $("#node-search-accept").css('color', '#555555');
276
- readyToAccept = true;
277
- } else {
278
- $("#node-search-accept").css('color', '#CCCCCC');
279
- readyToAccept = false;
280
- }
281
- if ($("#instance-search-sid").val() !== '+' && $("#instance-search-pid").val() !== '+') {
282
- $("#wildcard-alert-row").hide();
283
- } else {
284
- $("#wildcard-alert-row").show();
285
- }
286
- }
287
-
288
- // Respond to clicks
289
- $("#node-lookup-instance").click(function () { //When search button is clicked
290
- $("#instance-search-sid").val('');
291
- $("#instance-search-pid").val('');
292
- $("#instance-search-ins").val('');
293
- $("#node-lookup-instance").addClass('disabled');
294
- $("#node-search-return").removeClass('disabled');
295
- $("#node-search-accept").removeClass('disabled');
296
- $("#instance-row").hide();
297
- $("#instance-search-row").show();
298
- });
299
- $("#instance-search-sid").click(function () { //SID field clicked
300
- $("#instance-search-pid").val('')
301
- $("#instance-search-ins").val('')
302
- searchObject.pid = '';
303
- searchObject.ins = '';
304
- searchObject.objects = [];
305
- startSearch();
306
- })
307
- $("#instance-search-pid").click(function () { //PID field clicked
308
- $("#instance-search-ins").val('')
309
- searchObject.ins = '';
310
- if (searchObject.sid !== '') {
311
- pidsSearch(searchObject.objects);
312
- }
313
- })
314
- $("#instance-search-ins").click(function () { //INS field clicked
315
- if (searchObject.pid !== '' && searchObject.pid !== '+' && searchObject.sid !== '+') {
316
- insSearch(searchObject.objects, searchObject.pid);
317
- }
318
- })
319
- $("#node-search-return").click(function () { //Return/Back button clicked
320
- $("#node-search-return").addClass('disabled');
321
- $("#node-search-accept").addClass('disabled');
322
- $("#node-lookup-instance").removeClass('disabled');
323
- $("#instance-search-row").hide();
324
- $("#instance-row").show();
325
- });
326
- $("#node-search-accept").click(function () { //Accept button clicked
327
- if (readyToAccept) {
328
- finishSearch();
329
- }
330
- });
331
-
332
- // Respond to search field changes
333
- $("#instance-search-hid").change(function () {
334
- acceptCheck();
335
- $("#instance-search-sid").val('');
336
- $("#instance-search-pid").val('');
337
- $("#instance-search-ins").val('');
338
- });
339
- $("#instance-search-sid").change(function () {
340
- searchObject.sid = $("#instance-search-sid").val()
341
- acceptCheck();
342
- });
343
- $("#instance-search-pid").change(function () {
344
- searchObject.pid = $("#instance-search-pid").val()
345
- acceptCheck();
346
- });
347
- $("#instance-search-ins").change(function () {
348
- searchObject.ins = $("#instance-search-ins").val()
349
- acceptCheck();
350
- });
351
-
352
- // *** MOBSEARCH *** //
118
+ opts = {
119
+ htmlElementId: 'mobsearch',
120
+ uriFieldName: 'node-input-instance',
121
+ inputRowId: 'input-row',
122
+ };
123
+ initMobsearch.toIns(mobiusSrvc, opts);
353
124
  },
354
125
  oneditsave: function() {
355
126
  if($("#node-input-detailedOutput").prop('checked')) {
@@ -82,4 +82,12 @@ module.exports = function (RED) {
82
82
  }
83
83
 
84
84
  RED.nodes.registerType('mobius object cov', MobiusObjectCovNode);
85
+
86
+ RED.httpAdmin.get('/common/*', function (req, res) {
87
+ var options = {
88
+ root: __dirname + '/common/',
89
+ dotfiles: 'deny',
90
+ };
91
+ res.sendFile(req.params[0], options);
92
+ });
85
93
  };