Added loggin to advanced-reactor. Currently broken for some reason?
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
<script src="/advanced-reactor/menu.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
RED.nodes.registerType("advanced-reactor", {
|
||||
category: "WWTP",
|
||||
@@ -34,6 +36,16 @@
|
||||
return this.name || "advanced-reactor";
|
||||
},
|
||||
oneditprepare: function() {
|
||||
// wait for the menu scripts to load
|
||||
const waitForMenuData = () => {
|
||||
if (window.EVOLV?.nodes?.['advanced-reactor']?.initEditor) {
|
||||
window.EVOLV.nodes['advanced-reactor'].initEditor(this);
|
||||
} else {
|
||||
setTimeout(waitForMenuData, 50);
|
||||
}
|
||||
};
|
||||
waitForMenuData();
|
||||
|
||||
$("#node-input-volume").typedInput({
|
||||
type:"num",
|
||||
types:["num"]
|
||||
@@ -90,6 +102,11 @@
|
||||
}
|
||||
},
|
||||
oneditsave: function() {
|
||||
// save logger fields
|
||||
if (window.EVOLV?.nodes?.['advanced-reactor']?.loggerMenu?.saveEditor) {
|
||||
window.EVOLV.nodes['advanced-reactor'].loggerMenu.saveEditor(this);
|
||||
}
|
||||
|
||||
let volume = parseFloat($("#node-input-volume").typedInput("value"));
|
||||
if (isNaN(volume) || volume <= 0) {
|
||||
RED.notify("Fluid volume not set correctly", {type: "error"});
|
||||
@@ -194,6 +211,10 @@
|
||||
<label for="node-input-X_TS_init"><i class="fa fa-tag"></i> Initial total suspended solids [g TSS m-3]</label>
|
||||
<input type="text" id="node-input-X_TS_init" class="concentrations">
|
||||
</div>
|
||||
|
||||
<!-- Logger fields injected here -->
|
||||
<div id="logger-fields-placeholder"></div>
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-help-name="advanced-reactor">
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
const nameOfNode = "advanced-reactor"; // name of the node, should match file name and node type in Node-RED
|
||||
const nodeClass = require('./src/nodeClass.js'); // node class
|
||||
const { MenuManager } = require('generalFunctions');
|
||||
|
||||
|
||||
module.exports = function (RED) {
|
||||
// Register the node type
|
||||
@@ -9,4 +11,16 @@ module.exports = function (RED) {
|
||||
// Then create your custom class and attach it
|
||||
this.nodeClass = new nodeClass(config, RED, this, nameOfNode);
|
||||
});
|
||||
|
||||
const menuMgr = new MenuManager();
|
||||
|
||||
// Serve /advanced-reactor/menu.js
|
||||
RED.httpAdmin.get(`/${nameOfNode}/menu.js`, (req, res) => {
|
||||
try {
|
||||
const script = menuMgr.createEndpoint(nameOfNode, ['logger']);
|
||||
res.type('application/javascript').send(script);
|
||||
} catch (err) {
|
||||
res.status(500).send(`// Error generating menu: ${err.message}`);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user