🎉 Removed unnecessary files & logs, updated documentation & UI components. 🖥️🔍📚💻
This commit is contained in:
2
backend/static/css/tailwind.min.css
vendored
2
backend/static/css/tailwind.min.css
vendored
File diff suppressed because one or more lines are too long
@ -356,20 +356,60 @@ async function loadRecentActivity() {
|
||||
async function loadSystemStatus() {
|
||||
try {
|
||||
const response = await fetch('/api/stats');
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
// Update system stats
|
||||
document.getElementById('total-print-time').textContent =
|
||||
formatPrintTime(data.total_print_time_hours);
|
||||
document.getElementById('completed-jobs-count').textContent =
|
||||
data.total_jobs_completed || 0;
|
||||
document.getElementById('total-material-used').textContent =
|
||||
formatMaterialUsed(data.total_material_used);
|
||||
document.getElementById('last-updated-time').textContent =
|
||||
data.last_updated ? formatDateTime(data.last_updated) : '-';
|
||||
// Prüfen ob data gültig ist
|
||||
if (!data || typeof data !== 'object') {
|
||||
throw new Error('Ungültige Antwort vom Server erhalten');
|
||||
}
|
||||
|
||||
// Update system stats mit Fallback-Werten
|
||||
const totalPrintTimeEl = document.getElementById('total-print-time');
|
||||
if (totalPrintTimeEl) {
|
||||
totalPrintTimeEl.textContent = formatPrintTime(data.total_print_time_hours);
|
||||
}
|
||||
|
||||
const completedJobsEl = document.getElementById('completed-jobs-count');
|
||||
if (completedJobsEl) {
|
||||
completedJobsEl.textContent = data.total_jobs_completed || 0;
|
||||
}
|
||||
|
||||
const totalMaterialEl = document.getElementById('total-material-used');
|
||||
if (totalMaterialEl) {
|
||||
totalMaterialEl.textContent = formatMaterialUsed(data.total_material_used);
|
||||
}
|
||||
|
||||
const lastUpdatedEl = document.getElementById('last-updated-time');
|
||||
if (lastUpdatedEl) {
|
||||
lastUpdatedEl.textContent = data.last_updated ? formatDateTime(data.last_updated) : '-';
|
||||
}
|
||||
|
||||
console.log('✅ Systemstatus erfolgreich geladen:', data);
|
||||
} catch (error) {
|
||||
console.error('Error loading system status:', error);
|
||||
showToast('Fehler beim Laden des Systemstatus', 'error');
|
||||
const errorMessage = error.message || 'Unbekannter Systemfehler';
|
||||
showToast(`Fehler beim Laden des Systemstatus: ${errorMessage}`, 'error');
|
||||
|
||||
// Fallback-Werte anzeigen
|
||||
const elements = [
|
||||
'total-print-time',
|
||||
'completed-jobs-count',
|
||||
'total-material-used',
|
||||
'last-updated-time'
|
||||
];
|
||||
|
||||
elements.forEach(id => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) {
|
||||
el.textContent = 'Fehler beim Laden';
|
||||
el.classList.add('text-red-500');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@
|
||||
type: e.error ? e.error.constructor.name : 'Unbekannter Typ'
|
||||
};
|
||||
|
||||
console.error('🐛 JavaScript Error abgefangen:', errorInfo);
|
||||
console.error('🐛 JavaScript Error abgefangen:', JSON.stringify(errorInfo, null, 2));
|
||||
|
||||
// Spezifische Fehlerbehebungen
|
||||
if (e.message.includes('MVP.UI.DarkModeManager is not a constructor')) {
|
||||
@ -153,6 +153,12 @@
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (e.message.includes('showToast is not defined')) {
|
||||
console.log('🔧 showToast Fehler erkannt - verwende Fallback');
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Promise rejection handler
|
||||
|
@ -128,18 +128,48 @@ window.refreshJobs = async function() {
|
||||
}
|
||||
|
||||
try {
|
||||
// Jobs-Daten neu laden
|
||||
if (typeof jobManager !== 'undefined' && jobManager.loadJobs) {
|
||||
// Jobs-Daten neu laden mit verbesserter Fehlerbehandlung
|
||||
if (typeof window.jobManager !== 'undefined' && window.jobManager && window.jobManager.loadJobs) {
|
||||
await window.jobManager.loadJobs();
|
||||
} else if (typeof jobManager !== 'undefined' && jobManager && jobManager.loadJobs) {
|
||||
await jobManager.loadJobs();
|
||||
} else {
|
||||
// Fallback: Seite neu laden
|
||||
window.location.reload();
|
||||
// Fallback: API-Aufruf direkt
|
||||
console.log('📝 JobManager nicht verfügbar - verwende direkten API-Aufruf');
|
||||
const response = await fetch('/api/jobs', {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': getCSRFToken()
|
||||
}
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`API-Fehler: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log('📝 Jobs erfolgreich über API geladen:', data);
|
||||
|
||||
// Wenn JobsContainer vorhanden ist, versuche die Jobs zu rendern
|
||||
const jobsContainer = document.querySelector('.jobs-container, #jobs-container, .job-grid');
|
||||
if (jobsContainer && data.jobs) {
|
||||
// Einfache Jobs-Darstellung als Fallback
|
||||
jobsContainer.innerHTML = data.jobs.map(job => `
|
||||
<div class="job-card p-4 border rounded-lg">
|
||||
<h3 class="font-semibold">${job.filename || 'Unbekannter Job'}</h3>
|
||||
<p class="text-sm text-gray-600">Status: ${job.status || 'Unbekannt'}</p>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
}
|
||||
|
||||
showToast('✅ Druckaufträge erfolgreich aktualisiert', 'success');
|
||||
} catch (error) {
|
||||
console.error('Jobs-Refresh Fehler:', error);
|
||||
showToast('❌ Fehler beim Aktualisieren der Jobs', 'error');
|
||||
const errorMessage = error.message === 'undefined' ?
|
||||
'Jobs-Manager nicht verfügbar' :
|
||||
error.message || 'Unbekannter Fehler';
|
||||
showToast(`❌ Fehler beim Laden der Jobs: ${errorMessage}`, 'error');
|
||||
} finally {
|
||||
if (refreshButton) {
|
||||
refreshButton.disabled = false;
|
||||
|
@ -709,46 +709,40 @@ class OptimizationManager {
|
||||
}
|
||||
|
||||
showSuccessMessage(message) {
|
||||
this.showToast(message, 'success');
|
||||
// Verwende das globale Glassmorphism-System anstelle eines einfachen Toasts
|
||||
if (typeof showFlashMessage === 'function') {
|
||||
showFlashMessage(message, 'success');
|
||||
} else {
|
||||
console.log('Success:', message);
|
||||
}
|
||||
}
|
||||
|
||||
showErrorMessage(message) {
|
||||
this.showToast(message, 'error');
|
||||
// Verwende das globale Glassmorphism-System anstelle eines einfachen Toasts
|
||||
if (typeof showFlashMessage === 'function') {
|
||||
showFlashMessage(message, 'error');
|
||||
} else {
|
||||
console.error('Error:', message);
|
||||
}
|
||||
}
|
||||
|
||||
showWarningMessage(message) {
|
||||
this.showToast(message, 'warning');
|
||||
// Verwende das globale Glassmorphism-System anstelle eines einfachen Toasts
|
||||
if (typeof showFlashMessage === 'function') {
|
||||
showFlashMessage(message, 'warning');
|
||||
} else {
|
||||
console.warn('Warning:', message);
|
||||
}
|
||||
}
|
||||
|
||||
showToast(message, type = 'info') {
|
||||
// Einfache Toast-Benachrichtigung
|
||||
const toast = document.createElement('div');
|
||||
toast.className = `fixed top-4 right-4 z-50 p-4 rounded-lg shadow-lg transition-all duration-300 transform translate-x-full`;
|
||||
|
||||
const colors = {
|
||||
success: 'bg-green-500 text-white',
|
||||
error: 'bg-red-500 text-white',
|
||||
warning: 'bg-yellow-500 text-black',
|
||||
info: 'bg-blue-500 text-white'
|
||||
};
|
||||
|
||||
toast.className += ` ${colors[type]}`;
|
||||
toast.textContent = message;
|
||||
|
||||
document.body.appendChild(toast);
|
||||
|
||||
// Animation einblenden
|
||||
setTimeout(() => {
|
||||
toast.classList.remove('translate-x-full');
|
||||
}, 100);
|
||||
|
||||
// Nach 5 Sekunden automatisch entfernen
|
||||
setTimeout(() => {
|
||||
toast.classList.add('translate-x-full');
|
||||
setTimeout(() => {
|
||||
toast.remove();
|
||||
}, 300);
|
||||
}, 5000);
|
||||
// Verwende das globale Glassmorphism-System für alle Toast-Nachrichten
|
||||
if (typeof showFlashMessage === 'function') {
|
||||
showFlashMessage(message, type);
|
||||
} else {
|
||||
// Fallback falls Glassmorphism-System nicht verfügbar
|
||||
console.log(`${type.toUpperCase()}: ${message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
249
backend/static/js/validation-fix.js
Normal file
249
backend/static/js/validation-fix.js
Normal file
@ -0,0 +1,249 @@
|
||||
/**
|
||||
* MYP Platform - JavaScript Fehler Validierung und Überwachung
|
||||
* Überprüft die behobenen Fehler und aktiviert weitere Fallbacks bei Bedarf
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
console.log('🔍 JavaScript Fehlervalidierung wird gestartet...');
|
||||
|
||||
/**
|
||||
* Validierung der showToast-Verfügbarkeit
|
||||
*/
|
||||
function validateShowToast() {
|
||||
const testsPassed = [];
|
||||
|
||||
// Test 1: Grundfunktion verfügbar
|
||||
if (typeof window.showToast === 'function') {
|
||||
testsPassed.push('✅ window.showToast ist verfügbar');
|
||||
} else {
|
||||
console.warn('⚠️ window.showToast nicht verfügbar - aktiviere Fallback');
|
||||
|
||||
// Fallback aktivieren
|
||||
window.showToast = function(message, type = 'info', duration = 5000) {
|
||||
console.log(`🔧 Validation-Fallback showToast: [${type.toUpperCase()}] ${message}`);
|
||||
|
||||
// Versuche MYP.UI.toast zu verwenden
|
||||
if (window.MYP && window.MYP.UI && window.MYP.UI.toast && window.MYP.UI.toast.show) {
|
||||
window.MYP.UI.toast.show(message, type, duration);
|
||||
}
|
||||
};
|
||||
testsPassed.push('🔧 Fallback showToast aktiviert');
|
||||
}
|
||||
|
||||
// Test 2: MYP.UI.toast verfügbar
|
||||
if (window.MYP && window.MYP.UI && window.MYP.UI.toast) {
|
||||
testsPassed.push('✅ MYP.UI.toast ist verfügbar');
|
||||
} else {
|
||||
testsPassed.push('⚠️ MYP.UI.toast noch nicht verfügbar (wird später geladen)');
|
||||
}
|
||||
|
||||
return testsPassed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validierung der Manager-Verfügbarkeit
|
||||
*/
|
||||
function validateManagers() {
|
||||
const testsPassed = [];
|
||||
|
||||
// JobManager-Test
|
||||
if (typeof window.jobManager !== 'undefined' && window.jobManager) {
|
||||
testsPassed.push('✅ window.jobManager ist verfügbar');
|
||||
} else if (typeof jobManager !== 'undefined' && jobManager) {
|
||||
testsPassed.push('✅ jobManager (global) ist verfügbar');
|
||||
} else {
|
||||
testsPassed.push('⚠️ JobManager nicht verfügbar - API-Fallback wird verwendet');
|
||||
}
|
||||
|
||||
// Refresh-Funktionen Test
|
||||
if (typeof window.refreshJobs === 'function') {
|
||||
testsPassed.push('✅ refreshJobs-Funktion ist verfügbar');
|
||||
} else {
|
||||
testsPassed.push('❌ refreshJobs-Funktion fehlt');
|
||||
}
|
||||
|
||||
if (typeof window.refreshStats === 'function') {
|
||||
testsPassed.push('✅ refreshStats-Funktion ist verfügbar');
|
||||
} else {
|
||||
testsPassed.push('❌ refreshStats-Funktion fehlt');
|
||||
}
|
||||
|
||||
return testsPassed;
|
||||
}
|
||||
|
||||
/**
|
||||
* API-Endpunkt Validierung
|
||||
*/
|
||||
async function validateAPIEndpoints() {
|
||||
const testsPassed = [];
|
||||
const endpoints = [
|
||||
{ url: '/api/stats', name: 'Statistiken' },
|
||||
{ url: '/api/jobs', name: 'Jobs' }
|
||||
];
|
||||
|
||||
for (const endpoint of endpoints) {
|
||||
try {
|
||||
const response = await fetch(endpoint.url, {
|
||||
method: 'HEAD', // Nur Header abrufen, kein Body
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
if (response.ok || response.status === 405) { // 405 = Method Not Allowed ist OK
|
||||
testsPassed.push(`✅ ${endpoint.name} API (${endpoint.url}) ist erreichbar`);
|
||||
} else {
|
||||
testsPassed.push(`⚠️ ${endpoint.name} API (${endpoint.url}) antwortet mit Status ${response.status}`);
|
||||
}
|
||||
} catch (error) {
|
||||
testsPassed.push(`❌ ${endpoint.name} API (${endpoint.url}) nicht erreichbar: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
return testsPassed;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOM-Element Validierung
|
||||
*/
|
||||
function validateDOMElements() {
|
||||
const testsPassed = [];
|
||||
const criticalElements = [
|
||||
'total-print-time',
|
||||
'completed-jobs-count',
|
||||
'total-material-used',
|
||||
'last-updated-time'
|
||||
];
|
||||
|
||||
criticalElements.forEach(elementId => {
|
||||
const element = document.getElementById(elementId);
|
||||
if (element) {
|
||||
testsPassed.push(`✅ Element #${elementId} gefunden`);
|
||||
} else {
|
||||
testsPassed.push(`⚠️ Element #${elementId} nicht gefunden`);
|
||||
}
|
||||
});
|
||||
|
||||
// Container-Elemente
|
||||
const containers = [
|
||||
'.jobs-container',
|
||||
'#jobs-container',
|
||||
'.job-grid',
|
||||
'#refresh-button'
|
||||
];
|
||||
|
||||
containers.forEach(selector => {
|
||||
const element = document.querySelector(selector);
|
||||
if (element) {
|
||||
testsPassed.push(`✅ Container ${selector} gefunden`);
|
||||
} else {
|
||||
testsPassed.push(`⚠️ Container ${selector} nicht gefunden`);
|
||||
}
|
||||
});
|
||||
|
||||
return testsPassed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error Handler Validierung
|
||||
*/
|
||||
function validateErrorHandling() {
|
||||
const testsPassed = [];
|
||||
|
||||
// Test ob unser error handler aktiv ist
|
||||
const testError = new Error('Validation Test Error');
|
||||
window.dispatchEvent(new ErrorEvent('error', {
|
||||
message: 'Test error for validation',
|
||||
filename: 'validation-fix.js',
|
||||
lineno: 1,
|
||||
error: testError
|
||||
}));
|
||||
|
||||
testsPassed.push('✅ Error Handler Funktionalität getestet');
|
||||
|
||||
return testsPassed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vollständige Validierung durchführen
|
||||
*/
|
||||
async function runCompleteValidation() {
|
||||
console.log('🔍 Starte vollständige JavaScript-Validierung...');
|
||||
|
||||
const results = {
|
||||
showToast: validateShowToast(),
|
||||
managers: validateManagers(),
|
||||
domElements: validateDOMElements(),
|
||||
errorHandling: validateErrorHandling(),
|
||||
apiEndpoints: await validateAPIEndpoints()
|
||||
};
|
||||
|
||||
// Ergebnisse ausgeben
|
||||
console.group('🔍 Validierungsergebnisse:');
|
||||
|
||||
Object.keys(results).forEach(category => {
|
||||
console.group(`📋 ${category}:`);
|
||||
results[category].forEach(result => console.log(result));
|
||||
console.groupEnd();
|
||||
});
|
||||
|
||||
console.groupEnd();
|
||||
|
||||
// Zusammenfassung
|
||||
const allResults = Object.values(results).flat();
|
||||
const successCount = allResults.filter(r => r.startsWith('✅')).length;
|
||||
const warningCount = allResults.filter(r => r.startsWith('⚠️')).length;
|
||||
const errorCount = allResults.filter(r => r.startsWith('❌')).length;
|
||||
|
||||
console.log(`📊 Validierung abgeschlossen: ${successCount} OK, ${warningCount} Warnungen, ${errorCount} Fehler`);
|
||||
|
||||
// Status-Toast anzeigen
|
||||
if (typeof window.showToast === 'function') {
|
||||
if (errorCount === 0) {
|
||||
window.showToast(`✅ JavaScript-Validierung erfolgreich: ${successCount} Checks bestanden`, 'success');
|
||||
} else {
|
||||
window.showToast(`⚠️ JavaScript-Validierung: ${errorCount} Probleme gefunden`, 'warning');
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kontinuierliche Überwachung
|
||||
*/
|
||||
function startContinuousMonitoring() {
|
||||
setInterval(() => {
|
||||
// Prüfe kritische Funktionen
|
||||
if (typeof window.showToast !== 'function') {
|
||||
console.warn('⚠️ showToast-Funktion verloren - reaktiviere Fallback');
|
||||
validateShowToast();
|
||||
}
|
||||
|
||||
// Prüfe auf neue Fehler
|
||||
const errorElements = document.querySelectorAll('.text-red-500');
|
||||
if (errorElements.length > 0) {
|
||||
console.warn(`⚠️ ${errorElements.length} Fehler-Elemente gefunden`);
|
||||
}
|
||||
}, 30000); // Alle 30 Sekunden
|
||||
}
|
||||
|
||||
// Globale Funktionen exportieren
|
||||
window.validateJavaScript = runCompleteValidation;
|
||||
window.validateShowToast = validateShowToast;
|
||||
|
||||
// DOMContentLoaded abwarten und dann validieren
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
setTimeout(runCompleteValidation, 2000); // 2 Sekunden warten
|
||||
startContinuousMonitoring();
|
||||
});
|
||||
} else {
|
||||
setTimeout(runCompleteValidation, 2000);
|
||||
startContinuousMonitoring();
|
||||
}
|
||||
|
||||
console.log('✅ JavaScript Fehlervalidierung initialisiert');
|
||||
})();
|
Reference in New Issue
Block a user