Added new menu jsons

This commit is contained in:
znetsixe
2025-11-13 19:39:48 +01:00
parent 5df3881375
commit f2c9134b64
13 changed files with 2851 additions and 148 deletions

View File

@@ -2,13 +2,17 @@ const AssetMenu = require('./asset.js');
const { TagcodeApp, DynamicAssetMenu } = require('./tagcodeApp.js');
const LoggerMenu = require('./logger.js');
const PhysicalPositionMenu = require('./physicalPosition.js');
const ConfigManager = require('../configs');
class MenuManager {
constructor() {
this.registeredMenus = new Map();
this.configManager = new ConfigManager('../configs');
// Register factory functions
this.registerMenu('asset', () => new AssetMenu()); // static menu to be replaced by dynamic one but later
this.registerMenu('asset', (nodeName) => new AssetMenu({
softwareType: this._getSoftwareType(nodeName)
})); // static menu to be replaced by dynamic one but later
//this.registerMenu('asset', (nodeName) => new DynamicAssetMenu(nodeName, new TagcodeApp()));
this.registerMenu('logger', () => new LoggerMenu());
this.registerMenu('position', () => new PhysicalPositionMenu());
@@ -23,6 +27,20 @@ class MenuManager {
this.registeredMenus.set(menuType, menuFactory);
}
_getSoftwareType(nodeName) {
if (!nodeName) {
return null;
}
try {
const config = this.configManager.getConfig(nodeName);
return config?.functionality?.softwareType || nodeName;
} catch (error) {
console.warn(`Unable to determine softwareType for ${nodeName}: ${error.message}`);
return nodeName;
}
}
/**
* Create a complete endpoint script with data and initialization functions
* @param {string} nodeName - The name of the node type
@@ -54,7 +72,7 @@ class MenuManager {
try {
const handler = instantiatedMenus.get(menuType);
if (handler && typeof handler.getAllMenuData === 'function') {
menuData[menuType] = handler.getAllMenuData();
menuData[menuType] = handler.getAllMenuData(nodeName);
} else {
// Provide default empty data if method doesn't exist
menuData[menuType] = {};
@@ -172,4 +190,4 @@ class MenuManager {
}
}
module.exports = MenuManager;
module.exports = MenuManager;