node-red-contrib-mobius-flow-base 3.2.0 → 3.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine-api-calls.js +26 -6
- package/dist/engine-api-client.d.ts +4 -4
- package/dist/engine-api-client.js +10 -10
- package/dist/nodes/common/mobsearch.js +7 -3
- package/dist/nodes/mobius-clear-resource.js +96 -65
- package/dist/nodes/mobius-discover.html +43 -19
- package/dist/nodes/mobius-discover.js +8 -0
- package/dist/nodes/mobius-filter-by-rid-value.js +51 -3
- package/dist/nodes/mobius-flow-inject.js +40 -12
- package/dist/nodes/mobius-get-multi-object.html +98 -76
- package/dist/nodes/mobius-get-multi-object.js +22 -19
- package/dist/nodes/mobius-get-multi-resource.html +99 -75
- package/dist/nodes/mobius-get-multi-resource.js +22 -19
- package/dist/nodes/mobius-get-object.js +39 -7
- package/dist/nodes/mobius-get-resource.js +39 -7
- package/dist/nodes/mobius-set-multi-resource.js +73 -53
- package/dist/nodes/mobius-set-resource.js +57 -11
- package/package.json +1 -1
|
@@ -24,7 +24,10 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
24
24
|
POSSIBILITY OF SUCH DAMAGE.
|
|
25
25
|
-->
|
|
26
26
|
|
|
27
|
-
<script
|
|
27
|
+
<script
|
|
28
|
+
type="text/x-red"
|
|
29
|
+
data-template-name="mobius get multi-object"
|
|
30
|
+
>
|
|
28
31
|
<div class="form-row">
|
|
29
32
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
30
33
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
@@ -48,84 +51,96 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
48
51
|
RED.nodes.registerType('mobius get multi-object', {
|
|
49
52
|
category: 'mobius',
|
|
50
53
|
defaults: {
|
|
51
|
-
name: {value:
|
|
52
|
-
mobjects: {value:[{uri: '', comment: ''}]},
|
|
53
|
-
connection: {type:
|
|
54
|
+
name: { value: '' },
|
|
55
|
+
mobjects: { value: [{ uri: '', comment: '' }] },
|
|
56
|
+
connection: { type: 'mobius connection', required: true },
|
|
54
57
|
},
|
|
55
|
-
color:
|
|
56
|
-
inputs:1,
|
|
57
|
-
outputs:1,
|
|
58
|
-
outputLabels: [
|
|
59
|
-
icon:
|
|
60
|
-
align:
|
|
58
|
+
color: '#9ee3fa',
|
|
59
|
+
inputs: 1,
|
|
60
|
+
outputs: 1,
|
|
61
|
+
outputLabels: ['MOBiUS objects'],
|
|
62
|
+
icon: 'mobius.png',
|
|
63
|
+
align: 'left',
|
|
61
64
|
paletteLabel: 'get multi-object',
|
|
62
|
-
label: function() {
|
|
63
|
-
if(this.name) {
|
|
65
|
+
label: function () {
|
|
66
|
+
if (this.name) {
|
|
64
67
|
return this.name;
|
|
65
68
|
} else {
|
|
66
|
-
return
|
|
69
|
+
return 'get multi-object';
|
|
67
70
|
}
|
|
68
71
|
},
|
|
69
|
-
labelStyle: function() {
|
|
70
|
-
return this.name ?
|
|
72
|
+
labelStyle: function () {
|
|
73
|
+
return this.name ? 'node_label_italic' : '';
|
|
71
74
|
},
|
|
72
75
|
oneditprepare: function () {
|
|
73
76
|
var node = this;
|
|
74
|
-
let mobiusSrvc = $(
|
|
77
|
+
let mobiusSrvc = $('#node-input-connection').val();
|
|
75
78
|
|
|
76
79
|
/** Resize a object when it has changed */
|
|
77
|
-
function resizeObject
|
|
80
|
+
function resizeObject(mobject) {
|
|
78
81
|
let newWidth = mobject.width();
|
|
79
|
-
mobject.find(
|
|
82
|
+
mobject.find('.node-input-mobject-comment').width(newWidth - 300);
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
/** Create the objects container and populate it */
|
|
83
|
-
$('#node-input-mobjects-container')
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
86
|
+
$('#node-input-mobjects-container')
|
|
87
|
+
.css('min-height', '300px')
|
|
88
|
+
.css('min-width', '450px')
|
|
89
|
+
.editableList({
|
|
90
|
+
addButton: 'add',
|
|
91
|
+
removable: true,
|
|
92
|
+
sortable: true,
|
|
93
|
+
addItem: function (container, i, mobject) {
|
|
94
|
+
container.css({
|
|
95
|
+
overflow: 'hidden',
|
|
96
|
+
whiteSpace: 'nowrap',
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Add a default resource if it does not exist
|
|
100
|
+
if (!mobject.hasOwnProperty('uri')) {
|
|
101
|
+
mobject = { uri: '', comment: '' };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
var row = $('<div>URI</div>').appendTo(container);
|
|
105
|
+
var uriField = $('<input/>', {
|
|
106
|
+
class: 'node-input-mobject-uri',
|
|
107
|
+
type: 'text',
|
|
108
|
+
style: 'width: 200px; margin-left: 5px; text-align: left;',
|
|
109
|
+
}).appendTo(row);
|
|
110
|
+
|
|
111
|
+
// *** MOBSEARCH *** //
|
|
112
|
+
var searchField = $(
|
|
113
|
+
'<a class="searchbutton" style="margin-left: 5px; vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>'
|
|
114
|
+
).appendTo(row);
|
|
115
|
+
// *** END MOBSEARCH *** //
|
|
116
|
+
|
|
117
|
+
row.append(' - ');
|
|
118
|
+
var commentField = $('<input/>', {
|
|
119
|
+
class: 'node-input-mobject-comment',
|
|
120
|
+
type: 'text',
|
|
121
|
+
style: 'width: 35%; margin-left: 5px; text-align: left;',
|
|
122
|
+
}).appendTo(row);
|
|
123
|
+
|
|
124
|
+
// Populate the new stat
|
|
125
|
+
uriField.val(mobject.uri);
|
|
126
|
+
commentField.val(mobject.comment);
|
|
127
|
+
// resizeObject(container);
|
|
128
|
+
|
|
129
|
+
// *** MOBSEARCH *** //
|
|
130
|
+
|
|
131
|
+
if (!node.mobjects[i]) {
|
|
132
|
+
node.mobjects[i] = { uri: '', comment: '' };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
addMobsearchListButton(mobiusSrvc, searchField, i, mobsearchOpts);
|
|
136
|
+
// *** END MOBSEARCH *** //
|
|
137
|
+
},
|
|
138
|
+
// resizeItem: resizeObject
|
|
139
|
+
});
|
|
125
140
|
|
|
126
141
|
// If no mobjects exists, create a default one
|
|
127
142
|
if (!node.mobjects) {
|
|
128
|
-
node.mobjects = [mobject = {uri: '', comment: ''}];
|
|
143
|
+
node.mobjects = [(mobject = { uri: '', comment: '' })];
|
|
129
144
|
}
|
|
130
145
|
|
|
131
146
|
// *** MOBSEARCH *** //
|
|
@@ -136,43 +151,50 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
136
151
|
containerRowName: 'node-input-mobjects-container-row',
|
|
137
152
|
containerName: 'node-input-mobjects-container',
|
|
138
153
|
containerSecondFieldName: 'node-input-mobject-comment',
|
|
154
|
+
removeWildcards: true,
|
|
139
155
|
};
|
|
140
156
|
initMobsearch.toIns_listed(mobiusSrvc, mobsearchOpts);
|
|
141
157
|
|
|
142
158
|
// *** END MOBSEARCH *** //
|
|
143
|
-
|
|
159
|
+
|
|
144
160
|
// Populate list with all saved filters
|
|
145
161
|
for (let i = 0; i < node.mobjects.length; i++) {
|
|
146
162
|
let mobject = node.mobjects[i];
|
|
147
|
-
$(
|
|
163
|
+
$('#node-input-mobjects-container').editableList('addItem', mobject);
|
|
148
164
|
}
|
|
149
165
|
},
|
|
150
166
|
oneditresize(size) {
|
|
151
|
-
var rows = $(
|
|
167
|
+
var rows = $('#dialog-form>div:not(.node-input-mobjects-container-row)');
|
|
152
168
|
var height = size.height;
|
|
153
|
-
for (var i=0; i<rows.size(); i++) {
|
|
169
|
+
for (var i = 0; i < rows.size(); i++) {
|
|
154
170
|
height -= $(rows[i]).outerHeight(true);
|
|
155
171
|
}
|
|
156
|
-
var editorRow = $(
|
|
157
|
-
height -=
|
|
172
|
+
var editorRow = $('#dialog-form>div.node-input-mobjects-container-row');
|
|
173
|
+
height -=
|
|
174
|
+
4 *
|
|
175
|
+
(parseInt(editorRow.css('marginTop')) +
|
|
176
|
+
parseInt(editorRow.css('marginBottom')));
|
|
158
177
|
|
|
159
|
-
$(
|
|
178
|
+
$('#node-input-mobjects-container').editableList('height', height);
|
|
160
179
|
},
|
|
161
|
-
oneditsave: function() {
|
|
162
|
-
let mobjects = $(
|
|
180
|
+
oneditsave: function () {
|
|
181
|
+
let mobjects = $('#node-input-mobjects-container').editableList('items');
|
|
163
182
|
let node = this;
|
|
164
|
-
node.mobjects= [];
|
|
183
|
+
node.mobjects = [];
|
|
165
184
|
mobjects.each(function (i) {
|
|
166
185
|
let mobject = $(this);
|
|
167
|
-
let uri = mobject.find(
|
|
168
|
-
let comment = mobject.find(
|
|
169
|
-
node.mobjects.push({uri: uri, comment: comment});
|
|
186
|
+
let uri = mobject.find('.node-input-mobject-uri').val();
|
|
187
|
+
let comment = mobject.find('.node-input-mobject-comment').val();
|
|
188
|
+
node.mobjects.push({ uri: uri, comment: comment });
|
|
170
189
|
});
|
|
171
|
-
}
|
|
190
|
+
},
|
|
172
191
|
});
|
|
173
192
|
</script>
|
|
174
193
|
|
|
175
|
-
<script
|
|
194
|
+
<script
|
|
195
|
+
type="text/x-red"
|
|
196
|
+
data-help-name="mobius get multi-object"
|
|
197
|
+
>
|
|
176
198
|
<p>Read multiple MOBiUS object values.</p>
|
|
177
199
|
|
|
178
200
|
<h3>Configuration Page</h3>
|
|
@@ -34,6 +34,10 @@ module.exports = function (RED) {
|
|
|
34
34
|
this.serviceConn = RED.nodes.getNode(n.connection);
|
|
35
35
|
var node = this;
|
|
36
36
|
|
|
37
|
+
const uriValidTest = new RegExp(
|
|
38
|
+
`^[0-9A-Fa-f]{6}/[0-9A-Fa-f]{3}/[0-9A-Fa-f]{4}/[0-9A-Fa-f]{4}$`
|
|
39
|
+
);
|
|
40
|
+
|
|
37
41
|
if (node.serviceConn) {
|
|
38
42
|
node.status({
|
|
39
43
|
fill: 'red',
|
|
@@ -51,11 +55,11 @@ module.exports = function (RED) {
|
|
|
51
55
|
});
|
|
52
56
|
|
|
53
57
|
for (const mobject of node.mobjects) {
|
|
54
|
-
if (!
|
|
58
|
+
if (!uriValidTest.test(mobject.uri)) {
|
|
55
59
|
node.status({
|
|
56
60
|
fill: 'yellow',
|
|
57
61
|
shape: 'dot',
|
|
58
|
-
text: 'URIs not Valid',
|
|
62
|
+
text: 'Error: URIs not Valid',
|
|
59
63
|
});
|
|
60
64
|
if (done) {
|
|
61
65
|
return done();
|
|
@@ -79,12 +83,24 @@ module.exports = function (RED) {
|
|
|
79
83
|
node.status({
|
|
80
84
|
fill: 'yellow',
|
|
81
85
|
shape: 'dot',
|
|
82
|
-
text:
|
|
86
|
+
text: (() => {
|
|
87
|
+
if (err.response.status === 404) {
|
|
88
|
+
return `Error: One or more objects not found`;
|
|
89
|
+
} else {
|
|
90
|
+
return `Error: ${err.code ? err.code : 'Unknown'}`;
|
|
91
|
+
}
|
|
92
|
+
})(),
|
|
83
93
|
});
|
|
84
94
|
node.error(
|
|
85
|
-
|
|
86
|
-
err.
|
|
87
|
-
|
|
95
|
+
(() => {
|
|
96
|
+
if (err.response.status === 404) {
|
|
97
|
+
return `Error: One or more objects not found`;
|
|
98
|
+
} else {
|
|
99
|
+
return `Error: ${err.code ? err.code : 'Unknown'}, ${
|
|
100
|
+
err.message ? err.message : ''
|
|
101
|
+
}`;
|
|
102
|
+
}
|
|
103
|
+
})()
|
|
88
104
|
);
|
|
89
105
|
})
|
|
90
106
|
.finally(() => {
|
|
@@ -102,19 +118,6 @@ module.exports = function (RED) {
|
|
|
102
118
|
}
|
|
103
119
|
}
|
|
104
120
|
|
|
105
|
-
function validateResourceURI(uri) {
|
|
106
|
-
let parts = uri.split('/');
|
|
107
|
-
for (let lp = 0; lp < parts.length; lp++) {
|
|
108
|
-
if (parts[lp] === null || parts[lp] === '') {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (parts.length === 4) {
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
121
|
function readObject(node, uri) {
|
|
119
122
|
return new Promise((resolve, reject) => {
|
|
120
123
|
node.serviceConn.readObject(uri, (err, response) => {
|
|
@@ -24,7 +24,10 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
24
24
|
POSSIBILITY OF SUCH DAMAGE.
|
|
25
25
|
-->
|
|
26
26
|
|
|
27
|
-
<script
|
|
27
|
+
<script
|
|
28
|
+
type="text/x-red"
|
|
29
|
+
data-template-name="mobius get multi-resource"
|
|
30
|
+
>
|
|
28
31
|
<div class="form-row">
|
|
29
32
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
30
33
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
@@ -55,84 +58,96 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
55
58
|
RED.nodes.registerType('mobius get multi-resource', {
|
|
56
59
|
category: 'mobius',
|
|
57
60
|
defaults: {
|
|
58
|
-
name: {value:
|
|
59
|
-
send: {value:
|
|
60
|
-
resources: {value:[{uri: '', comment: ''}]},
|
|
61
|
-
connection: {type:
|
|
61
|
+
name: { value: '' },
|
|
62
|
+
send: { value: 'array', required: true },
|
|
63
|
+
resources: { value: [{ uri: '', comment: '' }] },
|
|
64
|
+
connection: { type: 'mobius connection', required: true },
|
|
62
65
|
},
|
|
63
|
-
color:
|
|
64
|
-
inputs:1,
|
|
65
|
-
outputs:1,
|
|
66
|
-
outputLabels: [
|
|
67
|
-
icon:
|
|
68
|
-
align:
|
|
66
|
+
color: '#9ee3fa',
|
|
67
|
+
inputs: 1,
|
|
68
|
+
outputs: 1,
|
|
69
|
+
outputLabels: ['MOBiUS resources'],
|
|
70
|
+
icon: 'mobius.png',
|
|
71
|
+
align: 'left',
|
|
69
72
|
paletteLabel: 'get multi-resource',
|
|
70
|
-
label: function() {
|
|
71
|
-
if(this.name) {
|
|
73
|
+
label: function () {
|
|
74
|
+
if (this.name) {
|
|
72
75
|
return this.name;
|
|
73
76
|
} else {
|
|
74
|
-
return
|
|
77
|
+
return 'get multi-resource';
|
|
75
78
|
}
|
|
76
79
|
},
|
|
77
|
-
labelStyle: function() {
|
|
78
|
-
return this.name ?
|
|
80
|
+
labelStyle: function () {
|
|
81
|
+
return this.name ? 'node_label_italic' : '';
|
|
79
82
|
},
|
|
80
83
|
oneditprepare: function () {
|
|
81
84
|
var node = this;
|
|
82
|
-
let mobiusSrvc = $(
|
|
85
|
+
let mobiusSrvc = $('#node-input-connection').val();
|
|
83
86
|
|
|
84
87
|
/** Resize a resource when it has changed */
|
|
85
|
-
function resizeResource
|
|
88
|
+
function resizeResource(resource) {
|
|
86
89
|
let newWidth = resource.width();
|
|
87
|
-
resource.find(
|
|
90
|
+
resource.find('.node-input-resource-comment').width(newWidth - 270);
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
/** Create the subs container and populate it */
|
|
91
|
-
$('#node-input-resources-container')
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
94
|
+
$('#node-input-resources-container')
|
|
95
|
+
.css('min-height', '300px')
|
|
96
|
+
.css('min-width', '450px')
|
|
97
|
+
.editableList({
|
|
98
|
+
addButton: 'add',
|
|
99
|
+
removable: true,
|
|
100
|
+
sortable: true,
|
|
101
|
+
addItem: function (container, i, resource) {
|
|
102
|
+
container.css({
|
|
103
|
+
overflow: 'hidden',
|
|
104
|
+
whiteSpace: 'nowrap',
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Add a default resource if it does not exist
|
|
108
|
+
if (!resource.hasOwnProperty('uri')) {
|
|
109
|
+
resource = { uri: '', comment: '' };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
var row = $('<div>URI</div>').appendTo(container);
|
|
113
|
+
var uriField = $('<input/>', {
|
|
114
|
+
class: 'node-input-resource-uri',
|
|
115
|
+
type: 'text',
|
|
116
|
+
style: 'width: 200px; margin-left: 5px; text-align: left;',
|
|
117
|
+
}).appendTo(row);
|
|
118
|
+
|
|
119
|
+
// *** MOBSEARCH *** //
|
|
120
|
+
var searchField = $(
|
|
121
|
+
'<a class="searchbutton" style="margin-left: 5px; vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>'
|
|
122
|
+
).appendTo(row);
|
|
123
|
+
|
|
124
|
+
// *** END MOBSEARCH *** //
|
|
125
|
+
|
|
126
|
+
row.append(' - ');
|
|
127
|
+
var commentField = $('<input/>', {
|
|
128
|
+
class: 'node-input-resource-comment',
|
|
129
|
+
type: 'text',
|
|
130
|
+
style: 'width: 35%; margin-left: 5px; text-align: left;',
|
|
131
|
+
}).appendTo(row);
|
|
132
|
+
|
|
133
|
+
// Populate the new stat
|
|
134
|
+
uriField.val(resource.uri);
|
|
135
|
+
commentField.val(resource.comment);
|
|
136
|
+
//resizeResource(container);
|
|
137
|
+
|
|
138
|
+
// *** MOBSEARCH *** //
|
|
139
|
+
if (!node.resources[i]) {
|
|
140
|
+
node.resources[i] = { uri: '', comment: '' };
|
|
141
|
+
}
|
|
142
|
+
addMobsearchListButton(mobiusSrvc, searchField, i, mobsearchOpts);
|
|
143
|
+
// *** END MOBSEARCH *** //
|
|
144
|
+
},
|
|
145
|
+
// resizeItem: resizeResource
|
|
146
|
+
});
|
|
132
147
|
|
|
133
148
|
// If no stat exists, create a default one
|
|
134
149
|
if (!node.resources) {
|
|
135
|
-
node.resources = [resource = {uri: '', comment: ''}];
|
|
150
|
+
node.resources = [(resource = { uri: '', comment: '' })];
|
|
136
151
|
}
|
|
137
152
|
|
|
138
153
|
// *** MOBSEARCH *** //
|
|
@@ -143,6 +158,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
143
158
|
containerRowName: 'node-input-resources-container-row',
|
|
144
159
|
containerName: 'node-input-resources-container',
|
|
145
160
|
containerSecondFieldName: 'node-input-resources-comment',
|
|
161
|
+
removeWildcards: true,
|
|
146
162
|
};
|
|
147
163
|
initMobsearch.toRid_listed(mobiusSrvc, mobsearchOpts);
|
|
148
164
|
|
|
@@ -151,35 +167,43 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
151
167
|
// Populate list with all saved filters
|
|
152
168
|
for (let i = 0; i < node.resources.length; i++) {
|
|
153
169
|
let resource = node.resources[i];
|
|
154
|
-
$(
|
|
170
|
+
$('#node-input-resources-container').editableList('addItem', resource);
|
|
155
171
|
}
|
|
156
172
|
},
|
|
157
173
|
oneditresize(size) {
|
|
158
|
-
var rows = $(
|
|
174
|
+
var rows = $('#dialog-form>div:not(.node-input-resources-container-row)');
|
|
159
175
|
var height = size.height;
|
|
160
|
-
for (var i=0; i<rows.size(); i++) {
|
|
176
|
+
for (var i = 0; i < rows.size(); i++) {
|
|
161
177
|
height -= $(rows[i]).outerHeight(true);
|
|
162
178
|
}
|
|
163
|
-
var editorRow = $(
|
|
164
|
-
height -=
|
|
179
|
+
var editorRow = $('#dialog-form>div.node-input-resources-container-row');
|
|
180
|
+
height -=
|
|
181
|
+
4 *
|
|
182
|
+
(parseInt(editorRow.css('marginTop')) +
|
|
183
|
+
parseInt(editorRow.css('marginBottom')));
|
|
165
184
|
|
|
166
|
-
$(
|
|
185
|
+
$('#node-input-resources-container').editableList('height', height);
|
|
167
186
|
},
|
|
168
|
-
oneditsave: function() {
|
|
169
|
-
let resources = $(
|
|
187
|
+
oneditsave: function () {
|
|
188
|
+
let resources = $('#node-input-resources-container').editableList(
|
|
189
|
+
'items'
|
|
190
|
+
);
|
|
170
191
|
let node = this;
|
|
171
|
-
node.resources= [];
|
|
192
|
+
node.resources = [];
|
|
172
193
|
resources.each(function (i) {
|
|
173
194
|
var resource = $(this);
|
|
174
|
-
let uri = resource.find(
|
|
175
|
-
let comment = resource.find(
|
|
176
|
-
node.resources.push({uri: uri, comment: comment});
|
|
195
|
+
let uri = resource.find('.node-input-resource-uri').val();
|
|
196
|
+
let comment = resource.find('.node-input-resource-comment').val();
|
|
197
|
+
node.resources.push({ uri: uri, comment: comment });
|
|
177
198
|
});
|
|
178
|
-
}
|
|
199
|
+
},
|
|
179
200
|
});
|
|
180
201
|
</script>
|
|
181
202
|
|
|
182
|
-
<script
|
|
203
|
+
<script
|
|
204
|
+
type="text/x-red"
|
|
205
|
+
data-help-name="mobius get multi-resource"
|
|
206
|
+
>
|
|
183
207
|
<p>Read multiple MOBiUS object resource values.</p>
|
|
184
208
|
|
|
185
209
|
<h3>Configuration Page</h3>
|
|
@@ -35,6 +35,10 @@ module.exports = function (RED) {
|
|
|
35
35
|
this.serviceConn = RED.nodes.getNode(n.connection);
|
|
36
36
|
var node = this;
|
|
37
37
|
|
|
38
|
+
const uriValidTest = new RegExp(
|
|
39
|
+
`^[0-9A-Fa-f]{6}/[0-9A-Fa-f]{3}/[0-9A-Fa-f]{4}/[0-9A-Fa-f]{4}/[0-9A-Fa-f]{2}$`
|
|
40
|
+
);
|
|
41
|
+
|
|
38
42
|
if (node.serviceConn) {
|
|
39
43
|
node.status({
|
|
40
44
|
fill: 'red',
|
|
@@ -52,11 +56,11 @@ module.exports = function (RED) {
|
|
|
52
56
|
});
|
|
53
57
|
|
|
54
58
|
for (const resource of node.resources) {
|
|
55
|
-
if (!
|
|
59
|
+
if (!uriValidTest.test(resource.uri)) {
|
|
56
60
|
node.status({
|
|
57
61
|
fill: 'yellow',
|
|
58
62
|
shape: 'dot',
|
|
59
|
-
text: 'URIs not Valid',
|
|
63
|
+
text: 'Error: URIs not Valid',
|
|
60
64
|
});
|
|
61
65
|
if (done) {
|
|
62
66
|
return done();
|
|
@@ -88,12 +92,24 @@ module.exports = function (RED) {
|
|
|
88
92
|
node.status({
|
|
89
93
|
fill: 'yellow',
|
|
90
94
|
shape: 'dot',
|
|
91
|
-
text:
|
|
95
|
+
text: (() => {
|
|
96
|
+
if (err.response.status === 404) {
|
|
97
|
+
return `Error: One or more resources not found`;
|
|
98
|
+
} else {
|
|
99
|
+
return `Error: ${err.code ? err.code : 'Unknown'}`;
|
|
100
|
+
}
|
|
101
|
+
})(),
|
|
92
102
|
});
|
|
93
103
|
node.error(
|
|
94
|
-
|
|
95
|
-
err.
|
|
96
|
-
|
|
104
|
+
(() => {
|
|
105
|
+
if (err.response.status === 404) {
|
|
106
|
+
return `Error: One or more resources not found`;
|
|
107
|
+
} else {
|
|
108
|
+
return `Error: ${err.code ? err.code : 'Unknown'}, ${
|
|
109
|
+
err.message ? err.message : ''
|
|
110
|
+
}`;
|
|
111
|
+
}
|
|
112
|
+
})()
|
|
97
113
|
);
|
|
98
114
|
})
|
|
99
115
|
.finally(() => {
|
|
@@ -111,19 +127,6 @@ module.exports = function (RED) {
|
|
|
111
127
|
}
|
|
112
128
|
}
|
|
113
129
|
|
|
114
|
-
function validateResourceURI(uri) {
|
|
115
|
-
let parts = uri.split('/');
|
|
116
|
-
for (let lp = 0; lp < parts.length; lp++) {
|
|
117
|
-
if (parts[lp] === null || parts[lp] === '') {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (parts.length === 5) {
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
130
|
function readResource(node, uri) {
|
|
128
131
|
return new Promise((resolve, reject) => {
|
|
129
132
|
node.serviceConn.readResource(uri, (err, response) => {
|