📝 "Refactor admin UI components for improved consistency and performance" 🌈
This commit is contained in:
@@ -897,7 +897,17 @@ class AdminDashboard {
|
||||
// Error-Management
|
||||
async checkSystemHealth() {
|
||||
try {
|
||||
const response = await fetch('/api/admin/system-health');
|
||||
const response = await fetch(`${this.apiBaseUrl}/api/admin/system/status`);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
||||
// Prüfe Content-Type vor JSON parsing
|
||||
const contentType = response.headers.get('content-type');
|
||||
if (!contentType || !contentType.includes('application/json')) {
|
||||
throw new Error('Server returned non-JSON response');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
@@ -975,10 +985,10 @@ class AdminDashboard {
|
||||
}
|
||||
};
|
||||
|
||||
console.log('📡 Sende Request an:', '/api/admin/fix-errors');
|
||||
console.log('📡 Sende Request an:', `${this.apiBaseUrl}/api/admin/fix-errors`);
|
||||
console.log('📝 Request Headers:', requestOptions.headers);
|
||||
|
||||
const response = await fetch('/api/admin/fix-errors', requestOptions);
|
||||
const response = await fetch(`${this.apiBaseUrl}/api/admin/fix-errors`, requestOptions);
|
||||
|
||||
console.log('📡 Response Status:', response.status);
|
||||
console.log('📡 Response Headers:', Object.fromEntries(response.headers.entries()));
|
||||
@@ -1062,7 +1072,7 @@ class AdminDashboard {
|
||||
|
||||
try {
|
||||
const filter = level || document.getElementById('log-level-filter')?.value || 'all';
|
||||
const url = `${this.apiBaseUrl}/admin/api/logs?level=${filter}&limit=100`;
|
||||
const url = `${this.apiBaseUrl}/api/admin/logs?level=${filter}&limit=100`;
|
||||
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
@@ -1205,7 +1215,7 @@ class AdminDashboard {
|
||||
this.showNotification('📥 Logs werden exportiert...', 'info');
|
||||
|
||||
const filter = document.getElementById('log-level-filter')?.value || 'all';
|
||||
const url = `${this.apiBaseUrl}/admin/api/logs/export`;
|
||||
const url = `${this.apiBaseUrl}/api/admin/logs/export`;
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
@@ -1313,10 +1323,10 @@ class AdminDashboard {
|
||||
}
|
||||
};
|
||||
|
||||
console.log('📡 TEST Request an:', '/api/admin/fix-errors');
|
||||
console.log('📡 TEST Request an:', `${this.apiBaseUrl}/api/admin/fix-errors`);
|
||||
console.log('📝 TEST Headers:', requestOptions.headers);
|
||||
|
||||
const response = await fetch('/api/admin/fix-errors', requestOptions);
|
||||
const response = await fetch(`${this.apiBaseUrl}/api/admin/fix-errors`, requestOptions);
|
||||
|
||||
console.log('📡 TEST Response Status:', response.status);
|
||||
console.log('📡 TEST Response Headers:', Object.fromEntries(response.headers.entries()));
|
||||
|
@@ -4,6 +4,28 @@
|
||||
let dashboardData = {};
|
||||
let updateInterval;
|
||||
|
||||
// API Base URL Detection
|
||||
function detectApiBaseUrl() {
|
||||
const currentPort = window.location.port;
|
||||
const currentProtocol = window.location.protocol;
|
||||
const currentHost = window.location.hostname;
|
||||
|
||||
// Development-Umgebung (Port 5000)
|
||||
if (currentPort === '5000') {
|
||||
return `${currentProtocol}//${currentHost}:${currentPort}`;
|
||||
}
|
||||
|
||||
// Production-Umgebung (Port 443 oder kein Port)
|
||||
if (currentPort === '443' || currentPort === '') {
|
||||
return `${currentProtocol}//${currentHost}`;
|
||||
}
|
||||
|
||||
// Fallback für andere Ports
|
||||
return window.location.origin;
|
||||
}
|
||||
|
||||
const API_BASE_URL = detectApiBaseUrl();
|
||||
|
||||
// DOM-Elemente
|
||||
const elements = {
|
||||
activeJobs: null,
|
||||
|
@@ -16,6 +16,9 @@ class PrinterMonitor {
|
||||
this.errorCount = 0;
|
||||
this.maxErrors = 3;
|
||||
|
||||
// API Base URL Detection für verschiedene Umgebungen
|
||||
this.apiBaseUrl = this.detectApiBaseUrl();
|
||||
|
||||
// Status-Kategorien für bessere Übersicht
|
||||
this.statusCategories = {
|
||||
'online': { label: 'Online', color: 'success', icon: '🟢' },
|
||||
@@ -26,6 +29,29 @@ class PrinterMonitor {
|
||||
};
|
||||
|
||||
console.log('🖨️ PrinterMonitor initialisiert');
|
||||
console.log('🌐 API Base URL:', this.apiBaseUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erkennt die korrekte API Base URL basierend auf der aktuellen Umgebung
|
||||
*/
|
||||
detectApiBaseUrl() {
|
||||
const currentPort = window.location.port;
|
||||
const currentProtocol = window.location.protocol;
|
||||
const currentHost = window.location.hostname;
|
||||
|
||||
// Development-Umgebung (Port 5000)
|
||||
if (currentPort === '5000') {
|
||||
return `${currentProtocol}//${currentHost}:${currentPort}`;
|
||||
}
|
||||
|
||||
// Production-Umgebung (Port 443 oder kein Port)
|
||||
if (currentPort === '443' || currentPort === '') {
|
||||
return `${currentProtocol}//${currentHost}`;
|
||||
}
|
||||
|
||||
// Fallback für andere Ports
|
||||
return window.location.origin;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +139,7 @@ class PrinterMonitor {
|
||||
}
|
||||
|
||||
try {
|
||||
const url = `/api/printers/status${forceRefresh ? '?force_refresh=true' : ''}`;
|
||||
const url = `${this.apiBaseUrl}/api/printers/status${forceRefresh ? '?force_refresh=true' : ''}`;
|
||||
const response = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
@@ -309,7 +335,7 @@ class PrinterMonitor {
|
||||
*/
|
||||
async clearCache() {
|
||||
try {
|
||||
const response = await fetch('/api/printers/monitor/clear-cache', {
|
||||
const response = await fetch(`${this.apiBaseUrl}/api/printers/monitor/clear-cache`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -334,7 +360,7 @@ class PrinterMonitor {
|
||||
*/
|
||||
async getSummary() {
|
||||
try {
|
||||
const response = await fetch('/api/printers/monitor/summary', {
|
||||
const response = await fetch(`${this.apiBaseUrl}/api/printers/monitor/summary`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -432,7 +458,7 @@ class PrinterMonitor {
|
||||
try {
|
||||
console.log('🔄 Starte Force-Network-Refresh...');
|
||||
|
||||
const response = await fetch('/api/printers/force-refresh', {
|
||||
const response = await fetch(`${this.apiBaseUrl}/api/printers/force-refresh`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -480,7 +506,7 @@ class PrinterMonitor {
|
||||
|
||||
async initializeAllOutlets() {
|
||||
try {
|
||||
const response = await fetch('/api/printers/monitor/initialize-outlets', {
|
||||
const response = await fetch(`${this.apiBaseUrl}/api/printers/monitor/initialize-outlets`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
Reference in New Issue
Block a user