some formatting

This commit is contained in:
znetsixe
2025-11-06 16:47:17 +01:00
parent 98cd44d3ae
commit 4a489acd89
3 changed files with 1383 additions and 21 deletions

View File

@@ -83,6 +83,7 @@
{ {
"id": "hidrostal-pump-001", "id": "hidrostal-pump-001",
"name": "hidrostal-H05K-S03R", "name": "hidrostal-H05K-S03R",
"units": ["l/s"] "units": ["l/s"]
}, },
{ {

File diff suppressed because one or more lines are too long

View File

@@ -47,30 +47,30 @@ class ConfigManager {
return fs.existsSync(configPath); return fs.existsSync(configPath);
} }
createEndpoint(nodeName) { createEndpoint(nodeName) {
try { try {
// Load the config for this node // Load the config for this node
const config = this.getConfig(nodeName); const config = this.getConfig(nodeName);
// Convert config to JSON // Convert config to JSON
const configJSON = JSON.stringify(config, null, 2); const configJSON = JSON.stringify(config, null, 2);
// Assemble the complete script // Assemble the complete script
return ` return `
// Create the namespace structure // Create the namespace structure
window.EVOLV = window.EVOLV || {}; window.EVOLV = window.EVOLV || {};
window.EVOLV.nodes = window.EVOLV.nodes || {}; window.EVOLV.nodes = window.EVOLV.nodes || {};
window.EVOLV.nodes.${nodeName} = window.EVOLV.nodes.${nodeName} || {}; window.EVOLV.nodes.${nodeName} = window.EVOLV.nodes.${nodeName} || {};
// Inject the pre-loaded config data directly into the namespace // Inject the pre-loaded config data directly into the namespace
window.EVOLV.nodes.${nodeName}.config = ${configJSON}; window.EVOLV.nodes.${nodeName}.config = ${configJSON};
console.log('${nodeName} config loaded and endpoint created'); console.log('${nodeName} config loaded and endpoint created');
`; `;
} catch (error) { } catch (error) {
throw new Error(`Failed to create endpoint for '${nodeName}': ${error.message}`); throw new Error(`Failed to create endpoint for '${nodeName}': ${error.message}`);
}
} }
}
} }
module.exports = ConfigManager; module.exports = ConfigManager;