node-red-contrib-mobius-flow-base 2.5.90 → 3.0.0-beta.12
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.
- package/.github/ISSUE_TEMPLATE/bug_report.md +16 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +16 -0
- package/.github/ISSUE_TEMPLATE/general.md +7 -0
- package/.github/workflows/build_publish.yml +80 -0
- package/README.md +4 -10
- package/dist/engine-api-calls.d.ts +18 -0
- package/dist/engine-api-calls.js +214 -0
- package/dist/engine-api-client.d.ts +7 -0
- package/dist/engine-api-client.js +92 -0
- package/dist/engine-websocket.d.ts +58 -0
- package/dist/engine-websocket.js +226 -0
- package/dist/node-red-ui-funcs.js +180 -0
- package/dist/nodes/common/mobsearch.js +576 -0
- package/dist/nodes/mobius-clear-resource.html +22 -3
- package/dist/nodes/mobius-clear-resource.js +17 -12
- package/dist/nodes/mobius-connection.html +30 -8
- package/dist/nodes/mobius-connection.js +194 -85
- package/dist/nodes/mobius-discover-object-list.html +185 -126
- package/dist/nodes/mobius-discover-object-list.js +27 -8
- package/dist/nodes/mobius-discover.js +7 -7
- package/dist/nodes/mobius-filter-by-rid-value.html +57 -41
- package/dist/nodes/mobius-filter-by-rid-value.js +38 -31
- package/dist/nodes/mobius-flow-inject.html +32 -2
- package/dist/nodes/mobius-get-multi-object.html +39 -5
- package/dist/nodes/mobius-get-multi-resource.html +36 -4
- package/dist/nodes/mobius-get-multi-resource.js +13 -12
- package/dist/nodes/mobius-get-object.html +25 -3
- package/dist/nodes/mobius-get-object.js +12 -9
- package/dist/nodes/mobius-get-resource.html +26 -3
- package/dist/nodes/mobius-get-resource.js +17 -12
- package/dist/nodes/mobius-object-cov.html +27 -3
- package/dist/nodes/mobius-object-cov.js +9 -6
- package/dist/nodes/mobius-resource-cov.html +23 -3
- package/dist/nodes/mobius-resource-cov.js +5 -5
- package/dist/nodes/mobius-set-multi-resource.html +24 -3
- package/dist/nodes/mobius-set-multi-resource.js +9 -11
- package/dist/nodes/mobius-set-resource.html +24 -3
- package/package.json +13 -7
- package/dist/nodes/node-red-ui-discover-devices.js +0 -103
|
@@ -0,0 +1,576 @@
|
|
|
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
|
+
|
|
37
|
+
initMobsearch = {
|
|
38
|
+
// Standard mobsearch to rid level
|
|
39
|
+
toRid: (mobiusSrvc, opts) => {
|
|
40
|
+
getMobsearch(mobiusSrvc, true, false, opts);
|
|
41
|
+
},
|
|
42
|
+
// Standard mobsearch to ins level
|
|
43
|
+
toIns: (mobiusSrvc, opts) => {
|
|
44
|
+
getMobsearch(mobiusSrvc, false, false, opts);
|
|
45
|
+
},
|
|
46
|
+
// Mobsearch to rid level, for nodes using editable list
|
|
47
|
+
toRid_listed: (mobiusSrvc, opts) => {
|
|
48
|
+
getMobsearch(mobiusSrvc, true, true, opts);
|
|
49
|
+
},
|
|
50
|
+
// Mobsearch to ins level, for nodes using editable list
|
|
51
|
+
toIns_listed: (mobiusSrvc, opts) => {
|
|
52
|
+
getMobsearch(mobiusSrvc, false, true, opts);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Make / Reset global selectionIndex vairable (variable to allow setting of correct list field)
|
|
57
|
+
if (typeof selectionIndex === undefined) {
|
|
58
|
+
let selectionIndex = 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* function to add search button functionality to list rows
|
|
63
|
+
* @param {object} field - The search field within a given list row
|
|
64
|
+
* @param {number} rowIndex - The list row index
|
|
65
|
+
* @param {object} opts - Mobsearch options object
|
|
66
|
+
*/
|
|
67
|
+
function addMobsearchListButton(field, rowIndex, opts) {
|
|
68
|
+
field.click(function () {
|
|
69
|
+
selectionIndex = rowIndex;
|
|
70
|
+
$(`#${opts.containerRowName}`).hide();
|
|
71
|
+
$('#instance-search-sid').val('');
|
|
72
|
+
$('#instance-search-pid').val('');
|
|
73
|
+
$('#instance-search-ins').val('');
|
|
74
|
+
$('#instance-search-rid').val('');
|
|
75
|
+
$('#node-search-return').removeClass('disabled');
|
|
76
|
+
$('#node-search-accept').removeClass('disabled');
|
|
77
|
+
$('#instance-search-row').show();
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @param mobiusSrvc - Connection to Mobius
|
|
84
|
+
* @param {boolean} useRid - Flag for Mobsearch to include rid field
|
|
85
|
+
* @param {boolean} listed - Flag for Mobsearch work with nodes using editableLists
|
|
86
|
+
* @param {object} opts - Mobsearhc options object
|
|
87
|
+
*/
|
|
88
|
+
function getMobsearch(mobiusSrvc, useRid, listed, opts) {
|
|
89
|
+
selectionIndex = 0;
|
|
90
|
+
// Get current state of input field
|
|
91
|
+
let uriFieldValue = '';
|
|
92
|
+
if (!listed) {
|
|
93
|
+
uriFieldValue = $(`#${opts.uriFieldName}`).val();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// * HTML INJECTION * //
|
|
97
|
+
|
|
98
|
+
const resourceHtml = `
|
|
99
|
+
<input type="text" id="instance-search-hid" style="width:13%;" placeholder="HID">
|
|
100
|
+
<input type="text" id="instance-search-sid" style="width:8%;" placeholder="SID">
|
|
101
|
+
<input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
|
|
102
|
+
<input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
|
|
103
|
+
<input type="text" id="instance-search-rid" style="width:8%;" placeholder="RID">
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
const instanceHtml = `
|
|
107
|
+
<input type="text" id="instance-search-hid" style="width:15%;" placeholder="HID">
|
|
108
|
+
<input type="text" id="instance-search-sid" style="width:10%;" placeholder="SID">
|
|
109
|
+
<input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
|
|
110
|
+
<input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
|
|
111
|
+
`;
|
|
112
|
+
|
|
113
|
+
//set level dependent html
|
|
114
|
+
let rows = useRid === true ? resourceHtml : instanceHtml;
|
|
115
|
+
let alertMsg = useRid === true ? `and/or RID ` : ``;
|
|
116
|
+
|
|
117
|
+
//Inject new html
|
|
118
|
+
document.getElementById(opts.htmlElementId).innerHTML += `
|
|
119
|
+
<div id="instance-search-row">
|
|
120
|
+
<div class="form-row">
|
|
121
|
+
<label for="instance-search-sid"><i class="fa fa-tasks"></i> URI</label>
|
|
122
|
+
${rows}
|
|
123
|
+
<a id="node-search-return" class="searchbutton" style="vertical-align: middle"><i id="node-search-return-icon" class="fa fa-arrow-left"></i></a>
|
|
124
|
+
<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>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
<div id="wildcard-alert-row" class="form-row hidden" style="color:#555555" align="center">
|
|
128
|
+
<p>Please note: The selection of wildcard '+'
|
|
129
|
+
means a search for a specific instance or resource
|
|
130
|
+
cannot be performed. As such, enter the
|
|
131
|
+
INS ${alertMsg}manually.</p>
|
|
132
|
+
</div>
|
|
133
|
+
`;
|
|
134
|
+
|
|
135
|
+
if (!listed) {
|
|
136
|
+
//Add search button
|
|
137
|
+
document.getElementById(opts.inputRowId).innerHTML += `
|
|
138
|
+
<a id="node-lookup-instance" class="searchbutton" style="margin-left: 13px; vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>
|
|
139
|
+
`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// * END HTML INJECTION * //
|
|
143
|
+
|
|
144
|
+
// * INIT SETUP * //
|
|
145
|
+
|
|
146
|
+
$('#instance-search-row').hide();
|
|
147
|
+
$('#wildcard-alert-row').hide();
|
|
148
|
+
$('#node-search-return').addClass('disabled');
|
|
149
|
+
$.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
|
|
150
|
+
$('#instance-search-hid').val(response);
|
|
151
|
+
});
|
|
152
|
+
let readyToAccept = false;
|
|
153
|
+
|
|
154
|
+
let searchObject = {};
|
|
155
|
+
if (listed) {
|
|
156
|
+
searchObject = {
|
|
157
|
+
hid: '',
|
|
158
|
+
sid: '',
|
|
159
|
+
pid: '',
|
|
160
|
+
ins: '',
|
|
161
|
+
rid: '',
|
|
162
|
+
objects: [],
|
|
163
|
+
};
|
|
164
|
+
} else {
|
|
165
|
+
searchObject = {
|
|
166
|
+
hid: $('#instance-search-hid').val(),
|
|
167
|
+
sid: $('#instance-search-sid').val(),
|
|
168
|
+
pid: $('#instance-search-pid').val(),
|
|
169
|
+
ins: $('#instance-search-ins').val(),
|
|
170
|
+
rid: $('#instance-search-rid').val(),
|
|
171
|
+
objects: [],
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// * END INIT SETUP * //
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Search for INSs present on selected PID
|
|
179
|
+
* @param {object} objects - Response from call to Mobiu, list of mobius objects
|
|
180
|
+
* @param {string} pid - The chosen PID
|
|
181
|
+
*/
|
|
182
|
+
function ridSearch(objects, ins) {
|
|
183
|
+
$.getJSON(
|
|
184
|
+
`mdiscover?mobius=${mobiusSrvc}&uri=${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`,
|
|
185
|
+
(response) => {
|
|
186
|
+
resList = response.data[0].resources;
|
|
187
|
+
ress = ['#'];
|
|
188
|
+
for (let j = 0; j < resList.length; j++) {
|
|
189
|
+
ress.push(`${resList[j].rid} - ${resList[j].name}`);
|
|
190
|
+
}
|
|
191
|
+
$('#instance-search-rid')
|
|
192
|
+
.autocomplete({
|
|
193
|
+
source: ress,
|
|
194
|
+
minLength: 0,
|
|
195
|
+
close: function (event, ui) {
|
|
196
|
+
acceptCheck();
|
|
197
|
+
$('#instance-search-rid').autocomplete('destroy');
|
|
198
|
+
$('#instance-search-rid').val($('#instance-search-rid').val().substring(0, 2));
|
|
199
|
+
searchObject.rid = $('#instance-search-rid').val();
|
|
200
|
+
},
|
|
201
|
+
})
|
|
202
|
+
.autocomplete('search', '');
|
|
203
|
+
}
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Search for INSs present on selected PID
|
|
209
|
+
* @param {object} objects - Response from call to Mobius, list of mobius objects
|
|
210
|
+
* @param {string} pid - The chosen PID
|
|
211
|
+
*/
|
|
212
|
+
function insSearch(objects, pid) {
|
|
213
|
+
let inss = ['#', '+'];
|
|
214
|
+
for (let i = 0; i < objects.length; i++) {
|
|
215
|
+
if (objects[i].pid === pid) {
|
|
216
|
+
const name = objects[i].resources[1].pv;
|
|
217
|
+
if (name === '') {
|
|
218
|
+
inss.push(objects[i].ins);
|
|
219
|
+
} else {
|
|
220
|
+
inss.push(`${objects[i].ins} - ${name}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
$('#instance-search-ins')
|
|
225
|
+
.autocomplete({
|
|
226
|
+
source: inss,
|
|
227
|
+
minLength: 0,
|
|
228
|
+
close: function (event, ui) {
|
|
229
|
+
acceptCheck();
|
|
230
|
+
$('#instance-search-ins').autocomplete('destroy');
|
|
231
|
+
if ($('#instance-search-ins').val().length > 4) {
|
|
232
|
+
$('#instance-search-ins').val($('#instance-search-ins').val().substring(0, 4));
|
|
233
|
+
}
|
|
234
|
+
searchObject.ins = $('#instance-search-ins').val();
|
|
235
|
+
},
|
|
236
|
+
})
|
|
237
|
+
.autocomplete('search', '');
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Search for PIDs present on selected service
|
|
242
|
+
* @param {object} objects - Response from call to Mobius, list of mobius objects
|
|
243
|
+
*/
|
|
244
|
+
function pidsSearch(objects) {
|
|
245
|
+
searchObject.objects = objects;
|
|
246
|
+
let pids = ['#', '+'];
|
|
247
|
+
for (let i = 0; i < objects.length; i++) {
|
|
248
|
+
pids.push(`${objects[i].pid} - ${objects[i].profileName}`);
|
|
249
|
+
}
|
|
250
|
+
pids = [...new Set(pids)];
|
|
251
|
+
$('#instance-search-pid')
|
|
252
|
+
.autocomplete({
|
|
253
|
+
source: pids,
|
|
254
|
+
minLength: 0,
|
|
255
|
+
close: function (event, ui) {
|
|
256
|
+
acceptCheck();
|
|
257
|
+
$('#instance-search-pid').autocomplete('destroy');
|
|
258
|
+
if ($('#instance-search-pid').val().length > 4) {
|
|
259
|
+
$('#instance-search-pid').val($('#instance-search-pid').val().substring(0, 4));
|
|
260
|
+
}
|
|
261
|
+
searchObject.pid = $('#instance-search-pid').val();
|
|
262
|
+
},
|
|
263
|
+
})
|
|
264
|
+
.autocomplete('search', '');
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Search for SIDs, and then fetch child objects based on selection
|
|
269
|
+
* @param {object} response - Response from call to Mobius
|
|
270
|
+
*/
|
|
271
|
+
function serviceSearch(response) {
|
|
272
|
+
let services = ['#', '+'];
|
|
273
|
+
for (let i = 0; i < response.length; i++) {
|
|
274
|
+
if (response[i].sid !== '009') {
|
|
275
|
+
services.push(`${response[i].sid} - ${response[i].name}`);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
$('#instance-search-sid')
|
|
279
|
+
.autocomplete({
|
|
280
|
+
source: services,
|
|
281
|
+
minLength: 0,
|
|
282
|
+
close: function (event, ui) {
|
|
283
|
+
acceptCheck();
|
|
284
|
+
$('#instance-search-sid').autocomplete('destroy');
|
|
285
|
+
if ($('#instance-search-sid').val().length > 3) {
|
|
286
|
+
$('#instance-search-sid').val($('#instance-search-sid').val().substring(0, 3));
|
|
287
|
+
}
|
|
288
|
+
searchObject.sid = $('#instance-search-sid').val();
|
|
289
|
+
if (searchObject.sid === '+') {
|
|
290
|
+
for (let i = 2; i < services.length; i++) {
|
|
291
|
+
$.getJSON(
|
|
292
|
+
`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${services[
|
|
293
|
+
i
|
|
294
|
+
].substring(0, 3)}`,
|
|
295
|
+
(objects) => {
|
|
296
|
+
searchObject.objects = searchObject.objects.concat(objects);
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
$.getJSON(
|
|
302
|
+
`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${searchObject.sid}`,
|
|
303
|
+
(objects) => {
|
|
304
|
+
searchObject.objects = objects;
|
|
305
|
+
}
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
})
|
|
310
|
+
.autocomplete('search', '');
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Start mobsearch
|
|
315
|
+
*/
|
|
316
|
+
function startSearch() {
|
|
317
|
+
$('#wildcard-alert-row').hide();
|
|
318
|
+
$('#instance-search-sid').val('');
|
|
319
|
+
$('#instance-search-pid').val('');
|
|
320
|
+
$('#instance-search-ins').val('');
|
|
321
|
+
searchObject.hid = $('#instance-search-hid').val();
|
|
322
|
+
searchObject.sid = '';
|
|
323
|
+
searchObject.pid = '';
|
|
324
|
+
searchObject.ins = '';
|
|
325
|
+
if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
|
|
326
|
+
$.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch).fail(
|
|
327
|
+
(err) => {
|
|
328
|
+
console.log('Mobsearch failed to contact Mobius');
|
|
329
|
+
}
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Finish mobsearch, compile full URI and set value in host node
|
|
336
|
+
*/
|
|
337
|
+
function finishSearch() {
|
|
338
|
+
$('#wildcard-alert-row').hide();
|
|
339
|
+
let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`;
|
|
340
|
+
if (useRid) {
|
|
341
|
+
uri = uri + `/${searchObject.rid}`;
|
|
342
|
+
}
|
|
343
|
+
if (uri.includes('#')) {
|
|
344
|
+
uri = uri.substring(0, uri.indexOf('#') + 1);
|
|
345
|
+
}
|
|
346
|
+
if (listed) {
|
|
347
|
+
opts.list[selectionIndex].uri = uri;
|
|
348
|
+
updateList();
|
|
349
|
+
} else {
|
|
350
|
+
$(`#${opts.uriFieldName}`).val(uri);
|
|
351
|
+
}
|
|
352
|
+
$('#node-search-accept').css('color', '#CCCCCC');
|
|
353
|
+
readyToAccept = false;
|
|
354
|
+
$('#node-search-return').addClass('disabled');
|
|
355
|
+
$('#node-search-accept').addClass('disabled');
|
|
356
|
+
$('#node-lookup-instance').removeClass('disabled');
|
|
357
|
+
$('#instance-search-row').hide();
|
|
358
|
+
$('#instance-row').show();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Update if accept button is grade out and functional, based on conditions of fields
|
|
363
|
+
*/
|
|
364
|
+
function acceptCheck() {
|
|
365
|
+
if (useRid) {
|
|
366
|
+
checkFieldsToRid();
|
|
367
|
+
} else {
|
|
368
|
+
checkFieldsToIns();
|
|
369
|
+
}
|
|
370
|
+
checkWildcards();
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Check state of all field to rid level, change state of accept button accordingly
|
|
375
|
+
*/
|
|
376
|
+
function checkFieldsToRid() {
|
|
377
|
+
if (
|
|
378
|
+
($('#instance-search-hid').val() !== '' &&
|
|
379
|
+
$('#instance-search-sid').val() !== '' &&
|
|
380
|
+
$('#instance-search-pid').val() !== '' &&
|
|
381
|
+
$('#instance-search-ins').val() !== '' &&
|
|
382
|
+
$('#instance-search-rid').val() !== '') ||
|
|
383
|
+
$('#instance-search-sid').val() === '#' ||
|
|
384
|
+
$('#instance-search-pid').val() === '#' ||
|
|
385
|
+
$('#instance-search-ins').val() === '#' ||
|
|
386
|
+
$('#instance-search-rid').val() === '#'
|
|
387
|
+
) {
|
|
388
|
+
$('#node-search-accept').css('color', '#555555');
|
|
389
|
+
readyToAccept = true;
|
|
390
|
+
} else {
|
|
391
|
+
$('#node-search-accept').css('color', '#CCCCCC');
|
|
392
|
+
readyToAccept = false;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Check state of all field to ins level, change state of accept button accordingly
|
|
398
|
+
*/
|
|
399
|
+
function checkFieldsToIns() {
|
|
400
|
+
if (
|
|
401
|
+
($('#instance-search-hid').val() !== '' &&
|
|
402
|
+
$('#instance-search-sid').val() !== '' &&
|
|
403
|
+
$('#instance-search-pid').val() !== '' &&
|
|
404
|
+
$('#instance-search-ins').val() !== '') ||
|
|
405
|
+
$('#instance-search-sid').val() === '#' ||
|
|
406
|
+
$('#instance-search-pid').val() === '#' ||
|
|
407
|
+
$('#instance-search-ins').val() === '#'
|
|
408
|
+
) {
|
|
409
|
+
$('#node-search-accept').css('color', '#555555');
|
|
410
|
+
readyToAccept = true;
|
|
411
|
+
} else {
|
|
412
|
+
$('#node-search-accept').css('color', '#CCCCCC');
|
|
413
|
+
readyToAccept = false;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Checks if + wildcard values are present, shows / hides alert message accordingly
|
|
419
|
+
*/
|
|
420
|
+
function checkWildcards() {
|
|
421
|
+
if (
|
|
422
|
+
$('#instance-search-sid').val() !== '+' &&
|
|
423
|
+
$('#instance-search-pid').val() !== '+' &&
|
|
424
|
+
$('#instance-search-ins').val() !== '+'
|
|
425
|
+
) {
|
|
426
|
+
$('#wildcard-alert-row').hide();
|
|
427
|
+
} else {
|
|
428
|
+
$('#wildcard-alert-row').show();
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Update editable list with results from mobsearch
|
|
434
|
+
*/
|
|
435
|
+
function updateList() {
|
|
436
|
+
$(`#${opts.containerName}`)
|
|
437
|
+
.editableList('items')
|
|
438
|
+
.each(function (i) {
|
|
439
|
+
let item = $(this);
|
|
440
|
+
let secondField = item.find(`.${opts.containerSecondFieldName}`).val();
|
|
441
|
+
opts.list[i][Object.keys(opts.list[i])[1]] = secondField;
|
|
442
|
+
});
|
|
443
|
+
$(`#${opts.containerName}`).editableList('empty');
|
|
444
|
+
for (let i = 0; i < opts.list.length; i++) {
|
|
445
|
+
let item = opts.list[i];
|
|
446
|
+
$(`#${opts.containerName}`).editableList('addItem', item);
|
|
447
|
+
}
|
|
448
|
+
$(`#${opts.containerRowName}`).show();
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// * CLICK RESPONSE * //
|
|
452
|
+
|
|
453
|
+
$('#node-lookup-instance').click(function () {
|
|
454
|
+
//When search button is clicked
|
|
455
|
+
$('#instance-search-sid').val('');
|
|
456
|
+
$('#instance-search-pid').val('');
|
|
457
|
+
$('#instance-search-ins').val('');
|
|
458
|
+
if (useRid) {
|
|
459
|
+
$('#instance-search-rid').val('');
|
|
460
|
+
}
|
|
461
|
+
$('#node-lookup-instance').addClass('disabled');
|
|
462
|
+
$('#node-search-return').removeClass('disabled');
|
|
463
|
+
$('#node-search-accept').removeClass('disabled');
|
|
464
|
+
$('#instance-row').hide();
|
|
465
|
+
$('#instance-search-row').show();
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
$('#instance-search-sid').click(function () {
|
|
469
|
+
//SID field clicked
|
|
470
|
+
$('#instance-search-pid').val('');
|
|
471
|
+
$('#instance-search-ins').val('');
|
|
472
|
+
searchObject.pid = '';
|
|
473
|
+
searchObject.ins = '';
|
|
474
|
+
if (useRid) {
|
|
475
|
+
searchObject.rid = '';
|
|
476
|
+
}
|
|
477
|
+
searchObject.objects = [];
|
|
478
|
+
startSearch();
|
|
479
|
+
});
|
|
480
|
+
$('#instance-search-pid').click(function () {
|
|
481
|
+
//PID field clicked
|
|
482
|
+
$('#instance-search-ins').val('');
|
|
483
|
+
|
|
484
|
+
searchObject.ins = '';
|
|
485
|
+
|
|
486
|
+
if (useRid) {
|
|
487
|
+
$('#instance-search-rid').val('');
|
|
488
|
+
searchObject.rid = '';
|
|
489
|
+
}
|
|
490
|
+
if (searchObject.sid !== '') {
|
|
491
|
+
pidsSearch(searchObject.objects);
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
$('#instance-search-ins').click(function () {
|
|
495
|
+
//INS field clicked
|
|
496
|
+
if (useRid) {
|
|
497
|
+
$('#instance-search-rid').val('');
|
|
498
|
+
searchObject.rid = '';
|
|
499
|
+
}
|
|
500
|
+
if (searchObject.pid !== '' && searchObject.pid !== '+' && searchObject.sid !== '+') {
|
|
501
|
+
insSearch(searchObject.objects, searchObject.pid);
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
if (useRid) {
|
|
506
|
+
$('#instance-search-rid').click(function () {
|
|
507
|
+
//RID clicked
|
|
508
|
+
if (
|
|
509
|
+
searchObject.ins !== '' &&
|
|
510
|
+
searchObject.ins !== '+' &&
|
|
511
|
+
searchObject.pid !== '+' &&
|
|
512
|
+
searchObject.sid !== '+'
|
|
513
|
+
) {
|
|
514
|
+
ridSearch(searchObject.objects, searchObject.ins);
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
$('#node-search-return').click(function () {
|
|
520
|
+
//Return/Back button clicked
|
|
521
|
+
$('#node-search-return').addClass('disabled');
|
|
522
|
+
$('#node-search-accept').addClass('disabled');
|
|
523
|
+
$('#node-lookup-instance').removeClass('disabled');
|
|
524
|
+
$('#instance-search-row').hide();
|
|
525
|
+
$('#instance-row').show();
|
|
526
|
+
});
|
|
527
|
+
$('#node-search-accept').click(function () {
|
|
528
|
+
//Accept button clicked
|
|
529
|
+
if (readyToAccept) {
|
|
530
|
+
finishSearch();
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
// * END CLICK RESPONSE * //
|
|
535
|
+
|
|
536
|
+
// * CHANGE RESPONSE * //
|
|
537
|
+
|
|
538
|
+
$('#instance-search-hid').change(function () {
|
|
539
|
+
acceptCheck();
|
|
540
|
+
$('#instance-search-sid').val('');
|
|
541
|
+
$('#instance-search-pid').val('');
|
|
542
|
+
$('#instance-search-ins').val('');
|
|
543
|
+
if (useRid) {
|
|
544
|
+
$('#instance-search-rid').val('');
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
$('#instance-search-sid').change(function () {
|
|
549
|
+
searchObject.sid = $('#instance-search-sid').val();
|
|
550
|
+
acceptCheck();
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
$('#instance-search-pid').change(function () {
|
|
554
|
+
searchObject.pid = $('#instance-search-pid').val();
|
|
555
|
+
acceptCheck();
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
$('#instance-search-ins').change(function () {
|
|
559
|
+
searchObject.ins = $('#instance-search-ins').val();
|
|
560
|
+
acceptCheck();
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
if (useRid) {
|
|
564
|
+
$('#instance-search-rid').change(function () {
|
|
565
|
+
searchObject.rid = $('#instance-search-rid').val();
|
|
566
|
+
acceptCheck();
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// * END CHANGE RESPONSE * //
|
|
571
|
+
|
|
572
|
+
// reset input filed after init
|
|
573
|
+
if (!listed) {
|
|
574
|
+
$(`#${opts.uriFieldName}`).val(uriFieldValue);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
@@ -29,10 +29,16 @@ 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
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
<hr>
|
|
33
|
+
|
|
34
|
+
<div id="instance-row">
|
|
35
|
+
<div class="form-row" id="input-row">
|
|
36
|
+
<label for="node-input-resource"><i class="fa fa-tasks"></i> URI</label>
|
|
37
|
+
<input type="text" id="node-input-resource" style="width:61%;" placeholder="Resource URI (hid/sid/pid/ins/rid)">
|
|
38
|
+
</div>
|
|
35
39
|
</div>
|
|
40
|
+
<div id="mobsearch"></div>
|
|
41
|
+
|
|
36
42
|
<div class="form-row">
|
|
37
43
|
<label for="node-input-priority"><i class="fa fa-exclamation-triangle"></i> Priority</label>
|
|
38
44
|
<input type="text" id="node-input-priority" placeholder="Priotity to clear">
|
|
@@ -49,6 +55,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
49
55
|
</div>
|
|
50
56
|
</script>
|
|
51
57
|
|
|
58
|
+
<script src="common/mobsearch.js"></script>
|
|
59
|
+
|
|
52
60
|
<script type="text/javascript">
|
|
53
61
|
RED.nodes.registerType('mobius clear resource',{
|
|
54
62
|
category: 'mobius',
|
|
@@ -90,6 +98,17 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
90
98
|
labelStyle: function() {
|
|
91
99
|
return this.name ? "node_label_italic":"";
|
|
92
100
|
},
|
|
101
|
+
oneditprepare: function () {
|
|
102
|
+
var node = this;
|
|
103
|
+
let mobiusSrvc = $("#node-input-connection").val();
|
|
104
|
+
|
|
105
|
+
opts = {
|
|
106
|
+
htmlElementId: 'mobsearch',
|
|
107
|
+
uriFieldName: 'node-input-resource',
|
|
108
|
+
inputRowId: 'input-row',
|
|
109
|
+
};
|
|
110
|
+
initMobsearch.toRid(mobiusSrvc, opts);
|
|
111
|
+
},
|
|
93
112
|
oneditsave: function() {
|
|
94
113
|
if($("#node-input-detailedOutput").prop('checked')) {
|
|
95
114
|
this.outputs = 4;
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
'use strict';
|
|
29
29
|
|
|
30
30
|
module.exports = function (RED) {
|
|
31
|
-
function MobiusClearResourceNode
|
|
31
|
+
function MobiusClearResourceNode(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) {
|
|
@@ -57,7 +57,7 @@ module.exports = function (RED) {
|
|
|
57
57
|
node.status({
|
|
58
58
|
fill: 'green',
|
|
59
59
|
shape: 'ring',
|
|
60
|
-
text: 'Busy'
|
|
60
|
+
text: 'Busy',
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
node.serviceConn.clearResourcePriority(uri, pri, (err, response) => {
|
|
@@ -65,29 +65,34 @@ module.exports = function (RED) {
|
|
|
65
65
|
node.status({
|
|
66
66
|
fill: 'yellow',
|
|
67
67
|
shape: 'dot',
|
|
68
|
-
text: 'Error: ' + JSON.stringify(err.code)
|
|
68
|
+
text: 'Error: ' + JSON.stringify(err.code),
|
|
69
69
|
});
|
|
70
70
|
node.error('Mobius error clearing resource priority ' + JSON.stringify(err));
|
|
71
71
|
if (node.detailedOutput === true) {
|
|
72
|
-
node.send([
|
|
72
|
+
node.send([
|
|
73
|
+
null,
|
|
74
|
+
null,
|
|
75
|
+
null,
|
|
76
|
+
{ topic: uri, payload: { error: true, response: err } },
|
|
77
|
+
]);
|
|
73
78
|
}
|
|
74
79
|
} else {
|
|
75
80
|
node.status({
|
|
76
81
|
fill: 'green',
|
|
77
82
|
shape: 'dot',
|
|
78
|
-
text: JSON.stringify(response.
|
|
83
|
+
text: JSON.stringify(response.data.pv),
|
|
79
84
|
});
|
|
80
85
|
if (node.detailedOutput === true) {
|
|
81
86
|
node.send([
|
|
82
|
-
{ topic: uri, payload: response.
|
|
83
|
-
{ topic: uri, payload: { pv: response.
|
|
84
|
-
{ topic: uri, payload: response.
|
|
85
|
-
{ topic: uri, payload: { error: false, response: response } }
|
|
87
|
+
{ topic: uri, payload: response.data.pv },
|
|
88
|
+
{ topic: uri, payload: { pv: response.data.pv, name: response.data.name } },
|
|
89
|
+
{ topic: uri, payload: response.data },
|
|
90
|
+
{ topic: uri, payload: { error: false, response: response } },
|
|
86
91
|
]);
|
|
87
92
|
} else {
|
|
88
93
|
node.send([
|
|
89
|
-
{ topic: uri, payload: response.
|
|
90
|
-
{ topic: uri, payload: { pv: response.
|
|
94
|
+
{ topic: uri, payload: response.data.pv },
|
|
95
|
+
{ topic: uri, payload: { pv: response.data.pv, name: response.data.name } },
|
|
91
96
|
]);
|
|
92
97
|
}
|
|
93
98
|
}
|