Skip to content

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.

Add cron job management (backend & frontend UI)

Juan Denis4cbde38363fe
diff --git a/backend/app/__init__.py b/backend/app/__init__.py
index ab49d37a..96f59aa8 100644
--- a/backend/app/__init__.py
+++ b/backend/app/__init__.py
@@ -117,6 +117,10 @@ def create_app(config_name=None):
from app.api.firewall import firewall_bp
app.register_blueprint(firewall_bp, url_prefix='/api/v1/firewall')
+ # Register blueprints - Cron Jobs
+ from app.api.cron import cron_bp
+ app.register_blueprint(cron_bp, url_prefix='/api/v1/cron')
+
# Create database tables
with app.app_context():
db.create_all()
diff --git a/backend/app/api/cron.py b/backend/app/api/cron.py
new file mode 100644
index 00000000..8fdbe873
--- /dev/null
+++ b/backend/app/api/cron.py
@@ -0,0 +1,101 @@
+"""
+Cron Job Management API
+
+Endpoints for managing scheduled tasks and cron jobs.
+"""
+
+from flask import Blueprint, request, jsonify
+from flask_jwt_extended import jwt_required
+
+from app.services.cron_service import CronService
+
+cron_bp = Blueprint('cron', __name__)
+
+
+@cron_bp.route('/status', methods=['GET'])
+@jwt_required()
+def get_status():
+ """Get cron service status."""
+ status = CronService.get_status()
+ return jsonify(status)
+
+
+@cron_bp.route('/jobs', methods=['GET'])
+@jwt_required()
+def list_jobs():
+ """List all cron jobs."""
+ result = CronService.list_jobs()
+ return jsonify(result)
+
+
+@cron_bp.route('/jobs', methods=['POST'])
+@jwt_required()
+def create_job():
+ """Create a new cron job."""
+ data = request.get_json()
+
+ schedule = data.get('schedule')
+ command = data.get('command')
+ name = data.get('name')
+ description = data.get('description')
+
+ if not schedule:
+ return jsonify({'success': False, 'error': 'Schedule is required'}), 400
+
+ if not command:
+ return jsonify({'success': False, 'error': 'Command is required'}), 400
+
+ result = CronService.add_job(
+ schedule=schedule,
+ command=command,
+ name=name,
+ description=description
+ )
+
+ if result.get('success'):
+ return jsonify(result), 201
+ return jsonify(result), 400
+
+
+@cron_bp.route('/jobs/<job_id>', methods=['DELETE'])
+@jwt_required()
+def delete_job(job_id):
+ """Delete a cron job."""
+ result = CronService.remove_job(job_id)
+
+ if result.get('success'):
+ return jsonify(result)
+ return jsonify(result), 400
+
+
+@cron_bp.route('/jobs/<job_id>/toggle', methods=['POST'])
+@jwt_required()
+def toggle_job(job_id):
+ """Enable or disable a cron job."""
+ data = request.get_json()
+ enabled = data.get('enabled', True)
+
+ result = CronService.toggle_job(job_id, enabled)
+
+ if result.get('success'):
+ return jsonify(result)
+ return jsonify(result), 400
+
+
+@cron_bp.route('/jobs/<job_id>/run', methods=['POST'])
+@jwt_required()
+def run_job(job_id):
+ """Run a job immediately."""
+ result = CronService.run_job_now(job_id)
+
+ if result.get('success'):
+ return jsonify(result)
+ return jsonify(result), 400
+
+
+@cron_bp.route('/presets', methods=['GET'])
+@jwt_required()
+def get_presets():
+ """Get available schedule presets."""
+ result = CronService.get_presets()
+ return jsonify(result)
diff --git a/backend/app/services/cron_service.py b/backend/app/services/cron_service.py
new file mode 100644
index 00000000..875569c7
--- /dev/null
+++ b/backend/app/services/cron_service.py
@@ -0,0 +1,543 @@
+"""
+Cron Job Management Service
+
+Manages scheduled tasks using cron (Linux) or provides a simple job scheduler
+for cross-platform compatibility.
+"""
+
+import os
+import re
+import subprocess
+import platform
+from typing import Dict, List, Optional
+from datetime import datetime
+import json
+
+# Path for storing job metadata
+JOBS_FILE = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'data', 'cron_jobs.json')
+
+
+class CronService:
+ """Service for managing cron jobs and scheduled tasks."""
+
+ # Common cron schedule presets
+ PRESETS = {
+ 'every_minute': '* * * * *',
+ 'every_5_minutes': '*/5 * * * *',
+ 'every_15_minutes': '*/15 * * * *',
+ 'every_30_minutes': '*/30 * * * *',
+ 'hourly': '0 * * * *',
+ 'daily': '0 0 * * *',
+ 'daily_midnight': '0 0 * * *',
+ 'daily_noon': '0 12 * * *',
+ 'weekly': '0 0 * * 0',
+ 'monthly': '0 0 1 * *',
+ 'yearly': '0 0 1 1 *',
+ }
+
+ @classmethod
+ def _ensure_data_dir(cls):
+ """Ensure data directory exists."""
+ data_dir = os.path.dirname(JOBS_FILE)
+ if not os.path.exists(data_dir):
+ os.makedirs(data_dir, exist_ok=True)
+
+ @classmethod
+ def _load_jobs_metadata(cls) -> Dict:
+ """Load job metadata from file."""
+ cls._ensure_data_dir()
+ if os.path.exists(JOBS_FILE):
+ try:
+ with open(JOBS_FILE, 'r') as f:
+ return json.load(f)
+ except (json.JSONDecodeError, IOError):
+ pass
+ return {'jobs': {}}
+
+ @classmethod
+ def _save_jobs_metadata(cls, data: Dict):
+ """Save job metadata to file."""
+ cls._ensure_data_dir()
+ with open(JOBS_FILE, 'w') as f:
+ json.dump(data, f, indent=2)
+
+ @classmethod
+ def is_linux(cls) -> bool:
+ """Check if running on Linux."""
+ return platform.system() == 'Linux'
+
+ @classmethod
+ def get_status(cls) -> Dict:
+ """Get cron service status."""
+ if cls.is_linux():
+ # Check if cron daemon is running
+ try:
+ result = subprocess.run(
+ ['systemctl', 'is-active', 'cron'],
+ capture_output=True,
+ text=True,
+ timeout=5
+ )
+ cron_active = result.stdout.strip() == 'active'
+ except (subprocess.SubprocessError, FileNotFoundError):
+ # Try alternative check
+ try:
+ result = subprocess.run(
+ ['pgrep', '-x', 'cron'],
+ capture_output=True,
+ text=True,
+ timeout=5
+ )
+ cron_active = result.returncode == 0
+ except (subprocess.SubprocessError, FileNotFoundError):
+ cron_active = False
+
+ return {
+ 'available': True,
+ 'running': cron_active,
+ 'platform': 'linux',
+ 'type': 'cron'
+ }
+ else:
+ # Windows - use internal scheduler simulation
+ return {
+ 'available': True,
+ 'running': True,
+ 'platform': 'windows',
+ 'type': 'serverkit_scheduler',
+ 'note': 'Using ServerKit internal scheduler (cron syntax supported for display)'
+ }
+
+ @classmethod
+ def list_jobs(cls) -> Dict:
+ """List all cron jobs."""
+ jobs = []
+ metadata = cls._load_jobs_metadata()
+
+ if cls.is_linux():
+ try:
+ # Get current user's crontab
+ result = subprocess.run(
+ ['crontab', '-l'],
+ capture_output=True,
+ text=True,
+ timeout=10
+ )
+
+ if result.returncode == 0:
+ lines = result.stdout.strip().split('\n')
+ for i, line in enumerate(lines):
+ line = line.strip()
+ # Skip empty lines and comments
+ if not line or line.startswith('#'):
+ continue
+
+ # Parse cron line
+ job = cls._parse_cron_line(line, i)
+ if job:
+ # Add metadata if available
+ job_id = job.get('id', str(i))
+ if job_id in metadata.get('jobs', {}):
+ job.update(metadata['jobs'][job_id])
+ jobs.append(job)
+
+ except subprocess.SubprocessError as e:
+ return {'success': False, 'error': str(e), 'jobs': []}
+ else:
+ # Return jobs from metadata for non-Linux systems
+ for job_id, job_data in metadata.get('jobs', {}).items():
+ jobs.append({
+ 'id': job_id,
+ **job_data,
+ 'source': 'serverkit'
+ })
+
+ return {
+ 'success': True,
+ 'jobs': jobs,
+ 'count': len(jobs)
+ }
+
+ @classmethod
+ def _parse_cron_line(cls, line: str, index: int) -> Optional[Dict]:
+ """Parse a cron line into a job dict."""
+ # Standard cron format: minute hour day month weekday command
+ pattern = r'^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$'
+ match = re.match(pattern, line)
+
+ if not match:
+ return None
+
+ minute, hour, day, month, weekday, command = match.groups()
+ schedule = f"{minute} {hour} {day} {month} {weekday}"
+
+ return {
+ 'id': f"cron_{index}",
+ 'schedule': schedule,
+ 'command': command,
+ 'minute': minute,
+ 'hour': hour,
+ 'day': day,
+ 'month': month,
+ 'weekday': weekday,
+ 'enabled': True,
+ 'description': cls._describe_schedule(schedule),
+ 'source': 'crontab'
+ }
+
+ @classmethod
+ def _describe_schedule(cls, schedule: str) -> str:
+ """Generate human-readable description of cron schedule."""
+ # Check against presets
+ for name, preset in cls.PRESETS.items():
+ if schedule == preset:
+ return name.replace('_', ' ').title()
+
+ parts = schedule.split()
+ if len(parts) != 5:
+ return schedule
+
+ minute, hour, day, month, weekday = parts
+
+ descriptions = []
+
+ # Minute
+ if minute == '*':
+ descriptions.append('every minute')
+ elif minute.startswith('*/'):
+ descriptions.append(f'every {minute[2:]} minutes')
+ elif minute == '0':
+ pass # Will be described with hour
+ else:
+ descriptions.append(f'at minute {minute}')
+
+ # Hour
+ if hour == '*':
+ if minute != '*' and not minute.startswith('*/'):
+ descriptions.append('every hour')
+ elif hour.startswith('*/'):
+ descriptions.append(f'every {hour[2:]} hours')
+ else:
+ descriptions.append(f'at {hour}:{minute.zfill(2) if minute != "*" else "00"}')
+
+ # Day of month
+ if day != '*':
+ descriptions.append(f'on day {day}')
+
+ # Month
+ if month != '*':
+ month_names = ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
+ try:
+ month_name = month_names[int(month)]
+ descriptions.append(f'in {month_name}')
+ except (ValueError, IndexError):
+ descriptions.append(f'month {month}')
+
+ # Day of week
+ if weekday != '*':
+ day_names = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
+ try:
+ day_name = day_names[int(weekday)]
+ descriptions.append(f'on {day_name}')
+ except (ValueError, IndexError):
+ descriptions.append(f'weekday {weekday}')
+
+ return ', '.join(descriptions) if descriptions else schedule
+
+ @classmethod
+ def add_job(cls, schedule: str, command: str, name: str = None,
+ description: str = None) -> Dict:
+ """Add a new cron job."""
+ # Validate schedule format
+ if not cls._validate_schedule(schedule):
+ return {'success': False, 'error': 'Invalid cron schedule format'}
+
+ # Validate command (basic security check)
+ if not command or not command.strip():
+ return {'success': False, 'error': 'Command cannot be empty'}
+
+ # Generate job ID
+ job_id = f"job_{datetime.now().strftime('%Y%m%d%H%M%S')}"
+
+ metadata = cls._load_jobs_metadata()
+
+ if cls.is_linux():
+ try:
+ # Get current crontab
+ result = subprocess.run(
+ ['crontab', '-l'],
+ capture_output=True,
+ text=True,
+ timeout=10
+ )
+
+ current_crontab = result.stdout if result.returncode == 0 else ''
+
+ # Add comment and new job
+ comment = f"# ServerKit Job: {name or job_id}"
+ new_line = f"{schedule} {command}"
+ new_crontab = f"{current_crontab.rstrip()}\n{comment}\n{new_line}\n"
+
+ # Install new crontab
+ process = subprocess.Popen(
+ ['crontab', '-'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ text=True
+ )
+ stdout, stderr = process.communicate(input=new_crontab, timeout=10)
+
+ if process.returncode != 0:
+ return {'success': False, 'error': stderr or 'Failed to install crontab'}
+
+ except subprocess.SubprocessError as e:
+ return {'success': False, 'error': str(e)}
+
+ # Save metadata
+ metadata['jobs'][job_id] = {
+ 'name': name or f'Job {job_id}',
+ 'schedule': schedule,
+ 'command': command,
+ 'description': description or cls._describe_schedule(schedule),
+ 'enabled': True,
+ 'created_at': datetime.now().isoformat(),
+ 'updated_at': datetime.now().isoformat()
+ }
+ cls._save_jobs_metadata(metadata)
+
+ return {
+ 'success': True,
+ 'job_id': job_id,
+ 'message': 'Job created successfully'
+ }
+
+ @classmethod
+ def remove_job(cls, job_id: str) -> Dict:
+ """Remove a cron job."""
+ metadata = cls._load_jobs_metadata()
+
+ if job_id not in metadata.get('jobs', {}):
+ # Try to find by cron index
+ pass
+
+ job_data = metadata.get('jobs', {}).get(job_id)
+
+ if cls.is_linux() and job_data:
+ try:
+ # Get current crontab
+ result = subprocess.run(
+ ['crontab', '-l'],
+ capture_output=True,
+ text=True,
+ timeout=10
+ )
+
+ if result.returncode == 0:
+ lines = result.stdout.split('\n')
+ command = job_data.get('command', '')
+ schedule = job_data.get('schedule', '')
+
+ # Filter out the job and its comment
+ new_lines = []
+ skip_next = False
+ for line in lines:
+ if skip_next:
+ skip_next = False
+ continue
+ if f"# ServerKit Job:" in line and job_id in line:
+ skip_next = True
+ continue
+ if command and schedule and f"{schedule} {command}" in line:
+ continue
+ new_lines.append(line)
+
+ new_crontab = '\n'.join(new_lines)
+
+ # Install updated crontab
+ process = subprocess.Popen(
+ ['crontab', '-'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ text=True
+ )
+ stdout, stderr = process.communicate(input=new_crontab, timeout=10)
+
+ if process.returncode != 0:
+ return {'success': False, 'error': stderr or 'Failed to update crontab'}
+
+ except subprocess.SubprocessError as e:
+ return {'success': False, 'error': str(e)}
+
+ # Remove from metadata
+ if job_id in metadata.get('jobs', {}):
+ del metadata['jobs'][job_id]
+ cls._save_jobs_metadata(metadata)
+
+ return {'success': True, 'message': 'Job removed successfully'}
+
+ @classmethod
+ def toggle_job(cls, job_id: str, enabled: bool) -> Dict:
+ """Enable or disable a cron job."""
+ metadata = cls._load_jobs_metadata()
+
+ if job_id not in metadata.get('jobs', {}):
+ return {'success': False, 'error': 'Job not found'}
+
+ job_data = metadata['jobs'][job_id]
+
+ if cls.is_linux():
+ try:
+ result = subprocess.run(
+ ['crontab', '-l'],
+ capture_output=True,
+ text=True,
+ timeout=10
+ )
+
+ if result.returncode == 0:
+ lines = result.stdout.split('\n')
+ command = job_data.get('command', '')
+ schedule = job_data.get('schedule', '')
+ job_line = f"{schedule} {command}"
+
+ new_lines = []
+ for line in lines:
+ if job_line in line:
+ if enabled:
+ # Remove leading # if present
+ new_lines.append(line.lstrip('# '))
+ else:
+ # Add # to comment out
+ if not line.startswith('#'):
+ new_lines.append(f"# {line}")
+ else:
+ new_lines.append(line)
+ else:
+ new_lines.append(line)
+
+ new_crontab = '\n'.join(new_lines)
+
+ process = subprocess.Popen(
+ ['crontab', '-'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ text=True
+ )
+ stdout, stderr = process.communicate(input=new_crontab, timeout=10)
+
+ if process.returncode != 0:
+ return {'success': False, 'error': stderr}
+
+ except subprocess.SubprocessError as e:
+ return {'success': False, 'error': str(e)}
+
+ # Update metadata
+ metadata['jobs'][job_id]['enabled'] = enabled
+ metadata['jobs'][job_id]['updated_at'] = datetime.now().isoformat()
+ cls._save_jobs_metadata(metadata)
+
+ return {
+ 'success': True,
+ 'enabled': enabled,
+ 'message': f"Job {'enabled' if enabled else 'disabled'} successfully"
+ }
+
+ @classmethod
+ def _validate_schedule(cls, schedule: str) -> bool:
+ """Validate cron schedule format."""
+ parts = schedule.split()
+ if len(parts) != 5:
+ return False
+
+ # Basic validation for each field
+ patterns = [
+ r'^(\*|([0-9]|[1-5][0-9])(-([0-9]|[1-5][0-9]))?)(,(\*|([0-9]|[1-5][0-9])(-([0-9]|[1-5][0-9]))?))*(/[0-9]+)?$', # minute
+ r'^(\*|([0-9]|1[0-9]|2[0-3])(-([0-9]|1[0-9]|2[0-3]))?)(,(\*|([0-9]|1[0-9]|2[0-3])(-([0-9]|1[0-9]|2[0-3]))?))*(/[0-9]+)?$', # hour
+ r'^(\*|([1-9]|[12][0-9]|3[01])(-([1-9]|[12][0-9]|3[01]))?)(,(\*|([1-9]|[12][0-9]|3[01])(-([1-9]|[12][0-9]|3[01]))?))*(/[0-9]+)?$', # day
+ r'^(\*|([1-9]|1[0-2])(-([1-9]|1[0-2]))?)(,(\*|([1-9]|1[0-2])(-([1-9]|1[0-2]))?))*(/[0-9]+)?$', # month
+ r'^(\*|[0-6](-[0-6])?)(,(\*|[0-6](-[0-6])?))*(/[0-9]+)?$', # weekday
+ ]
+
+ for i, part in enumerate(parts):
+ # Simplified validation - accept common patterns
+ if part == '*':
+ continue
+ if part.startswith('*/') and part[2:].isdigit():
+ continue
+ if part.isdigit():
+ continue
+ if ',' in part:
+ # Check comma-separated values
+ if all(p.isdigit() or p == '*' for p in part.split(',')):
+ continue
+ if '-' in part:
+ # Check range
+ range_parts = part.split('-')
+ if len(range_parts) == 2 and all(p.isdigit() for p in range_parts):
+ continue
+ # Allow complex patterns
+ try:
+ if re.match(patterns[i], part):
+ continue
+ except (re.error, IndexError):
+ pass
+
+ # If we got here with a simple pattern that looks valid, accept it
+ if re.match(r'^[\d\*,\-/]+$', part):
+ continue
+
+ return False
+
+ return True
+
+ @classmethod
+ def get_presets(cls) -> Dict:
+ """Get available schedule presets."""
+ return {
+ 'success': True,
+ 'presets': [
+ {'name': name, 'schedule': schedule, 'description': cls._describe_schedule(schedule)}
+ for name, schedule in cls.PRESETS.items()
+ ]
+ }
+
+ @classmethod
+ def run_job_now(cls, job_id: str) -> Dict:
+ """Execute a job immediately."""
+ metadata = cls._load_jobs_metadata()
+
+ if job_id not in metadata.get('jobs', {}):
+ return {'success': False, 'error': 'Job not found'}
+
+ job_data = metadata['jobs'][job_id]
+ command = job_data.get('command', '')
+
+ if not command:
+ return {'success': False, 'error': 'Job has no command'}
+
+ try:
+ # Run the command
+ result = subprocess.run(
+ command,
+ shell=True,
+ capture_output=True,
+ text=True,
+ timeout=60
+ )
+
+ return {
+ 'success': True,
+ 'exit_code': result.returncode,
+ 'stdout': result.stdout,
+ 'stderr': result.stderr,
+ 'message': 'Job executed'
+ }
+
+ except subprocess.TimeoutExpired:
+ return {'success': False, 'error': 'Job execution timed out (60s limit)'}
+ except subprocess.SubprocessError as e:
+ return {'success': False, 'error': str(e)}
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index 392e1236..3f05a142 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -20,6 +20,7 @@ import FileManager from './pages/FileManager';
import FTPServer from './pages/FTPServer';
import PHP from './pages/PHP';
import Firewall from './pages/Firewall';
+import CronJobs from './pages/CronJobs';
function PrivateRoute({ children }) {
const { isAuthenticated, loading } = useAuth();
@@ -72,6 +73,7 @@ function AppRoutes() {
<Route path="ftp" element={<FTPServer />} />
<Route path="monitoring" element={<Monitoring />} />
<Route path="backups" element={<Backups />} />
+ <Route path="cron" element={<CronJobs />} />
<Route path="terminal" element={<Terminal />} />
<Route path="settings" element={<Settings />} />
</Route>
diff --git a/frontend/src/components/Sidebar.jsx b/frontend/src/components/Sidebar.jsx
index 2e74ef44..0c895bbe 100644
--- a/frontend/src/components/Sidebar.jsx
+++ b/frontend/src/components/Sidebar.jsx
@@ -117,6 +117,13 @@ const Sidebar = () => {
</svg>
Backups
</NavLink>
+ <NavLink to="/cron" className={({ isActive }) => `nav-item ${isActive ? 'active' : ''}`}>
+ <svg viewBox="0 0 24 24">
+ <circle cx="12" cy="12" r="10"/>
+ <polyline points="12 6 12 12 16 14"/>
+ </svg>
+ Cron Jobs
+ </NavLink>
</nav>
<div className="menu-label">System</div>
diff --git a/frontend/src/pages/CronJobs.jsx b/frontend/src/pages/CronJobs.jsx
new file mode 100644
index 00000000..8de92fc5
--- /dev/null
+++ b/frontend/src/pages/CronJobs.jsx
@@ -0,0 +1,440 @@
+import React, { useState, useEffect } from 'react';
+import api from '../services/api';
+import { useToast } from '../contexts/ToastContext';
+
+const CronJobs = () => {
+ const toast = useToast();
+ const [status, setStatus] = useState(null);
+ const [jobs, setJobs] = useState([]);
+ const [presets, setPresets] = useState({});
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState(null);
+
+ // Modal states
+ const [showCreateModal, setShowCreateModal] = useState(false);
+ const [runningJobId, setRunningJobId] = useState(null);
+
+ // Form state
+ const [jobForm, setJobForm] = useState({
+ name: '',
+ command: '',
+ schedule: '',
+ description: '',
+ usePreset: true,
+ preset: 'daily'
+ });
+
+ useEffect(() => {
+ loadData();
+ }, []);
+
+ const loadData = async () => {
+ try {
+ setLoading(true);
+ const [statusRes, jobsRes, presetsRes] = await Promise.all([
+ api.getCronStatus(),
+ api.getCronJobs(),
+ api.getCronPresets()
+ ]);
+
+ setStatus(statusRes);
+ setJobs(jobsRes.jobs || []);
+ setPresets(presetsRes.presets || {});
+ } catch (err) {
+ setError(err.message);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ const handleCreateJob = async (e) => {
+ e.preventDefault();
+ try {
+ const schedule = jobForm.usePreset
+ ? presets[jobForm.preset]
+ : jobForm.schedule;
+
+ await api.createCronJob({
+ name: jobForm.name,
+ command: jobForm.command,
+ schedule: schedule,
+ description: jobForm.description
+ });
+
+ toast.success('Cron job created successfully');
+ setShowCreateModal(false);
+ resetForm();
+ loadData();
+ } catch (err) {
+ toast.error(err.message);
+ }
+ };
+
+ const handleDeleteJob = async (jobId) => {
+ if (!window.confirm('Are you sure you want to delete this cron job?')) return;
+ try {
+ await api.deleteCronJob(jobId);
+ toast.success('Cron job deleted');
+ loadData();
+ } catch (err) {
+ toast.error(err.message);
+ }
+ };
+
+ const handleToggleJob = async (jobId, currentEnabled) => {
+ try {
+ await api.toggleCronJob(jobId, !currentEnabled);
+ toast.success(`Cron job ${!currentEnabled ? 'enabled' : 'disabled'}`);
+ loadData();
+ } catch (err) {
+ toast.error(err.message);
+ }
+ };
+
+ const handleRunJob = async (jobId) => {
+ try {
+ setRunningJobId(jobId);
+ const result = await api.runCronJob(jobId);
+ if (result.success) {
+ toast.success('Job executed successfully');
+ } else {
+ toast.error(result.error || 'Job execution failed');
+ }
+ } catch (err) {
+ toast.error(err.message);
+ } finally {
+ setRunningJobId(null);
+ }
+ };
+
+ const resetForm = () => {
+ setJobForm({
+ name: '',
+ command: '',
+ schedule: '',
+ description: '',
+ usePreset: true,
+ preset: 'daily'
+ });
+ };
+
+ const formatSchedule = (schedule) => {
+ const presetEntry = Object.entries(presets).find(([, value]) => value === schedule);
+ if (presetEntry) {
+ return presetEntry[0].replace(/_/g, ' ');
+ }
+ return schedule;
+ };
+
+ const getScheduleDescription = (schedule) => {
+ const descriptions = {
+ '* * * * *': 'Every minute',
+ '0 * * * *': 'Every hour',
+ '0 0 * * *': 'Daily at midnight',
+ '0 0 * * 0': 'Weekly on Sunday',
+ '0 0 1 * *': 'Monthly on the 1st',
+ '0 0 * * 1-5': 'Weekdays at midnight',
+ '0 */6 * * *': 'Every 6 hours',
+ '0 */12 * * *': 'Every 12 hours',
+ '*/5 * * * *': 'Every 5 minutes',
+ '*/15 * * * *': 'Every 15 minutes',
+ '*/30 * * * *': 'Every 30 minutes'
+ };
+ return descriptions[schedule] || schedule;
+ };
+
+ if (loading) {
+ return <div className="page"><div className="loading">Loading cron jobs...</div></div>;
+ }
+
+ return (
+ <div className="page cron-page">
+ <div className="page-header">
+ <div>
+ <h1>Cron Jobs</h1>
+ <p className="page-subtitle">Manage scheduled tasks and automated jobs</p>
+ </div>
+ <div className="page-actions">
+ <button className="btn btn-secondary" onClick={loadData}>
+ <svg viewBox="0 0 24 24" width="16" height="16">
+ <polyline points="23 4 23 10 17 10"/>
+ <polyline points="1 20 1 14 7 14"/>
+ <path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/>
+ </svg>
+ Refresh
+ </button>
+ <button className="btn btn-primary" onClick={() => setShowCreateModal(true)}>
+ <svg viewBox="0 0 24 24" width="16" height="16">
+ <line x1="12" y1="5" x2="12" y2="19"/>
+ <line x1="5" y1="12" x2="19" y2="12"/>
+ </svg>
+ Create Job
+ </button>
+ </div>
+ </div>
+
+ {error && (
+ <div className="alert alert-danger">
+ {error}
+ <button onClick={() => setError(null)} className="alert-close">&times;</button>
+ </div>
+ )}
+
+ {/* Status Cards */}
+ <div className="stats-grid">
+ <div className="stat-card">
+ <div className="stat-icon cron">
+ <svg viewBox="0 0 24 24" width="24" height="24">
+ <circle cx="12" cy="12" r="10"/>
+ <polyline points="12 6 12 12 16 14"/>
+ </svg>
+ </div>
+ <div className="stat-content">
+ <span className="stat-label">Cron Service</span>
+ <span className="stat-value">{status?.cron_available ? 'Available' : 'Not Available'}</span>
+ </div>
+ </div>
+
+ <div className="stat-card">
+ <div className="stat-icon jobs">
+ <svg viewBox="0 0 24 24" width="24" height="24">
+ <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
+ <polyline points="14 2 14 8 20 8"/>
+ <line x1="16" y1="13" x2="8" y2="13"/>
+ <line x1="16" y1="17" x2="8" y2="17"/>
+ <polyline points="10 9 9 9 8 9"/>
+ </svg>
+ </div>
+ <div className="stat-content">
+ <span className="stat-label">Total Jobs</span>
+ <span className="stat-value">{jobs.length}</span>
+ </div>
+ </div>
+
+ <div className="stat-card">
+ <div className="stat-icon active">
+ <svg viewBox="0 0 24 24" width="24" height="24">
+ <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
+ <polyline points="22 4 12 14.01 9 11.01"/>
+ </svg>
+ </div>
+ <div className="stat-content">
+ <span className="stat-label">Active Jobs</span>
+ <span className="stat-value">{jobs.filter(j => j.enabled).length}</span>
+ </div>
+ </div>
+
+ <div className="stat-card">
+ <div className="stat-icon platform">
+ <svg viewBox="0 0 24 24" width="24" height="24">
+ <rect x="2" y="3" width="20" height="14" rx="2" ry="2"/>
+ <line x1="8" y1="21" x2="16" y2="21"/>
+ <line x1="12" y1="17" x2="12" y2="21"/>
+ </svg>
+ </div>
+ <div className="stat-content">
+ <span className="stat-label">Platform</span>
+ <span className="stat-value">{status?.platform || 'Unknown'}</span>
+ </div>
+ </div>
+ </div>
+
+ {/* Jobs List */}
+ <div className="card">
+ <div className="card-header">
+ <h3>Scheduled Jobs</h3>
+ </div>
+ <div className="card-body">
+ {jobs.length === 0 ? (
+ <div className="empty-state">
+ <svg viewBox="0 0 24 24" width="48" height="48">
+ <circle cx="12" cy="12" r="10"/>
+ <polyline points="12 6 12 12 16 14"/>
+ </svg>
+ <h3>No Cron Jobs</h3>
+ <p>No scheduled jobs found. Create your first cron job to automate tasks.</p>
+ <button className="btn btn-primary" onClick={() => setShowCreateModal(true)}>
+ Create Job
+ </button>
+ </div>
+ ) : (
+ <div className="cron-list">
+ {jobs.map((job) => (
+ <div key={job.id} className={`cron-item ${!job.enabled ? 'disabled' : ''}`}>
+ <div className="cron-item-info">
+ <div className="cron-item-icon">
+ <svg viewBox="0 0 24 24" width="20" height="20">
+ <circle cx="12" cy="12" r="10"/>
+ <polyline points="12 6 12 12 16 14"/>
+ </svg>
+ </div>
+ <div className="cron-item-details">
+ <h3>{job.name || 'Unnamed Job'}</h3>
+ <div className="cron-item-meta">
+ <span className="mono" title={job.schedule}>
+ {getScheduleDescription(job.schedule)}
+ </span>
+ {job.description && (
+ <span className="description">{job.description}</span>
+ )}
+ </div>
+ <div className="cron-item-command">
+ <code>{job.command}</code>
+ </div>
+ </div>
+ </div>
+
+ <div className="cron-item-status">
+ <span className={`badge badge-${job.enabled ? 'success' : 'secondary'}`}>
+ {job.enabled ? 'Active' : 'Disabled'}
+ </span>
+ </div>
+
+ <div className="cron-item-actions">
+ <button
+ className="btn btn-sm btn-secondary"
+ onClick={() => handleRunJob(job.id)}
+ disabled={runningJobId === job.id}
+ title="Run now"
+ >
+ {runningJobId === job.id ? (
+ <span className="spinner-inline"></span>
+ ) : (
+ <svg viewBox="0 0 24 24" width="14" height="14">
+ <polygon points="5 3 19 12 5 21 5 3"/>
+ </svg>
+ )}
+ </button>
+ <button
+ className={`btn btn-sm ${job.enabled ? 'btn-warning' : 'btn-success'}`}
+ onClick={() => handleToggleJob(job.id, job.enabled)}
+ title={job.enabled ? 'Disable' : 'Enable'}
+ >
+ {job.enabled ? (
+ <svg viewBox="0 0 24 24" width="14" height="14">
+ <rect x="6" y="4" width="4" height="16"/>
+ <rect x="14" y="4" width="4" height="16"/>
+ </svg>
+ ) : (
+ <svg viewBox="0 0 24 24" width="14" height="14">
+ <polygon points="5 3 19 12 5 21 5 3"/>
+ </svg>
+ )}
+ </button>
+ <button
+ className="btn btn-sm btn-danger"
+ onClick={() => handleDeleteJob(job.id)}
+ title="Delete"
+ >
+ <svg viewBox="0 0 24 24" width="14" height="14">
+ <polyline points="3 6 5 6 21 6"/>
+ <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
+ </svg>
+ </button>
+ </div>
+ </div>
+ ))}
+ </div>
+ )}
+ </div>
+ </div>
+
+ {/* Create Job Modal */}
+ {showCreateModal && (
+ <div className="modal-overlay" onClick={() => setShowCreateModal(false)}>
+ <div className="modal" onClick={e => e.stopPropagation()}>
+ <div className="modal-header">
+ <h2>Create Cron Job</h2>
+ <button className="modal-close" onClick={() => setShowCreateModal(false)}>&times;</button>
+ </div>
+ <form onSubmit={handleCreateJob}>
+ <div className="modal-body">
+ <div className="form-group">
+ <label>Job Name</label>
+ <input
+ type="text"
+ value={jobForm.name}
+ onChange={(e) => setJobForm({...jobForm, name: e.target.value})}
+ placeholder="My Backup Job"
+ required
+ />
+ </div>
+
+ <div className="form-group">
+ <label>Command</label>
+ <input
+ type="text"
+ value={jobForm.command}
+ onChange={(e) => setJobForm({...jobForm, command: e.target.value})}
+ placeholder="/usr/bin/backup.sh"
+ required
+ />
+ <span className="form-help">The command or script to execute</span>
+ </div>
+
+ <div className="form-group">
+ <label className="checkbox-label">
+ <input
+ type="checkbox"
+ checked={jobForm.usePreset}
+ onChange={(e) => setJobForm({...jobForm, usePreset: e.target.checked})}
+ />
+ <span>Use preset schedule</span>
+ </label>
+ </div>
+
+ {jobForm.usePreset ? (
+ <div className="form-group">
+ <label>Schedule Preset</label>
+ <select
+ value={jobForm.preset}
+ onChange={(e) => setJobForm({...jobForm, preset: e.target.value})}
+ >
+ {Object.entries(presets).map(([key, value]) => (
+ <option key={key} value={key}>
+ {key.replace(/_/g, ' ')} ({value})
+ </option>
+ ))}
+ </select>
+ </div>
+ ) : (
+ <div className="form-group">
+ <label>Cron Schedule</label>
+ <input
+ type="text"
+ value={jobForm.schedule}
+ onChange={(e) => setJobForm({...jobForm, schedule: e.target.value})}
+ placeholder="0 0 * * *"
+ required={!jobForm.usePreset}
+ />
+ <span className="form-help">
+ Format: minute hour day month weekday (e.g., "0 0 * * *" for daily at midnight)
+ </span>
+ </div>
+ )}
+
+ <div className="form-group">
+ <label>Description (optional)</label>
+ <textarea
+ value={jobForm.description}
+ onChange={(e) => setJobForm({...jobForm, description: e.target.value})}
+ placeholder="What does this job do?"
+ rows="2"
+ />
+ </div>
+ </div>
+ <div className="modal-footer">
+ <button type="button" className="btn btn-secondary" onClick={() => setShowCreateModal(false)}>
+ Cancel
+ </button>
+ <button type="submit" className="btn btn-primary">Create Job</button>
+ </div>
+ </form>
+ </div>
+ </div>
+ )}
+ </div>
+ );
+};
+
+export default CronJobs;
diff --git a/frontend/src/pages/Docker.jsx b/frontend/src/pages/Docker.jsx
index 036789a3..38bca113 100644
--- a/frontend/src/pages/Docker.jsx
+++ b/frontend/src/pages/Docker.jsx
@@ -28,19 +28,46 @@ const Docker = () => {
if (!dockerStatus?.installed) {
return (
- <div>
- <header className="top-bar">
- <div>
+ <div className="page docker-page">
+ <div className="page-header">
+ <div className="page-header-content">
<h1>Docker</h1>
- <div className="subtitle">Container management</div>
+ <p className="page-description">Container management</p>
</div>
- </header>
- <div className="empty-state">
- <svg viewBox="0 0 24 24" width="48" height="48" stroke="currentColor" fill="none" strokeWidth="1.5">
- <path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/>
- </svg>
- <h3>Docker not available</h3>
- <p>{dockerStatus?.error || 'Docker is not installed or running on this server.'}</p>
+ </div>
+ <div className="docker-unavailable">
+ <div className="docker-unavailable-icon">
+ <svg viewBox="0 0 24 24" width="64" height="64" stroke="currentColor" fill="none" strokeWidth="1">
+ <rect x="2" y="7" width="5" height="5" rx="1"/>
+ <rect x="9" y="7" width="5" height="5" rx="1"/>
+ <rect x="16" y="7" width="5" height="5" rx="1"/>
+ <rect x="2" y="14" width="5" height="5" rx="1"/>
+ <rect x="9" y="14" width="5" height="5" rx="1"/>
+ <path d="M21 12c0 4-3 7-8 7s-8-3-8-7" strokeDasharray="2 2"/>
+ </svg>
+ </div>
+ <h2>Docker Not Available</h2>
+ <p className="docker-unavailable-message">
+ Docker is not installed or not running on this system.
+ </p>
+ <div className="docker-unavailable-details">
+ <code>{dockerStatus?.error || 'Unable to connect to Docker daemon'}</code>
+ </div>
+ <div className="docker-unavailable-help">
+ <h4>To use Docker management:</h4>
+ <ul>
+ <li>Ensure Docker Desktop is installed and running</li>
+ <li>On Linux, make sure the Docker daemon is started</li>
+ <li>Verify the user has permissions to access Docker</li>
+ </ul>
+ </div>
+ <button className="btn btn-primary" onClick={checkDockerStatus}>
+ <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">
+ <path d="M23 4v6h-6M1 20v-6h6"/>
+ <path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/>
+ </svg>
+ Retry Connection
+ </button>
</div>
</div>
);
diff --git a/frontend/src/services/api.js b/frontend/src/services/api.js
index ededf680..05663916 100644
--- a/frontend/src/services/api.js
+++ b/frontend/src/services/api.js
@@ -1456,6 +1456,43 @@ class ApiService {
body: { firewall }
});
}
+
+ // ========================================
+ // Cron Job endpoints
+ // ========================================
+ async getCronStatus() {
+ return this.request('/cron/status');
+ }
+
+ async getCronJobs() {
+ return this.request('/cron/jobs');
+ }
+
+ async createCronJob(data) {
+ return this.request('/cron/jobs', {
+ method: 'POST',
+ body: data
+ });
+ }
+
+ async deleteCronJob(jobId) {
+ return this.request(`/cron/jobs/${jobId}`, { method: 'DELETE' });
+ }
+
+ async toggleCronJob(jobId, enabled) {
+ return this.request(`/cron/jobs/${jobId}/toggle`, {
+ method: 'POST',
+ body: { enabled }
+ });
+ }
+
+ async runCronJob(jobId) {
+ return this.request(`/cron/jobs/${jobId}/run`, { method: 'POST' });
+ }
+
+ async getCronPresets() {
+ return this.request('/cron/presets');
+ }
}
export const api = new ApiService();
diff --git a/frontend/src/styles/main.less b/frontend/src/styles/main.less
index 88e0e21c..f053f9e6 100644
--- a/frontend/src/styles/main.less
+++ b/frontend/src/styles/main.less
@@ -57,3 +57,4 @@
@import 'pages/_ftp-server';
@import 'pages/_php';
@import 'pages/_firewall';
+@import 'pages/_cron';
diff --git a/frontend/src/styles/pages/_cron.less b/frontend/src/styles/pages/_cron.less
new file mode 100644
index 00000000..8e36f2ec
--- /dev/null
+++ b/frontend/src/styles/pages/_cron.less
@@ -0,0 +1,181 @@
+// ============================================
+// CRON JOBS PAGE
+// ============================================
+
+.cron-page {
+ .page-header {
+ margin-bottom: @space-6;
+
+ .page-header-content {
+ h1 {
+ font-size: @font-size-2xl;
+ font-weight: @font-weight-semibold;
+ margin: 0 0 @space-1 0;
+ }
+
+ .page-description {
+ color: @text-secondary;
+ margin: 0;
+ }
+ }
+ }
+}
+
+// Stats icons
+.stat-icon {
+ &.cron {
+ background: fade(@accent-primary, 10%);
+ color: @accent-primary;
+ }
+
+ &.jobs {
+ background: fade(@color-docker, 10%);
+ color: @color-docker;
+ }
+
+ &.active {
+ background: fade(@success, 10%);
+ color: @success;
+ }
+
+ &.platform {
+ background: fade(@warning, 10%);
+ color: @warning;
+ }
+}
+
+.cron-list {
+ .flex-column-gap(@space-3);
+}
+
+.cron-item {
+ .list-item-base();
+ transition: opacity 0.2s ease;
+
+ &.disabled {
+ opacity: 0.6;
+
+ .cron-item-icon {
+ color: @text-tertiary;
+ }
+ }
+}
+
+.cron-item-info {
+ .flex-start();
+ gap: @space-4;
+ flex: 1;
+ min-width: 0;
+}
+
+.cron-item-icon {
+ .icon-box();
+ background: @bg-hover;
+ border-radius: @radius-lg;
+ color: @accent-primary;
+}
+
+.cron-item-details {
+ min-width: 0;
+ flex: 1;
+
+ h3 {
+ font-size: @font-size-base;
+ font-weight: @font-weight-semibold;
+ color: @text-primary;
+ margin-bottom: @space-1;
+ .truncate();
+ }
+}
+
+.cron-item-meta {
+ .flex-start();
+ gap: @space-3;
+ font-size: @font-size-sm;
+ color: @text-tertiary;
+ flex-wrap: wrap;
+ margin-bottom: @space-2;
+
+ .mono {
+ .mono-text();
+ background: @bg-hover;
+ padding: @space-1 - 2 @space-2 - 2;
+ border-radius: @radius-sm;
+ }
+
+ .description {
+ color: @text-secondary;
+ }
+}
+
+.cron-item-command {
+ code {
+ display: inline-block;
+ max-width: 100%;
+ font-family: @font-mono;
+ font-size: @font-size-xs;
+ color: @text-secondary;
+ background: @bg-hover;
+ padding: @space-1 @space-2;
+ border-radius: @radius-sm;
+ .truncate();
+ }
+}
+
+.cron-item-status {
+ flex-shrink: 0;
+ margin-right: @space-3;
+}
+
+.cron-item-actions {
+ display: flex;
+ gap: @space-2;
+ flex-shrink: 0;
+
+ .btn {
+ padding: @space-2;
+
+ svg {
+ stroke: currentColor;
+ stroke-width: 2;
+ fill: none;
+ }
+ }
+
+ .btn-warning {
+ background: fade(@warning, 10%);
+ color: @warning;
+ border: 1px solid fade(@warning, 20%);
+
+ &:hover {
+ background: fade(@warning, 20%);
+ }
+ }
+
+ .btn-success {
+ background: fade(@success, 10%);
+ color: @success;
+ border: 1px solid fade(@success, 20%);
+
+ &:hover {
+ background: fade(@success, 20%);
+ }
+ }
+}
+
+// Spinner inline for running jobs
+.spinner-inline {
+ display: inline-block;
+ width: 14px;
+ height: 14px;
+ border: 2px solid @border-subtle;
+ border-top-color: @accent-primary;
+ border-radius: 50%;
+ animation: spin 0.8s linear infinite;
+}
+
+@keyframes spin {
+ to {
+ transform: rotate(360deg);
+ }
+}
diff --git a/frontend/src/styles/pages/_docker.less b/frontend/src/styles/pages/_docker.less
index 9d24e474..75599d15 100644
--- a/frontend/src/styles/pages/_docker.less
+++ b/frontend/src/styles/pages/_docker.less
@@ -191,3 +191,126 @@
opacity: 0.5;
}
}
+
+// Docker Unavailable State
+.docker-page {
+ .page-header {
+ margin-bottom: @space-6;
+
+ .page-header-content {
+ h1 {
+ font-size: @font-size-2xl;
+ font-weight: @font-weight-semibold;
+ margin: 0 0 @space-1 0;
+ }
+
+ .page-description {
+ color: @text-secondary;
+ margin: 0;
+ }
+ }
+ }
+}
+
+.docker-unavailable {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ text-align: center;
+ padding: @space-12 @space-6;
+ background: @bg-card;
+ border: 1px solid @border-subtle;
+ border-radius: @radius-xl;
+ max-width: 600px;
+ margin: 0 auto;
+
+ .docker-unavailable-icon {
+ width: 100px;
+ height: 100px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: fade(@color-docker, 10%);
+ border-radius: @radius-xl;
+ margin-bottom: @space-6;
+
+ svg {
+ stroke: @color-docker;
+ opacity: 0.6;
+ }
+ }
+
+ h2 {
+ font-size: @font-size-xl;
+ font-weight: @font-weight-semibold;
+ margin: 0 0 @space-2 0;
+ color: @text-primary;
+ }
+
+ .docker-unavailable-message {
+ color: @text-secondary;
+ font-size: @font-size-base;
+ margin: 0 0 @space-4 0;
+ }
+
+ .docker-unavailable-details {
+ width: 100%;
+ margin-bottom: @space-6;
+
+ code {
+ display: block;
+ padding: @space-3 @space-4;
+ background: @bg-hover;
+ border: 1px solid @border-subtle;
+ border-radius: @radius-md;
+ font-family: @font-mono;
+ font-size: @font-size-xs;
+ color: @text-tertiary;
+ word-break: break-all;
+ text-align: left;
+ }
+ }
+
+ .docker-unavailable-help {
+ width: 100%;
+ padding: @space-5;
+ background: @bg-hover;
+ border-radius: @radius-lg;
+ text-align: left;
+ margin-bottom: @space-6;
+
+ h4 {
+ font-size: @font-size-sm;
+ font-weight: @font-weight-semibold;
+ margin: 0 0 @space-3 0;
+ color: @text-primary;
+ }
+
+ ul {
+ margin: 0;
+ padding-left: @space-5;
+
+ li {
+ font-size: @font-size-sm;
+ color: @text-secondary;
+ margin-bottom: @space-2;
+
+ &:last-child {
+ margin-bottom: 0;
+ }
+ }
+ }
+ }
+
+ .btn {
+ display: inline-flex;
+ align-items: center;
+ gap: @space-2;
+
+ svg {
+ width: 16px;
+ height: 16px;
+ }
+ }
+}
diff --git a/frontend/src/styles/pages/_settings.less b/frontend/src/styles/pages/_settings.less
index 443cc7cf..eab38040 100644
--- a/frontend/src/styles/pages/_settings.less
+++ b/frontend/src/styles/pages/_settings.less
@@ -3,264 +3,419 @@
// ============================================
.settings-page {
- padding: @space-6;
- max-width: 1200px;
- margin: 0 auto;
-}
+ .page-header {
+ margin-bottom: @space-6;
-.settings-header {
- margin-bottom: @space-8;
+ h1 {
+ font-size: @font-size-2xl;
+ font-weight: @font-weight-semibold;
+ margin: 0 0 @space-1 0;
+ }
- h1 {
- font-size: 1.75rem;
- font-weight: 600;
- color: @text-primary;
- margin: 0 0 @space-1 0;
+ .page-subtitle {
+ color: @text-secondary;
+ margin: 0;
+ }
}
+}
- p {
- color: @text-secondary;
- margin: 0;
+.settings-layout {
+ display: grid;
+ grid-template-columns: 240px 1fr;
+ gap: @space-6;
+ min-height: calc(100vh - 200px);
+
+ @media (max-width: @breakpoint-lg) {
+ grid-template-columns: 1fr;
}
}
-.settings-content {
+// Settings Navigation
+.settings-nav {
display: flex;
- gap: @space-8;
+ flex-direction: column;
+ gap: @space-1;
+ position: sticky;
+ top: @space-6;
+ height: fit-content;
- @media (max-width: 900px) {
- flex-direction: column;
+ @media (max-width: @breakpoint-lg) {
+ flex-direction: row;
+ flex-wrap: wrap;
+ position: static;
+ background: @bg-card;
+ padding: @space-2;
+ border-radius: @radius-lg;
}
}
-// Settings Navigation
-.settings-nav {
- flex: 0 0 220px;
+.settings-nav-item {
+ display: flex;
+ align-items: center;
+ gap: @space-3;
+ padding: @space-3 @space-4;
+ background: transparent;
+ border: none;
+ border-radius: @radius-md;
+ color: @text-secondary;
+ font-size: @font-size-sm;
+ font-weight: @font-weight-medium;
+ cursor: pointer;
+ transition: all @transition-fast;
+ text-align: left;
+ width: 100%;
- @media (max-width: 900px) {
- flex: none;
+ svg {
+ width: 18px;
+ height: 18px;
+ stroke: currentColor;
+ fill: none;
+ stroke-width: 2;
+ flex-shrink: 0;
}
- ul {
- list-style: none;
- padding: 0;
- margin: 0;
- display: flex;
- flex-direction: column;
- gap: @space-1;
+ &:hover {
+ background: @bg-hover;
+ color: @text-primary;
+ }
- @media (max-width: 900px) {
- flex-direction: row;
- flex-wrap: wrap;
+ &.active {
+ background: @accent-primary;
+ color: white;
+
+ svg {
+ stroke: white;
}
}
- li button {
- width: 100%;
- display: flex;
- align-items: center;
- gap: @space-2;
+ @media (max-width: @breakpoint-lg) {
+ width: auto;
padding: @space-2 @space-3;
- background: transparent;
- border: none;
- border-radius: @radius-md;
- color: @text-secondary;
- font-size: 0.9rem;
- cursor: pointer;
- transition: all 0.2s ease;
- text-align: left;
+ }
+}
- @media (max-width: 900px) {
- width: auto;
- }
+// Settings Content Area
+.settings-content {
+ min-width: 0;
+}
- &:hover {
- background: @bg-hover;
- color: @text-primary;
- }
+// Settings Section
+.settings-section {
+ display: flex;
+ flex-direction: column;
+ gap: @space-5;
- &.active {
- background: @accent-primary;
- color: white;
+ .section-header {
+ margin-bottom: @space-2;
+
+ h2 {
+ font-size: @font-size-lg;
+ font-weight: @font-weight-semibold;
+ margin: 0 0 @space-1 0;
}
- .nav-icon {
- font-size: 1.1rem;
- width: 20px;
- text-align: center;
+ p {
+ color: @text-secondary;
+ margin: 0;
+ font-size: @font-size-sm;
}
}
-}
-// Settings Sections Container
-.settings-sections {
- flex: 1;
- min-width: 0;
+ h3 {
+ font-size: @font-size-base;
+ font-weight: @font-weight-semibold;
+ margin: 0 0 @space-3 0;
+ color: @text-primary;
+ }
}
-// Individual Settings Section
-.settings-section {
+// Settings Cards
+.settings-card {
background: @bg-card;
border: 1px solid @border-subtle;
border-radius: @radius-lg;
- padding: @space-6;
- margin-bottom: @space-6;
-
- &:last-child {
- margin-bottom: 0;
- }
-}
+ padding: @space-5;
-.section-header {
- display: flex;
- align-items: center;
- gap: @space-2;
- margin-bottom: @space-6;
- padding-bottom: @space-4;
- border-bottom: 1px solid @border-subtle;
-
- .section-icon {
- font-size: 1.25rem;
- color: @accent-primary;
+ h3 {
+ margin-bottom: @space-2;
}
- h2 {
- font-size: 1.1rem;
- font-weight: 600;
- color: @text-primary;
- margin: 0;
+ > p {
+ color: @text-secondary;
+ font-size: @font-size-sm;
+ margin: 0 0 @space-4 0;
}
}
-// Settings Form Groups
+// Settings Form
.settings-form {
- display: flex;
- flex-direction: column;
- gap: @space-6;
-}
+ background: @bg-card;
+ border: 1px solid @border-subtle;
+ border-radius: @radius-lg;
+ padding: @space-5;
-.form-row {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
- gap: @space-4;
-}
+ .form-group {
+ margin-bottom: @space-4;
-.form-group {
- display: flex;
- flex-direction: column;
- gap: @space-1;
+ &:last-of-type {
+ margin-bottom: 0;
+ }
- label {
- font-size: 0.85rem;
- font-weight: 500;
- color: @text-secondary;
- }
+ label {
+ display: block;
+ font-size: @font-size-sm;
+ font-weight: @font-weight-medium;
+ color: @text-secondary;
+ margin-bottom: @space-2;
+ }
- input, select {
- padding: @space-2 @space-3;
- background: @bg-hover;
- border: 1px solid @border-subtle;
- border-radius: @radius-md;
- color: @text-primary;
- font-size: 0.9rem;
- transition: border-color 0.2s ease;
+ input, select, textarea {
+ width: 100%;
+ padding: @space-3;
+ background: @bg-hover;
+ border: 1px solid @border-subtle;
+ border-radius: @radius-md;
+ color: @text-primary;
+ font-size: @font-size-sm;
+ transition: border-color @transition-fast;
+
+ &:focus {
+ outline: none;
+ border-color: @accent-primary;
+ }
- &:focus {
- outline: none;
- border-color: @accent-primary;
+ &:disabled,
+ &.input-disabled {
+ opacity: 0.6;
+ cursor: not-allowed;
+ background: @bg-body;
+ }
}
- &:disabled {
- opacity: 0.6;
- cursor: not-allowed;
+ .form-help {
+ display: block;
+ margin-top: @space-1;
+ font-size: @font-size-xs;
+ color: @text-tertiary;
}
}
- .input-hint {
- font-size: 0.8rem;
- color: @text-tertiary;
+ .form-actions {
+ margin-top: @space-5;
+ padding-top: @space-5;
+ border-top: 1px solid @border-subtle;
+ display: flex;
+ gap: @space-2;
}
}
-.form-actions {
- display: flex;
- gap: @space-2;
- margin-top: @space-4;
- padding-top: @space-4;
- border-top: 1px solid @border-subtle;
+// Alert Messages
+.alert {
+ padding: @space-3 @space-4;
+ border-radius: @radius-md;
+ font-size: @font-size-sm;
+ margin-bottom: @space-4;
+
+ &.alert-success {
+ background: @success-bg;
+ border: 1px solid @success-border;
+ color: @success;
+ }
- &.no-border {
- border-top: none;
- padding-top: 0;
+ &.alert-danger {
+ background: @danger-bg;
+ border: 1px solid @danger-border;
+ color: @danger;
+ }
+
+ &.alert-warning {
+ background: @warning-bg;
+ border: 1px solid @warning-border;
+ color: @warning;
}
}
-// Password Change Section
-.password-section {
- .password-fields {
+// Session Items
+.session-item {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: @space-4;
+ background: @bg-hover;
+ border-radius: @radius-md;
+ margin-top: @space-3;
+
+ .session-info {
display: flex;
- flex-direction: column;
- gap: @space-4;
- }
+ align-items: center;
+ gap: @space-3;
- .password-requirements {
- font-size: 0.8rem;
- color: @text-tertiary;
- margin-top: @space-1;
+ svg {
+ stroke: @text-secondary;
+ fill: none;
+ stroke-width: 2;
+ }
+
+ .session-device {
+ display: block;
+ font-weight: @font-weight-medium;
+ color: @text-primary;
+ }
+
+ .session-details {
+ display: block;
+ font-size: @font-size-xs;
+ color: @text-tertiary;
+ }
}
}
// Theme Options
.theme-options {
- display: flex;
- gap: @space-4;
- flex-wrap: wrap;
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ gap: @space-3;
+
+ @media (max-width: @breakpoint-md) {
+ grid-template-columns: 1fr;
+ }
}
.theme-option {
- flex: 1;
- min-width: 150px;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: @space-3;
padding: @space-4;
- background: @bg-hover;
+ background: transparent;
border: 2px solid @border-subtle;
- border-radius: @radius-md;
+ border-radius: @radius-lg;
cursor: pointer;
- transition: all 0.2s ease;
- text-align: center;
+ transition: all @transition-fast;
&:hover {
- border-color: @accent-primary;
+ border-color: @border-active;
}
&.active {
border-color: @accent-primary;
- background: fade(@accent-primary, 10%);
+ background: fade(@accent-primary, 5%);
}
- .theme-icon {
- font-size: 2rem;
- margin-bottom: @space-2;
+ span {
+ font-size: @font-size-sm;
+ font-weight: @font-weight-medium;
+ color: @text-primary;
}
+}
- .theme-name {
- font-weight: 500;
- color: @text-primary;
- margin-bottom: @space-1;
+.theme-preview {
+ width: 100%;
+ height: 80px;
+ border-radius: @radius-md;
+ display: flex;
+ overflow: hidden;
+
+ .preview-sidebar {
+ width: 25%;
+ background: #18181b;
}
- .theme-desc {
- font-size: 0.8rem;
- color: @text-secondary;
+ .preview-content {
+ flex: 1;
+ padding: @space-2;
+ display: flex;
+ flex-direction: column;
+ gap: @space-1;
+ }
+
+ .preview-card {
+ flex: 1;
+ border-radius: @radius-sm;
+ }
+
+ &.dark {
+ border: 1px solid @border-subtle;
+
+ .preview-sidebar {
+ background: #0f0f11;
+ }
+
+ .preview-content {
+ background: #09090b;
+ }
+
+ .preview-card {
+ background: #18181b;
+ }
+ }
+
+ &.light {
+ border: 1px solid #e5e5e5;
+
+ .preview-sidebar {
+ background: #f5f5f5;
+ }
+
+ .preview-content {
+ background: #ffffff;
+ }
+
+ .preview-card {
+ background: #f5f5f5;
+ }
+ }
+
+ &.system {
+ border: 1px solid @border-subtle;
+ background: linear-gradient(135deg, #09090b 50%, #ffffff 50%);
+
+ .preview-sidebar {
+ background: linear-gradient(180deg, #0f0f11 50%, #f5f5f5 50%);
+ }
+
+ .preview-content {
+ background: transparent;
+ }
+
+ .preview-card {
+ background: linear-gradient(135deg, #18181b 50%, #f5f5f5 50%);
+ }
}
}
-// Notification Toggles
-.notification-settings {
+// Density Options
+.density-options {
display: flex;
- flex-direction: column;
gap: @space-4;
}
+.radio-option {
+ display: flex;
+ align-items: center;
+ gap: @space-2;
+ cursor: pointer;
+
+ input[type="radio"] {
+ width: 18px;
+ height: 18px;
+ accent-color: @accent-primary;
+ cursor: pointer;
+ }
+
+ span {
+ font-size: @font-size-sm;
+ color: @text-primary;
+ }
+}
+
+// Notification Options
+.notification-options {
+ display: flex;
+ flex-direction: column;
+ gap: @space-3;
+}
+
.notification-item {
display: flex;
justify-content: space-between;
@@ -268,19 +423,22 @@
padding: @space-4;
background: @bg-hover;
border-radius: @radius-md;
+ gap: @space-4;
.notification-info {
flex: 1;
- .notification-label {
- font-weight: 500;
+ .notification-title {
+ display: block;
+ font-weight: @font-weight-medium;
color: @text-primary;
margin-bottom: @space-1;
}
.notification-desc {
- font-size: 0.85rem;
- color: @text-secondary;
+ display: block;
+ font-size: @font-size-xs;
+ color: @text-tertiary;
}
}
}
@@ -288,8 +446,10 @@
// Toggle Switch
.toggle-switch {
position: relative;
- width: 48px;
- height: 26px;
+ display: inline-block;
+ width: 44px;
+ height: 24px;
+ flex-shrink: 0;
input {
opacity: 0;
@@ -300,7 +460,7 @@
background: @accent-primary;
&::before {
- transform: translateX(22px);
+ transform: translateX(20px);
}
}
@@ -316,20 +476,20 @@
left: 0;
right: 0;
bottom: 0;
- background: @border-subtle;
- border-radius: 26px;
- transition: all 0.3s ease;
+ background: @border-active;
+ border-radius: 24px;
+ transition: all @transition-fast;
&::before {
content: '';
position: absolute;
- height: 20px;
- width: 20px;
+ height: 18px;
+ width: 18px;
left: 3px;
bottom: 3px;
background: white;
border-radius: 50%;
- transition: transform 0.3s ease;
+ transition: transform @transition-fast;
}
}
}
@@ -337,181 +497,161 @@
// System Info Grid
.system-info-grid {
display: grid;
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
+ grid-template-columns: repeat(2, 1fr);
gap: @space-4;
-}
-
-.info-card {
- padding: @space-4;
- background: @bg-hover;
- border-radius: @radius-md;
- text-align: center;
- .info-icon {
- font-size: 1.5rem;
- color: @accent-primary;
- margin-bottom: @space-2;
- }
-
- .info-label {
- font-size: 0.8rem;
- color: @text-secondary;
- margin-bottom: @space-1;
+ @media (max-width: @breakpoint-md) {
+ grid-template-columns: 1fr;
}
+}
- .info-value {
- font-size: 1.25rem;
- font-weight: 600;
- color: @text-primary;
- }
+.info-list {
+ display: flex;
+ flex-direction: column;
+ gap: @space-2;
- .info-bar {
- margin-top: @space-2;
- height: 6px;
- background: @border-subtle;
- border-radius: 3px;
- overflow: hidden;
+ .info-item {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: @space-2 0;
+ border-bottom: 1px solid @border-subtle;
- .info-bar-fill {
- height: 100%;
- background: @accent-primary;
- border-radius: 3px;
- transition: width 0.3s ease;
+ &:last-child {
+ border-bottom: none;
+ }
- &.warning {
- background: @warning;
- }
+ .info-label {
+ font-size: @font-size-sm;
+ color: @text-tertiary;
+ }
- &.danger {
- background: @danger;
- }
+ .info-value {
+ font-size: @font-size-sm;
+ font-weight: @font-weight-medium;
+ color: @text-primary;
}
}
}
// About Section
-.about-section {
- .app-info {
+.about-card {
+ background: @bg-card;
+ border: 1px solid @border-subtle;
+ border-radius: @radius-lg;
+ padding: @space-8;
+ text-align: center;
+
+ .about-logo {
+ width: 80px;
+ height: 80px;
+ margin: 0 auto @space-4;
+ background: linear-gradient(135deg, @accent-primary 0%, @accent-hover 100%);
+ border-radius: @radius-xl;
display: flex;
align-items: center;
- gap: @space-6;
- margin-bottom: @space-6;
- padding-bottom: @space-6;
- border-bottom: 1px solid @border-subtle;
+ justify-content: center;
- .app-logo {
- width: 64px;
- height: 64px;
- background: linear-gradient(135deg, @accent-primary 0%, @accent-hover 100%);
- border-radius: @radius-lg;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 2rem;
+ svg {
+ stroke: white;
}
+ }
- .app-details {
- .app-name {
- font-size: 1.25rem;
- font-weight: 600;
- color: @text-primary;
- margin-bottom: @space-1;
- }
+ h3 {
+ font-size: @font-size-xl;
+ margin-bottom: @space-1;
+ }
- .app-version {
- font-size: 0.9rem;
- color: @text-secondary;
- }
- }
+ .version {
+ color: @text-tertiary;
+ font-size: @font-size-sm;
+ margin-bottom: @space-4;
}
- .features-list {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
- gap: @space-2;
- margin-bottom: @space-6;
+ .description {
+ color: @text-secondary;
+ font-size: @font-size-sm;
+ line-height: @line-height-relaxed;
+ max-width: 500px;
+ margin: 0 auto;
+ }
+}
- .feature-item {
- display: flex;
- align-items: center;
- gap: @space-2;
- padding: @space-2;
- color: @text-secondary;
+// Feature List
+.feature-list {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ display: grid;
+ grid-template-columns: repeat(2, 1fr);
+ gap: @space-2;
- .feature-check {
- color: @success;
- }
- }
+ @media (max-width: @breakpoint-md) {
+ grid-template-columns: 1fr;
}
- .about-links {
+ li {
display: flex;
- gap: @space-4;
- flex-wrap: wrap;
-
- a {
- display: flex;
- align-items: center;
- gap: @space-1;
- padding: @space-2 @space-3;
- background: @bg-hover;
- border-radius: @radius-md;
- color: @text-secondary;
- text-decoration: none;
- transition: all 0.2s ease;
+ align-items: center;
+ gap: @space-2;
+ padding: @space-2;
+ font-size: @font-size-sm;
+ color: @text-secondary;
- &:hover {
- background: @accent-primary;
- color: white;
- }
+ svg {
+ stroke: @success;
+ fill: none;
+ stroke-width: 2;
+ flex-shrink: 0;
}
}
}
-// Success/Error Messages
-.settings-message {
- padding: @space-2 @space-3;
- border-radius: @radius-md;
- margin-bottom: @space-4;
+// Link List
+.link-list {
display: flex;
- align-items: center;
+ flex-direction: column;
gap: @space-2;
+}
- &.success {
- background: fade(@success, 15%);
- color: @success;
- border: 1px solid fade(@success, 30%);
+.link-item {
+ display: flex;
+ align-items: center;
+ gap: @space-3;
+ padding: @space-3 @space-4;
+ background: @bg-hover;
+ border-radius: @radius-md;
+ color: @text-secondary;
+ text-decoration: none;
+ font-size: @font-size-sm;
+ transition: all @transition-fast;
+
+ svg {
+ stroke: currentColor;
+ fill: none;
+ stroke-width: 2;
+ flex-shrink: 0;
}
- &.error {
- background: fade(@danger, 15%);
- color: @danger;
- border: 1px solid fade(@danger, 30%);
+ &:hover {
+ background: @accent-primary;
+ color: white;
}
}
+// License Text
+.license-text {
+ color: @text-secondary;
+ font-size: @font-size-sm;
+ margin: 0;
+}
+
// Loading State
-.settings-loading {
+.loading {
display: flex;
- flex-direction: column;
align-items: center;
justify-content: center;
- padding: @space-16;
+ padding: @space-12;
color: @text-secondary;
-
- .spinner {
- width: 40px;
- height: 40px;
- border: 3px solid @border-subtle;
- border-top-color: @accent-primary;
- border-radius: 50%;
- animation: spin 1s linear infinite;
- margin-bottom: @space-4;
- }
-}
-
-@keyframes spin {
- to {
- transform: rotate(360deg);
- }
+ font-size: @font-size-sm;
}