diff --git a/backend/app/api/routes/support.py b/backend/app/api/routes/support.py index a22a92fd0..94117d674 100644 --- a/backend/app/api/routes/support.py +++ b/backend/app/api/routes/support.py @@ -30,10 +30,6 @@ from backend.app.models.user import User router = APIRouter(prefix="/support", tags=["support"]) logger = logging.getLogger(__name__) -# In-memory state for debug logging (persisted to settings DB) -_debug_logging_enabled = False -_debug_logging_enabled_at: datetime | None = None - class DebugLoggingState(BaseModel): enabled: bool @@ -114,12 +110,8 @@ async def get_debug_logging_state( _: User | None = RequirePermissionIfAuthEnabled(Permission.SETTINGS_READ), ): """Get current debug logging state.""" - global _debug_logging_enabled, _debug_logging_enabled_at - async with async_session() as db: enabled, enabled_at = await _get_debug_setting(db) - _debug_logging_enabled = enabled - _debug_logging_enabled_at = enabled_at duration = None if enabled and enabled_at: @@ -138,12 +130,8 @@ async def toggle_debug_logging( _: User | None = RequirePermissionIfAuthEnabled(Permission.SETTINGS_UPDATE), ): """Enable or disable debug logging.""" - global _debug_logging_enabled, _debug_logging_enabled_at - async with async_session() as db: enabled_at = await _set_debug_setting(db, toggle.enabled) - _debug_logging_enabled = toggle.enabled - _debug_logging_enabled_at = enabled_at _apply_log_level(toggle.enabled) @@ -458,13 +446,9 @@ async def generate_support_bundle( _: User | None = RequirePermissionIfAuthEnabled(Permission.SETTINGS_READ), ): """Generate a support bundle ZIP file for issue reporting.""" - global _debug_logging_enabled, _debug_logging_enabled_at - # Check if debug logging is enabled async with async_session() as db: - enabled, enabled_at = await _get_debug_setting(db) - _debug_logging_enabled = enabled - _debug_logging_enabled_at = enabled_at + enabled, _enabled_at = await _get_debug_setting(db) if not enabled: raise HTTPException( @@ -500,13 +484,9 @@ async def generate_support_bundle( async def init_debug_logging(): """Initialize debug logging state from database on startup.""" - global _debug_logging_enabled, _debug_logging_enabled_at - try: async with async_session() as db: - enabled, enabled_at = await _get_debug_setting(db) - _debug_logging_enabled = enabled - _debug_logging_enabled_at = enabled_at + enabled, _ = await _get_debug_setting(db) if enabled: _apply_log_level(True) diff --git a/frontend/src/pages/PrintersPage.tsx b/frontend/src/pages/PrintersPage.tsx index 0d3487d54..9f938570e 100644 --- a/frontend/src/pages/PrintersPage.tsx +++ b/frontend/src/pages/PrintersPage.tsx @@ -398,9 +398,7 @@ function hexToBasicColorName(hex: string | null | undefined): string { if (h < 200) return 'Cyan'; if (h < 260) return 'Blue'; if (h < 290) return 'Purple'; - if (h < 345) return 'Pink'; - - return 'Unknown'; + return 'Pink'; } // Format K value with 3 decimal places, default to 0.020 if null @@ -707,8 +705,7 @@ function getPrinterImage(model: string | null | undefined): string { return '/img/printers/default.png'; } -function getWifiStrength(rssi: number | null | undefined): { labelKey: string; color: string; bars: number } { - if (rssi == null) return { labelKey: '', color: 'text-bambu-gray', bars: 0 }; +function getWifiStrength(rssi: number): { labelKey: string; color: string; bars: number } { if (rssi >= -50) return { labelKey: 'printers.wifiSignal.excellent', color: 'text-bambu-green', bars: 4 }; if (rssi >= -60) return { labelKey: 'printers.wifiSignal.good', color: 'text-bambu-green', bars: 3 }; if (rssi >= -70) return { labelKey: 'printers.wifiSignal.fair', color: 'text-yellow-400', bars: 2 }; diff --git a/frontend/src/utils/colors.ts b/frontend/src/utils/colors.ts index 413f8ec69..3d1ba7108 100644 --- a/frontend/src/utils/colors.ts +++ b/frontend/src/utils/colors.ts @@ -90,8 +90,7 @@ export function hexToColorName(hex: string | null | undefined): string { if (h < 200) return 'Cyan'; if (h < 260) return 'Blue'; if (h < 290) return 'Purple'; - if (h < 345) return 'Pink'; - return 'Unknown'; + return 'Pink'; } /**