node-red-contrib-mobius-flow-base 2.5.86-beta.8 → 2.5.86-beta.83
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.
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param mobiusSrvc - Connection to Mobius
|
|
4
|
+
* @param {object} opts - Options object, field explained below
|
|
5
|
+
|
|
6
|
+
OPTS OBJECT (opts.)
|
|
7
|
+
ALL CASES
|
|
8
|
+
htmlElementId - The id of the HTML element that mobsearch will inject into
|
|
9
|
+
NON-LISTED ONLY
|
|
10
|
+
uriFieldName - The id of the URI HTML field, mobsearch will set the value of this field to be the result
|
|
11
|
+
inputRowId - The id of the main input, mobsearch will add the search button to this row
|
|
12
|
+
LISTED ONLY (Uses editable list)
|
|
13
|
+
list - Array containing current list items in object form
|
|
14
|
+
containerRowName - The id of the row containing the HTML container
|
|
15
|
+
containerName - The id of the HTML container
|
|
16
|
+
containerSecondFieldName - The id of the secondary field (Not URI field) within HTML container
|
|
17
|
+
|
|
18
|
+
EXAMPLE OPTS OBJECT - context of getMultiResource (node using editable list)
|
|
19
|
+
opts = {
|
|
20
|
+
htmlElementId: 'mobsearch',
|
|
21
|
+
list: node.resources,
|
|
22
|
+
containerRowName: 'node-input-resources-container-row',
|
|
23
|
+
containerName: 'node-input-resources-container',
|
|
24
|
+
containerSecondFieldName: 'node-input-resources-comment',
|
|
25
|
+
};
|
|
26
|
+
EXAMPLE OPTS OBJECT - context of getResource (standard node, not using editable list)
|
|
27
|
+
opts = {
|
|
28
|
+
htmlElementId: 'mobsearch',
|
|
29
|
+
uriFieldName: 'node-input-resource',
|
|
30
|
+
inputRowId: 'input-row',
|
|
31
|
+
};
|
|
32
|
+
*
|
|
33
|
+
*
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
initMobsearch = {
|
|
37
|
+
// Standard mobsearch to rid level
|
|
38
|
+
toRid: (mobiusSrvc, opts) => {
|
|
39
|
+
getMobsearch(mobiusSrvc, true, false, opts);
|
|
40
|
+
},
|
|
41
|
+
// Standard mobsearch to ins level
|
|
42
|
+
toIns: (mobiusSrvc, opts) => {
|
|
43
|
+
getMobsearch(mobiusSrvc, false, false, opts);
|
|
44
|
+
},
|
|
45
|
+
// Mobsearch to rid level, for nodes using editable list
|
|
46
|
+
toRid_listed: (mobiusSrvc, opts) => {
|
|
47
|
+
getMobsearch(mobiusSrvc, true, true, opts);
|
|
48
|
+
},
|
|
49
|
+
// Mobsearch to ins level, for nodes using editable list
|
|
50
|
+
toIns_listed: (mobiusSrvc, opts) => {
|
|
51
|
+
getMobsearch(mobiusSrvc, false, true, opts);
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Make / Reset global selectionIndex vairable (variable to allow setting of correct list field)
|
|
56
|
+
if (typeof selectionIndex === undefined) {
|
|
57
|
+
let selectionIndex = 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* function to add search button functionality to list rows
|
|
62
|
+
* @param {object} field - The search field within a given list row
|
|
63
|
+
* @param {number} rowIndex - The list row index
|
|
64
|
+
* @param {object} opts - Mobsearch options object
|
|
65
|
+
*/
|
|
66
|
+
function addMobsearchListButton(field, rowIndex, opts) {
|
|
67
|
+
field.click(function () {
|
|
68
|
+
selectionIndex = rowIndex;
|
|
69
|
+
$(`#${opts.containerRowName}`).hide();
|
|
70
|
+
$('#instance-search-sid').val('');
|
|
71
|
+
$('#instance-search-pid').val('');
|
|
72
|
+
$('#instance-search-ins').val('');
|
|
73
|
+
$('#instance-search-rid').val('');
|
|
74
|
+
$('#node-search-return').removeClass('disabled');
|
|
75
|
+
$('#node-search-accept').removeClass('disabled');
|
|
76
|
+
$('#instance-search-row').show();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
*
|
|
82
|
+
* @param mobiusSrvc - Connection to Mobius
|
|
83
|
+
* @param {boolean} useRid - Flag for Mobsearch to include rid field
|
|
84
|
+
* @param {boolean} listed - Flag for Mobsearch work with nodes using editableLists
|
|
85
|
+
* @param {object} opts - Mobsearhc options object
|
|
86
|
+
*/
|
|
87
|
+
function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
88
|
+
selectionIndex = 0;
|
|
89
|
+
// Get current state of input field
|
|
90
|
+
let uriFieldValue = '';
|
|
91
|
+
if (!listed) {
|
|
92
|
+
uriFieldValue = $(`#${opts.uriFieldName}`).val();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// * HTML INJECTION * //
|
|
96
|
+
|
|
97
|
+
const resourceHtml = `
|
|
98
|
+
<input type="text" id="instance-search-hid" style="width:13%;" placeholder="HID">
|
|
99
|
+
<input type="text" id="instance-search-sid" style="width:8%;" placeholder="SID">
|
|
100
|
+
<input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
|
|
101
|
+
<input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
|
|
102
|
+
<input type="text" id="instance-search-rid" style="width:8%;" placeholder="RID">
|
|
103
|
+
`;
|
|
104
|
+
|
|
105
|
+
const instanceHtml = `
|
|
106
|
+
<input type="text" id="instance-search-hid" style="width:15%;" placeholder="HID">
|
|
107
|
+
<input type="text" id="instance-search-sid" style="width:10%;" placeholder="SID">
|
|
108
|
+
<input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
|
|
109
|
+
<input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
|
|
110
|
+
`;
|
|
111
|
+
|
|
112
|
+
//set level dependent html
|
|
113
|
+
let rows = useRid === true ? resourceHtml : instanceHtml;
|
|
114
|
+
let alertMsg = useRid === true ? `and/or RID ` : ``;
|
|
115
|
+
|
|
116
|
+
//Inject new html
|
|
117
|
+
document.getElementById(opts.htmlElementId).innerHTML += `
|
|
118
|
+
<div id="instance-search-row">
|
|
119
|
+
<div class="form-row">
|
|
120
|
+
<label for="instance-search-sid"><i class="fa fa-tasks"></i> URI</label>
|
|
121
|
+
${rows}
|
|
122
|
+
<a id="node-search-return" class="searchbutton" style="vertical-align: middle"><i id="node-search-return-icon" class="fa fa-arrow-left"></i></a>
|
|
123
|
+
<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>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
<div id="wildcard-alert-row" class="form-row hidden" style="color:#555555" align="center">
|
|
127
|
+
<p>Please note: The selection of wildcard '+'
|
|
128
|
+
means a search for a specific instance or resource
|
|
129
|
+
cannot be performed. As such, enter the
|
|
130
|
+
INS ${alertMsg}manually.</p>
|
|
131
|
+
</div>
|
|
132
|
+
`;
|
|
133
|
+
|
|
134
|
+
if (!listed) {
|
|
135
|
+
//Add search button
|
|
136
|
+
document.getElementById(opts.inputRowId).innerHTML += `
|
|
137
|
+
<a id="node-lookup-instance" class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>
|
|
138
|
+
`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// * END HTML INJECTION * //
|
|
142
|
+
|
|
143
|
+
// * INIT SETUP * //
|
|
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
|
+
let readyToAccept = false;
|
|
152
|
+
|
|
153
|
+
let searchObject = {};
|
|
154
|
+
if (listed) {
|
|
155
|
+
searchObject = {
|
|
156
|
+
hid: '',
|
|
157
|
+
sid: '',
|
|
158
|
+
pid: '',
|
|
159
|
+
ins: '',
|
|
160
|
+
rid: '',
|
|
161
|
+
objects: [],
|
|
162
|
+
};
|
|
163
|
+
} else {
|
|
164
|
+
searchObject = {
|
|
165
|
+
hid: $('#instance-search-hid').val(),
|
|
166
|
+
sid: $('#instance-search-sid').val(),
|
|
167
|
+
pid: $('#instance-search-pid').val(),
|
|
168
|
+
ins: $('#instance-search-ins').val(),
|
|
169
|
+
rid: $('#instance-search-rid').val(),
|
|
170
|
+
objects: [],
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// * END INIT SETUP * //
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Search for INSs present on selected PID
|
|
178
|
+
* @param {object} objects - Response from call to Mobiu, list of mobius objects
|
|
179
|
+
* @param {string} pid - The chosen PID
|
|
180
|
+
*/
|
|
181
|
+
function ridSearch(objects, ins) {
|
|
182
|
+
$.getJSON(
|
|
183
|
+
`mdiscover?mobius=${mobiusSrvc}&uri=${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`,
|
|
184
|
+
(response) => {
|
|
185
|
+
resList = response.value[0].resources;
|
|
186
|
+
ress = ['#'];
|
|
187
|
+
for (let j = 0; j < resList.length; j++) {
|
|
188
|
+
ress.push(`${resList[j].rid} - ${resList[j].name}`);
|
|
189
|
+
}
|
|
190
|
+
$('#instance-search-rid')
|
|
191
|
+
.autocomplete({
|
|
192
|
+
source: ress,
|
|
193
|
+
minLength: 0,
|
|
194
|
+
close: function (event, ui) {
|
|
195
|
+
acceptCheck();
|
|
196
|
+
$('#instance-search-rid').autocomplete('destroy');
|
|
197
|
+
$('#instance-search-rid').val($('#instance-search-rid').val().substring(0, 2));
|
|
198
|
+
searchObject.rid = $('#instance-search-rid').val();
|
|
199
|
+
},
|
|
200
|
+
})
|
|
201
|
+
.autocomplete('search', '');
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Search for INSs present on selected PID
|
|
208
|
+
* @param {object} objects - Response from call to Mobius, list of mobius objects
|
|
209
|
+
* @param {string} pid - The chosen PID
|
|
210
|
+
*/
|
|
211
|
+
function insSearch(objects, pid) {
|
|
212
|
+
let inss = ['#', '+'];
|
|
213
|
+
for (let i = 0; i < objects.length; i++) {
|
|
214
|
+
if (objects[i].pid === pid) {
|
|
215
|
+
const name = objects[i].resources[1].pv;
|
|
216
|
+
if (name === '') {
|
|
217
|
+
inss.push(objects[i].ins);
|
|
218
|
+
} else {
|
|
219
|
+
inss.push(`${objects[i].ins} - ${name}`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
$('#instance-search-ins')
|
|
224
|
+
.autocomplete({
|
|
225
|
+
source: inss,
|
|
226
|
+
minLength: 0,
|
|
227
|
+
close: function (event, ui) {
|
|
228
|
+
acceptCheck();
|
|
229
|
+
$('#instance-search-ins').autocomplete('destroy');
|
|
230
|
+
if ($('#instance-search-ins').val().length > 4) {
|
|
231
|
+
$('#instance-search-ins').val($('#instance-search-ins').val().substring(0, 4));
|
|
232
|
+
}
|
|
233
|
+
searchObject.ins = $('#instance-search-ins').val();
|
|
234
|
+
},
|
|
235
|
+
})
|
|
236
|
+
.autocomplete('search', '');
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Search for PIDs present on selected service
|
|
241
|
+
* @param {object} objects - Response from call to Mobius, list of mobius objects
|
|
242
|
+
*/
|
|
243
|
+
function pidsSearch(objects) {
|
|
244
|
+
searchObject.objects = objects;
|
|
245
|
+
let pids = ['#', '+'];
|
|
246
|
+
for (let i = 0; i < objects.length; i++) {
|
|
247
|
+
pids.push(`${objects[i].pid} - ${objects[i].profileName}`);
|
|
248
|
+
}
|
|
249
|
+
pids = [...new Set(pids)];
|
|
250
|
+
$('#instance-search-pid')
|
|
251
|
+
.autocomplete({
|
|
252
|
+
source: pids,
|
|
253
|
+
minLength: 0,
|
|
254
|
+
close: function (event, ui) {
|
|
255
|
+
acceptCheck();
|
|
256
|
+
$('#instance-search-pid').autocomplete('destroy');
|
|
257
|
+
if ($('#instance-search-pid').val().length > 4) {
|
|
258
|
+
$('#instance-search-pid').val($('#instance-search-pid').val().substring(0, 4));
|
|
259
|
+
}
|
|
260
|
+
searchObject.pid = $('#instance-search-pid').val();
|
|
261
|
+
},
|
|
262
|
+
})
|
|
263
|
+
.autocomplete('search', '');
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Search for SIDs, and then fetch child objects based on selection
|
|
268
|
+
* @param {object} response - Response from call to Mobius
|
|
269
|
+
*/
|
|
270
|
+
function serviceSearch(response) {
|
|
271
|
+
let services = ['#', '+'];
|
|
272
|
+
for (let i = 0; i < response.length; i++) {
|
|
273
|
+
if (response[i].sid !== '009') {
|
|
274
|
+
services.push(`${response[i].sid} - ${response[i].name}`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
$('#instance-search-sid')
|
|
278
|
+
.autocomplete({
|
|
279
|
+
source: services,
|
|
280
|
+
minLength: 0,
|
|
281
|
+
close: function (event, ui) {
|
|
282
|
+
acceptCheck();
|
|
283
|
+
$('#instance-search-sid').autocomplete('destroy');
|
|
284
|
+
if ($('#instance-search-sid').val().length > 3) {
|
|
285
|
+
$('#instance-search-sid').val($('#instance-search-sid').val().substring(0, 3));
|
|
286
|
+
}
|
|
287
|
+
searchObject.sid = $('#instance-search-sid').val();
|
|
288
|
+
if (searchObject.sid === '+') {
|
|
289
|
+
for (let i = 2; i < services.length; i++) {
|
|
290
|
+
$.getJSON(
|
|
291
|
+
`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${services[
|
|
292
|
+
i
|
|
293
|
+
].substring(0, 3)}`,
|
|
294
|
+
(objects) => {
|
|
295
|
+
searchObject.objects = searchObject.objects.concat(objects);
|
|
296
|
+
}
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
} else {
|
|
300
|
+
$.getJSON(
|
|
301
|
+
`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${searchObject.sid}`,
|
|
302
|
+
(objects) => {
|
|
303
|
+
searchObject.objects = objects;
|
|
304
|
+
}
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
})
|
|
309
|
+
.autocomplete('search', '');
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Start mobsearch
|
|
314
|
+
*/
|
|
315
|
+
function startSearch() {
|
|
316
|
+
$('#wildcard-alert-row').hide();
|
|
317
|
+
$('#instance-search-sid').val('');
|
|
318
|
+
$('#instance-search-pid').val('');
|
|
319
|
+
$('#instance-search-ins').val('');
|
|
320
|
+
searchObject.hid = $('#instance-search-hid').val();
|
|
321
|
+
searchObject.sid = '';
|
|
322
|
+
searchObject.pid = '';
|
|
323
|
+
searchObject.ins = '';
|
|
324
|
+
if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
|
|
325
|
+
$.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch).fail(
|
|
326
|
+
(err) => {
|
|
327
|
+
console.log('Mobsearch failed to contact Mobius');
|
|
328
|
+
}
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Finish mobsearch, compile full URI and set value in host node
|
|
335
|
+
*/
|
|
336
|
+
function finishSearch() {
|
|
337
|
+
$('#wildcard-alert-row').hide();
|
|
338
|
+
let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`;
|
|
339
|
+
if (useRid) {
|
|
340
|
+
uri = uri + `/${searchObject.rid}`;
|
|
341
|
+
}
|
|
342
|
+
if (uri.includes('#')) {
|
|
343
|
+
uri = uri.substring(0, uri.indexOf('#') + 1);
|
|
344
|
+
}
|
|
345
|
+
if (listed) {
|
|
346
|
+
opts.list[selectionIndex].uri = uri;
|
|
347
|
+
updateList();
|
|
348
|
+
} else {
|
|
349
|
+
$(`#${opts.uriFieldName}`).val(uri);
|
|
350
|
+
}
|
|
351
|
+
$('#node-search-accept').css('color', '#CCCCCC');
|
|
352
|
+
readyToAccept = false;
|
|
353
|
+
$('#node-search-return').addClass('disabled');
|
|
354
|
+
$('#node-search-accept').addClass('disabled');
|
|
355
|
+
$('#node-lookup-instance').removeClass('disabled');
|
|
356
|
+
$('#instance-search-row').hide();
|
|
357
|
+
$('#instance-row').show();
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Update if accept button is grade out and functional, based on conditions of fields
|
|
362
|
+
*/
|
|
363
|
+
function acceptCheck() {
|
|
364
|
+
if (useRid) {
|
|
365
|
+
checkFieldsToRid();
|
|
366
|
+
} else {
|
|
367
|
+
checkFieldsToIns();
|
|
368
|
+
}
|
|
369
|
+
checkWildcards();
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Check state of all field to rid level, change state of accept button accordingly
|
|
374
|
+
*/
|
|
375
|
+
function checkFieldsToRid() {
|
|
376
|
+
if (
|
|
377
|
+
($('#instance-search-hid').val() !== '' &&
|
|
378
|
+
$('#instance-search-sid').val() !== '' &&
|
|
379
|
+
$('#instance-search-pid').val() !== '' &&
|
|
380
|
+
$('#instance-search-ins').val() !== '' &&
|
|
381
|
+
$('#instance-search-rid').val() !== '') ||
|
|
382
|
+
$('#instance-search-sid').val() === '#' ||
|
|
383
|
+
$('#instance-search-pid').val() === '#' ||
|
|
384
|
+
$('#instance-search-ins').val() === '#' ||
|
|
385
|
+
$('#instance-search-rid').val() === '#'
|
|
386
|
+
) {
|
|
387
|
+
$('#node-search-accept').css('color', '#555555');
|
|
388
|
+
readyToAccept = true;
|
|
389
|
+
} else {
|
|
390
|
+
$('#node-search-accept').css('color', '#CCCCCC');
|
|
391
|
+
readyToAccept = false;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Check state of all field to ins level, change state of accept button accordingly
|
|
397
|
+
*/
|
|
398
|
+
function checkFieldsToIns() {
|
|
399
|
+
if (
|
|
400
|
+
($('#instance-search-hid').val() !== '' &&
|
|
401
|
+
$('#instance-search-sid').val() !== '' &&
|
|
402
|
+
$('#instance-search-pid').val() !== '' &&
|
|
403
|
+
$('#instance-search-ins').val() !== '') ||
|
|
404
|
+
$('#instance-search-sid').val() === '#' ||
|
|
405
|
+
$('#instance-search-pid').val() === '#' ||
|
|
406
|
+
$('#instance-search-ins').val() === '#'
|
|
407
|
+
) {
|
|
408
|
+
$('#node-search-accept').css('color', '#555555');
|
|
409
|
+
readyToAccept = true;
|
|
410
|
+
} else {
|
|
411
|
+
$('#node-search-accept').css('color', '#CCCCCC');
|
|
412
|
+
readyToAccept = false;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Checks if + wildcard values are present, shows / hides alert message accordingly
|
|
418
|
+
*/
|
|
419
|
+
function checkWildcards() {
|
|
420
|
+
if (
|
|
421
|
+
$('#instance-search-sid').val() !== '+' &&
|
|
422
|
+
$('#instance-search-pid').val() !== '+' &&
|
|
423
|
+
$('#instance-search-ins').val() !== '+'
|
|
424
|
+
) {
|
|
425
|
+
$('#wildcard-alert-row').hide();
|
|
426
|
+
} else {
|
|
427
|
+
$('#wildcard-alert-row').show();
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Update editable list with results from mobsearch
|
|
433
|
+
*/
|
|
434
|
+
function updateList() {
|
|
435
|
+
$(`#${opts.containerName}`)
|
|
436
|
+
.editableList('items')
|
|
437
|
+
.each(function (i) {
|
|
438
|
+
let item = $(this);
|
|
439
|
+
let secondField = item.find(`.${opts.containerSecondFieldName}`).val();
|
|
440
|
+
opts.list[i][Object.keys(opts.list[i])[1]] = secondField;
|
|
441
|
+
});
|
|
442
|
+
$(`#${opts.containerName}`).editableList('empty');
|
|
443
|
+
for (let i = 0; i < opts.list.length; i++) {
|
|
444
|
+
let item = opts.list[i];
|
|
445
|
+
$(`#${opts.containerName}`).editableList('addItem', item);
|
|
446
|
+
}
|
|
447
|
+
$(`#${opts.containerRowName}`).show();
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// * CLICK RESPONSE * //
|
|
451
|
+
|
|
452
|
+
$('#node-lookup-instance').click(function () {
|
|
453
|
+
//When search button is clicked
|
|
454
|
+
$('#instance-search-sid').val('');
|
|
455
|
+
$('#instance-search-pid').val('');
|
|
456
|
+
$('#instance-search-ins').val('');
|
|
457
|
+
if (useRid) {
|
|
458
|
+
$('#instance-search-rid').val('');
|
|
459
|
+
}
|
|
460
|
+
$('#node-lookup-instance').addClass('disabled');
|
|
461
|
+
$('#node-search-return').removeClass('disabled');
|
|
462
|
+
$('#node-search-accept').removeClass('disabled');
|
|
463
|
+
$('#instance-row').hide();
|
|
464
|
+
$('#instance-search-row').show();
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
$('#instance-search-sid').click(function () {
|
|
468
|
+
//SID field clicked
|
|
469
|
+
$('#instance-search-pid').val('');
|
|
470
|
+
$('#instance-search-ins').val('');
|
|
471
|
+
searchObject.pid = '';
|
|
472
|
+
searchObject.ins = '';
|
|
473
|
+
if (useRid) {
|
|
474
|
+
searchObject.rid = '';
|
|
475
|
+
}
|
|
476
|
+
searchObject.objects = [];
|
|
477
|
+
startSearch();
|
|
478
|
+
});
|
|
479
|
+
$('#instance-search-pid').click(function () {
|
|
480
|
+
//PID field clicked
|
|
481
|
+
$('#instance-search-ins').val('');
|
|
482
|
+
|
|
483
|
+
searchObject.ins = '';
|
|
484
|
+
|
|
485
|
+
if (useRid) {
|
|
486
|
+
$('#instance-search-rid').val('');
|
|
487
|
+
searchObject.rid = '';
|
|
488
|
+
}
|
|
489
|
+
if (searchObject.sid !== '') {
|
|
490
|
+
pidsSearch(searchObject.objects);
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
$('#instance-search-ins').click(function () {
|
|
494
|
+
//INS field clicked
|
|
495
|
+
if (useRid) {
|
|
496
|
+
$('#instance-search-rid').val('');
|
|
497
|
+
searchObject.rid = '';
|
|
498
|
+
}
|
|
499
|
+
if (searchObject.pid !== '' && searchObject.pid !== '+' && searchObject.sid !== '+') {
|
|
500
|
+
insSearch(searchObject.objects, searchObject.pid);
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
if (useRid) {
|
|
505
|
+
$('#instance-search-rid').click(function () {
|
|
506
|
+
//RID clicked
|
|
507
|
+
if (
|
|
508
|
+
searchObject.ins !== '' &&
|
|
509
|
+
searchObject.ins !== '+' &&
|
|
510
|
+
searchObject.pid !== '+' &&
|
|
511
|
+
searchObject.sid !== '+'
|
|
512
|
+
) {
|
|
513
|
+
ridSearch(searchObject.objects, searchObject.ins);
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
$('#node-search-return').click(function () {
|
|
519
|
+
//Return/Back button clicked
|
|
520
|
+
$('#node-search-return').addClass('disabled');
|
|
521
|
+
$('#node-search-accept').addClass('disabled');
|
|
522
|
+
$('#node-lookup-instance').removeClass('disabled');
|
|
523
|
+
$('#instance-search-row').hide();
|
|
524
|
+
$('#instance-row').show();
|
|
525
|
+
});
|
|
526
|
+
$('#node-search-accept').click(function () {
|
|
527
|
+
//Accept button clicked
|
|
528
|
+
if (readyToAccept) {
|
|
529
|
+
finishSearch();
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
// * END CLICK RESPONSE * //
|
|
534
|
+
|
|
535
|
+
// * CHANGE RESPONSE * //
|
|
536
|
+
|
|
537
|
+
$('#instance-search-hid').change(function () {
|
|
538
|
+
acceptCheck();
|
|
539
|
+
$('#instance-search-sid').val('');
|
|
540
|
+
$('#instance-search-pid').val('');
|
|
541
|
+
$('#instance-search-ins').val('');
|
|
542
|
+
if (useRid) {
|
|
543
|
+
$('#instance-search-rid').val('');
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
$('#instance-search-sid').change(function () {
|
|
548
|
+
searchObject.sid = $('#instance-search-sid').val();
|
|
549
|
+
acceptCheck();
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
$('#instance-search-pid').change(function () {
|
|
553
|
+
searchObject.pid = $('#instance-search-pid').val();
|
|
554
|
+
acceptCheck();
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
$('#instance-search-ins').change(function () {
|
|
558
|
+
searchObject.ins = $('#instance-search-ins').val();
|
|
559
|
+
acceptCheck();
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
if (useRid) {
|
|
563
|
+
$('#instance-search-rid').change(function () {
|
|
564
|
+
searchObject.rid = $('#instance-search-rid').val();
|
|
565
|
+
acceptCheck();
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// * END CHANGE RESPONSE * //
|
|
570
|
+
|
|
571
|
+
// reset input filed after init
|
|
572
|
+
if (!listed) {
|
|
573
|
+
$(`#${opts.uriFieldName}`).val(uriFieldValue);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
@@ -193,6 +193,42 @@ module.exports = function (RED) {
|
|
|
193
193
|
});
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
+
/**
|
|
197
|
+
* Update a given node's node status based on last active time
|
|
198
|
+
* @param {Object} mobiusNode - The node whos status is to be updated
|
|
199
|
+
*/
|
|
200
|
+
node.updateNodeStatus = function (mobiusNode) {
|
|
201
|
+
node.users[mobiusNode.id] = mobiusNode;
|
|
202
|
+
const timeSinceLastActive = Date.now() - node.users[mobiusNode.id].lastActiveTime;
|
|
203
|
+
let statusText = '';
|
|
204
|
+
let statusColour = 'green';
|
|
205
|
+
if (timeSinceLastActive < 15 * 60000) {
|
|
206
|
+
statusText = 'Active less than 15 minutes ago';
|
|
207
|
+
}
|
|
208
|
+
if (timeSinceLastActive >= 15 * 60000 && timeSinceLastActive < 3 * 60 * 60000) {
|
|
209
|
+
statusText = 'Active less than 3 hours ago';
|
|
210
|
+
}
|
|
211
|
+
if (timeSinceLastActive >= 3 * 60 * 60000 && timeSinceLastActive < 12 * 60 * 60000) {
|
|
212
|
+
statusText = 'Active less than 12 hours ago';
|
|
213
|
+
}
|
|
214
|
+
if (timeSinceLastActive >= 12 * 60 * 60000 && timeSinceLastActive < 24 * 60 * 60000) {
|
|
215
|
+
statusText = 'Active less than 24 hours ago';
|
|
216
|
+
}
|
|
217
|
+
if (timeSinceLastActive > 24 * 60 * 60000 && node.users[mobiusNode.id].lastActiveTime > 0) {
|
|
218
|
+
statusColour = 'grey';
|
|
219
|
+
statusText = 'Active more than 24 hours ago';
|
|
220
|
+
}
|
|
221
|
+
if (node.users[mobiusNode.id].lastActiveTime === 0) {
|
|
222
|
+
statusColour = 'grey';
|
|
223
|
+
statusText = 'Never Active';
|
|
224
|
+
}
|
|
225
|
+
node.users[mobiusNode.id].status({
|
|
226
|
+
fill: statusColour,
|
|
227
|
+
shape: 'dot',
|
|
228
|
+
text: statusText,
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
|
|
196
232
|
/**
|
|
197
233
|
* Register a new Mobius node with this config node
|
|
198
234
|
* @param {Object} mobiusNode - The new node to register
|
|
@@ -206,6 +242,17 @@ module.exports = function (RED) {
|
|
|
206
242
|
text: 'Connected',
|
|
207
243
|
});
|
|
208
244
|
}
|
|
245
|
+
node.users[mobiusNode.id].lastActiveTime = 0;
|
|
246
|
+
node.users[mobiusNode.id].on('send', () => {
|
|
247
|
+
console.log('lalala');
|
|
248
|
+
console.log(Date.now());
|
|
249
|
+
node.users[mobiusNode.id].lastActiveTime = Date.now();
|
|
250
|
+
node.updateNodeStatus(mobiusNode);
|
|
251
|
+
console.log(node.users[mobiusNode.id].lastActiveTime);
|
|
252
|
+
});
|
|
253
|
+
node.users[mobiusNode.id].statusCheckLoop = setInterval(() => {
|
|
254
|
+
node.updateNodeStatus(mobiusNode);
|
|
255
|
+
}, 60000);
|
|
209
256
|
};
|
|
210
257
|
|
|
211
258
|
/**
|
|
@@ -214,6 +261,7 @@ module.exports = function (RED) {
|
|
|
214
261
|
* @param {Function} done - A callback to be run by the node after it has been deregistered
|
|
215
262
|
*/
|
|
216
263
|
node.deregister = function (mobiusNode, done) {
|
|
264
|
+
clearInterval(node.users[mobiusNode.id].statusCheckLoop);
|
|
217
265
|
delete node.users[mobiusNode.id];
|
|
218
266
|
if (node.service) {
|
|
219
267
|
try {
|
|
@@ -520,30 +568,6 @@ module.exports = function (RED) {
|
|
|
520
568
|
node.updateObjectInServiceConfig = function (hid, sid, pid, ins, config, callback) {
|
|
521
569
|
node.service.srvcAPI.updateObjectInServiceConfig(hid, sid, pid, ins, config, callback);
|
|
522
570
|
};
|
|
523
|
-
|
|
524
|
-
node.getNodeConfig = function (hid) {
|
|
525
|
-
return new Promise((resolve, reject) => {
|
|
526
|
-
node.service.srvcAPI.getNodeConfig(hid, (err, response) => {
|
|
527
|
-
if (!err) {
|
|
528
|
-
resolve(response);
|
|
529
|
-
} else {
|
|
530
|
-
reject(err);
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
});
|
|
534
|
-
};
|
|
535
|
-
|
|
536
|
-
node.getServiceConfigProm = function (hid, sid) {
|
|
537
|
-
return new Promise((resolve, reject) => {
|
|
538
|
-
node.service.srvcAPI.getServiceConfig(hid, sid, (err, response) => {
|
|
539
|
-
if (!err) {
|
|
540
|
-
resolve(response);
|
|
541
|
-
} else {
|
|
542
|
-
reject(err);
|
|
543
|
-
}
|
|
544
|
-
});
|
|
545
|
-
});
|
|
546
|
-
};
|
|
547
571
|
}
|
|
548
572
|
|
|
549
573
|
RED.nodes.registerType('mobius connection', MobiusConnectionNode);
|
|
@@ -604,42 +628,4 @@ module.exports = function (RED) {
|
|
|
604
628
|
}
|
|
605
629
|
}
|
|
606
630
|
);
|
|
607
|
-
|
|
608
|
-
// Register the endpoint for node-red mobius discovery in node-red node config pages
|
|
609
|
-
RED.httpAdmin.get('/mdiscover', RED.auth.needsPermission('serial.read'), function (req, res) {
|
|
610
|
-
let conn = RED.nodes.getNode(req.query.mobius);
|
|
611
|
-
let uri = req.query.uri;
|
|
612
|
-
if (conn === null || !conn.service.connected) {
|
|
613
|
-
RED.log.error('Discover services failed - could not to connect to MOBiUS hub.');
|
|
614
|
-
throw new Error('Discover services failed - could not to connect to MOBiUS hub.');
|
|
615
|
-
} else {
|
|
616
|
-
uiDeviceDiscovery
|
|
617
|
-
.discover(conn, uri)
|
|
618
|
-
.then((response) => {
|
|
619
|
-
res.json(response);
|
|
620
|
-
})
|
|
621
|
-
.catch((err) => {
|
|
622
|
-
throw err;
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
});
|
|
626
|
-
|
|
627
|
-
// Register the endpoint for node-red mobius discovery in node-red node config pages
|
|
628
|
-
RED.httpAdmin.get('/mgetservices', RED.auth.needsPermission('serial.read'), function (req, res) {
|
|
629
|
-
let conn = RED.nodes.getNode(req.query.mobius);
|
|
630
|
-
let hid = req.query.hid;
|
|
631
|
-
if (conn === null || !conn.service.connected) {
|
|
632
|
-
RED.log.error('Get services failed - could not to connect to MOBiUS hub.');
|
|
633
|
-
throw new Error('Get services failed - could not to connect to MOBiUS hub.');
|
|
634
|
-
} else {
|
|
635
|
-
uiDeviceDiscovery
|
|
636
|
-
.getServiceList(conn, hid)
|
|
637
|
-
.then((response) => {
|
|
638
|
-
res.json(response);
|
|
639
|
-
})
|
|
640
|
-
.catch((err) => {
|
|
641
|
-
RED.log.warn(`Get services failed - ${err}`);
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
631
|
};
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
var _ = require('lodash');
|
|
30
30
|
|
|
31
31
|
module.exports = function (RED) {
|
|
32
|
-
function MobiusObjectCovNode
|
|
32
|
+
function MobiusObjectCovNode(n) {
|
|
33
33
|
RED.nodes.createNode(this, n);
|
|
34
34
|
this.detailedOutput = n.detailedOutput;
|
|
35
35
|
this.object = n.object;
|
|
@@ -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
48
|
node.serviceConn.subscribeToObjectCOV(node.object, 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(
|
|
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 });
|
|
@@ -69,6 +72,9 @@ module.exports = function (RED) {
|
|
|
69
72
|
});
|
|
70
73
|
|
|
71
74
|
node.serviceConn.register(node);
|
|
75
|
+
node.on('send', () => {
|
|
76
|
+
console.log('Send Detect');
|
|
77
|
+
});
|
|
72
78
|
|
|
73
79
|
node.on('close', function (done) {
|
|
74
80
|
node.serviceConn.deregister(node, done);
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
const _ = require('lodash');
|
|
30
30
|
|
|
31
31
|
module.exports = {
|
|
32
|
-
async discover(connection, uri) {
|
|
32
|
+
async discover (connection, uri) {
|
|
33
33
|
return new Promise((resolve, reject) => {
|
|
34
34
|
connection.discover(uri, (err, response) => {
|
|
35
35
|
if (err) {
|
|
@@ -41,7 +41,7 @@ module.exports = {
|
|
|
41
41
|
});
|
|
42
42
|
},
|
|
43
43
|
|
|
44
|
-
async discoverDevicesByPID(RED, connection, hid, spids, pid) {
|
|
44
|
+
async discoverDevicesByPID (RED, connection, hid, spids, pid) {
|
|
45
45
|
let devices = [];
|
|
46
46
|
if (!hid || hid === '') {
|
|
47
47
|
hid = connection.service.srvcAPI.status.hubId;
|
|
@@ -54,17 +54,12 @@ module.exports = {
|
|
|
54
54
|
throw new Error(`Discover devices failed (${hid}) - ${err.message}`);
|
|
55
55
|
}
|
|
56
56
|
for (let srvcLoop = 0; srvcLoop < services.value.length; srvcLoop++) {
|
|
57
|
-
if (
|
|
58
|
-
services.value[srvcLoop].status === 'online' &&
|
|
59
|
-
(spids.length === 0 || spids.includes(services.value[srvcLoop].spid))
|
|
60
|
-
) {
|
|
57
|
+
if (services.value[srvcLoop].status === 'online' && (spids.length === 0 || spids.includes(services.value[srvcLoop].spid))) {
|
|
61
58
|
let insURI = `${hid}/${services.value[srvcLoop].id.split('/')[1]}/${pid}`;
|
|
62
59
|
try {
|
|
63
60
|
let instances = await this.discover(connection, insURI);
|
|
64
61
|
for (let insLoop = 0; insLoop < instances.value.length; insLoop++) {
|
|
65
|
-
let deviceURI = `${hid}/${services.value[srvcLoop].id.split('/')[1]}/${pid}/${
|
|
66
|
-
instances.value[insLoop]
|
|
67
|
-
}`;
|
|
62
|
+
let deviceURI = `${hid}/${services.value[srvcLoop].id.split('/')[1]}/${pid}/${instances.value[insLoop]}`;
|
|
68
63
|
let device = await this.discover(connection, deviceURI);
|
|
69
64
|
let resourcesByName = _.keyBy(device.value[0].resources, 'name');
|
|
70
65
|
let deviceName = resourcesByName['name'].pv;
|
|
@@ -84,7 +79,7 @@ module.exports = {
|
|
|
84
79
|
});
|
|
85
80
|
},
|
|
86
81
|
|
|
87
|
-
async discoverServicesBySPID(RED, connection, hid, spid) {
|
|
82
|
+
async discoverServicesBySPID (RED, connection, hid, spid) {
|
|
88
83
|
if (!hid || hid === '') {
|
|
89
84
|
hid = connection.service.srvcAPI.status.hubId;
|
|
90
85
|
}
|
|
@@ -104,104 +99,5 @@ module.exports = {
|
|
|
104
99
|
return new Promise((resolve) => {
|
|
105
100
|
resolve(srvcs);
|
|
106
101
|
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
getServiceList(connection, hid) {
|
|
110
|
-
// getNodeConfig -> id, spid, uri, name, enabled, runAtStart
|
|
111
|
-
// For every: getServiceConfig -> mobiusSettings, customSettings
|
|
112
|
-
// discover -> registered, last connected, status + any remaining if new service
|
|
113
|
-
// For every: discover object -/0001/0001 -> status, statusText
|
|
114
|
-
return new Promise(async (resolve, reject) => {
|
|
115
|
-
try {
|
|
116
|
-
// Fetch information from node config
|
|
117
|
-
const nodeConfig = await connection.getNodeConfig(hid);
|
|
118
|
-
console.log(nodeConfig);
|
|
119
|
-
const servicesFromConfig = nodeConfig.value.services;
|
|
120
|
-
let services = [];
|
|
121
|
-
for (let i = 0; i < servicesFromConfig.length; i++) {
|
|
122
|
-
services.push({
|
|
123
|
-
id: servicesFromConfig.id,
|
|
124
|
-
spid: servicesFromConfig.id.split('/')[0],
|
|
125
|
-
sid: servicesFromConfig.id.split('/')[1],
|
|
126
|
-
uri: `${nodeConfig.uri}/${servicesFromConfig.id.split('/')[1]}`,
|
|
127
|
-
name: servicesFromConfig.name,
|
|
128
|
-
enabled: servicesFromConfig.enabled,
|
|
129
|
-
runAtStart: servicesFromConfig.runAtStart,
|
|
130
|
-
registered: null,
|
|
131
|
-
lastConnected: null,
|
|
132
|
-
status: null,
|
|
133
|
-
statusText: null,
|
|
134
|
-
mobiusSettings: null,
|
|
135
|
-
customSettings: null,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
console.log('Following get node config');
|
|
140
|
-
console.log(services);
|
|
141
|
-
|
|
142
|
-
// Fetch information from each service config
|
|
143
|
-
for (i = 0; i < services.length; i++) {
|
|
144
|
-
const fullServiceConfig = await connection.getServiceConfigProm(hid, services[i].sid);
|
|
145
|
-
services[i].mobiusSettings = fullServiceConfig.value.serviceConfig.settings;
|
|
146
|
-
services[i].customSettings = fullServiceConfig.value.serviceConfig.custom;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
console.log('Following service node configs');
|
|
150
|
-
console.log(services);
|
|
151
|
-
|
|
152
|
-
// Fetch information from discovered services
|
|
153
|
-
const discoveryResponse = await this.discover(connection, hid);
|
|
154
|
-
const servicesFromDiscovery = discoveryResponse.value;
|
|
155
|
-
for (i = 0; i < servicesFromDiscovery.length; i++) {
|
|
156
|
-
let serviceFound = false;
|
|
157
|
-
for (j = 0; j < services.length; j++) {
|
|
158
|
-
if (servicesFromDiscovery[i].id === services[j].id) {
|
|
159
|
-
serviceFound = true;
|
|
160
|
-
services[j].registered = servicesFromDiscovery[i].registered;
|
|
161
|
-
services[j].lastConnected = servicesFromDiscovery[i].lastconnected;
|
|
162
|
-
j = services.length;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
if (!serviceFound) {
|
|
166
|
-
services.push({
|
|
167
|
-
id: servicesFromDiscovery[i].id,
|
|
168
|
-
spid: servicesFromDiscovery[i].id.split('/')[0],
|
|
169
|
-
sid: servicesFromDiscovery[i].id.split('/')[1],
|
|
170
|
-
uri: `${nodeConfig.uri}/${servicesFromDiscovery[i].id.split('/')[1]}`,
|
|
171
|
-
name: null,
|
|
172
|
-
enabled: null,
|
|
173
|
-
runAtStart: null,
|
|
174
|
-
registered: servicesFromDiscovery[i].registered,
|
|
175
|
-
lastConnected: servicesFromDiscovery[i].lastconnected,
|
|
176
|
-
status: null,
|
|
177
|
-
statusText: null,
|
|
178
|
-
mobiusSettings: null,
|
|
179
|
-
customSettings: null,
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
console.log('Following discover');
|
|
185
|
-
console.log(services);
|
|
186
|
-
|
|
187
|
-
// Fetch status object from all services
|
|
188
|
-
for (i = 0; i < services.length; i++) {
|
|
189
|
-
const statusObjectResponse = await this.discover(
|
|
190
|
-
connection,
|
|
191
|
-
`${hid}/${services[i].sid}/0001/0001`
|
|
192
|
-
);
|
|
193
|
-
const statusObject = statusObjectResponse.value;
|
|
194
|
-
services[i].status = statusObject.resources[1].pv;
|
|
195
|
-
services[i].statusText = `${statusObject.resources[2].pv}`;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
console.log('Complete');
|
|
199
|
-
console.log(services);
|
|
200
|
-
|
|
201
|
-
resolve(services);
|
|
202
|
-
} catch (err) {
|
|
203
|
-
reject(err);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
},
|
|
102
|
+
}
|
|
207
103
|
};
|