app.locals repalced

This commit is contained in:
2026-04-28 12:51:46 +02:00
parent d84ee90cd2
commit 9ffea9ee45
7 changed files with 109 additions and 98 deletions

View File

@@ -1,4 +1,5 @@
const { Op } = require('sequelize');
const { localPath, cache, runtimeFile } = require('@root/globalize.js');
/**
* Custom event logging class
*
@@ -27,8 +28,8 @@ class EventManager {
async write(objectGuid, levelId, pluginName = null, ...args) {
const err = new Error();
const stackLine = args[0].stack !== undefined ? args[0].stack : err.stack.split('\n')[2]; // calls trace-line
//const trace = stackLine.split("\n") !== undefined ? stackLine.split("\n")[1].trim() : stackLine.match(/\/.*\d+/)[0].replace(this.app.locals.path.root, '') || ''; // path:line:column
const trace = stackLine?.split("\n")?.[1]?.trim() ?? stackLine?.match(/\/.*\d+/)?.[0]?.replace(this.app.locals.path.root, '') ?? '';
//const trace = stackLine.split("\n") !== undefined ? stackLine.split("\n")[1].trim() : stackLine.match(/\/.*\d+/)[0].replace(this.localPath.root, '') || ''; // path:line:column
const trace = stackLine?.split("\n")?.[1]?.trim() ?? stackLine?.match(/\/.*\d+/)?.[0]?.replace(localPath.root, '') ?? '';
// const message = !Array.isArray(...args) ? [...args][0] : [...args][0][0]
const message = args[0].stack !== undefined ? args[0].message : args.join('\r\n\t');
@@ -48,7 +49,7 @@ class EventManager {
this.socketManager.broadcast('admin', 'eventlog_table', newLogEntry);
}
if(this.app.locals.configuration.debug.active && levelId >= this.app.locals.configuration.debug.levelId) {
if(runtimeFile.configuration.live.debug.active && levelId >= runtimeFile.configuration.live.debug.levelId) {
this.socketManager.broadcast('admin', 'eventlog', { levelId: levelId, pluginName: pluginName, datetime: `[${dateFormat(new Date(), 'yyyy-mm-dd HH:MM:SS')}]`, trace: `[${trace}]`, message: message })
}
@@ -68,7 +69,7 @@ class EventManager {
async writeLog(objectGuid, levelId, pluginName = null, ...args) {
const err = new Error();
const stackLine = args[0].stack !== undefined ? args[0].stack : err.stack.split('\n')[2]; // calls trace-line
const trace = args[0].stack !== undefined ? stackLine.split("\n")[1].trim() : stackLine.match(/\/.*\d+/)[0].replace(this.app.locals.path.root, ''); // path:line:column
const trace = args[0].stack !== undefined ? stackLine.split("\n")[1].trim() : stackLine.match(/\/.*\d+/)[0].replace(localPath.root, ''); // path:line:column
// const message = !Array.isArray(...args) ? [...args][0] : [...args][0][0]
const message = args[0].stack !== undefined ? args[0].message : args.join('\r\n\t');
@@ -98,7 +99,7 @@ class EventManager {
async clear() {
const err = new Error();
const stackLine = err.stack.split('\n')[2]; // calls trace-line
const trace = stackLine.match(/\/.*\d+/)[0].replace(this.app.locals.path.root, ''); // path:line:column
const trace = stackLine.match(/\/.*\d+/)[0].replace(localPath.root, ''); // path:line:column
const message = `${this.EventLog.tableName} cleared successfully`;
await this.EventLog.destroy({

View File

@@ -1,11 +1,12 @@
const { service } = require('@root/server.js');
const { localPath, cache, runtimeFile } = require('@root/globalize.js');
module.exports = {
renderWindow: async function(app, view, data = {}, extraData = {}, res) {
const name = res.req.body.name;
const label = res.req.body.viewLabel;
try {
const plugin = app.locals.startMenuItems.find(plugin => plugin.name == name);
const plugin = cache.startMenuItems.find(plugin => plugin.name == name);
const windowData = plugin.menu.items.find(item => item.label == label);
// Alle Daten zusammenführen