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