node-red-contrib-uos-nats 0.1.26 → 0.1.28
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-input.html +33 -23
- package/package.json +1 -1
package/nodes/datahub-input.html
CHANGED
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
const variableLabel = (variable) => variable.tagName || variable.key || variable.name || variable.path || variable.id || 'Unnamed variable';
|
|
71
71
|
|
|
72
72
|
const syncVariablesField = () => {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
// For checkboxes, we update the hidden field directly on change.
|
|
74
|
+
// This helper is kept if needed for initial loading but usually not needed.
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
let providerRequest = 0;
|
|
@@ -101,43 +101,54 @@
|
|
|
101
101
|
const loadVariables = (providerId, keepSelection = false) => {
|
|
102
102
|
const configId = $config.val();
|
|
103
103
|
if (!configId || !providerId) {
|
|
104
|
-
$
|
|
104
|
+
$variablesContainer.empty().append('<div style="color:#aaa; font-style:italic; padding:5px;">Select a provider to load variables...</div>');
|
|
105
105
|
setVariableStatus('Select a provider to load variables.');
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
108
|
const seq = ++variableRequest;
|
|
109
109
|
setVariableStatus('Loading variables…');
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
$.getJSON(`uos/providers/${configId}/${encodeURIComponent(providerId)}/variables`)
|
|
112
112
|
.done((payload) => {
|
|
113
|
-
if (seq !== variableRequest)
|
|
114
|
-
|
|
115
|
-
}
|
|
113
|
+
if (seq !== variableRequest) return;
|
|
114
|
+
|
|
116
115
|
const vars = normalizeVariables(payload);
|
|
117
|
-
$
|
|
116
|
+
$variablesContainer.empty();
|
|
118
117
|
if (!vars.length) {
|
|
119
118
|
setVariableStatus('No variables returned. Check Data Hub permissions.');
|
|
120
|
-
$
|
|
119
|
+
$variablesContainer.append('<div style="color:#aaa; padding:5px;">No variables found.</div>');
|
|
121
120
|
syncVariablesField();
|
|
122
121
|
return;
|
|
123
122
|
}
|
|
123
|
+
|
|
124
|
+
const preset = keepSelection ? ($variablesHidden.val() || '').split(',').map(e => e.trim()).filter(Boolean) : initialVars;
|
|
125
|
+
const currentSet = new Set(preset);
|
|
126
|
+
|
|
124
127
|
vars.forEach((variable) => {
|
|
125
128
|
const value = variableValue(variable);
|
|
126
|
-
if (!value)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
if (!value) return;
|
|
130
|
+
|
|
131
|
+
const isChecked = currentSet.has(value) ? 'checked' : '';
|
|
132
|
+
// Create checkbox row
|
|
133
|
+
const row = $(`<div style="display:flex; align-items:center; margin-bottom:2px;">
|
|
134
|
+
<input type="checkbox" id="uv-${seq}-${value}" value="${value}" ${isChecked} style="width:auto; margin:0 5px 0 0;">
|
|
135
|
+
<label for="uv-${seq}-${value}" style="width:auto; margin-bottom:0; cursor:pointer;">${variableLabel(variable)}</label>
|
|
136
|
+
</div>`);
|
|
137
|
+
|
|
138
|
+
$variablesContainer.append(row);
|
|
133
139
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
140
|
+
|
|
141
|
+
// Re-bind change events for new checkboxes
|
|
142
|
+
$variablesContainer.find('input[type="checkbox"]').on('change', () => {
|
|
143
|
+
const selected = [];
|
|
144
|
+
$variablesContainer.find('input[type="checkbox"]:checked').each(function () {
|
|
145
|
+
selected.push($(this).val());
|
|
146
|
+
});
|
|
147
|
+
$variablesHidden.val(selected.join(','));
|
|
148
|
+
});
|
|
149
|
+
|
|
139
150
|
syncVariablesField();
|
|
140
|
-
setVariableStatus('Select
|
|
151
|
+
setVariableStatus('Select variables. Leave all unchecked to receive EVERYTHING.');
|
|
141
152
|
})
|
|
142
153
|
.fail((xhr) => {
|
|
143
154
|
console.error('Variable load failed', xhr);
|
|
@@ -148,7 +159,6 @@
|
|
|
148
159
|
}
|
|
149
160
|
setVariableStatus(msg);
|
|
150
161
|
$variablesContainer.empty().append('<div style="color:#aaa; font-style:italic; padding:5px;">To load variables, the Config Node must be deployed first.</div>');
|
|
151
|
-
$variables.prop('disabled', true);
|
|
152
162
|
syncVariablesField();
|
|
153
163
|
});
|
|
154
164
|
};
|