From d84ee90cd24c0035bb0f7087df4055233e47d414 Mon Sep 17 00:00:00 2001 From: "manuel.sowada" Date: Tue, 28 Apr 2026 09:34:12 +0200 Subject: [PATCH] startmenuitems debug --- globalize.js | 26 ++++++++++++++++++++++++++ utils.js | 21 +++++++++++---------- 2 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 globalize.js diff --git a/globalize.js b/globalize.js new file mode 100644 index 0000000..4879485 --- /dev/null +++ b/globalize.js @@ -0,0 +1,26 @@ +const { dirname } = require('path'); +const { File: HotReload } = require(`./src/services/hotReload.js`); +const path = require('path'); + +const root = dirname(require.main.filename); +const localPath = { + root: root, + plugins: `${root}/plugins`, + public: `${root}/public`, + source: `${root}/src` +}; + +module.exports = { + localPath, + cache: { + startMenuItems: [], + }, + runtimeFile: { + package: new HotReload(path.join(localPath.source, 'package.json')), + releaseNotes: new HotReload(path.join(localPath.source, 'models', 'releasenotes.json')), + configuration: new HotReload(path.join(localPath.source, 'models', 'configuration.json')), + stylesheet: new HotReload(path.join(localPath.source, 'models', 'stylesheet.json')), + indexRoutes: new HotReload(path.join(localPath.source, 'routes', 'indexRoutes.js'), { historyLimit: 50, fileType: 'js' }), + startMenuItems: new HotReload(path.join(localPath.source, 'models', 'integratedStartMenuItems.json')) + }, +} diff --git a/utils.js b/utils.js index 5fa665f..1a700ce 100644 --- a/utils.js +++ b/utils.js @@ -4,6 +4,7 @@ const { permission } = require('process'); const { dirname } = require('path'); const { File: HotReload } = require(`@services/hotReload.js`); const { service } = require(`@root/server.js`); +const { json } = require('body-parser'); // let integratedStartmenuItems = require('@models/integratedStartmenuItems'); @@ -23,14 +24,16 @@ global.json = { startMenuItems: new HotReload(path.join(global.path.source, 'models', 'integratedStartMenuItems.json')) } -module.exports = startMenuItems = async function (app, objectGuid, debug = false) { +module.exports = startMenuItems = async function (app, objectGuid) { + const debug = global.json.configuration.live.debug.startMenuItems; + let logContent = []; function safeClone(obj) { return JSON.parse(JSON.stringify(obj)); } const log = (...args) => { - if (debug) console.log('[RBAC DEBUG]', ...args); + if (debug) logContent.push(...args); }; // ========================= @@ -62,8 +65,6 @@ module.exports = startMenuItems = async function (app, objectGuid, debug = false resource: p.resource || null })); - log('USER OBJECTGUID:', objectGuid); - log('PERMISSIONS:', normalizedPermissions); // ========================= // SUPER ADMIN CHECK @@ -74,7 +75,7 @@ module.exports = startMenuItems = async function (app, objectGuid, debug = false p.action === 'ALL' ); - log('SUPER ADMIN:', isSuperAdmin); + log(`PERMISSIONS: ${JSON.stringify(normalizedPermissions)} - IS SUPER ADMIN: ${isSuperAdmin}`); // ========================= // BUILD MENU @@ -125,9 +126,7 @@ module.exports = startMenuItems = async function (app, objectGuid, debug = false }); if (debug) { - log(`\n--- MENU ITEM: ${item.label} ---`); - log('AUTHORIZED:', authorized); - log('TRACE:', debugTrace); + log(`\nMENU ITEM: ${item.label} - AUTHORIZED:', ${authorized} - TRACE:', ${debugTrace}`); } return { @@ -140,8 +139,7 @@ module.exports = startMenuItems = async function (app, objectGuid, debug = false plugin.menu.items.every(i => !i.authorized); if (debug) { - log(`PLUGIN: ${plugin.name}`); - log('VISIBLE:', !plugin.onlyAdministration); + log(`PLUGIN: ${plugin.name} - VISIBLE:', ${!plugin.onlyAdministration}`); } } @@ -152,6 +150,9 @@ module.exports = startMenuItems = async function (app, objectGuid, debug = false .filter(p => !p.onlyAdministration) .filter(p => p.active); app.locals.startMenuItems = allPlugins; + if(debug) { + service.get('eventManager').writeLog(objectGuid, 0, 'StartMenuItems', logContent); + } return allPlugins; };