standaardisation of EVOLV eco

This commit is contained in:
znetsixe
2025-06-24 10:48:40 +02:00
parent d05d521408
commit 0f855a8d2f
2 changed files with 49 additions and 21 deletions

View File

@@ -51,21 +51,54 @@
setTimeout(waitForMenuData, 50);
}
};
// Wait for the menu data to be ready before initializing the editor
waitForMenuData();
// --------------- Initialize the dropdowns and other specific UI elements -------------- this should be derived from the config in the future (make config based menu)
// Populate smoothing methods dropdown
const smoothMethodSelect = document.getElementById('node-input-smooth_method');
const options = window.EVOLV?.nodes?.measurement?.config?.smoothing?.smoothMethod?.rules?.values || [];
console.log("Smoothing methods options:", options);
// Clear existing options
smoothMethodSelect.innerHTML = '';
// Add empty option
const emptyOption = document.createElement('option');
emptyOption.value = '';
emptyOption.textContent = 'Select method...';
smoothMethodSelect.appendChild(emptyOption);
// Add smoothing method options
options.forEach(option => {
const optionElement = document.createElement('option');
optionElement.value = option.value;
optionElement.textContent = option.value;
optionElement.title = option.description; // Add tooltip with full description
smoothMethodSelect.appendChild(optionElement);
});
// Set current value if it exists
if (this.smooth_method) {
smoothMethodSelect.value = this.smooth_method;
}
//------------------- END OF CUSTOM config UI ELEMENTS ------------------- //
},
oneditsave: function () {
const node = this;
console.log(`------------ Saving changes to node ------------`);
console.log(`${node.uuid}`);
// Validate asset properties using the asset menu
if (window.EVOLV?.nodes?.measurement?.assetMenu?.saveEditor) {
success = window.EVOLV.nodes.measurement.assetMenu.saveEditor(this);
}
// Save basic properties
["name", "supplier", "category", "assetType", "model", "unit", "smooth_method"].forEach(
["name", "smooth_method"].forEach(
(field) => (node[field] = document.getElementById(`node-input-${field}`).value || "")
);
// Save numeric and boolean properties
["scaling", "enableLog", "simulator"].forEach(
["scaling", "simulator"].forEach(
(field) => (node[field] = document.getElementById(`node-input-${field}`).checked)
);
@@ -74,23 +107,15 @@
);
node.logLevel = document.getElementById("node-input-logLevel").value || "info";
node.enableLog = document.getElementById("node-input-enableLog").checked;
// Validation checks
if (node.scaling && (isNaN(node.i_min) || isNaN(node.i_max))) {
RED.notify("Scaling enabled, but input range is incomplete!", "error");
}
if (!node.unit) {
RED.notify("Unit selection is required.", "error");
}
// Validation checks - FIXED
if (node.assetType && !node.unit) {
RED.notify("Unit must be set when specifying a type.", "error");
}
console.log("stored node modelData", node.modelMetadata);
console.log("------------ Changes saved to measurement node preparing to save to API ------------");
},
});