🎛️ Web-GUI Management System mit Custom Tags
✨ Neue Features: - Vollständiges Management Dashboard (Port 3000) - Custom Tags System mit REST-API Integration - Mehrere Tags erstellbar und konfigurierbar - Externe Tag-Aktivierung per REST-API - Server-Fernsteuerung (Start/Stop/Restart) - SSL-Zertifikat Management - Echtzeit-Überwachung mit Socket.IO 🏷️ Custom Tags Features: - Dynamische Tag-Erstellung über GUI - Tag-Aktivierung/Deaktivierung per Toggle - REST-APIs für externe Tag-Kontrolle - Integration in Template-Verarbeitung - Konfigurierbare Positionen und Typen 📁 Neue Dateien: - management/ - Komplettes Management-System - API-TAGS-DOCUMENTATION.md - API Dokumentation - start-management.sh - Startup Script 🔧 Verbesserte Template-Verarbeitung: - Automatisches Laden aktivierter Custom Tags - Priorität: Custom-Daten → Custom Tags → Auto-Generierung - Erweiterte Logging und Status-Meldungen 🌐 REST-APIs: - GET /api/public/tags - Alle Tags auflisten - POST /api/public/tags/{TAG_NAME}/activate - Tag aktivieren - POST /api/public/tags/{TAG_NAME}/deactivate - Tag deaktivieren - Management APIs für vollständige CRUD-Operationen
This commit is contained in:
62
server.js
62
server.js
@@ -12,6 +12,32 @@ const { faker } = require('@faker-js/faker');
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 80;
|
||||
|
||||
// Management-System Integration (falls verfügbar)
|
||||
let DataSourceManager, CustomTagProcessor;
|
||||
try {
|
||||
const managementModules = require('./management/data-sources');
|
||||
DataSourceManager = managementModules.DataSourceManager;
|
||||
CustomTagProcessor = managementModules.CustomTagProcessor;
|
||||
console.log('✅ Management-System Integration geladen');
|
||||
} catch (error) {
|
||||
console.log('ℹ️ Management-System nicht verfügbar (optional)');
|
||||
}
|
||||
|
||||
// Konfiguration laden
|
||||
function loadManagementConfig() {
|
||||
try {
|
||||
const configPath = path.join(__dirname, 'management', 'config.json');
|
||||
if (fs.existsSync(configPath)) {
|
||||
return JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('ℹ️ Management-Konfiguration nicht verfügbar');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const managementConfig = loadManagementConfig();
|
||||
|
||||
// Middleware
|
||||
app.use(helmet());
|
||||
app.use(cors());
|
||||
@@ -180,6 +206,33 @@ class DemoDataGenerator {
|
||||
|
||||
// Template-Verarbeitung
|
||||
class TemplateProcessor {
|
||||
// Custom Tags aus Management-System laden
|
||||
static loadCustomTags() {
|
||||
try {
|
||||
const configPath = path.join(__dirname, 'management', 'config.json');
|
||||
if (!fs.existsSync(configPath)) {
|
||||
console.log('📝 Keine Management-Konfiguration gefunden');
|
||||
return {};
|
||||
}
|
||||
|
||||
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
||||
const customTags = config.customTags || [];
|
||||
const activeTagsData = {};
|
||||
|
||||
customTags
|
||||
.filter(tag => tag.enabled) // Nur aktive Tags
|
||||
.forEach(tag => {
|
||||
activeTagsData[tag.tagName] = tag.content || '';
|
||||
console.log(`✅ Custom Tag aktiviert: ${tag.tagName} = "${tag.content}"`);
|
||||
});
|
||||
|
||||
return activeTagsData;
|
||||
} catch (error) {
|
||||
console.log('⚠️ Fehler beim Laden der Custom Tags:', error.message);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
static extractTags(content) {
|
||||
const simpleTags = [...content.matchAll(/\{([^#/}]+)\}/g)].map(match => match[1].trim());
|
||||
const loopTags = [...content.matchAll(/\{#(\w+)\}/g)].map(match => match[1].trim());
|
||||
@@ -202,13 +255,20 @@ class TemplateProcessor {
|
||||
|
||||
console.log(`📝 Gefundene Tags: ${simpleTags.length} einfache, ${loopTags.length} Schleifen`);
|
||||
|
||||
// Daten zusammenstellen: Custom-Daten haben Priorität, dann Auto-Generierung
|
||||
// Custom Tags aus Management-System laden
|
||||
const customTagsData = this.loadCustomTags();
|
||||
console.log(`🏷️ Custom Tags geladen: ${Object.keys(customTagsData).length} aktive Tags`);
|
||||
|
||||
// Daten zusammenstellen: Custom-Daten haben Priorität, dann Custom Tags, dann Auto-Generierung
|
||||
let data = {};
|
||||
if (customData && typeof customData === 'object') {
|
||||
data = { ...customData };
|
||||
console.log(`🎯 Custom-Daten verwendet: ${Object.keys(customData).length} Felder`);
|
||||
}
|
||||
|
||||
// Custom Tags hinzufügen
|
||||
data = { ...data, ...customTagsData };
|
||||
|
||||
// Fehlende Tags automatisch generieren
|
||||
const missingTags = simpleTags.filter(tag => !(tag in data));
|
||||
if (missingTags.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user