📝 "Refactor admin UI components for improved consistency and performance" 🌈
This commit is contained in:
@ -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