node-red-contrib-mobius-flow-base 2.5.86-beta.27 → 2.5.86-beta.30

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.
@@ -53,10 +53,29 @@ POSSIBILITY OF SUCH DAMAGE.
53
53
  <option value="array">Array of Items</option>
54
54
  </select>
55
55
  </div>
56
- <div class="form-row node-input-subs-container-row">
56
+ <div id="node-input-subs-container-row" class="form-row node-input-subs-container-row">
57
57
  <label for="node-input-subs-container" style="width:105px;float:left;"><i class="fa fa-bars"></i> Discover</label>
58
58
  <ol id="node-input-subs-container"></ol>
59
59
  </div>
60
+
61
+ <div id="instance-search-row">
62
+ <div class="form-row">
63
+ <label for="instance-search-sid"><i class="fa fa-search"></i> Search</label>
64
+ <input type="text" id="instance-search-hid" style="width:15%;" placeholder="HID">
65
+ <input type="text" id="instance-search-sid" style="width:10%;" placeholder="SID">
66
+ <input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
67
+ <input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
68
+ <a id="node-search-return" class="searchbutton" style="vertical-align: middle"><i id="node-search-return-icon" class="fa fa-arrow-left"></i></a>
69
+ <a id="node-search-accept" class="searchbutton" style="vertical-align: middle"><i id="node-search-accept-icon" class="fa fa-check"></i></a>
70
+ </div>
71
+ </div>
72
+ <div id="wildcard-alert-row" class="form-row hidden" style="color:#555555" align="center">
73
+ <p>Please note: The selection of wildcard '+'
74
+ means a search for a specific instance or resource
75
+ cannot be performed. As such, enter the
76
+ INS manually.</p>
77
+ </div>
78
+
60
79
  <div class="form-row">
61
80
  <label for="node-input-useRIDValueFiltering" style="width:178px;float:left;"><i class="fa fa-filter"></i> Filter by Resource Value</label>
62
81
  <input type="checkbox" id="node-input-useRIDValueFiltering" style="display: inline-block; width: auto; vertical-align: top;">
@@ -119,6 +138,215 @@ POSSIBILITY OF SUCH DAMAGE.
119
138
  },
120
139
  oneditprepare: function () {
121
140
  var node = this;
141
+ let mobiusSrvc = $("#node-input-connection").val();
142
+
143
+ // *** MOBSEARCH *** //
144
+
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
+
152
+ let globalSubscriptionIndex = 0;
153
+
154
+ let searchObject = {
155
+ hid: '',
156
+ sid: '',
157
+ pid: '',
158
+ ins: '',
159
+ objects: []
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
+ searchObject.objects = [];
255
+ if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
256
+ $.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch)
257
+ .fail((err) => {
258
+ console.log('Some kind of html failure message on service discovery');
259
+ });
260
+ }
261
+ }
262
+
263
+ //Finish a search
264
+ function finishSearch() {
265
+ $("#wildcard-alert-row").hide();
266
+ let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`
267
+ if (uri.includes('#')) {
268
+ uri = uri.substring(0,uri.indexOf('#') + 1)
269
+ }
270
+ node.subscriptions[globalSubscriptionIndex].uri = uri;
271
+ updateList()
272
+ $("#node-search-accept").css('color', '#CCCCCC');
273
+ readyToAccept = false;
274
+ $("#node-search-return").addClass('disabled');
275
+ $("#node-search-accept").addClass('disabled');
276
+ $("#instance-search-row").hide();
277
+ $('#node-input-subs-container-row').show();
278
+ }
279
+
280
+ //Function to update if accept button is grade out and functions based on conditions of fields
281
+ function acceptCheck() {
282
+ if (($("#instance-search-hid").val() !== '' && $("#instance-search-sid").val() !== '' && $("#instance-search-pid").val() !== '' && $("#instance-search-ins").val() !== '') ||
283
+ $("#instance-search-sid").val() === '#' || $("#instance-search-pid").val() === '#' || $("#instance-search-ins").val() === '#') {
284
+ $("#node-search-accept").css('color', '#555555');
285
+ readyToAccept = true;
286
+ } else {
287
+ $("#node-search-accept").css('color', '#CCCCCC');
288
+ readyToAccept = false;
289
+ }
290
+ if ($("#instance-search-sid").val() !== '+' && $("#instance-search-pid").val() !== '+') {
291
+ $("#wildcard-alert-row").hide();
292
+ } else {
293
+ $("#wildcard-alert-row").show();
294
+ }
295
+ }
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
+ $("#instance-search-row").hide();
321
+ $('#node-input-subs-container-row').show();
322
+ });
323
+ $("#node-search-accept").click(function () { //Accept button clicked
324
+ if (readyToAccept) {
325
+ finishSearch();
326
+ }
327
+ });
328
+
329
+ // Respond to search field changes
330
+ $("#instance-search-hid").change(function () {
331
+ acceptCheck();
332
+ $("#instance-search-sid").val('');
333
+ $("#instance-search-pid").val('');
334
+ $("#instance-search-ins").val('');
335
+ });
336
+ $("#instance-search-sid").change(function () {
337
+ searchObject.sid = $("#instance-search-sid").val()
338
+ acceptCheck();
339
+ });
340
+ $("#instance-search-pid").change(function () {
341
+ searchObject.pid = $("#instance-search-pid").val()
342
+ acceptCheck();
343
+ });
344
+ $("#instance-search-ins").change(function () {
345
+ searchObject.ins = $("#instance-search-ins").val()
346
+ acceptCheck();
347
+ });
348
+
349
+ // *** END MOBSEARCH *** //
122
350
 
123
351
  /** Create the subs container and populate it */
124
352
  $('#node-input-subs-container').css('min-height', '200px').css('min-width', '345px').editableList ({
@@ -137,7 +365,12 @@ POSSIBILITY OF SUCH DAMAGE.
137
365
  }
138
366
 
139
367
  var row = $('<div>URI</div>').appendTo(container);
140
- var uriField = $('<input/>',{class: "node-input-sub-uri", type: "text", style: "width: 170px; margin-left: 5px; text-align: left;"}).appendTo(row);
368
+ var uriField = $('<input/>',{class: "node-input-sub-uri", type: "text", style: "width: 150px; margin-left: 5px; text-align: left;"}).appendTo(row);
369
+
370
+ // *** MOBSEARCH *** //
371
+ var searchField = $('<a class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
372
+ // *** END MOBSEARCH *** //
373
+
141
374
  var typeField = $('<select/>',{class: "node-input-sub-type", style: "width:auto; margin-left: 5px; text-align: center;"}).appendTo(row);
142
375
  typeField.append($("<option></option>").val('include').text('Include'));
143
376
  typeField.append($("<option></option>").val('exclude').text('Exclude'));
@@ -145,6 +378,25 @@ POSSIBILITY OF SUCH DAMAGE.
145
378
  // Populate the new stat
146
379
  uriField.val(subscription.uri);
147
380
  typeField.val(subscription.type);
381
+
382
+ // *** MOBSEARCH *** //
383
+
384
+ if (!node.subscriptions[i]) {
385
+ node.subscriptions[i] = {uri: '', type: 'include'}
386
+ }
387
+
388
+ searchField.click(function () {
389
+ globalSubscriptionIndex = i;
390
+ $('#node-input-subs-container-row').hide();
391
+ $("#instance-search-sid").val('');
392
+ $("#instance-search-pid").val('');
393
+ $("#instance-search-ins").val('');
394
+ $("#node-search-return").removeClass('disabled');
395
+ $("#node-search-accept").removeClass('disabled');
396
+ $("#instance-search-row").show();
397
+
398
+ });
399
+ // *** END MOBSEARCH *** //
148
400
  }
149
401
  });
150
402
 
@@ -154,11 +406,19 @@ POSSIBILITY OF SUCH DAMAGE.
154
406
  if (!node.subscriptions) {
155
407
  node.subscriptions = [subscription = {uri: '', type: 'include'}];
156
408
  }
157
- // Populate list with all saved filters
158
- for (let i = 0; i < node.subscriptions.length; i++) {
159
- let subscription = node.subscriptions[i];
160
- $("#node-input-subs-container").editableList('addItem', subscription);
409
+
410
+ // *** MOBSEARCH *** //
411
+
412
+ function updateList() {
413
+ $("#node-input-subs-container").editableList('empty');
414
+ for (let i = 0; i < node.subscriptions.length; i++) {
415
+ let subscription = node.subscriptions[i];
416
+ $("#node-input-subs-container").editableList('addItem', subscription);
417
+ }
161
418
  }
419
+ updateList()
420
+
421
+ // *** END MOBSEARCH *** //
162
422
 
163
423
  function showRIDFilterInputs() {
164
424
  if($("#node-input-useRIDValueFiltering").is(':checked')) {
@@ -34,10 +34,28 @@ POSSIBILITY OF SUCH DAMAGE.
34
34
  <label for="node-input-connection"><i class="fa fa-globe"></i> MOBiUS</label>
35
35
  <input type="text" id="node-input-connection">
36
36
  </div>
37
- <div class="form-row node-input-mobjects-container-row">
37
+ <div id="node-input-subs-container-row" class="form-row node-input-mobjects-container-row">
38
38
  <label for="node-input-mobjects-container"><i class="fa fa-bars"></i> Objects</label>
39
39
  <ol id="node-input-mobjects-container"></ol>
40
40
  </div>
41
+
42
+ <div id="instance-search-row">
43
+ <div class="form-row">
44
+ <label for="instance-search-sid"><i class="fa fa-search"></i> Search</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>
41
59
  </script>
42
60
 
43
61
  <script type="text/javascript">
@@ -74,6 +92,216 @@ POSSIBILITY OF SUCH DAMAGE.
74
92
  mobject.find(".node-input-mobject-comment").width(newWidth - 270);
75
93
  }
76
94
 
95
+ let mobiusSrvc = $("#node-input-connection").val();
96
+
97
+ // *** MOBSEARCH *** //
98
+
99
+ $("#instance-search-row").hide();
100
+ $("#wildcard-alert-row").hide();
101
+ $("#node-search-return").addClass('disabled');
102
+ $.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
103
+ $("#instance-search-hid").val(response);
104
+ })
105
+
106
+ let globalSubscriptionIndex = 0;
107
+
108
+ let searchObject = {
109
+ hid: '',
110
+ sid: '',
111
+ pid: '',
112
+ ins: '',
113
+ objects: []
114
+ }
115
+
116
+ //Function to search for INSs
117
+ function insSearch (objects, pid) {
118
+ let inss = ['#'];
119
+ for (let i = 0; i < objects.length; i++) {
120
+ if (objects[i].pid === pid) {
121
+ const name = objects[i].resources[1].pv;
122
+ if (name === '') {
123
+ inss.push(objects[i].ins);
124
+ } else {
125
+ inss.push(`${objects[i].ins} - ${name}`);
126
+ }
127
+ }
128
+ }
129
+ $("#instance-search-ins").autocomplete({
130
+ source: inss,
131
+ minLength: 0,
132
+ close: function (event, ui) {
133
+ acceptCheck();
134
+ $("#instance-search-ins").autocomplete('destroy');
135
+ if ($("#instance-search-ins").val().length > 4) {
136
+ $("#instance-search-ins").val($("#instance-search-ins").val().substring(0, 4))
137
+ }
138
+ searchObject.ins = $("#instance-search-ins").val();
139
+ }
140
+ }).autocomplete('search', '');
141
+ }
142
+
143
+ //Function to search for PIDs
144
+ function pidsSearch(objects) {
145
+ searchObject.objects = objects;
146
+ let pids = ['#', '+'];
147
+ for (let i = 0; i < objects.length; i++) {
148
+ pids.push(`${objects[i].pid} - ${objects[i].profileName}`);
149
+ }
150
+ pids = [...new Set(pids)];
151
+ $("#instance-search-pid").autocomplete({
152
+ source: pids,
153
+ minLength: 0,
154
+ close: function (event, ui) {
155
+ acceptCheck();
156
+ $("#instance-search-pid").autocomplete('destroy');
157
+ if ($("#instance-search-pid").val().length > 4) {
158
+ $("#instance-search-pid").val($("#instance-search-pid").val().substring(0, 4))
159
+ }
160
+ searchObject.pid = $("#instance-search-pid").val();
161
+ }
162
+ }).autocomplete('search', '');
163
+ }
164
+
165
+ //Function to search for SIDs, and then fetch child objects based on selection
166
+ function serviceSearch(response) {
167
+ let services = ['#', '+'];
168
+ for (let i = 0; i < response.length; i++) {
169
+ if (response[i].sid !== '009') {
170
+ services.push(`${response[i].sid} - ${response[i].name}`);
171
+ }
172
+ }
173
+ $("#instance-search-sid").autocomplete({
174
+ source: services,
175
+ minLength: 0,
176
+ close: function (event, ui) {
177
+ acceptCheck();
178
+ $("#instance-search-sid").autocomplete('destroy');
179
+ if ($("#instance-search-sid").val().length > 3) {
180
+ $("#instance-search-sid").val($("#instance-search-sid").val().substring(0, 3))
181
+ }
182
+ searchObject.sid = $("#instance-search-sid").val();
183
+ if (searchObject.sid === '+') {
184
+ for (let i = 2; i < services.length; i++) {
185
+ $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${services[i].substring(0, 3)}`, (objects) => {
186
+ searchObject.objects = searchObject.objects.concat(objects);
187
+ })
188
+ }
189
+ } else {
190
+ $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${searchObject.sid}`, (objects) => {
191
+ searchObject.objects = objects;
192
+ })
193
+ }
194
+ }
195
+ }).autocomplete('search', '');
196
+ }
197
+
198
+ //Start a new search
199
+ function startSearch() {
200
+ $("#wildcard-alert-row").hide();
201
+ $("#instance-search-sid").val('');
202
+ $("#instance-search-pid").val('');
203
+ $("#instance-search-ins").val('');
204
+ searchObject.hid = $("#instance-search-hid").val()
205
+ searchObject.sid = '';
206
+ searchObject.pid = '';
207
+ searchObject.ins = '';
208
+ searchObject.objects = [];
209
+ if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
210
+ $.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch)
211
+ .fail((err) => {
212
+ console.log('Some kind of html failure message on service discovery');
213
+ });
214
+ }
215
+ }
216
+
217
+ //Finish a search
218
+ function finishSearch() {
219
+ $("#wildcard-alert-row").hide();
220
+ let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`
221
+ if (uri.includes('#')) {
222
+ uri = uri.substring(0,uri.indexOf('#') + 1)
223
+ }
224
+ node.mobjects[globalSubscriptionIndex].uri = uri;
225
+ updateList()
226
+ $("#node-search-accept").css('color', '#CCCCCC');
227
+ readyToAccept = false;
228
+ $("#node-search-return").addClass('disabled');
229
+ $("#node-search-accept").addClass('disabled');
230
+ $("#instance-search-row").hide();
231
+ $('#node-input-subs-container-row').show();
232
+ }
233
+
234
+ //Function to update if accept button is grade out and functions based on conditions of fields
235
+ function acceptCheck() {
236
+ if (($("#instance-search-hid").val() !== '' && $("#instance-search-sid").val() !== '' && $("#instance-search-pid").val() !== '' && $("#instance-search-ins").val() !== '') ||
237
+ $("#instance-search-sid").val() === '#' || $("#instance-search-pid").val() === '#' || $("#instance-search-ins").val() === '#') {
238
+ $("#node-search-accept").css('color', '#555555');
239
+ readyToAccept = true;
240
+ } else {
241
+ $("#node-search-accept").css('color', '#CCCCCC');
242
+ readyToAccept = false;
243
+ }
244
+ if ($("#instance-search-sid").val() !== '+' && $("#instance-search-pid").val() !== '+') {
245
+ $("#wildcard-alert-row").hide();
246
+ } else {
247
+ $("#wildcard-alert-row").show();
248
+ }
249
+ }
250
+
251
+ $("#instance-search-sid").click(function () { //SID field clicked
252
+ $("#instance-search-pid").val('')
253
+ $("#instance-search-ins").val('')
254
+ searchObject.pid = '';
255
+ searchObject.ins = '';
256
+ searchObject.objects = [];
257
+ startSearch();
258
+ })
259
+ $("#instance-search-pid").click(function () { //PID field clicked
260
+ $("#instance-search-ins").val('')
261
+ searchObject.ins = '';
262
+ if (searchObject.sid !== '') {
263
+ pidsSearch(searchObject.objects);
264
+ }
265
+ })
266
+ $("#instance-search-ins").click(function () { //INS field clicked
267
+ if (searchObject.pid !== '' && searchObject.pid !== '+' && searchObject.sid !== '+') {
268
+ insSearch(searchObject.objects, searchObject.pid);
269
+ }
270
+ })
271
+ $("#node-search-return").click(function () { //Return/Back button clicked
272
+ $("#node-search-return").addClass('disabled');
273
+ $("#node-search-accept").addClass('disabled');
274
+ $("#instance-search-row").hide();
275
+ $('#node-input-subs-container-row').show();
276
+ });
277
+ $("#node-search-accept").click(function () { //Accept button clicked
278
+ if (readyToAccept) {
279
+ finishSearch();
280
+ }
281
+ });
282
+
283
+ // Respond to search field changes
284
+ $("#instance-search-hid").change(function () {
285
+ acceptCheck();
286
+ $("#instance-search-sid").val('');
287
+ $("#instance-search-pid").val('');
288
+ $("#instance-search-ins").val('');
289
+ });
290
+ $("#instance-search-sid").change(function () {
291
+ searchObject.sid = $("#instance-search-sid").val()
292
+ acceptCheck();
293
+ });
294
+ $("#instance-search-pid").change(function () {
295
+ searchObject.pid = $("#instance-search-pid").val()
296
+ acceptCheck();
297
+ });
298
+ $("#instance-search-ins").change(function () {
299
+ searchObject.ins = $("#instance-search-ins").val()
300
+ acceptCheck();
301
+ });
302
+
303
+ // *** END MOBSEARCH *** //
304
+
77
305
  /** Create the objects container and populate it */
78
306
  $('#node-input-mobjects-container').css('min-height', '300px').css('min-width', '450px').editableList ({
79
307
  addButton: "add",
@@ -93,12 +321,36 @@ POSSIBILITY OF SUCH DAMAGE.
93
321
  var row = $('<div>URI</div>').appendTo(container);
94
322
  var uriField = $('<input/>',{class: "node-input-mobject-uri", type: "text", style: "width: 200px; margin-left: 5px; text-align: left;"}).appendTo(row);
95
323
  row.append('&nbsp;&nbsp;-&nbsp;');
324
+
325
+ // *** MOBSEARCH *** //
326
+ var searchField = $('<a class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
327
+ // *** END MOBSEARCH *** //
328
+
96
329
  var commentField = $('<input/>',{class: "node-input-mobject-comment", type: "text", style: "margin-left: 5px; text-align: left;"}).appendTo(row);
97
330
 
98
331
  // Populate the new stat
99
332
  uriField.val(mobject.uri);
100
333
  commentField.val(mobject.comment);
101
334
  resizeObject(container);
335
+
336
+ // *** MOBSEARCH *** //
337
+
338
+ if (!node.mobjects[i]) {
339
+ node.mobjects[i] = {uri: '', type: 'include'}
340
+ }
341
+
342
+ searchField.click(function () {
343
+ globalSubscriptionIndex = i;
344
+ $('#node-input-subs-container-row').hide();
345
+ $("#instance-search-sid").val('');
346
+ $("#instance-search-pid").val('');
347
+ $("#instance-search-ins").val('');
348
+ $("#node-search-return").removeClass('disabled');
349
+ $("#node-search-accept").removeClass('disabled');
350
+ $("#instance-search-row").show();
351
+
352
+ });
353
+ // *** END MOBSEARCH *** //
102
354
  },
103
355
  resizeItem: resizeObject
104
356
  });
@@ -107,11 +359,18 @@ POSSIBILITY OF SUCH DAMAGE.
107
359
  if (!node.mobjects) {
108
360
  node.mobjects = [mobject = {uri: '', comment: ''}];
109
361
  }
110
- // Populate list with all saved filters
111
- for (let i = 0; i < node.mobjects.length; i++) {
112
- let mobject = node.mobjects[i];
113
- $("#node-input-mobjects-container").editableList('addItem', mobject);
362
+ // *** MOBSEARCH *** //
363
+
364
+ function updateList() {
365
+ $("#node-input-subs-container").editableList('empty');
366
+ for (let i = 0; i < node.mobjects.length; i++) {
367
+ let mobject = node.mobjects[i];
368
+ $("#node-input-subs-container").editableList('addItem', mobject);
369
+ }
114
370
  }
371
+ updateList()
372
+
373
+ // *** END MOBSEARCH *** //
115
374
  },
116
375
  oneditresize(size) {
117
376
  var rows = $("#dialog-form>div:not(.node-input-mobjects-container-row)");
@@ -59,14 +59,14 @@ POSSIBILITY OF SUCH DAMAGE.
59
59
  cannot be performed. As such, enter the
60
60
  INS manually.</p>
61
61
  </div>
62
- <div id="node-input-format-row" class="form-row">
62
+ <div class="form-row">
63
63
  <label for="node-input-format"><i class="fa fa-bars"></i> Format</label>
64
64
  <select type="text" id="node-input-format" style="display: inline-block; width: auto; vertical-align: center;">
65
65
  <option value="name">By Name</option>
66
66
  <option value="rid">By RID</option>
67
67
  </select>
68
68
  </div>
69
- <div id="node-input-detailedOutput-row" class="form-row">
69
+ <div class="form-row">
70
70
  <label>&nbsp;</label>
71
71
  <input type="checkbox" id="node-input-detailedOutput" style="display: inline-block; width: auto; vertical-align: top;">
72
72
  <label for="node-input-detailedOutput" style="width: 70%;"> Use detailed outputs</label>
@@ -272,9 +272,6 @@ POSSIBILITY OF SUCH DAMAGE.
272
272
  $("#node-lookup-instance").removeClass('disabled');
273
273
  $("#instance-search-row").hide();
274
274
  $("#instance-row").show();
275
-
276
- $("#node-input-format-row").show();
277
- $("#node-input-detailedOutput-row").show();
278
275
  }
279
276
 
280
277
  //Function to update if accept button is grade out and functions based on conditions of fields
@@ -304,9 +301,6 @@ POSSIBILITY OF SUCH DAMAGE.
304
301
  $("#node-search-accept").removeClass('disabled');
305
302
  $("#instance-row").hide();
306
303
  $("#instance-search-row").show();
307
-
308
- $("#node-input-format-row").hide();
309
- $("#node-input-detailedOutput-row").hide();
310
304
  });
311
305
  $("#instance-search-sid").click(function () { //SID field clicked
312
306
  $("#instance-search-pid").val('')
@@ -334,9 +328,6 @@ POSSIBILITY OF SUCH DAMAGE.
334
328
  $("#node-lookup-instance").removeClass('disabled');
335
329
  $("#instance-search-row").hide();
336
330
  $("#instance-row").show();
337
-
338
- $("#node-input-format-row").show();
339
- $("#node-input-detailedOutput-row").show();
340
331
  });
341
332
  $("#node-search-accept").click(function () { //Accept button clicked
342
333
  if (readyToAccept) {
@@ -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 });
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.27",
3
+ "version": "2.5.86-beta.30",
4
4
  "description": "Node-RED base nodes for Mobius Flow",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",