feat: Enhance frontend loading experience and service status handling
Some checks failed
Integration Tests / integration-tests (push) Failing after 20s
Integration Tests / performance-tests (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.11) (push) Failing after 23s
Frontend (React) / test (20) (push) Failing after 1m3s
Frontend (React) / build (push) Has been skipped
Frontend (React) / lighthouse (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.12) (push) Failing after 23s
Service Adapters (Python FastAPI) / test (3.13) (push) Failing after 20s
Service Adapters (Python FastAPI) / build (push) Has been skipped

### Summary of Changes
- Removed proxy configuration in `rsbuild.config.js` as the API Gateway is not running.
- Added smooth transitions and gentle loading overlays in CSS for improved user experience during data loading.
- Updated `Dashboard` component to conditionally display loading spinner and gentle loading overlay based on data fetching state.
- Enhanced `useOfflineAwareServiceStatus` and `useOfflineAwareSystemData` hooks to manage loading states and service status more effectively.
- Increased refresh intervals for service status and system data to reduce API call frequency.

### Expected Results
- Improved user experience with smoother loading transitions and better feedback during data refreshes.
- Enhanced handling of service status checks, providing clearer information when services are unavailable.
- Streamlined code for managing loading states, making it easier to maintain and extend in the future.
This commit is contained in:
GSRN
2025-09-18 11:09:51 +02:00
parent 48c755dff3
commit 7373ccfa1d
30 changed files with 2402 additions and 89 deletions

View File

@@ -0,0 +1,9 @@
"""
Middleware Package
This package contains custom middleware for the service adapters.
"""
from .logging_middleware import LoggingMiddleware
__all__ = ["LoggingMiddleware"]

View File

@@ -0,0 +1,75 @@
"""
Logging Middleware
This module provides custom logging middleware for FastAPI requests
to ensure consistent logging format with application logs.
"""
import logging
import time
from typing import Callable
from fastapi import Request, Response
from starlette.middleware.base import BaseHTTPMiddleware
from services.logging_config import get_request_logger
logger = get_request_logger()
class LoggingMiddleware(BaseHTTPMiddleware):
"""Custom logging middleware for unified request logging."""
async def dispatch(self, request: Request, call_next: Callable) -> Response:
"""
Log each request with unified formatting.
Args:
request: The incoming request
call_next: The next middleware/handler in the chain
Returns:
The response
"""
# Start timing
start_time = time.time()
# Extract request information
method = request.method
url_path = request.url.path
client_ip = request.client.host if request.client else "unknown"
user_agent = request.headers.get("user-agent", "unknown")
# Log request start
logger.info(
f"Request started: {method} {url_path} from {client_ip} "
f"(User-Agent: {user_agent})"
)
try:
# Process the request
response = await call_next(request)
# Calculate processing time
process_time = time.time() - start_time
# Log successful response
logger.info(
f"Request completed: {method} {url_path} -> "
f"{response.status_code} in {process_time:.3f}s"
)
return response
except Exception as e:
# Calculate processing time for failed requests
process_time = time.time() - start_time
# Log error
logger.error(
f"Request failed: {method} {url_path} -> "
f"Exception: {str(e)} in {process_time:.3f}s"
)
# Re-raise the exception
raise