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.
@@ -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
- const values = $variables.val() || [];
74
- $variablesHidden.val(values.join(','));
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
- $variables.empty();
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
- $variables.prop('disabled', true);
110
+
111
111
  $.getJSON(`uos/providers/${configId}/${encodeURIComponent(providerId)}/variables`)
112
112
  .done((payload) => {
113
- if (seq !== variableRequest) {
114
- return;
115
- }
113
+ if (seq !== variableRequest) return;
114
+
116
115
  const vars = normalizeVariables(payload);
117
- $variables.empty();
116
+ $variablesContainer.empty();
118
117
  if (!vars.length) {
119
118
  setVariableStatus('No variables returned. Check Data Hub permissions.');
120
- $variables.prop('disabled', true);
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
- return;
128
- }
129
- const option = $('<option></option>')
130
- .attr('value', value)
131
- .text(variableLabel(variable));
132
- $variables.append(option);
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
- $variables.prop('disabled', false);
135
- const preset = keepSelection ? ($variablesHidden.val() || '').split(',').map((entry) => entry.trim()).filter(Boolean) : initialVars;
136
- if (preset.length) {
137
- $variables.val(preset);
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 one or multiple variables (Ctrl/Cmd + click). Leave empty to receive all.');
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-uos-nats",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "description": "Node-RED nodes for u-OS Data Hub via NATS",
5
5
  "repository": {
6
6
  "type": "git",