updates for standaardisation
This commit is contained in:
@@ -2,10 +2,11 @@
|
||||
* Thin wrapper that registers a node with Node-RED and exposes HTTP endpoints. and loads EVOLV in a standard way
|
||||
*/
|
||||
|
||||
const nodeClass = require('./src/nodeClass.js');
|
||||
const nameOfNode = 'measurement'; // this is the name of the node, it should match the file name and the node type in Node-RED
|
||||
const nodeClass = require('./src/nodeClass.js'); // this is the specific node class
|
||||
const { MenuManager, configManager } = require('generalFunctions');
|
||||
const nameOfNode = 'measurement';
|
||||
|
||||
// This is the main entry point for the Node-RED node, it will register the node and setup the endpoints
|
||||
module.exports = function(RED) {
|
||||
// Register the node type
|
||||
RED.nodes.registerType(nameOfNode, function(config) {
|
||||
@@ -17,14 +18,15 @@ module.exports = function(RED) {
|
||||
});
|
||||
|
||||
// Setup admin UIs
|
||||
const menuMgr = new MenuManager();
|
||||
const cfgMgr = new configManager();
|
||||
const menuMgr = new MenuManager(); //this will handle the menu endpoints so we can load them dynamically
|
||||
const cfgMgr = new configManager(); // this will handle the config endpoints so we can load them dynamically
|
||||
|
||||
console.log(`Loading endpoint for ${nameOfNode} menu...`);
|
||||
// Register the menu for the measurement node
|
||||
|
||||
// Register the different menu's for the measurement node (in the future we could automate this further by refering to the config)
|
||||
RED.httpAdmin.get('/measurement/menu.js', (req, res) => {
|
||||
try {
|
||||
const script = menuMgr.createEndpoint(nameOfNode, ['asset']);
|
||||
const script = menuMgr.createEndpoint(nameOfNode, ['asset','logger','position']);
|
||||
res.type('application/javascript').send(script);
|
||||
} catch (err) {
|
||||
res.status(500).send(`// Error generating menu: ${err.message}`);
|
||||
@@ -32,7 +34,8 @@ module.exports = function(RED) {
|
||||
});
|
||||
|
||||
console.log(`Loading endpoint for ${nameOfNode} config...`);
|
||||
// Endpoint to get the configuration data for the measurement node
|
||||
|
||||
// Endpoint to get the configuration data for the specific node
|
||||
RED.httpAdmin.get(`/measurement/configData.js`, (req, res) => {
|
||||
try {
|
||||
const script = cfgMgr.createEndpoint(nameOfNode);
|
||||
|
||||
Reference in New Issue
Block a user