startmenuitems debug

This commit is contained in:
2026-04-28 09:34:12 +02:00
parent e623c590f0
commit d84ee90cd2
2 changed files with 37 additions and 10 deletions

26
globalize.js Normal file
View File

@@ -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'))
},
}

View File

@@ -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;
};