node-red-contrib-mobius-flow-base 2.5.86-beta.85 → 2.5.86-beta.88
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.
|
@@ -194,33 +194,55 @@ module.exports = function (RED) {
|
|
|
194
194
|
};
|
|
195
195
|
|
|
196
196
|
/**
|
|
197
|
-
*
|
|
198
|
-
* @param
|
|
197
|
+
* Select status text and colour of node status based on last active time
|
|
198
|
+
* @param {number} lastActiveTime - The node's last active time
|
|
199
|
+
* @returns Object containing status text and status colour
|
|
199
200
|
*/
|
|
200
|
-
node.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
node.getLastActiveTimeStatus = function (lastActiveTime) {
|
|
202
|
+
let response = {
|
|
203
|
+
text: 'Unknown',
|
|
204
|
+
colour: 'green',
|
|
205
|
+
};
|
|
206
|
+
const timeSinceLastActive = Date.now() - lastActiveTime;
|
|
205
207
|
if (timeSinceLastActive < 15 * 60000) {
|
|
206
|
-
|
|
208
|
+
response.text = 'Active less than 15 minutes ago';
|
|
207
209
|
}
|
|
208
210
|
if (timeSinceLastActive >= 15 * 60000 && timeSinceLastActive < 3 * 60 * 60000) {
|
|
209
|
-
|
|
211
|
+
response.text = 'Active less than 3 hours ago';
|
|
210
212
|
}
|
|
211
213
|
if (timeSinceLastActive >= 3 * 60 * 60000 && timeSinceLastActive < 12 * 60 * 60000) {
|
|
212
|
-
|
|
214
|
+
response.text = 'Active less than 12 hours ago';
|
|
213
215
|
}
|
|
214
216
|
if (timeSinceLastActive >= 12 * 60 * 60000 && timeSinceLastActive < 24 * 60 * 60000) {
|
|
215
|
-
|
|
217
|
+
response.text = 'Active less than 24 hours ago';
|
|
218
|
+
}
|
|
219
|
+
if (timeSinceLastActive > 24 * 60 * 60000 && lastActiveTime > 0) {
|
|
220
|
+
response.colour = 'grey';
|
|
221
|
+
response.text = 'Active more than 24 hours ago';
|
|
216
222
|
}
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
|
|
223
|
+
if (lastActiveTime === 0) {
|
|
224
|
+
response.colour = 'grey';
|
|
225
|
+
response.text = 'Never Active';
|
|
220
226
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
227
|
+
return response;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Update a given node's node status based on last active time
|
|
232
|
+
* @param {Object} mobiusNode - The node whos status is to be updated
|
|
233
|
+
*/
|
|
234
|
+
node.updateNodeStatus = function (mobiusNode) {
|
|
235
|
+
console.log('Update');
|
|
236
|
+
console.log(node.users[mobiusNode.id].statusType);
|
|
237
|
+
node.users[mobiusNode.id] = mobiusNode;
|
|
238
|
+
let statusText = 'Unknown';
|
|
239
|
+
let statusColour = 'green';
|
|
240
|
+
if (node.users[mobiusNode.id].statusType === 'timeSinceLastActive') {
|
|
241
|
+
let result = getLastActiveTimeStatus(node.users[mobiusNode.id].lastActiveTime);
|
|
242
|
+
statusText = result.text;
|
|
243
|
+
statusColour = result.colour;
|
|
244
|
+
} else {
|
|
245
|
+
statusText = node.users[mobiusNode.id].latestUri;
|
|
224
246
|
}
|
|
225
247
|
node.users[mobiusNode.id].status({
|
|
226
248
|
fill: statusColour,
|
|
@@ -254,7 +276,9 @@ module.exports = function (RED) {
|
|
|
254
276
|
}
|
|
255
277
|
node.users[mobiusNode.id].lastActiveTime = 0;
|
|
256
278
|
node.users[mobiusNode.id].statusCheckLoop = setInterval(() => {
|
|
257
|
-
node.
|
|
279
|
+
if (node.connected) {
|
|
280
|
+
node.updateNodeStatus(mobiusNode);
|
|
281
|
+
}
|
|
258
282
|
}, 60000);
|
|
259
283
|
};
|
|
260
284
|
|
|
@@ -53,6 +53,13 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
53
53
|
<label for="node-input-detailedOutput" style="width: 70%;"> Use detailed outputs</label>
|
|
54
54
|
</div>
|
|
55
55
|
<hr>
|
|
56
|
+
<div class="form-row">
|
|
57
|
+
<label for="node-input-statusType"><i class="fa fa-bars"></i> Status Display</label>
|
|
58
|
+
<select type="text" id="node-input-statusType" style="display: inline-block; width: auto; vertical-align: center;">
|
|
59
|
+
<option value="timeSinceLastActive">Time since last active</option>
|
|
60
|
+
<option value="lastUri">Last URI</option>
|
|
61
|
+
</select>
|
|
62
|
+
</div>
|
|
56
63
|
<div class="form-row">
|
|
57
64
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
58
65
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
@@ -64,6 +71,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
64
71
|
category: 'mobius',
|
|
65
72
|
defaults: {
|
|
66
73
|
name: {value:""},
|
|
74
|
+
statusType: {value:""},
|
|
67
75
|
detailedOutput: {value:false},
|
|
68
76
|
format: {value: "name", required: true},
|
|
69
77
|
include: {value: "changed", required: true},
|
|
@@ -36,8 +36,12 @@ module.exports = function (RED) {
|
|
|
36
36
|
this.format = n.format;
|
|
37
37
|
this.include = n.include;
|
|
38
38
|
this.serviceConn = RED.nodes.getNode(n.connection);
|
|
39
|
+
this.latestUri = '';
|
|
40
|
+
this.statusType = n.statusType;
|
|
39
41
|
var node = this;
|
|
40
42
|
|
|
43
|
+
console.log(node.statusType);
|
|
44
|
+
|
|
41
45
|
if (node.serviceConn) {
|
|
42
46
|
node.status({
|
|
43
47
|
fill: 'red',
|
|
@@ -46,11 +50,9 @@ module.exports = function (RED) {
|
|
|
46
50
|
});
|
|
47
51
|
|
|
48
52
|
node.serviceConn.subscribeToObjectCOV(node.object, this.id, (response) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
text: JSON.stringify(response.uri),
|
|
53
|
-
});
|
|
53
|
+
console.log('COV Event');
|
|
54
|
+
node.latestUri = JSON.stringify(response.uri);
|
|
55
|
+
node.serviceConn.updateNodeStatus(node);
|
|
54
56
|
let allResources = _.keyBy(
|
|
55
57
|
response.value.resources,
|
|
56
58
|
node.format === 'name' ? 'name' : 'rid'
|
package/package.json
CHANGED
|
@@ -1,575 +0,0 @@
|
|
|
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
|
-
}
|