startmenuitems debug
This commit is contained in:
21
utils.js
21
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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user