node-red-contrib-uos-nats 0.2.38 → 0.2.39
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/nodes/datahub-write.html +99 -98
- package/package.json +1 -1
package/nodes/datahub-write.html
CHANGED
|
@@ -16,116 +16,117 @@
|
|
|
16
16
|
return this.name || "DataHub - Write";
|
|
17
17
|
},
|
|
18
18
|
paletteLabel: "DataHub - Write",
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
19
|
+
oneditprepare: function () {
|
|
20
|
+
// Search Button Handler
|
|
21
|
+
$('#node-config-lookup-var').click(function () {
|
|
22
|
+
const configId = $('#node-input-connection').val();
|
|
23
|
+
const providerId = $('#node-input-providerId').val();
|
|
24
|
+
|
|
25
|
+
if (!configId || configId === '_ADD_') {
|
|
26
|
+
RED.notify("Please select a valid Configuration Node first.", "error");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (!providerId) {
|
|
30
|
+
RED.notify("Please enter a Provider ID to search.", "error");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const notification = RED.notify("Searching variables... please wait...", "info");
|
|
35
|
+
|
|
36
|
+
$.getJSON('datahub-nats/variables/' + configId + '/' + providerId, function (data) {
|
|
37
|
+
notification.close();
|
|
38
|
+
|
|
39
|
+
// Build table
|
|
40
|
+
let rows = "";
|
|
41
|
+
data.sort((a, b) => a.key.localeCompare(b.key));
|
|
42
|
+
|
|
43
|
+
data.forEach(v => {
|
|
44
|
+
rows += `<tr class="node-dialog-var-row" style="cursor:pointer;" data-id="${v.id}" data-key="${v.key}">
|
|
45
|
+
<td>${v.id}</td>
|
|
46
|
+
<td>${v.key}</td>
|
|
47
|
+
<td>${v.dataType}</td>
|
|
48
|
+
<td>${v.access}</td>
|
|
49
|
+
</tr>`;
|
|
50
|
+
});
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
52
|
+
const dialogHtml = `
|
|
53
|
+
<div id="node-lookup-var-dialog" title="Select Variable">
|
|
54
|
+
<input type="text" id="node-lookup-var-search" placeholder="Filter variables..." style="width:100%; margin-bottom:10px;">
|
|
55
|
+
<div style="height:300px; overflow-y:scroll; border:1px solid #ccc;">
|
|
56
|
+
<table class="table table-hover" style="width:100%">
|
|
57
|
+
<thead>
|
|
58
|
+
<tr>
|
|
59
|
+
<th>ID</th>
|
|
60
|
+
<th>Key</th>
|
|
61
|
+
<th>Type</th>
|
|
62
|
+
<th>Access</th>
|
|
63
|
+
</tr>
|
|
64
|
+
</thead>
|
|
65
|
+
<tbody id="node-lookup-var-list">
|
|
66
|
+
${rows}
|
|
67
|
+
</tbody>
|
|
68
|
+
</table>
|
|
69
|
+
</div>
|
|
68
70
|
</div>
|
|
69
|
-
|
|
70
|
-
`;
|
|
71
|
+
`;
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
// Show Dialog (using jquery-ui which Node-RED has)
|
|
74
|
+
const $dialog = $(dialogHtml).appendTo("body");
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
// Filter Logic
|
|
77
|
+
$('#node-lookup-var-search').on('keyup', function () {
|
|
78
|
+
const val = $(this).val().toLowerCase();
|
|
79
|
+
$("#node-lookup-var-list tr").filter(function () {
|
|
80
|
+
$(this).toggle($(this).text().toLowerCase().indexOf(val) > -1)
|
|
81
|
+
});
|
|
80
82
|
});
|
|
81
|
-
});
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
// Row Click Logic
|
|
85
|
+
$('.node-dialog-var-row').click(function () {
|
|
86
|
+
const id = $(this).data('id');
|
|
87
|
+
const key = $(this).data('key');
|
|
87
88
|
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
$('#node-input-variableId').val(id);
|
|
90
|
+
$('#node-input-variableKey').val(key);
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
$dialog.dialog('close');
|
|
93
|
+
$dialog.remove();
|
|
94
|
+
});
|
|
94
95
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
$dialog.dialog({
|
|
97
|
+
modal: true,
|
|
98
|
+
autoOpen: true,
|
|
99
|
+
width: 600,
|
|
100
|
+
title: `Variables for ${providerId}`,
|
|
101
|
+
buttons: {
|
|
102
|
+
"Cancel": function () {
|
|
103
|
+
$(this).dialog("close");
|
|
104
|
+
$(this).remove();
|
|
105
|
+
}
|
|
104
106
|
}
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
+
});
|
|
107
108
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
}).fail(function (jqxhr) {
|
|
110
|
+
notification.close();
|
|
111
|
+
RED.notify("Search failed: " + jqxhr.responseText, "error");
|
|
112
|
+
});
|
|
111
113
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
},
|
|
114
|
+
|
|
115
|
+
// Validate: at least one of ID or Key required
|
|
116
|
+
const validateVar = () => {
|
|
117
|
+
const hasId = $('#node-input-variableId').val();
|
|
118
|
+
const hasKey = $('#node-input-variableKey').val();
|
|
119
|
+
if (!hasId && !hasKey) {
|
|
120
|
+
$('#var-validation-error').show();
|
|
121
|
+
return false;
|
|
122
|
+
} else {
|
|
123
|
+
$('#var-validation-error').hide();
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
$('#node-input-variableId, #node-input-variableKey').on('change keyup', validateVar);
|
|
129
|
+
},
|
|
129
130
|
oneditsave: function () {
|
|
130
131
|
// Loose validation - server side will check
|
|
131
132
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-uos-nats",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.39",
|
|
4
4
|
"description": "Node-RED nodes for Weidmüller u-OS Data Hub. Read, write, and provide variables via NATS protocol with OAuth2 authentication. Features: Variable Key resolution, custom icons, example flows, and provider definition caching.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "IoTUeli",
|