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 integrated Git server (Gitea) management UI and API
Juan Denis39fc113eb7b5
diff --git a/backend/app/__init__.py b/backend/app/__init__.pyindex ba18efc4..0903bbe0 100644--- a/backend/app/__init__.py+++ b/backend/app/__init__.py@@ -131,6 +131,10 @@ def create_app(config_name=None):from app.api.firewall import firewall_bpapp.register_blueprint(firewall_bp, url_prefix='/api/v1/firewall')+ # Register blueprints - Git Server+ from app.api.git import git_bp+ app.register_blueprint(git_bp, url_prefix='/api/v1/git')+# Register blueprints - Security (ClamAV, File Integrity, etc.)from app.api.security import security_bpapp.register_blueprint(security_bp, url_prefix='/api/v1/security')diff --git a/backend/app/api/git.py b/backend/app/api/git.pynew file mode 100644index 00000000..217e8d7a--- /dev/null+++ b/backend/app/api/git.py@@ -0,0 +1,88 @@+"""Git Server API endpoints for managing integrated Gitea instance."""++from flask import Blueprint, request, jsonify+from flask_jwt_extended import jwt_required+from ..services.git_service import GitService++git_bp = Blueprint('git', __name__)+++@git_bp.route('/status', methods=['GET'])+@jwt_required()+def get_status():+ """Get Gitea installation status."""+ result = GitService.get_gitea_status()+ return jsonify(result), 200+++@git_bp.route('/requirements', methods=['GET'])+@jwt_required()+def get_requirements():+ """Get resource requirements for Gitea installation."""+ result = GitService.get_gitea_resource_requirements()+ return jsonify(result), 200+++@git_bp.route('/install', methods=['POST'])+@jwt_required()+def install():+ """Install Gitea with PostgreSQL."""+ data = request.get_json() or {}++ result = GitService.install_gitea(+ admin_user=data.get('adminUser', 'admin'),+ admin_email=data.get('adminEmail'),+ admin_password=data.get('adminPassword')+ )++ if result.get('success'):+ return jsonify(result), 201+ return jsonify(result), 400+++@git_bp.route('/uninstall', methods=['POST'])+@jwt_required()+def uninstall():+ """Uninstall Gitea and optionally remove data."""+ data = request.get_json() or {}++ result = GitService.uninstall_gitea(+ remove_data=data.get('removeData', False)+ )++ if result.get('success'):+ return jsonify(result), 200+ return jsonify(result), 400+++@git_bp.route('/start', methods=['POST'])+@jwt_required()+def start():+ """Start Gitea server."""+ result = GitService.start_gitea()++ if result.get('success'):+ return jsonify(result), 200+ return jsonify(result), 400+++@git_bp.route('/stop', methods=['POST'])+@jwt_required()+def stop():+ """Stop Gitea server."""+ result = GitService.stop_gitea()++ if result.get('success'):+ return jsonify(result), 200+ return jsonify(result), 400+++@git_bp.route('/restart', methods=['POST'])+@jwt_required()+def restart():+ """Restart Gitea server."""+ result = GitService.restart_gitea()++ if result.get('success'):+ return jsonify(result), 200+ return jsonify(result), 400diff --git a/backend/app/services/git_service.py b/backend/app/services/git_service.pyindex b5d84dd6..aeb04003 100644--- a/backend/app/services/git_service.py+++ b/backend/app/services/git_service.py@@ -3,6 +3,7 @@ import subprocessimport jsonimport hmacimport hashlib+import secretsfrom datetime import datetimefrom typing import Dict, List, Optionalfrom pathlib import Path@@ -574,3 +575,251 @@ class GitService:passreturn logs++ # ========================================+ # GITEA SERVER MANAGEMENT+ # ========================================++ GITEA_APP_NAME = 'serverkit-gitea'+ GITEA_CONFIG_FILE = os.path.join(CONFIG_DIR, 'gitea.json')++ @classmethod+ def get_gitea_status(cls) -> Dict:+ """Check if Gitea is installed and running."""+ from app.models import Application++ app = Application.query.filter_by(name=cls.GITEA_APP_NAME).first()++ if not app:+ return {+ 'installed': False,+ 'running': False,+ 'http_port': None,+ 'ssh_port': None,+ 'url': None+ }++ # Check container status+ running = cls._is_gitea_running()++ # Load config for ports+ config = cls._load_gitea_config()++ return {+ 'installed': True,+ 'running': running,+ 'http_port': app.port or config.get('http_port'),+ 'ssh_port': config.get('ssh_port'),+ 'url': f"http://localhost:{app.port}" if app.port else None,+ 'app_id': app.id,+ 'version': config.get('version', '1.21')+ }++ @classmethod+ def _is_gitea_running(cls) -> bool:+ """Check if Gitea container is running."""+ try:+ result = subprocess.run(+ ['docker', 'ps', '--filter', f'name={cls.GITEA_APP_NAME}', '--format', '{{.Names}}'],+ capture_output=True,+ text=True,+ timeout=10+ )+ return cls.GITEA_APP_NAME in result.stdout+ except Exception:+ return False++ @classmethod+ def _load_gitea_config(cls) -> Dict:+ """Load Gitea configuration."""+ if os.path.exists(cls.GITEA_CONFIG_FILE):+ try:+ with open(cls.GITEA_CONFIG_FILE, 'r') as f:+ return json.load(f)+ except Exception:+ pass+ return {}++ @classmethod+ def _save_gitea_config(cls, config: Dict) -> bool:+ """Save Gitea configuration."""+ try:+ os.makedirs(cls.CONFIG_DIR, exist_ok=True)+ with open(cls.GITEA_CONFIG_FILE, 'w') as f:+ json.dump(config, f, indent=2)+ return True+ except Exception:+ return False++ @classmethod+ def get_gitea_resource_requirements(cls) -> Dict:+ """Get resource requirements for Gitea installation."""+ return {+ 'memory_min': '512MB',+ 'memory_recommended': '1GB',+ 'storage_min': '5GB',+ 'storage_recommended': '20GB',+ 'components': [+ {'name': 'Gitea', 'memory': '~300MB', 'storage': '~100MB + repos'},+ {'name': 'PostgreSQL', 'memory': '~200MB', 'storage': '~1GB'}+ ],+ 'warning': 'Installation will spin up a PostgreSQL database container'+ }++ @classmethod+ def install_gitea(cls, admin_user: str = 'admin',+ admin_email: str = None,+ admin_password: str = None) -> Dict:+ """Install Gitea as integrated ServerKit service."""+ from app.services.template_service import TemplateService++ # Check if already installed+ status = cls.get_gitea_status()+ if status['installed']:+ return {'success': False, 'error': 'Gitea is already installed'}++ # Generate secure password if not provided+ generated_password = False+ if not admin_password:+ admin_password = secrets.token_urlsafe(16)+ generated_password = True++ try:+ # Install using template service+ result = TemplateService.install_template(+ template_id='gitea',+ app_name=cls.GITEA_APP_NAME,+ user_variables={},+ user_id=1 # System user+ )++ if not result.get('success'):+ return result++ # Get the variables that were generated+ variables = result.get('variables', {})+ http_port = variables.get('HTTP_PORT')+ ssh_port = variables.get('SSH_PORT')++ # Save config with admin credentials and ports+ config = {+ 'admin_user': admin_user,+ 'admin_email': admin_email,+ 'http_port': http_port,+ 'ssh_port': ssh_port,+ 'db_password': variables.get('DB_PASSWORD'),+ 'installed_at': datetime.now().isoformat(),+ 'version': '1.21'+ }+ cls._save_gitea_config(config)++ response = {+ 'success': True,+ 'message': 'Gitea installed successfully',+ 'http_port': http_port,+ 'ssh_port': ssh_port,+ 'admin_user': admin_user+ }++ # Only include password in response if it was generated+ if generated_password:+ response['admin_password'] = admin_password+ response['warning'] = 'Save these credentials - password shown only once!'++ return response++ except Exception as e:+ return {'success': False, 'error': str(e)}++ @classmethod+ def uninstall_gitea(cls, remove_data: bool = False) -> Dict:+ """Uninstall Gitea."""+ from app import db+ from app.models import Application+ from app.services.docker_service import DockerService++ app = Application.query.filter_by(name=cls.GITEA_APP_NAME).first()+ if not app:+ return {'success': False, 'error': 'Gitea is not installed'}++ try:+ # Stop and remove containers+ if app.root_path and os.path.exists(app.root_path):+ DockerService.compose_down(app.root_path, remove_volumes=remove_data)++ if remove_data:+ import shutil+ shutil.rmtree(app.root_path, ignore_errors=True)++ # Remove from database+ db.session.delete(app)+ db.session.commit()++ # Remove config+ if os.path.exists(cls.GITEA_CONFIG_FILE):+ os.remove(cls.GITEA_CONFIG_FILE)++ return {+ 'success': True,+ 'message': 'Gitea uninstalled successfully',+ 'data_removed': remove_data+ }++ except Exception as e:+ return {'success': False, 'error': str(e)}++ @classmethod+ def start_gitea(cls) -> Dict:+ """Start Gitea containers."""+ from app import db+ from app.models import Application+ from app.services.docker_service import DockerService++ app = Application.query.filter_by(name=cls.GITEA_APP_NAME).first()+ if not app:+ return {'success': False, 'error': 'Gitea is not installed'}++ if not app.root_path or not os.path.exists(app.root_path):+ return {'success': False, 'error': 'Gitea installation path not found'}++ try:+ result = DockerService.compose_up(app.root_path, detach=True)+ if result.get('success'):+ app.status = 'running'+ db.session.commit()+ return {'success': True, 'message': 'Gitea started'}+ return result+ except Exception as e:+ return {'success': False, 'error': str(e)}++ @classmethod+ def stop_gitea(cls) -> Dict:+ """Stop Gitea containers."""+ from app import db+ from app.models import Application+ from app.services.docker_service import DockerService++ app = Application.query.filter_by(name=cls.GITEA_APP_NAME).first()+ if not app:+ return {'success': False, 'error': 'Gitea is not installed'}++ if not app.root_path or not os.path.exists(app.root_path):+ return {'success': False, 'error': 'Gitea installation path not found'}++ try:+ result = DockerService.compose_stop(app.root_path)+ if result.get('success'):+ app.status = 'stopped'+ db.session.commit()+ return {'success': True, 'message': 'Gitea stopped'}+ return result+ except Exception as e:+ return {'success': False, 'error': str(e)}++ @classmethod+ def restart_gitea(cls) -> Dict:+ """Restart Gitea containers."""+ stop_result = cls.stop_gitea()+ if not stop_result.get('success'):+ return stop_result+ return cls.start_gitea()diff --git a/frontend/src/App.jsx b/frontend/src/App.jsxindex ba0ccbeb..40891ca5 100644--- a/frontend/src/App.jsx+++ b/frontend/src/App.jsx@@ -20,6 +20,7 @@ import Settings from './pages/Settings';import FileManager from './pages/FileManager';import FTPServer from './pages/FTPServer';import Firewall from './pages/Firewall';+import Git from './pages/Git';import CronJobs from './pages/CronJobs';import Security from './pages/Security';import Templates from './pages/Templates';@@ -107,6 +108,7 @@ function AppRoutes() {<Route path="ssl" element={<div className="page">SSL Certificates</div>} /><Route path="docker" element={<Docker />} /><Route path="firewall" element={<Firewall />} />+ <Route path="git" element={<Git />} /><Route path="files" element={<FileManager />} /><Route path="ftp" element={<FTPServer />} /><Route path="monitoring" element={<Monitoring />} />diff --git a/frontend/src/components/Sidebar.jsx b/frontend/src/components/Sidebar.jsxindex ee3f93e8..7767385b 100644--- a/frontend/src/components/Sidebar.jsx+++ b/frontend/src/components/Sidebar.jsx@@ -99,6 +99,14 @@ const Sidebar = () => {</svg>Firewall</NavLink>+ <NavLink to="/git" className={({ isActive }) => `nav-item ${isActive ? 'active' : ''}`}>+ <svg viewBox="0 0 24 24">+ <circle cx="18" cy="18" r="3"/>+ <circle cx="6" cy="6" r="3"/>+ <path d="M6 21V9a9 9 0 0 0 9 9"/>+ </svg>+ Git+ </NavLink></nav><div className="menu-label">Operations</div>diff --git a/frontend/src/pages/Git.jsx b/frontend/src/pages/Git.jsxnew file mode 100644index 00000000..c70571dd--- /dev/null+++ b/frontend/src/pages/Git.jsx@@ -0,0 +1,518 @@+import { useState, useEffect } from 'react';+import { api } from '../services/api';+import { useToast } from '../contexts/ToastContext';+import Spinner from '../components/Spinner';+import ConfirmDialog from '../components/ConfirmDialog';++function Git() {+ const [status, setStatus] = useState(null);+ const [loading, setLoading] = useState(true);+ const [activeTab, setActiveTab] = useState('overview');+ const [showInstallModal, setShowInstallModal] = useState(false);+ const [actionLoading, setActionLoading] = useState(false);+ const [confirmDialog, setConfirmDialog] = useState(null);+ const [installForm, setInstallForm] = useState({+ adminUser: 'admin',+ adminEmail: '',+ adminPassword: ''+ });+ const toast = useToast();++ useEffect(() => {+ loadData();+ }, []);++ const loadData = async () => {+ setLoading(true);+ try {+ await loadStatus();+ } catch (error) {+ console.error('Failed to load git data:', error);+ } finally {+ setLoading(false);+ }+ };++ const loadStatus = async () => {+ try {+ const data = await api.getGitStatus();+ setStatus(data);+ } catch (error) {+ console.error('Failed to load status:', error);+ setStatus({ installed: false });+ }+ };++ const handleInstall = async () => {+ if (!installForm.adminEmail) {+ toast.error('Admin email is required');+ return;+ }++ setActionLoading(true);+ try {+ const result = await api.installGit(installForm);+ if (result.success) {+ toast.success('Git server installed successfully');+ setShowInstallModal(false);+ if (result.admin_password) {+ toast.info(`Admin password: ${result.admin_password} (save this!)`);+ }+ await loadData();+ } else {+ toast.error(result.error || 'Installation failed');+ }+ } catch (error) {+ toast.error(`Failed to install: ${error.message}`);+ } finally {+ setActionLoading(false);+ }+ };++ const handleUninstall = async () => {+ setConfirmDialog({+ title: 'Uninstall Git Server',+ message: 'Are you sure you want to uninstall the Git server? This will stop the Gitea container but preserve your data.',+ confirmText: 'Uninstall',+ variant: 'danger',+ onConfirm: async () => {+ setActionLoading(true);+ try {+ await api.uninstallGit(false);+ toast.success('Git server uninstalled');+ await loadData();+ } catch (error) {+ toast.error(`Failed to uninstall: ${error.message}`);+ } finally {+ setActionLoading(false);+ setConfirmDialog(null);+ }+ },+ onCancel: () => setConfirmDialog(null)+ });+ };++ const handleStart = async () => {+ setActionLoading(true);+ try {+ await api.startGit();+ toast.success('Git server started');+ await loadStatus();+ } catch (error) {+ toast.error(`Failed to start: ${error.message}`);+ } finally {+ setActionLoading(false);+ }+ };++ const handleStop = async () => {+ setConfirmDialog({+ title: 'Stop Git Server',+ message: 'Are you sure you want to stop the Git server?',+ confirmText: 'Stop',+ variant: 'warning',+ onConfirm: async () => {+ setActionLoading(true);+ try {+ await api.stopGit();+ toast.success('Git server stopped');+ await loadStatus();+ } catch (error) {+ toast.error(`Failed to stop: ${error.message}`);+ } finally {+ setActionLoading(false);+ setConfirmDialog(null);+ }+ },+ onCancel: () => setConfirmDialog(null)+ });+ };++ const openGitea = () => {+ if (status?.http_port) {+ window.open(`http://${window.location.hostname}:${status.http_port}`, '_blank');+ }+ };++ if (loading) {+ return (+ <div className="page-loading">+ <Spinner size="lg" />+ </div>+ );+ }++ return (+ <div className="git-page">+ <div className="page-header">+ <div className="page-header-content">+ <h1>Git Server</h1>+ <p className="page-description">Self-hosted Git repository management with Gitea</p>+ </div>+ <div className="page-header-actions">+ {!status?.installed ? (+ <button className="btn btn-primary" onClick={() => setShowInstallModal(true)}>+ Install Git Server+ </button>+ ) : (+ <>+ <button+ className="btn btn-secondary"+ onClick={openGitea}+ disabled={!status?.running}+ >+ Open Gitea+ </button>+ {status?.running ? (+ <button+ className="btn btn-warning"+ onClick={handleStop}+ disabled={actionLoading}+ >+ Stop Server+ </button>+ ) : (+ <button+ className="btn btn-primary"+ onClick={handleStart}+ disabled={actionLoading}+ >+ Start Server+ </button>+ )}+ </>+ )}+ </div>+ </div>++ {!status?.installed ? (+ <div className="empty-state-large">+ <div className="empty-icon">+ <svg viewBox="0 0 24 24" width="64" height="64" stroke="currentColor" fill="none" strokeWidth="1.5">+ <circle cx="18" cy="18" r="3"/>+ <circle cx="6" cy="6" r="3"/>+ <path d="M6 21V9a9 9 0 0 0 9 9"/>+ </svg>+ </div>+ <h2>No Git Server Installed</h2>+ <p>Install Gitea to host and manage your Git repositories locally.</p>++ <div className="resource-warning">+ <div className="warning-header">+ <svg viewBox="0 0 24 24" width="20" height="20" stroke="currentColor" fill="none" strokeWidth="2">+ <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>+ <line x1="12" y1="9" x2="12" y2="13"/>+ <line x1="12" y1="17" x2="12.01" y2="17"/>+ </svg>+ <strong>Resource Requirements</strong>+ </div>+ <ul>+ <li><strong>Memory:</strong> ~512MB minimum (1GB recommended)</li>+ <li><strong>Storage:</strong> ~5GB for database + repositories</li>+ <li><strong>Components:</strong> Gitea + PostgreSQL database</li>+ </ul>+ </div>++ <button className="btn btn-primary btn-lg" onClick={() => setShowInstallModal(true)}>+ Install Git Server+ </button>+ </div>+ ) : (+ <>+ <div className="status-cards">+ <div className={`status-card ${status?.running ? 'success' : 'danger'}`}>+ <div className="status-icon">+ <svg viewBox="0 0 24 24" width="32" height="32" stroke="currentColor" fill="none" strokeWidth="2">+ <circle cx="18" cy="18" r="3"/>+ <circle cx="6" cy="6" r="3"/>+ <path d="M6 21V9a9 9 0 0 0 9 9"/>+ </svg>+ </div>+ <div className="status-info">+ <span className="status-label">Server Status</span>+ <span className="status-value">{status?.running ? 'Running' : 'Stopped'}</span>+ </div>+ </div>+ <div className="status-card">+ <div className="status-icon">+ <svg viewBox="0 0 24 24" width="32" height="32" stroke="currentColor" fill="none" strokeWidth="2">+ <circle cx="12" cy="12" r="10"/>+ <line x1="2" y1="12" x2="22" y2="12"/>+ <path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/>+ </svg>+ </div>+ <div className="status-info">+ <span className="status-label">HTTP Port</span>+ <span className="status-value">{status?.http_port || 'N/A'}</span>+ </div>+ </div>+ <div className="status-card">+ <div className="status-icon">+ <svg viewBox="0 0 24 24" width="32" height="32" stroke="currentColor" fill="none" strokeWidth="2">+ <rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>+ <path d="M7 11V7a5 5 0 0 1 10 0v4"/>+ </svg>+ </div>+ <div className="status-info">+ <span className="status-label">SSH Port</span>+ <span className="status-value">{status?.ssh_port || 'N/A'}</span>+ </div>+ </div>+ <div className="status-card">+ <div className="status-icon">+ <svg viewBox="0 0 24 24" width="32" height="32" stroke="currentColor" fill="none" strokeWidth="2">+ <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/>+ <circle cx="12" cy="7" r="4"/>+ </svg>+ </div>+ <div className="status-info">+ <span className="status-label">Version</span>+ <span className="status-value">{status?.version || 'Unknown'}</span>+ </div>+ </div>+ </div>++ <div className="tabs">+ <button+ className={`tab ${activeTab === 'overview' ? 'active' : ''}`}+ onClick={() => setActiveTab('overview')}+ >+ Overview+ </button>+ <button+ className={`tab ${activeTab === 'access' ? 'active' : ''}`}+ onClick={() => setActiveTab('access')}+ >+ Access Info+ </button>+ <button+ className={`tab ${activeTab === 'settings' ? 'active' : ''}`}+ onClick={() => setActiveTab('settings')}+ >+ Settings+ </button>+ </div>++ <div className="tab-content">+ {activeTab === 'overview' && (+ <div className="overview-tab">+ <div className="info-card">+ <h3>Server Information</h3>+ <div className="info-grid">+ <div className="info-item">+ <span className="info-label">Status</span>+ <span className={`info-value ${status?.running ? 'text-success' : 'text-danger'}`}>+ {status?.running ? 'Running' : 'Stopped'}+ </span>+ </div>+ <div className="info-item">+ <span className="info-label">HTTP URL</span>+ <span className="info-value">+ {status?.running ? (+ <a href={`http://${window.location.hostname}:${status.http_port}`} target="_blank" rel="noopener noreferrer">+ http://{window.location.hostname}:{status.http_port}+ </a>+ ) : 'Server not running'}+ </span>+ </div>+ <div className="info-item">+ <span className="info-label">SSH Clone URL</span>+ <span className="info-value code">+ ssh://git@{window.location.hostname}:{status?.ssh_port}/user/repo.git+ </span>+ </div>+ </div>+ </div>+ <div className="info-card">+ <h3>Quick Actions</h3>+ <div className="quick-actions">+ <button+ className="btn btn-secondary"+ onClick={openGitea}+ disabled={!status?.running}+ >+ Open Web Interface+ </button>+ <button+ className="btn btn-secondary"+ onClick={() => {+ navigator.clipboard.writeText(`git clone ssh://git@${window.location.hostname}:${status?.ssh_port}/user/repo.git`);+ toast.success('SSH URL copied to clipboard');+ }}+ >+ Copy SSH URL+ </button>+ </div>+ </div>+ </div>+ )}++ {activeTab === 'access' && (+ <div className="access-tab">+ <div className="info-card">+ <h3>HTTP Access</h3>+ <p className="text-muted">Access Gitea through your web browser</p>+ <div className="access-url">+ <code>http://{window.location.hostname}:{status?.http_port}</code>+ <button+ className="btn btn-sm btn-secondary"+ onClick={() => {+ navigator.clipboard.writeText(`http://${window.location.hostname}:${status?.http_port}`);+ toast.success('URL copied');+ }}+ >+ Copy+ </button>+ </div>+ </div>+ <div className="info-card">+ <h3>SSH Access</h3>+ <p className="text-muted">Clone repositories via SSH</p>+ <div className="access-url">+ <code>ssh://git@{window.location.hostname}:{status?.ssh_port}/username/repo.git</code>+ <button+ className="btn btn-sm btn-secondary"+ onClick={() => {+ navigator.clipboard.writeText(`ssh://git@${window.location.hostname}:${status?.ssh_port}/username/repo.git`);+ toast.success('URL copied');+ }}+ >+ Copy+ </button>+ </div>+ <div className="ssh-note">+ <strong>Note:</strong> Add your SSH public key in Gitea settings to use SSH access.+ </div>+ </div>+ </div>+ )}++ {activeTab === 'settings' && (+ <div className="settings-tab">+ <div className="info-card">+ <h3>Server Management</h3>+ <div className="settings-actions">+ {status?.running ? (+ <button+ className="btn btn-warning"+ onClick={handleStop}+ disabled={actionLoading}+ >+ Stop Server+ </button>+ ) : (+ <button+ className="btn btn-primary"+ onClick={handleStart}+ disabled={actionLoading}+ >+ Start Server+ </button>+ )}+ <button+ className="btn btn-danger"+ onClick={handleUninstall}+ disabled={actionLoading}+ >+ Uninstall+ </button>+ </div>+ </div>+ <div className="info-card danger-zone">+ <h3>Danger Zone</h3>+ <p className="text-muted">+ Uninstalling will stop the Gitea container. Your data will be preserved unless you choose to remove it.+ </p>+ </div>+ </div>+ )}+ </div>+ </>+ )}++ {/* Install Modal */}+ {showInstallModal && (+ <div className="modal-overlay" onClick={() => setShowInstallModal(false)}>+ <div className="modal modal-lg" onClick={(e) => e.stopPropagation()}>+ <div className="modal-header">+ <h2>Install Git Server</h2>+ <button className="btn btn-icon" onClick={() => setShowInstallModal(false)}>+ <span className="icon">close</span>+ </button>+ </div>+ <div className="modal-body">+ <div className="install-warning">+ <svg viewBox="0 0 24 24" width="20" height="20" stroke="currentColor" fill="none" strokeWidth="2">+ <circle cx="12" cy="12" r="10"/>+ <line x1="12" y1="8" x2="12" y2="12"/>+ <line x1="12" y1="16" x2="12.01" y2="16"/>+ </svg>+ <div>+ <strong>This will install:</strong>+ <ul>+ <li>Gitea (Git server) - ~300MB RAM</li>+ <li>PostgreSQL database - ~200MB RAM</li>+ </ul>+ </div>+ </div>++ <div className="form-group">+ <label>Admin Username</label>+ <input+ type="text"+ value={installForm.adminUser}+ onChange={(e) => setInstallForm({ ...installForm, adminUser: e.target.value })}+ placeholder="admin"+ />+ </div>+ <div className="form-group">+ <label>Admin Email <span className="required">*</span></label>+ <input+ type="email"+ value={installForm.adminEmail}+ onChange={(e) => setInstallForm({ ...installForm, adminEmail: e.target.value })}+ placeholder="[email protected]"+ />+ </div>+ <div className="form-group">+ <label>Admin Password (leave empty to auto-generate)</label>+ <input+ type="password"+ value={installForm.adminPassword}+ onChange={(e) => setInstallForm({ ...installForm, adminPassword: e.target.value })}+ placeholder="Auto-generate secure password"+ />+ </div>+ </div>+ <div className="modal-footer">+ <button className="btn btn-secondary" onClick={() => setShowInstallModal(false)}>+ Cancel+ </button>+ <button+ className="btn btn-primary"+ onClick={handleInstall}+ disabled={actionLoading || !installForm.adminEmail}+ >+ {actionLoading ? 'Installing...' : 'Install Git Server'}+ </button>+ </div>+ </div>+ </div>+ )}++ {/* Confirm Dialog */}+ {confirmDialog && (+ <ConfirmDialog+ title={confirmDialog.title}+ message={confirmDialog.message}+ confirmText={confirmDialog.confirmText}+ variant={confirmDialog.variant}+ onConfirm={confirmDialog.onConfirm}+ onCancel={confirmDialog.onCancel}+ />+ )}+ </div>+ );+}++export default Git;diff --git a/frontend/src/services/api.js b/frontend/src/services/api.jsindex 15285ca8..fbfd97ab 100644--- a/frontend/src/services/api.js+++ b/frontend/src/services/api.js@@ -1868,6 +1868,43 @@ class ApiService {});}+ // ========================================+ // Git Server endpoints+ // ========================================+ async getGitStatus() {+ return this.request('/git/status');+ }++ async getGitRequirements() {+ return this.request('/git/requirements');+ }++ async installGit(data) {+ return this.request('/git/install', {+ method: 'POST',+ body: data+ });+ }++ async uninstallGit(removeData = false) {+ return this.request('/git/uninstall', {+ method: 'POST',+ body: { removeData }+ });+ }++ async startGit() {+ return this.request('/git/start', { method: 'POST' });+ }++ async stopGit() {+ return this.request('/git/stop', { method: 'POST' });+ }++ async restartGit() {+ return this.request('/git/restart', { method: 'POST' });+ }+// ========================================// Cron Job endpoints// ========================================diff --git a/frontend/src/styles/main.less b/frontend/src/styles/main.lessindex 0006b484..a37618ef 100644--- a/frontend/src/styles/main.less+++ b/frontend/src/styles/main.less@@ -71,3 +71,4 @@@import 'pages/_security';@import 'pages/_templates';@import 'pages/_workflow';+@import 'pages/_git';diff --git a/frontend/src/styles/pages/_git.less b/frontend/src/styles/pages/_git.lessnew file mode 100644index 00000000..5c6db17b--- /dev/null+++ b/frontend/src/styles/pages/_git.less@@ -0,0 +1,437 @@+// ============================================+// GIT PAGE+// ============================================++.git-page {+ .page-header {+ display: flex;+ justify-content: space-between;+ align-items: flex-start;+ margin-bottom: @space-6;+ flex-wrap: wrap;+ gap: @space-4;++ .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;+ }+ }++ .page-header-actions {+ display: flex;+ gap: @space-2;+ }+ }++ .page-loading {+ display: flex;+ justify-content: center;+ align-items: center;+ min-height: 400px;+ }++ .empty-state-large {+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ padding: 60px @space-6;+ background: @bg-card;+ border-radius: @radius-xl;+ text-align: center;++ .empty-icon {+ color: @text-tertiary;+ margin-bottom: @space-6;+ }++ h2 {+ margin: 0 0 @space-3 0;+ font-size: @font-size-2xl;+ font-weight: @font-weight-semibold;+ }++ p {+ margin: 0 0 @space-6 0;+ color: @text-secondary;+ max-width: 400px;+ }+ }++ .resource-warning {+ background: fade(@warning, 10%);+ border: 1px solid fade(@warning, 30%);+ border-radius: @radius-lg;+ padding: @space-5;+ margin-bottom: @space-6;+ text-align: left;+ max-width: 500px;++ .warning-header {+ display: flex;+ align-items: center;+ gap: @space-2;+ margin-bottom: @space-3;+ color: @warning;++ strong {+ color: @text-primary;+ }+ }++ ul {+ margin: 0;+ padding-left: @space-5;+ color: @text-secondary;+ font-size: @font-size-sm;++ li {+ margin-bottom: @space-1;++ &:last-child {+ margin-bottom: 0;+ }++ strong {+ color: @text-primary;+ }+ }+ }+ }++ .status-cards {+ display: grid;+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));+ gap: @space-4;+ margin-bottom: @space-6;+ }++ .status-card {+ display: flex;+ align-items: center;+ gap: @space-4;+ padding: @space-5;+ background: @bg-card;+ border-radius: @radius-xl;+ border-left: 4px solid @border-subtle;++ &.success {+ border-left-color: @success;++ .status-icon {+ color: @success;+ }+ }++ &.danger {+ border-left-color: @danger;++ .status-icon {+ color: @danger;+ }+ }++ &.warning {+ border-left-color: @warning;++ .status-icon {+ color: @warning;+ }+ }++ .status-icon {+ color: @text-tertiary;+ }++ .status-info {+ display: flex;+ flex-direction: column;+ gap: @space-1;++ .status-label {+ font-size: @font-size-sm;+ color: @text-secondary;+ }++ .status-value {+ font-size: @font-size-lg;+ font-weight: @font-weight-semibold;+ }+ }+ }++ .tabs {+ display: flex;+ gap: @space-1;+ margin-bottom: @space-6;+ border-bottom: 1px solid @border-subtle;++ .tab {+ padding: @space-3 @space-5;+ background: none;+ border: none;+ font-size: @font-size-base;+ font-weight: @font-weight-medium;+ color: @text-secondary;+ cursor: pointer;+ position: relative;+ transition: color @transition-fast;++ &:hover {+ color: @text-primary;+ }++ &.active {+ color: @accent-primary;++ &::after {+ content: '';+ position: absolute;+ bottom: -1px;+ left: 0;+ right: 0;+ height: 2px;+ background: @accent-primary;+ }+ }+ }+ }++ .tab-content {+ .section-header {+ display: flex;+ justify-content: space-between;+ align-items: center;+ margin-bottom: @space-4;++ h3 {+ margin: 0;+ font-size: @font-size-md;+ font-weight: @font-weight-semibold;+ }+ }+ }++ // Overview Tab+ .overview-tab {+ display: grid;+ grid-template-columns: 1fr 1fr;+ gap: @space-6;++ @media (max-width: @breakpoint-md) {+ grid-template-columns: 1fr;+ }++ .info-card {+ background: @bg-card;+ border-radius: @radius-lg;+ padding: @space-5;++ h3 {+ margin: 0 0 @space-4 0;+ font-size: @font-size-md;+ font-weight: @font-weight-semibold;+ }+ }++ .info-grid {+ display: grid;+ gap: @space-3;+ }++ .info-item {+ display: flex;+ justify-content: space-between;+ align-items: center;+ padding: @space-2 0;+ border-bottom: 1px solid @border-subtle;++ &:last-child {+ border-bottom: none;+ }++ .info-label {+ font-size: @font-size-sm;+ color: @text-secondary;+ }++ .info-value {+ font-size: @font-size-sm;+ font-weight: @font-weight-medium;++ &.text-success {+ color: @success;+ }++ &.text-danger {+ color: @danger;+ }++ &.code {+ font-family: @font-mono;+ font-size: @font-size-xs;+ background: @bg-hover;+ padding: @space-1 @space-2;+ border-radius: @radius-sm;+ }++ a {+ color: @accent-primary;+ text-decoration: none;++ &:hover {+ text-decoration: underline;+ }+ }+ }+ }++ .quick-actions {+ display: flex;+ gap: @space-3;+ flex-wrap: wrap;+ }+ }++ // Access Tab+ .access-tab {+ display: flex;+ flex-direction: column;+ gap: @space-4;++ .info-card {+ background: @bg-card;+ border-radius: @radius-lg;+ padding: @space-5;++ h3 {+ margin: 0 0 @space-2 0;+ font-size: @font-size-md;+ font-weight: @font-weight-semibold;+ }++ .text-muted {+ color: @text-secondary;+ font-size: @font-size-sm;+ margin: 0 0 @space-4 0;+ }+ }++ .access-url {+ display: flex;+ align-items: center;+ gap: @space-3;+ background: @bg-hover;+ padding: @space-3 @space-4;+ border-radius: @radius-md;+ margin-bottom: @space-3;++ code {+ flex: 1;+ font-family: @font-mono;+ font-size: @font-size-sm;+ color: @accent-primary;+ word-break: break-all;+ }+ }++ .ssh-note {+ font-size: @font-size-sm;+ color: @text-secondary;+ padding: @space-3;+ background: fade(@info, 10%);+ border-radius: @radius-md;+ border-left: 3px solid @info;++ strong {+ color: @text-primary;+ }+ }+ }++ // Settings Tab+ .settings-tab {+ display: flex;+ flex-direction: column;+ gap: @space-4;++ .info-card {+ background: @bg-card;+ border-radius: @radius-lg;+ padding: @space-5;++ h3 {+ margin: 0 0 @space-4 0;+ font-size: @font-size-md;+ font-weight: @font-weight-semibold;+ }++ &.danger-zone {+ border: 1px solid fade(@danger, 30%);+ background: fade(@danger, 5%);++ h3 {+ color: @danger;+ }++ .text-muted {+ color: @text-secondary;+ font-size: @font-size-sm;+ margin: 0;+ }+ }+ }++ .settings-actions {+ display: flex;+ gap: @space-3;+ }+ }++ // Install Modal+ .modal-lg {+ max-width: 500px;+ }++ .install-warning {+ display: flex;+ gap: @space-3;+ background: fade(@info, 10%);+ border: 1px solid fade(@info, 30%);+ border-radius: @radius-lg;+ padding: @space-4;+ margin-bottom: @space-5;++ svg {+ flex-shrink: 0;+ color: @info;+ }++ strong {+ display: block;+ margin-bottom: @space-2;+ }++ ul {+ margin: 0;+ padding-left: @space-4;+ font-size: @font-size-sm;+ color: @text-secondary;++ li {+ margin-bottom: @space-1;+ }+ }+ }++ .required {+ color: @danger;+ }+}