ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
Add server uptime tracking and visualization
Juan Denisfc55530d8f53
diff --git a/backend/app/__init__.py b/backend/app/__init__.pyindex 96f59aa8..eaf9c0d7 100644--- a/backend/app/__init__.py+++ b/backend/app/__init__.py@@ -121,6 +121,10 @@ def create_app(config_name=None):from app.api.cron import cron_bpapp.register_blueprint(cron_bp, url_prefix='/api/v1/cron')+ # Register blueprints - Uptime Tracking+ from app.api.uptime import uptime_bp+ app.register_blueprint(uptime_bp, url_prefix='/api/v1/uptime')+# Create database tableswith app.app_context():db.create_all()diff --git a/backend/app/api/uptime.py b/backend/app/api/uptime.pynew file mode 100644index 00000000..2e5a06cf--- /dev/null+++ b/backend/app/api/uptime.py@@ -0,0 +1,92 @@+"""+Uptime Tracking API++Endpoints for server uptime monitoring and statistics.+"""++from flask import Blueprint, request, jsonify+from flask_jwt_extended import jwt_required++from app.services.uptime_service import UptimeService++uptime_bp = Blueprint('uptime', __name__)+++@uptime_bp.route('/current', methods=['GET'])+@jwt_required()+def get_current_uptime():+ """Get current server uptime."""+ uptime = UptimeService.get_current_uptime()+ return jsonify(uptime)+++@uptime_bp.route('/stats', methods=['GET'])+@jwt_required()+def get_uptime_stats():+ """Get comprehensive uptime statistics."""+ stats = UptimeService.get_uptime_stats()+ return jsonify(stats)+++@uptime_bp.route('/graph', methods=['GET'])+@jwt_required()+def get_uptime_graph():+ """+ Get uptime graph data.++ Query params:+ period: '24h', '7d', '30d', '90d' (default: '24h')+ """+ period = request.args.get('period', '24h')+ if period not in ['24h', '7d', '30d', '90d']:+ period = '24h'++ data = UptimeService.get_uptime_graph_data(period)+ return jsonify(data)+++@uptime_bp.route('/history', methods=['GET'])+@jwt_required()+def get_uptime_history():+ """+ Get uptime check history.++ Query params:+ hours: Number of hours to look back (default: 24)+ """+ hours = request.args.get('hours', 24, type=int)+ hours = min(max(hours, 1), 24 * 90) # Limit to 90 days++ history = UptimeService.get_uptime_history(hours)+ return jsonify({+ 'hours': hours,+ 'checks': history,+ 'total': len(history)+ })+++@uptime_bp.route('/tracking/start', methods=['POST'])+@jwt_required()+def start_tracking():+ """Start uptime tracking."""+ result = UptimeService.start_tracking()+ if result.get('success'):+ return jsonify(result)+ return jsonify(result), 400+++@uptime_bp.route('/tracking/stop', methods=['POST'])+@jwt_required()+def stop_tracking():+ """Stop uptime tracking."""+ result = UptimeService.stop_tracking()+ return jsonify(result)+++@uptime_bp.route('/tracking/status', methods=['GET'])+@jwt_required()+def get_tracking_status():+ """Get uptime tracking status."""+ return jsonify({+ 'is_tracking': UptimeService.is_tracking()+ })diff --git a/backend/app/services/uptime_service.py b/backend/app/services/uptime_service.pynew file mode 100644index 00000000..34dd6f43--- /dev/null+++ b/backend/app/services/uptime_service.py@@ -0,0 +1,317 @@+"""+Uptime Tracking Service++Tracks server uptime history and provides uptime statistics.+"""++import os+import json+import time+import psutil+from datetime import datetime, timedelta+from typing import Dict, List, Optional+from pathlib import Path+import threading+++class UptimeService:+ """Service for tracking and reporting server uptime."""++ DATA_DIR = '/var/lib/serverkit'+ UPTIME_FILE = os.path.join(DATA_DIR, 'uptime_history.json')++ # For Windows compatibility+ if os.name == 'nt':+ DATA_DIR = os.path.join(os.environ.get('APPDATA', '.'), 'ServerKit')+ UPTIME_FILE = os.path.join(DATA_DIR, 'uptime_history.json')++ # Check interval in seconds (every 5 minutes)+ CHECK_INTERVAL = 300++ # How many data points to keep (90 days worth at 5-minute intervals)+ MAX_DATA_POINTS = 90 * 24 * 12++ _tracking_thread = None+ _stop_tracking = False++ @classmethod+ def _ensure_data_dir(cls) -> None:+ """Ensure data directory exists."""+ os.makedirs(cls.DATA_DIR, exist_ok=True)++ @classmethod+ def _load_history(cls) -> Dict:+ """Load uptime history from file."""+ cls._ensure_data_dir()++ if os.path.exists(cls.UPTIME_FILE):+ try:+ with open(cls.UPTIME_FILE, 'r') as f:+ return json.load(f)+ except Exception:+ pass++ return {+ 'start_time': datetime.now().isoformat(),+ 'checks': [],+ 'incidents': []+ }++ @classmethod+ def _save_history(cls, history: Dict) -> None:+ """Save uptime history to file."""+ cls._ensure_data_dir()++ try:+ with open(cls.UPTIME_FILE, 'w') as f:+ json.dump(history, f)+ except Exception:+ pass++ @classmethod+ def get_boot_time(cls) -> datetime:+ """Get system boot time."""+ return datetime.fromtimestamp(psutil.boot_time())++ @classmethod+ def get_current_uptime(cls) -> Dict:+ """Get current uptime information."""+ boot_time = cls.get_boot_time()+ now = datetime.now()+ uptime_delta = now - boot_time++ total_seconds = int(uptime_delta.total_seconds())+ days = total_seconds // 86400+ hours = (total_seconds % 86400) // 3600+ minutes = (total_seconds % 3600) // 60+ seconds = total_seconds % 60++ return {+ 'boot_time': boot_time.isoformat(),+ 'current_time': now.isoformat(),+ 'uptime_seconds': total_seconds,+ 'uptime_formatted': {+ 'days': days,+ 'hours': hours,+ 'minutes': minutes,+ 'seconds': seconds+ },+ 'uptime_string': f"{days}d {hours}h {minutes}m {seconds}s"+ }++ @classmethod+ def record_check(cls, status: str = 'up') -> None:+ """Record an uptime check."""+ history = cls._load_history()++ check = {+ 'timestamp': datetime.now().isoformat(),+ 'status': status,+ 'uptime_seconds': cls.get_current_uptime()['uptime_seconds']+ }++ history['checks'].append(check)++ # Trim old data points+ if len(history['checks']) > cls.MAX_DATA_POINTS:+ history['checks'] = history['checks'][-cls.MAX_DATA_POINTS:]++ cls._save_history(history)++ @classmethod+ def record_incident(cls, incident_type: str, details: str = '') -> None:+ """Record a downtime incident."""+ history = cls._load_history()++ incident = {+ 'timestamp': datetime.now().isoformat(),+ 'type': incident_type,+ 'details': details+ }++ history['incidents'].append(incident)+ cls._save_history(history)++ @classmethod+ def get_uptime_history(cls, hours: int = 24) -> List[Dict]:+ """Get uptime history for the specified number of hours."""+ history = cls._load_history()+ cutoff = datetime.now() - timedelta(hours=hours)++ checks = []+ for check in history.get('checks', []):+ try:+ check_time = datetime.fromisoformat(check['timestamp'])+ if check_time >= cutoff:+ checks.append(check)+ except Exception:+ pass++ return checks++ @classmethod+ def get_uptime_graph_data(cls, period: str = '24h') -> Dict:+ """+ Get data formatted for uptime graph visualization.++ period: '24h', '7d', '30d', '90d'+ """+ period_hours = {+ '24h': 24,+ '7d': 24 * 7,+ '30d': 24 * 30,+ '90d': 24 * 90+ }++ hours = period_hours.get(period, 24)+ history = cls._load_history()+ now = datetime.now()+ cutoff = now - timedelta(hours=hours)++ # Determine the number of segments based on period+ if period == '24h':+ num_segments = 48 # 30-minute segments+ segment_duration = timedelta(minutes=30)+ elif period == '7d':+ num_segments = 84 # 2-hour segments+ segment_duration = timedelta(hours=2)+ elif period == '30d':+ num_segments = 60 # 12-hour segments+ segment_duration = timedelta(hours=12)+ else: # 90d+ num_segments = 90 # Daily segments+ segment_duration = timedelta(days=1)++ # Create segments+ segments = []+ segment_start = cutoff++ for i in range(num_segments):+ segment_end = segment_start + segment_duration++ # Find checks within this segment+ segment_checks = []+ for check in history.get('checks', []):+ try:+ check_time = datetime.fromisoformat(check['timestamp'])+ if segment_start <= check_time < segment_end:+ segment_checks.append(check)+ except Exception:+ pass++ # Determine segment status+ if segment_checks:+ down_checks = sum(1 for c in segment_checks if c.get('status') != 'up')+ total_checks = len(segment_checks)+ uptime_ratio = (total_checks - down_checks) / total_checks if total_checks > 0 else 1++ if uptime_ratio >= 0.99:+ status = 'up'+ elif uptime_ratio >= 0.9:+ status = 'degraded'+ else:+ status = 'down'+ else:+ # No data for this segment (before tracking started or gap)+ status = 'no_data' if segment_start < datetime.fromisoformat(history.get('start_time', now.isoformat())) else 'up'++ segments.append({+ 'start': segment_start.isoformat(),+ 'end': segment_end.isoformat(),+ 'status': status,+ 'checks_count': len(segment_checks)+ })++ segment_start = segment_end++ # Calculate overall uptime percentage+ all_checks = cls.get_uptime_history(hours)+ if all_checks:+ up_checks = sum(1 for c in all_checks if c.get('status') == 'up')+ uptime_percentage = (up_checks / len(all_checks)) * 100+ else:+ uptime_percentage = 100.0 # Assume 100% if no data yet++ return {+ 'period': period,+ 'segments': segments,+ 'total_segments': num_segments,+ 'uptime_percentage': round(uptime_percentage, 2),+ 'total_checks': len(all_checks),+ 'current_status': 'up' # We're running, so we're up+ }++ @classmethod+ def get_uptime_stats(cls) -> Dict:+ """Get comprehensive uptime statistics."""+ current = cls.get_current_uptime()+ history = cls._load_history()++ # Calculate stats for different periods+ periods = {+ '24h': 24,+ '7d': 24 * 7,+ '30d': 24 * 30,+ '90d': 24 * 90+ }++ stats = {}+ for period_name, hours in periods.items():+ checks = cls.get_uptime_history(hours)+ if checks:+ up_checks = sum(1 for c in checks if c.get('status') == 'up')+ stats[period_name] = {+ 'total_checks': len(checks),+ 'up_checks': up_checks,+ 'uptime_percentage': round((up_checks / len(checks)) * 100, 2)+ }+ else:+ stats[period_name] = {+ 'total_checks': 0,+ 'up_checks': 0,+ 'uptime_percentage': 100.0+ }++ return {+ 'current': current,+ 'periods': stats,+ 'incidents': history.get('incidents', [])[-10:], # Last 10 incidents+ 'tracking_since': history.get('start_time')+ }++ @classmethod+ def start_tracking(cls) -> Dict:+ """Start background uptime tracking."""+ if cls._tracking_thread and cls._tracking_thread.is_alive():+ return {'success': False, 'error': 'Tracking already running'}++ cls._stop_tracking = False+ cls._tracking_thread = threading.Thread(target=cls._tracking_loop, daemon=True)+ cls._tracking_thread.start()++ # Record initial check+ cls.record_check('up')++ return {'success': True, 'message': 'Uptime tracking started'}++ @classmethod+ def stop_tracking(cls) -> Dict:+ """Stop background uptime tracking."""+ cls._stop_tracking = True+ return {'success': True, 'message': 'Uptime tracking stopped'}++ @classmethod+ def _tracking_loop(cls) -> None:+ """Background tracking loop."""+ while not cls._stop_tracking:+ try:+ cls.record_check('up')+ except Exception:+ pass++ time.sleep(cls.CHECK_INTERVAL)++ @classmethod+ def is_tracking(cls) -> bool:+ """Check if uptime tracking is active."""+ return cls._tracking_thread is not None and cls._tracking_thread.is_alive()diff --git a/frontend/src/components/UptimeGraph.jsx b/frontend/src/components/UptimeGraph.jsxnew file mode 100644index 00000000..37b72b33--- /dev/null+++ b/frontend/src/components/UptimeGraph.jsx@@ -0,0 +1,226 @@+import React, { useState, useEffect } from 'react';+import { Server, Activity, Clock, CheckCircle, AlertTriangle, XCircle } from 'lucide-react';+import api from '../services/api';++const UptimeGraph = ({ compact = false }) => {+ const [uptime, setUptime] = useState(null);+ const [graphData, setGraphData] = useState(null);+ const [stats, setStats] = useState(null);+ const [period, setPeriod] = useState('24h');+ const [loading, setLoading] = useState(true);+ const [error, setError] = useState(null);++ useEffect(() => {+ loadData();+ }, [period]);++ const loadData = async () => {+ try {+ setLoading(true);+ const [uptimeRes, graphRes, statsRes] = await Promise.all([+ api.getCurrentUptime(),+ api.getUptimeGraph(period),+ api.getUptimeStats()+ ]);++ setUptime(uptimeRes);+ setGraphData(graphRes);+ setStats(statsRes);+ setError(null);+ } catch (err) {+ setError(err.message);+ } finally {+ setLoading(false);+ }+ };++ const getStatusColor = (status) => {+ switch (status) {+ case 'up': return 'var(--success)';+ case 'degraded': return 'var(--warning)';+ case 'down': return 'var(--danger)';+ default: return 'var(--border-subtle)';+ }+ };++ const getStatusIcon = (status) => {+ switch (status) {+ case 'up': return <CheckCircle size={16} />;+ case 'degraded': return <AlertTriangle size={16} />;+ case 'down': return <XCircle size={16} />;+ default: return <Activity size={16} />;+ }+ };++ const formatSegmentTime = (isoString) => {+ const date = new Date(isoString);+ if (period === '24h') {+ return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });+ } else if (period === '7d') {+ return date.toLocaleDateString([], { weekday: 'short', hour: '2-digit' });+ } else {+ return date.toLocaleDateString([], { month: 'short', day: 'numeric' });+ }+ };++ const getUptimeClass = (percentage) => {+ if (percentage >= 99.9) return 'excellent';+ if (percentage >= 99) return 'good';+ if (percentage >= 95) return 'fair';+ return 'poor';+ };++ if (loading && !uptime) {+ return (+ <div className="uptime-card loading">+ <div className="loading-spinner" />+ </div>+ );+ }++ if (error) {+ return (+ <div className="uptime-card error">+ <AlertTriangle size={24} />+ <span>Failed to load uptime data</span>+ </div>+ );+ }++ const uptimeFormatted = uptime?.uptime_formatted || { days: 0, hours: 0, minutes: 0, seconds: 0 };+ const uptimePercent = graphData?.uptime_percentage || 100;++ if (compact) {+ return (+ <div className="uptime-compact">+ <div className="uptime-compact-status">+ <Server size={20} style={{ color: 'var(--success)' }} />+ <span className="uptime-compact-label">Uptime</span>+ <span className={`uptime-compact-percent ${getUptimeClass(uptimePercent)}`}>+ {uptimePercent}%+ </span>+ </div>+ <div className="uptime-compact-time">+ <span className="value">{uptimeFormatted.days}</span>+ <span className="unit">d</span>+ <span className="value">{String(uptimeFormatted.hours).padStart(2, '0')}</span>+ <span className="unit">h</span>+ <span className="value">{String(uptimeFormatted.minutes).padStart(2, '0')}</span>+ <span className="unit">m</span>+ </div>+ </div>+ );+ }++ return (+ <div className="uptime-card">+ <div className="uptime-header">+ <div className="uptime-title">+ <Server size={24} className="uptime-icon" />+ <div>+ <h3>Server Uptime</h3>+ <span className="uptime-status online">+ <span className="status-dot" />+ Operational+ </span>+ </div>+ </div>+ <div className="uptime-percentage">+ <span className={`percentage-value ${getUptimeClass(uptimePercent)}`}>+ {uptimePercent}%+ </span>+ <span className="percentage-label">uptime</span>+ </div>+ </div>++ <div className="uptime-counter">+ <div className="uptime-counter-item">+ <span className="counter-value">{uptimeFormatted.days}</span>+ <span className="counter-label">Days</span>+ </div>+ <span className="counter-separator">:</span>+ <div className="uptime-counter-item">+ <span className="counter-value">{String(uptimeFormatted.hours).padStart(2, '0')}</span>+ <span className="counter-label">Hours</span>+ </div>+ <span className="counter-separator">:</span>+ <div className="uptime-counter-item">+ <span className="counter-value">{String(uptimeFormatted.minutes).padStart(2, '0')}</span>+ <span className="counter-label">Minutes</span>+ </div>+ <span className="counter-separator">:</span>+ <div className="uptime-counter-item">+ <span className="counter-value">{String(uptimeFormatted.seconds).padStart(2, '0')}</span>+ <span className="counter-label">Seconds</span>+ </div>+ </div>++ <div className="uptime-graph-section">+ <div className="uptime-graph-header">+ <span className="graph-title">Uptime History</span>+ <div className="period-selector">+ {['24h', '7d', '30d', '90d'].map(p => (+ <button+ key={p}+ className={`period-btn ${period === p ? 'active' : ''}`}+ onClick={() => setPeriod(p)}+ >+ {p}+ </button>+ ))}+ </div>+ </div>++ <div className="uptime-graph">+ {graphData?.segments?.map((segment, index) => (+ <div+ key={index}+ className={`graph-bar ${segment.status}`}+ style={{ backgroundColor: getStatusColor(segment.status) }}+ title={`${formatSegmentTime(segment.start)}: ${segment.status}`}+ />+ ))}+ </div>++ <div className="uptime-graph-labels">+ <span>{period === '24h' ? '24 hours ago' : period === '7d' ? '7 days ago' : period === '30d' ? '30 days ago' : '90 days ago'}</span>+ <span>Now</span>+ </div>+ </div>++ <div className="uptime-legend">+ <div className="legend-item">+ <span className="legend-dot up" />+ <span>Operational</span>+ </div>+ <div className="legend-item">+ <span className="legend-dot degraded" />+ <span>Degraded</span>+ </div>+ <div className="legend-item">+ <span className="legend-dot down" />+ <span>Down</span>+ </div>+ <div className="legend-item">+ <span className="legend-dot no-data" />+ <span>No Data</span>+ </div>+ </div>++ {stats?.periods && (+ <div className="uptime-stats-grid">+ {Object.entries(stats.periods).map(([periodKey, periodStats]) => (+ <div key={periodKey} className="uptime-stat">+ <span className="stat-period">{periodKey}</span>+ <span className={`stat-value ${getUptimeClass(periodStats.uptime_percentage)}`}>+ {periodStats.uptime_percentage}%+ </span>+ </div>+ ))}+ </div>+ )}+ </div>+ );+};++export default UptimeGraph;diff --git a/frontend/src/pages/Dashboard.jsx b/frontend/src/pages/Dashboard.jsxindex 50ef3426..c3f88d0a 100644--- a/frontend/src/pages/Dashboard.jsx+++ b/frontend/src/pages/Dashboard.jsx@@ -1,13 +1,14 @@import React, { useState, useEffect } from 'react';import { useNavigate } from 'react-router-dom';import {- Cpu, MemoryStick, HardDrive, Clock, Server,- Plus, FileText, RefreshCw, Activity, Layers,- Database, Globe, Container, Code, CheckCircle,- AlertCircle, XCircle, ArrowRight+ Cpu, MemoryStick, HardDrive, Server,+ Plus, RefreshCw, Activity, Layers,+ Database, Globe, Container, Code,+ ArrowRight} from 'lucide-react';import api from '../services/api';import { useMetrics } from '../hooks/useMetrics';+import UptimeGraph from '../components/UptimeGraph';const Dashboard = () => {const navigate = useNavigate();@@ -70,22 +71,6 @@ const Dashboard = () => {return colors[type] || '#6366f1';}- function parseUptime(uptimeStr) {- if (!uptimeStr) return { days: 0, hours: 0, minutes: 0 };-- const match = uptimeStr.match(/(\d+)d\s*(\d+)h\s*(\d+)m|(\d+)h\s*(\d+)m|(\d+)m/);- if (!match) return { days: 0, hours: 0, minutes: 0 };-- if (match[1]) {- return { days: parseInt(match[1]), hours: parseInt(match[2]), minutes: parseInt(match[3]) };- } else if (match[4]) {- return { days: 0, hours: parseInt(match[4]), minutes: parseInt(match[5]) };- } else {- return { days: 0, hours: 0, minutes: parseInt(match[6]) };- }- }-- const uptime = parseUptime(metrics?.system?.uptime_human);const runningApps = apps.filter(a => a.status === 'running').length;const runningServices = services.filter(s => s.status === 'running').length;@@ -115,41 +100,8 @@ const Dashboard = () => {</div></header>- {/* Uptime Display */}- {metrics?.system && (- <div className="uptime-display">- <Server size={24} style={{ color: 'var(--success)' }} />- <div style={{ flex: 1 }}>- <div style={{ fontSize: '13px', color: 'var(--text-tertiary)', marginBottom: '4px' }}>- Server Uptime- </div>- <div style={{ display: 'flex', alignItems: 'center', gap: '16px' }}>- <div className="uptime-item">- <span className="uptime-value">{uptime.days}</span>- <span className="uptime-label">Days</span>- </div>- <span className="uptime-separator">:</span>- <div className="uptime-item">- <span className="uptime-value">{String(uptime.hours).padStart(2, '0')}</span>- <span className="uptime-label">Hours</span>- </div>- <span className="uptime-separator">:</span>- <div className="uptime-item">- <span className="uptime-value">{String(uptime.minutes).padStart(2, '0')}</span>- <span className="uptime-label">Minutes</span>- </div>- </div>- </div>- <div style={{ textAlign: 'right' }}>- <div style={{ fontSize: '12px', color: 'var(--text-tertiary)' }}>- {metrics.system?.hostname}- </div>- <div style={{ fontSize: '11px', color: 'var(--text-tertiary)' }}>- {metrics.system?.platform}- </div>- </div>- </div>- )}+ {/* Uptime Graph */}+ <UptimeGraph />{/* System Metrics */}{metrics && (diff --git a/frontend/src/services/api.js b/frontend/src/services/api.jsindex 05663916..cdb4daad 100644--- a/frontend/src/services/api.js+++ b/frontend/src/services/api.js@@ -1493,6 +1493,37 @@ class ApiService {async getCronPresets() {return this.request('/cron/presets');}++ // ========================================+ // Uptime Tracking endpoints+ // ========================================+ async getCurrentUptime() {+ return this.request('/uptime/current');+ }++ async getUptimeStats() {+ return this.request('/uptime/stats');+ }++ async getUptimeGraph(period = '24h') {+ return this.request(`/uptime/graph?period=${period}`);+ }++ async getUptimeHistory(hours = 24) {+ return this.request(`/uptime/history?hours=${hours}`);+ }++ async startUptimeTracking() {+ return this.request('/uptime/tracking/start', { method: 'POST' });+ }++ async stopUptimeTracking() {+ return this.request('/uptime/tracking/stop', { method: 'POST' });+ }++ async getUptimeTrackingStatus() {+ return this.request('/uptime/tracking/status');+ }}export const api = new ApiService();diff --git a/frontend/src/styles/components/_uptime.less b/frontend/src/styles/components/_uptime.lessnew file mode 100644index 00000000..b07b3f7c--- /dev/null+++ b/frontend/src/styles/components/_uptime.less@@ -0,0 +1,445 @@+// ============================================+// UPTIME GRAPH COMPONENT+// ============================================++.uptime-card {+ background: @bg-card;+ border: 1px solid @border-subtle;+ border-radius: @radius-xl;+ padding: @space-6;++ &.loading,+ &.error {+ display: flex;+ align-items: center;+ justify-content: center;+ gap: @space-3;+ min-height: 200px;+ color: @text-tertiary;+ }++ &.error {+ color: @danger;+ }+}++.uptime-header {+ display: flex;+ align-items: flex-start;+ justify-content: space-between;+ margin-bottom: @space-6;+}++.uptime-title {+ display: flex;+ align-items: center;+ gap: @space-3;++ .uptime-icon {+ color: @success;+ }++ h3 {+ font-size: @font-size-lg;+ font-weight: @font-weight-semibold;+ color: @text-primary;+ margin: 0 0 @space-1 0;+ }+}++.uptime-status {+ display: inline-flex;+ align-items: center;+ gap: @space-2;+ font-size: @font-size-sm;+ color: @text-secondary;++ .status-dot {+ width: 8px;+ height: 8px;+ border-radius: 50%;+ background: @text-tertiary;+ }++ &.online {+ color: @success;++ .status-dot {+ background: @success;+ box-shadow: 0 0 8px @success;+ animation: pulse-dot 2s ease-in-out infinite;+ }+ }++ &.degraded {+ color: @warning;++ .status-dot {+ background: @warning;+ }+ }++ &.offline {+ color: @danger;++ .status-dot {+ background: @danger;+ }+ }+}++@keyframes pulse-dot {+ 0%, 100% {+ opacity: 1;+ transform: scale(1);+ }+ 50% {+ opacity: 0.7;+ transform: scale(1.2);+ }+}++.uptime-percentage {+ text-align: right;++ .percentage-value {+ display: block;+ font-size: @font-size-2xl;+ font-weight: @font-weight-bold;+ font-family: @font-mono;+ color: @text-primary;++ &.excellent {+ color: @success;+ }++ &.good {+ color: @success;+ }++ &.fair {+ color: @warning;+ }++ &.poor {+ color: @danger;+ }+ }++ .percentage-label {+ font-size: @font-size-xs;+ color: @text-tertiary;+ text-transform: uppercase;+ letter-spacing: 0.5px;+ }+}++// Uptime Counter+.uptime-counter {+ display: flex;+ align-items: center;+ justify-content: center;+ gap: @space-2;+ padding: @space-5;+ background: linear-gradient(135deg, fade(@accent-primary, 5%), fade(@success, 5%));+ border: 1px solid @border-subtle;+ border-radius: @radius-lg;+ margin-bottom: @space-6;+}++.uptime-counter-item {+ display: flex;+ flex-direction: column;+ align-items: center;+ min-width: 60px;++ .counter-value {+ font-size: 32px;+ font-weight: @font-weight-bold;+ font-family: @font-mono;+ color: @text-primary;+ line-height: 1;+ }++ .counter-label {+ font-size: @font-size-xs;+ color: @text-tertiary;+ text-transform: uppercase;+ letter-spacing: 0.5px;+ margin-top: @space-1;+ }+}++.counter-separator {+ font-size: 32px;+ font-weight: @font-weight-bold;+ font-family: @font-mono;+ color: @text-tertiary;+ margin: 0 @space-1;+ margin-bottom: @space-4;+}++// Graph Section+.uptime-graph-section {+ margin-bottom: @space-5;+}++.uptime-graph-header {+ display: flex;+ align-items: center;+ justify-content: space-between;+ margin-bottom: @space-3;++ .graph-title {+ font-size: @font-size-sm;+ font-weight: @font-weight-medium;+ color: @text-secondary;+ }+}++.period-selector {+ display: flex;+ gap: @space-1;+ background: @bg-hover;+ padding: @space-1;+ border-radius: @radius-md;+}++.period-btn {+ padding: @space-1 @space-3;+ font-size: @font-size-xs;+ font-weight: @font-weight-medium;+ color: @text-tertiary;+ background: transparent;+ border: none;+ border-radius: @radius-sm;+ cursor: pointer;+ transition: all @transition-fast;++ &:hover {+ color: @text-primary;+ }++ &.active {+ background: @accent-primary;+ color: white;+ }+}++.uptime-graph {+ display: flex;+ gap: 2px;+ height: 32px;+ background: @bg-hover;+ border-radius: @radius-md;+ overflow: hidden;+ padding: 4px;+}++.graph-bar {+ flex: 1;+ border-radius: 2px;+ transition: transform @transition-fast, opacity @transition-fast;+ cursor: pointer;+ min-width: 4px;++ &:hover {+ transform: scaleY(1.1);+ opacity: 0.8;+ }++ &.up {+ background: @success;+ }++ &.degraded {+ background: @warning;+ }++ &.down {+ background: @danger;+ }++ &.no_data,+ &.no-data {+ background: @border-subtle;+ }+}++.uptime-graph-labels {+ display: flex;+ justify-content: space-between;+ margin-top: @space-2;+ font-size: @font-size-xs;+ color: @text-tertiary;+}++// Legend+.uptime-legend {+ display: flex;+ align-items: center;+ justify-content: center;+ gap: @space-5;+ padding: @space-3 0;+ border-top: 1px solid @border-subtle;+ border-bottom: 1px solid @border-subtle;+ margin-bottom: @space-5;+}++.legend-item {+ display: flex;+ align-items: center;+ gap: @space-2;+ font-size: @font-size-xs;+ color: @text-secondary;+}++.legend-dot {+ width: 10px;+ height: 10px;+ border-radius: 2px;++ &.up {+ background: @success;+ }++ &.degraded {+ background: @warning;+ }++ &.down {+ background: @danger;+ }++ &.no-data {+ background: @border-subtle;+ }+}++// Stats Grid+.uptime-stats-grid {+ display: grid;+ grid-template-columns: repeat(4, 1fr);+ gap: @space-3;+}++.uptime-stat {+ display: flex;+ flex-direction: column;+ align-items: center;+ padding: @space-3;+ background: @bg-hover;+ border-radius: @radius-md;++ .stat-period {+ font-size: @font-size-xs;+ color: @text-tertiary;+ text-transform: uppercase;+ margin-bottom: @space-1;+ }++ .stat-value {+ font-size: @font-size-md;+ font-weight: @font-weight-bold;+ font-family: @font-mono;+ color: @text-primary;++ &.excellent,+ &.good {+ color: @success;+ }++ &.fair {+ color: @warning;+ }++ &.poor {+ color: @danger;+ }+ }+}++// Compact Version+.uptime-compact {+ display: flex;+ align-items: center;+ justify-content: space-between;+ padding: @space-4 @space-5;+ background: @bg-card;+ border: 1px solid @border-subtle;+ border-radius: @radius-lg;+}++.uptime-compact-status {+ display: flex;+ align-items: center;+ gap: @space-3;++ .uptime-compact-label {+ font-size: @font-size-sm;+ color: @text-secondary;+ }++ .uptime-compact-percent {+ font-size: @font-size-base;+ font-weight: @font-weight-bold;+ font-family: @font-mono;+ padding: @space-1 @space-2;+ border-radius: @radius-sm;+ background: @success-bg;+ color: @success;++ &.fair {+ background: @warning-bg;+ color: @warning;+ }++ &.poor {+ background: @danger-bg;+ color: @danger;+ }+ }+}++.uptime-compact-time {+ display: flex;+ align-items: baseline;+ gap: 2px;+ font-family: @font-mono;++ .value {+ font-size: @font-size-lg;+ font-weight: @font-weight-bold;+ color: @text-primary;+ }++ .unit {+ font-size: @font-size-sm;+ color: @text-tertiary;+ margin-right: @space-1;+ }+}++// Responsive+@media (max-width: @breakpoint-md) {+ .uptime-counter-item {+ min-width: 50px;++ .counter-value {+ font-size: 24px;+ }+ }++ .counter-separator {+ font-size: 24px;+ }++ .uptime-stats-grid {+ grid-template-columns: repeat(2, 1fr);+ }++ .uptime-legend {+ flex-wrap: wrap;+ gap: @space-3;+ }+}diff --git a/frontend/src/styles/main.less b/frontend/src/styles/main.lessindex f053f9e6..d1eb7969 100644--- a/frontend/src/styles/main.less+++ b/frontend/src/styles/main.less@@ -39,6 +39,7 @@@import 'components/_credentials';@import 'components/_toasts';@import 'components/_spinner';+@import 'components/_uptime';// --------------------------------------------// 5. PAGE-SPECIFIC STYLES