node-red-contrib-mobius-flow-base 3.1.0 → 3.1.1

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.
@@ -24,7 +24,10 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24
24
  POSSIBILITY OF SUCH DAMAGE.
25
25
  -->
26
26
 
27
- <script type="text/x-red" data-template-name="mobius discover object list">
27
+ <script
28
+ type="text/x-red"
29
+ data-template-name="mobius discover object list"
30
+ >
28
31
  <div class="form-row">
29
32
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
30
33
  <input type="text" id="node-input-name" placeholder="Name">
@@ -138,7 +141,7 @@ POSSIBILITY OF SUCH DAMAGE.
138
141
  },
139
142
  oneditprepare: function () {
140
143
  var node = this;
141
- let mobiusSrvc = $("#node-input-connection").val();
144
+ let mobiusSrvc = $('#node-input-connection').val();
142
145
 
143
146
  /** Create the subs container and populate it */
144
147
  $('#node-input-subs-container')
@@ -167,15 +170,21 @@ POSSIBILITY OF SUCH DAMAGE.
167
170
  }).appendTo(row);
168
171
 
169
172
  // *** MOBSEARCH *** //
170
- var searchField = $('<a class="searchbutton" style="margin-left: 5px; vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
173
+ var searchField = $(
174
+ '<a class="searchbutton" style="margin-left: 5px; vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>'
175
+ ).appendTo(row);
171
176
  // *** END MOBSEARCH *** //
172
177
 
173
178
  var typeField = $('<select/>', {
174
179
  class: 'node-input-sub-type',
175
180
  style: 'width:auto; margin-left: 5px; text-align: center;',
176
181
  }).appendTo(row);
177
- typeField.append($('<option></option>').val('include').text('Include'));
178
- typeField.append($('<option></option>').val('exclude').text('Exclude'));
182
+ typeField.append(
183
+ $('<option></option>').val('include').text('Include')
184
+ );
185
+ typeField.append(
186
+ $('<option></option>').val('exclude').text('Exclude')
187
+ );
179
188
 
180
189
  // Populate the new stat
181
190
  uriField.val(subscription.uri);
@@ -184,10 +193,10 @@ POSSIBILITY OF SUCH DAMAGE.
184
193
  // *** MOBSEARCH *** //
185
194
 
186
195
  if (!node.subscriptions[i]) {
187
- node.subscriptions[i] = {uri: '', type: 'include'}
196
+ node.subscriptions[i] = { uri: '', type: 'include' };
188
197
  }
189
198
 
190
- addMobsearchListButton(mobiusSrvc, searchField, i, mobsearchOpts)
199
+ addMobsearchListButton(mobiusSrvc, searchField, i, mobsearchOpts);
191
200
  // *** END MOBSEARCH *** //
192
201
  },
193
202
  });
@@ -198,7 +207,7 @@ POSSIBILITY OF SUCH DAMAGE.
198
207
  if (!node.subscriptions) {
199
208
  node.subscriptions = [(subscription = { uri: '', type: 'include' })];
200
209
  }
201
-
210
+
202
211
  // *** MOBSEARCH *** //
203
212
 
204
213
  mobsearchOpts = {
@@ -244,7 +253,9 @@ POSSIBILITY OF SUCH DAMAGE.
244
253
  }
245
254
  var editorRow = $('#dialog-form>div.node-input-subs-container-row');
246
255
  height -=
247
- 4 * (parseInt(editorRow.css('marginTop')) + parseInt(editorRow.css('marginBottom')));
256
+ 4 *
257
+ (parseInt(editorRow.css('marginTop')) +
258
+ parseInt(editorRow.css('marginBottom')));
248
259
 
249
260
  $('#node-input-subs-container').editableList('height', height);
250
261
  },
@@ -270,7 +281,10 @@ POSSIBILITY OF SUCH DAMAGE.
270
281
  });
271
282
  </script>
272
283
 
273
- <script type="text/x-red" data-help-name="mobius discover object list">
284
+ <script
285
+ type="text/x-red"
286
+ data-help-name="mobius discover object list"
287
+ >
274
288
  <p>Discover MOBiUS objects and return a filtered list of objects or URIs.</p>
275
289
 
276
290
  <h3>Configuration Page</h3>
@@ -126,7 +126,11 @@ module.exports = function (RED) {
126
126
  let objectList = [];
127
127
  try {
128
128
  const hid = node.hid === '' ? node.serviceConn.hubId : node.hid;
129
- const profiles = await discoverProfiles(node.serviceConn, hid, node.subscriptions);
129
+ const profiles = await discoverProfiles(
130
+ node.serviceConn,
131
+ hid,
132
+ node.subscriptions
133
+ );
130
134
 
131
135
  for await (let entry of profiles.entries()) {
132
136
  let discoverParams = {};
@@ -150,15 +154,28 @@ module.exports = function (RED) {
150
154
  };
151
155
  }
152
156
  try {
153
- let objects = await filterObjectsByRIDValue(node.serviceConn, discoverParams);
157
+ let objects = await filterObjectsByRIDValue(
158
+ node.serviceConn,
159
+ discoverParams
160
+ );
154
161
  for (let lp = 0; lp < objects.value.length; lp++) {
155
162
  objects.value[lp][
156
163
  'uri'
157
164
  ] = `${serviceURI}/${objects.value[lp].pid}/${objects.value[lp].ins}`;
158
- objectList.push(objects.value[lp]);
165
+ if (
166
+ isIncluded(
167
+ `${objects.value[lp]['uri']}`,
168
+ node.subscriptions
169
+ ) &&
170
+ !isExcluded(`${objects.value[lp]['uri']}`, node.subscriptions)
171
+ ) {
172
+ objectList.push(objects.value[lp]);
173
+ }
159
174
  }
160
175
  } catch (err) {
161
- node.warn(`Discover object failed for service (${serviceURI}) - ${err.message}`);
176
+ node.warn(
177
+ `Discover object failed for service (${serviceURI}) - ${err.message}`
178
+ );
162
179
  }
163
180
  }
164
181
 
@@ -185,10 +202,7 @@ module.exports = function (RED) {
185
202
  let profiles = await discover(serviceConn, `${hid}/${sid}`);
186
203
  let pids = [];
187
204
  for (const pid of profiles.data) {
188
- if (
189
- isIncluded(`${hid}/${sid}/${pid}/#`, subscriptions) &&
190
- !isExcluded(`${hid}/${sid}/${pid}/#`, subscriptions)
191
- ) {
205
+ if (isIncluded(`${hid}/${sid}/${pid}/#`, subscriptions)) {
192
206
  pids.push(pid);
193
207
  }
194
208
  }
@@ -198,7 +212,9 @@ module.exports = function (RED) {
198
212
  }
199
213
  } else {
200
214
  RED.log.warn(
201
- `Failed to discover objects for service ${service.id.split('/')[1]} as it is offline.`
215
+ `Failed to discover objects for service ${
216
+ service.id.split('/')[1]
217
+ } as it is offline.`
202
218
  );
203
219
  }
204
220
  }
@@ -240,7 +256,10 @@ module.exports = function (RED) {
240
256
  function isIncluded(uri, subscriptions) {
241
257
  let include = false;
242
258
  for (const subscription of subscriptions) {
243
- if (subscription.type === 'include' && validateSubscription(subscription.uri)) {
259
+ if (
260
+ subscription.type === 'include' &&
261
+ validateSubscription(subscription.uri)
262
+ ) {
244
263
  if (matchTopic(subscription.uri, uri)) {
245
264
  include = true;
246
265
  }
@@ -252,7 +271,10 @@ module.exports = function (RED) {
252
271
  function isExcluded(uri, subscriptions) {
253
272
  let exclude = false;
254
273
  for (const subscription of subscriptions) {
255
- if (subscription.type === 'exclude' && validateSubscription(subscription.uri)) {
274
+ if (
275
+ subscription.type === 'exclude' &&
276
+ validateSubscription(subscription.uri)
277
+ ) {
256
278
  if (matchTopic(subscription.uri, uri)) {
257
279
  exclude = true;
258
280
  }
@@ -280,12 +302,23 @@ module.exports = function (RED) {
280
302
  function matchTopic(filter, topic) {
281
303
  const filterArray = filter.split('/');
282
304
  const topicArray = topic.split('/');
283
- const length = filterArray.length < topicArray.length ? filterArray.length : topicArray.length;
305
+ const length =
306
+ filterArray.length < topicArray.length
307
+ ? filterArray.length
308
+ : topicArray.length;
284
309
 
285
310
  for (let i = 0; i < length; ++i) {
286
311
  const left = filterArray[i];
287
312
  const right = topicArray[i];
288
- if (!(left === right || left === '+' || left === '#' || right === '+' || right === '#')) {
313
+ if (
314
+ !(
315
+ left === right ||
316
+ left === '+' ||
317
+ left === '#' ||
318
+ right === '+' ||
319
+ right === '#'
320
+ )
321
+ ) {
289
322
  return false;
290
323
  }
291
324
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-mobius-flow-base",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "Node-RED base nodes for Mobius Flow",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",