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 Services UI and service-detail pages

Juan Denis6b9b542ded86
diff --git a/Dockerfile b/Dockerfile
index eb2faa23..b3d3866b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -62,8 +62,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
RUN groupadd -r serverkit && useradd -r -g serverkit serverkit
# Create necessary directories
-RUN mkdir -p /etc/serverkit /var/log/serverkit /var/quarantine /var/backups/serverkit \
- && chown -R serverkit:serverkit /etc/serverkit /var/log/serverkit /var/quarantine /var/backups/serverkit
+RUN mkdir -p /etc/serverkit /var/serverkit/apps /var/log/serverkit /var/quarantine /var/backups/serverkit \
+ && chown -R serverkit:serverkit /etc/serverkit /var/serverkit /var/log/serverkit /var/quarantine /var/backups/serverkit
# Set working directory
WORKDIR /app
diff --git a/backend/Dockerfile b/backend/Dockerfile
index fc3339a4..8f78167b 100644
--- a/backend/Dockerfile
+++ b/backend/Dockerfile
@@ -30,7 +30,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean
# Create directories for ServerKit
-RUN mkdir -p /etc/serverkit /app/logs /var/quarantine /app/instance /var/backups/serverkit
+RUN mkdir -p /etc/serverkit /var/serverkit/apps /app/logs /var/quarantine /app/instance /var/backups/serverkit
# Copy requirements first for caching
COPY requirements.txt .
diff --git a/backend/app/api/api_analytics.py b/backend/app/api/api_analytics.py
index e4ff45ef..cdfb6ad2 100644
--- a/backend/app/api/api_analytics.py
+++ b/backend/app/api/api_analytics.py
@@ -42,7 +42,7 @@ def timeseries():
@api_analytics_bp.route('/keys/<int:key_id>/usage', methods=['GET'])
-@auth_required
+@auth_required()
def key_usage(key_id):
"""Get usage stats for a specific API key."""
period = request.args.get('period', '24h')
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index 51b70402..511ab200 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -25,6 +25,8 @@ import FTPServer from './pages/FTPServer';
import Git from './pages/Git';
import CronJobs from './pages/CronJobs';
import Security from './pages/Security';
+import Services from './pages/Services';
+import ServiceDetail from './pages/ServiceDetail';
import Templates from './pages/Templates';
import WorkflowBuilder from './pages/WorkflowBuilder';
import Servers from './pages/Servers';
@@ -45,6 +47,7 @@ const PAGE_TITLES = {
'/login': 'Login',
'/register': 'Register',
'/setup': 'Setup',
+ '/services': 'Services',
'/apps': 'Applications',
'/wordpress': 'WordPress Sites',
'/wordpress/projects': 'WordPress Projects',
@@ -82,7 +85,8 @@ function PageTitleUpdater() {
const basePath = '/' + path.split('/')[1];
if (PAGE_TITLES[basePath]) {
title = PAGE_TITLES[basePath];
- } else if (path.startsWith('/apps/')) title = 'Application Details';
+ } else if (path.startsWith('/services/')) title = 'Service Details';
+ else if (path.startsWith('/apps/')) title = 'Application Details';
else if (path.startsWith('/servers/')) title = 'Server Details';
else if (path.startsWith('/wordpress/projects/')) title = 'WordPress Pipeline';
else if (path.startsWith('/wordpress/')) title = 'WordPress Site';
@@ -178,7 +182,9 @@ function AppRoutes() {
</PrivateRoute>
}>
<Route index element={<Dashboard />} />
- <Route path="apps" element={<Applications />} />
+ <Route path="services" element={<Services />} />
+ <Route path="services/:id" element={<ServiceDetail />} />
+ <Route path="apps" element={<Navigate to="/services" replace />} />
<Route path="apps/:id" element={<ApplicationDetail />} />
<Route path="apps/:id/:tab" element={<ApplicationDetail />} />
<Route path="wordpress" element={<WordPress />} />
diff --git a/frontend/src/components/Sidebar.jsx b/frontend/src/components/Sidebar.jsx
index f56dd003..8fb567af 100644
--- a/frontend/src/components/Sidebar.jsx
+++ b/frontend/src/components/Sidebar.jsx
@@ -161,13 +161,13 @@ const Sidebar = () => {
</svg>
Domains & Sites
</NavLink>
- <NavLink to="/apps" className={({ isActive }) => `nav-item ${isActive ? 'active' : ''}`}>
+ <NavLink to="/services" className={({ isActive }) => `nav-item ${isActive ? 'active' : ''}`}>
<svg className="nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
<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"/>
<polyline points="3.27 6.96 12 12.01 20.73 6.96"/>
<line x1="12" y1="22.08" x2="12" y2="12"/>
</svg>
- Applications
+ Services
</NavLink>
<NavLink to="/wordpress" className={({ isActive }) => `nav-item ${isActive ? 'active' : ''}`}>
<svg className="nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
diff --git a/frontend/src/components/service-detail/CommandsTab.jsx b/frontend/src/components/service-detail/CommandsTab.jsx
new file mode 100644
index 00000000..7fea60d7
--- /dev/null
+++ b/frontend/src/components/service-detail/CommandsTab.jsx
@@ -0,0 +1,87 @@
+import React, { useState } from 'react';
+import api from '../../services/api';
+
+const CommandsTab = ({ appId, appType }) => {
+ const [command, setCommand] = useState('');
+ const [output, setOutput] = useState(null);
+ const [running, setRunning] = useState(false);
+
+ const quickCommands = appType === 'django' ? [
+ { label: 'Run Migrations', cmd: 'python manage.py migrate' },
+ { label: 'Collect Static', cmd: 'python manage.py collectstatic --noinput' },
+ { label: 'Create Superuser', cmd: 'python manage.py createsuperuser' },
+ { label: 'Shell', cmd: 'python manage.py shell' },
+ { label: 'Check', cmd: 'python manage.py check' },
+ ] : [
+ { label: 'Flask Routes', cmd: 'flask routes' },
+ { label: 'Flask Shell', cmd: 'flask shell' },
+ { label: 'DB Upgrade', cmd: 'flask db upgrade' },
+ { label: 'DB Migrate', cmd: 'flask db migrate' },
+ ];
+
+ async function handleRun(cmd) {
+ const commandToRun = cmd || command;
+ if (!commandToRun.trim()) return;
+
+ setRunning(true);
+ setOutput(null);
+
+ try {
+ const result = await api.runPythonCommand(appId, commandToRun);
+ setOutput(result);
+ } catch (err) {
+ setOutput({ success: false, stderr: err.message });
+ } finally {
+ setRunning(false);
+ }
+ }
+
+ return (
+ <div>
+ <h3>Run Commands</h3>
+ <p className="hint">Commands run in the app's virtual environment context.</p>
+
+ <div className="quick-commands">
+ {quickCommands.map(({ label, cmd }) => (
+ <button
+ key={cmd}
+ className="btn btn-secondary btn-sm"
+ onClick={() => handleRun(cmd)}
+ disabled={running}
+ >
+ {label}
+ </button>
+ ))}
+ </div>
+
+ <div className="command-input">
+ <input
+ type="text"
+ value={command}
+ onChange={(e) => setCommand(e.target.value)}
+ placeholder="Enter command..."
+ onKeyDown={(e) => e.key === 'Enter' && handleRun()}
+ />
+ <button
+ className="btn btn-primary"
+ onClick={() => handleRun()}
+ disabled={running}
+ >
+ {running ? 'Running...' : 'Run'}
+ </button>
+ </div>
+
+ {output && (
+ <div className={`command-output ${output.success ? '' : 'error'}`}>
+ {output.stdout && <pre>{output.stdout}</pre>}
+ {output.stderr && <pre className="stderr">{output.stderr}</pre>}
+ {!output.stdout && !output.stderr && (
+ <pre>{output.success ? 'Command completed successfully' : 'Command failed'}</pre>
+ )}
+ </div>
+ )}
+ </div>
+ );
+};
+
+export default CommandsTab;
diff --git a/frontend/src/components/service-detail/EventsTab.jsx b/frontend/src/components/service-detail/EventsTab.jsx
new file mode 100644
index 00000000..b92733d1
--- /dev/null
+++ b/frontend/src/components/service-detail/EventsTab.jsx
@@ -0,0 +1,101 @@
+import React, { useState } from 'react';
+import { useDeployments } from '../../hooks/useDeployments';
+import { getDeployStatus, formatRelativeTime, formatDuration } from '../../utils/serviceTypes';
+
+const EventsTab = ({ appId }) => {
+ const { deployments, loading, error, reload } = useDeployments(appId);
+ const [expandedId, setExpandedId] = useState(null);
+
+ if (loading) {
+ return <div className="loading">Loading deployment history...</div>;
+ }
+
+ if (error) {
+ return (
+ <div className="events-tab__empty">
+ <h3>Failed to load events</h3>
+ <p>{error}</p>
+ <button className="btn btn-secondary" onClick={reload}>Retry</button>
+ </div>
+ );
+ }
+
+ if (deployments.length === 0) {
+ return (
+ <div className="events-tab__empty">
+ <svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" style={{ opacity: 0.4 }}>
+ <circle cx="12" cy="12" r="10"/>
+ <polyline points="12 6 12 12 16 14"/>
+ </svg>
+ <h3>No deployments yet</h3>
+ <p>Deploy your service to see events here.</p>
+ </div>
+ );
+ }
+
+ return (
+ <div className="events-tab">
+ <div className="events-tab__header">
+ <h3>Deployment Events</h3>
+ <button className="btn btn-secondary btn-sm" onClick={reload}>Refresh</button>
+ </div>
+
+ <div className="events-tab__timeline">
+ {deployments.map((deploy, idx) => {
+ const statusInfo = getDeployStatus(deploy.status);
+ const isExpanded = expandedId === deploy.id;
+ const isLatest = idx === 0 && deploy.status === 'success';
+
+ return (
+ <div
+ key={deploy.id}
+ className={`events-tab__event ${isExpanded ? 'events-tab__event--expanded' : ''}`}
+ onClick={() => setExpandedId(isExpanded ? null : deploy.id)}
+ >
+ <div
+ className="events-tab__event-status"
+ style={{ backgroundColor: statusInfo.color }}
+ />
+ <div className="events-tab__event-body">
+ <div className="events-tab__event-header">
+ <div className="events-tab__event-commit">
+ {deploy.commitSha && (
+ <span className="events-tab__event-sha">
+ {deploy.commitSha.substring(0, 7)}
+ </span>
+ )}
+ <span className="events-tab__event-message">
+ {deploy.commitMessage || deploy.version || `Deployment #${deployments.length - idx}`}
+ </span>
+ </div>
+ <span
+ className="events-tab__event-badge"
+ style={{
+ backgroundColor: statusInfo.color + '1a',
+ color: statusInfo.color,
+ }}
+ >
+ {isLatest ? 'Live' : statusInfo.label}
+ </span>
+ </div>
+ <div className="events-tab__event-meta">
+ {deploy.duration && <span>{formatDuration(deploy.duration)}</span>}
+ {deploy.trigger && <span>{deploy.trigger}</span>}
+ {deploy.branch && <span>{deploy.branch}</span>}
+ <span>{formatRelativeTime(deploy.timestamp)}</span>
+ </div>
+ {isExpanded && deploy.logs && (
+ <div className="events-tab__event-logs">
+ <pre>{deploy.logs}</pre>
+ </div>
+ )}
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ );
+};
+
+export default EventsTab;
diff --git a/frontend/src/components/service-detail/GitConnectModal.jsx b/frontend/src/components/service-detail/GitConnectModal.jsx
new file mode 100644
index 00000000..8b6675a3
--- /dev/null
+++ b/frontend/src/components/service-detail/GitConnectModal.jsx
@@ -0,0 +1,167 @@
+import React, { useState, useEffect } from 'react';
+import api from '../../services/api';
+import { useToast } from '../../contexts/ToastContext';
+
+const GitConnectModal = ({ appId, deployConfig, onClose, onSaved }) => {
+ const toast = useToast();
+ const [saving, setSaving] = useState(false);
+ const [repoUrl, setRepoUrl] = useState(deployConfig?.repo_url || '');
+ const [branch, setBranch] = useState(deployConfig?.branch || 'main');
+ const [autoDeploy, setAutoDeploy] = useState(deployConfig?.auto_deploy ?? true);
+ const [preDeployScript, setPreDeployScript] = useState(deployConfig?.pre_deploy_script || '');
+ const [postDeployScript, setPostDeployScript] = useState(deployConfig?.post_deploy_script || '');
+
+ function detectProvider(url) {
+ if (url.includes('github.com')) return 'GitHub';
+ if (url.includes('gitlab.com')) return 'GitLab';
+ if (url.includes('bitbucket.org')) return 'Bitbucket';
+ return null;
+ }
+
+ const provider = detectProvider(repoUrl);
+
+ async function handleSubmit(e) {
+ e.preventDefault();
+ if (!repoUrl.trim()) return;
+
+ setSaving(true);
+ try {
+ await api.configureDeployment(
+ appId,
+ repoUrl.trim(),
+ branch || 'main',
+ autoDeploy,
+ preDeployScript || null,
+ postDeployScript || null
+ );
+
+ if (autoDeploy && !deployConfig) {
+ try {
+ await api.createWebhook({
+ deploy_on_push: true,
+ app_id: appId,
+ repo_url: repoUrl.trim(),
+ branch: branch || 'main',
+ });
+ } catch {
+ // Webhook creation is best-effort
+ }
+ }
+
+ toast.success('Repository connected');
+ onSaved();
+ } catch (err) {
+ toast.error('Failed to save deployment configuration');
+ } finally {
+ setSaving(false);
+ }
+ }
+
+ async function handleDisconnect() {
+ if (!confirm('Disconnect this repository? Auto-deploy will stop.')) return;
+
+ setSaving(true);
+ try {
+ await api.removeDeployment(appId);
+ toast.success('Repository disconnected');
+ onSaved();
+ } catch (err) {
+ toast.error('Failed to disconnect repository');
+ setSaving(false);
+ }
+ }
+
+ return (
+ <div className="modal-overlay" onClick={onClose}>
+ <div className="modal-content" onClick={(e) => e.stopPropagation()}>
+ <div className="modal-header">
+ <h2>{deployConfig ? 'Edit Repository' : 'Connect Repository'}</h2>
+ <button className="modal-close" onClick={onClose}>&times;</button>
+ </div>
+
+ <form className="git-connect-modal__form" onSubmit={handleSubmit}>
+ <div className="git-connect-modal__field">
+ <label>Repository URL</label>
+ <input
+ type="text"
+ value={repoUrl}
+ onChange={(e) => setRepoUrl(e.target.value)}
+ placeholder="https://github.com/user/repo.git"
+ required
+ />
+ {provider && (
+ <span className="settings-hint" style={{ marginTop: '4px', display: 'block' }}>
+ Detected: {provider}
+ </span>
+ )}
+ </div>
+
+ <div className="git-connect-modal__field">
+ <label>Branch</label>
+ <input
+ type="text"
+ value={branch}
+ onChange={(e) => setBranch(e.target.value)}
+ placeholder="main"
+ />
+ </div>
+
+ <div className="git-connect-modal__toggle">
+ <div className="git-connect-modal__toggle-label">
+ Auto-deploy on push
+ <span>Automatically deploy when new commits are pushed to the branch.</span>
+ </div>
+ <label className="toggle">
+ <input
+ type="checkbox"
+ checked={autoDeploy}
+ onChange={(e) => setAutoDeploy(e.target.checked)}
+ />
+ <span className="toggle-slider"></span>
+ </label>
+ </div>
+
+ <div className="git-connect-modal__field">
+ <label>Pre-deploy Script (optional)</label>
+ <textarea
+ value={preDeployScript}
+ onChange={(e) => setPreDeployScript(e.target.value)}
+ placeholder="Commands to run before deployment..."
+ />
+ </div>
+
+ <div className="git-connect-modal__field">
+ <label>Post-deploy Script (optional)</label>
+ <textarea
+ value={postDeployScript}
+ onChange={(e) => setPostDeployScript(e.target.value)}
+ placeholder="Commands to run after deployment..."
+ />
+ </div>
+
+ <div className="git-connect-modal__actions">
+ {deployConfig && (
+ <button
+ type="button"
+ className="btn btn-danger"
+ onClick={handleDisconnect}
+ disabled={saving}
+ style={{ marginRight: 'auto' }}
+ >
+ Disconnect
+ </button>
+ )}
+ <button type="button" className="btn btn-secondary" onClick={onClose}>
+ Cancel
+ </button>
+ <button type="submit" className="btn btn-primary" disabled={saving}>
+ {saving ? 'Saving...' : deployConfig ? 'Save Changes' : 'Connect'}
+ </button>
+ </div>
+ </form>
+ </div>
+ </div>
+ );
+};
+
+export default GitConnectModal;
diff --git a/frontend/src/components/service-detail/GunicornTab.jsx b/frontend/src/components/service-detail/GunicornTab.jsx
new file mode 100644
index 00000000..f377270c
--- /dev/null
+++ b/frontend/src/components/service-detail/GunicornTab.jsx
@@ -0,0 +1,60 @@
+import React, { useState, useEffect } from 'react';
+import api from '../../services/api';
+import { useToast } from '../../contexts/ToastContext';
+
+const GunicornTab = ({ appId }) => {
+ const toast = useToast();
+ const [config, setConfig] = useState('');
+ const [loading, setLoading] = useState(true);
+ const [saving, setSaving] = useState(false);
+
+ useEffect(() => {
+ loadConfig();
+ }, [appId]);
+
+ async function loadConfig() {
+ try {
+ const data = await api.getGunicornConfig(appId);
+ setConfig(data.content || '');
+ } catch (err) {
+ console.error('Failed to load config:', err);
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ async function handleSave() {
+ setSaving(true);
+ try {
+ await api.updateGunicornConfig(appId, config);
+ toast.success('Configuration saved. Restart the app to apply changes.');
+ } catch (err) {
+ toast.error('Failed to save configuration');
+ } finally {
+ setSaving(false);
+ }
+ }
+
+ if (loading) {
+ return <div className="loading">Loading Gunicorn configuration...</div>;
+ }
+
+ return (
+ <div>
+ <div className="section-header">
+ <h3>Gunicorn Configuration</h3>
+ <button className="btn btn-primary" onClick={handleSave} disabled={saving}>
+ {saving ? 'Saving...' : 'Save'}
+ </button>
+ </div>
+ <textarea
+ className="code-editor"
+ value={config}
+ onChange={(e) => setConfig(e.target.value)}
+ spellCheck={false}
+ />
+ </div>
+ );
+};
+
+export default GunicornTab;
diff --git a/frontend/src/components/service-detail/LogsTab.jsx b/frontend/src/components/service-detail/LogsTab.jsx
new file mode 100644
index 00000000..3c40dba2
--- /dev/null
+++ b/frontend/src/components/service-detail/LogsTab.jsx
@@ -0,0 +1,66 @@
+import React, { useState, useEffect } from 'react';
+import api from '../../services/api';
+
+const LogsTab = ({ app }) => {
+ const [logs, setLogs] = useState('');
+ const [loading, setLoading] = useState(true);
+ const [autoRefresh, setAutoRefresh] = useState(false);
+
+ const isDockerApp = app.app_type === 'docker';
+ const isPythonApp = ['flask', 'django'].includes(app.app_type);
+
+ useEffect(() => {
+ loadLogs();
+ }, [app.id]);
+
+ useEffect(() => {
+ if (!autoRefresh) return;
+ const interval = setInterval(loadLogs, 5000);
+ return () => clearInterval(interval);
+ }, [autoRefresh, app.id]);
+
+ async function loadLogs() {
+ try {
+ let data;
+ if (isDockerApp) {
+ data = await api.getDockerAppLogs(app.id, 200);
+ } else if (isPythonApp) {
+ data = await api.getPythonAppLogs(app.id, 200);
+ } else {
+ data = { logs: 'Logs not available for this app type.' };
+ }
+ setLogs(data.logs || 'No logs available');
+ } catch (err) {
+ console.error('Failed to load logs:', err);
+ setLogs('Failed to load logs');
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ return (
+ <div className="logs-tab">
+ <div className="logs-header">
+ <h3>Application Logs</h3>
+ <div className="logs-controls">
+ {isPythonApp && <span className="hint">Gunicorn/systemd Logs</span>}
+ {isDockerApp && <span className="hint">Docker Compose Logs</span>}
+ <label className="checkbox-inline">
+ <input
+ type="checkbox"
+ checked={autoRefresh}
+ onChange={(e) => setAutoRefresh(e.target.checked)}
+ />
+ Auto-refresh
+ </label>
+ <button className="btn btn-secondary btn-sm" onClick={loadLogs}>
+ Refresh
+ </button>
+ </div>
+ </div>
+ <pre className="log-viewer">{loading ? 'Loading...' : logs}</pre>
+ </div>
+ );
+};
+
+export default LogsTab;
diff --git a/frontend/src/components/service-detail/MetricsTab.jsx b/frontend/src/components/service-detail/MetricsTab.jsx
new file mode 100644
index 00000000..ccaffe60
--- /dev/null
+++ b/frontend/src/components/service-detail/MetricsTab.jsx
@@ -0,0 +1,182 @@
+import React, { useState, useEffect } from 'react';
+import api from '../../services/api';
+
+const MetricsTab = ({ app }) => {
+ const [stats, setStats] = useState(null);
+ const [processInfo, setProcessInfo] = useState(null);
+ const [loading, setLoading] = useState(true);
+
+ const isDocker = app.app_type === 'docker';
+ const isPython = ['flask', 'django'].includes(app.app_type);
+
+ useEffect(() => {
+ loadMetrics();
+ const interval = setInterval(loadMetrics, 10000);
+ return () => clearInterval(interval);
+ }, [app.id]);
+
+ async function loadMetrics() {
+ try {
+ if (isDocker) {
+ const data = await api.getContainers(true);
+ const appContainers = (data.containers || []).filter(c =>
+ c.Names?.some(n => n.includes(app.name)) ||
+ c.Labels?.['com.docker.compose.project'] === app.name
+ );
+
+ if (appContainers.length > 0) {
+ const containerStats = await api.getContainerStats(appContainers[0].Id);
+ setStats(containerStats);
+ }
+ } else if (isPython) {
+ const data = await api.getPythonAppStatus(app.id);
+ setProcessInfo(data);
+ }
+ } catch (err) {
+ console.error('Failed to load metrics:', err);
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ function getBarColor(percent) {
+ if (percent > 80) return 'var(--danger, #ef4444)';
+ if (percent > 60) return 'var(--warning, #f59e0b)';
+ return 'var(--success, #10b981)';
+ }
+
+ if (loading) {
+ return <div className="loading">Loading metrics...</div>;
+ }
+
+ if (isDocker && stats) {
+ const cpuPercent = parseFloat(stats.cpu_percent || stats.CPUPerc || 0);
+ const memPercent = parseFloat(stats.memory_percent || stats.MemPerc || 0);
+ const memUsage = stats.memory_usage || stats.MemUsage || 'N/A';
+ const netIO = stats.net_io || stats.NetIO || 'N/A';
+ const blockIO = stats.block_io || stats.BlockIO || 'N/A';
+ const pids = stats.pids || stats.PIDs || 'N/A';
+
+ return (
+ <div className="metrics-tab">
+ <div className="metrics-tab__grid">
+ <div className="metrics-tab__card">
+ <div className="metrics-tab__card-header">
+ <h4>CPU Usage</h4>
+ <span>{cpuPercent.toFixed(1)}%</span>
+ </div>
+ <div className="metrics-tab__bar">
+ <div
+ className="metrics-tab__bar-fill"
+ style={{
+ width: `${Math.min(cpuPercent, 100)}%`,
+ backgroundColor: getBarColor(cpuPercent),
+ }}
+ />
+ </div>
+ </div>
+
+ <div className="metrics-tab__card">
+ <div className="metrics-tab__card-header">
+ <h4>Memory Usage</h4>
+ <span>{memPercent.toFixed(1)}%</span>
+ </div>
+ <div className="metrics-tab__bar">
+ <div
+ className="metrics-tab__bar-fill"
+ style={{
+ width: `${Math.min(memPercent, 100)}%`,
+ backgroundColor: getBarColor(memPercent),
+ }}
+ />
+ </div>
+ <div className="metrics-tab__info">{memUsage}</div>
+ </div>
+
+ <div className="metrics-tab__card">
+ <div className="metrics-tab__card-header">
+ <h4>Network I/O</h4>
+ </div>
+ <div className="metrics-tab__info">{netIO}</div>
+ </div>
+
+ <div className="metrics-tab__card">
+ <div className="metrics-tab__card-header">
+ <h4>Block I/O</h4>
+ </div>
+ <div className="metrics-tab__info">{blockIO}</div>
+ </div>
+
+ <div className="metrics-tab__card">
+ <div className="metrics-tab__card-header">
+ <h4>Processes</h4>
+ <span>{pids}</span>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+ }
+
+ if (isPython && processInfo) {
+ return (
+ <div className="metrics-tab">
+ <div className="metrics-tab__grid">
+ <div className="metrics-tab__card">
+ <div className="metrics-tab__card-header">
+ <h4>Service Status</h4>
+ </div>
+ <div className="metrics-tab__info">
+ {processInfo.active ? 'Active (running)' : 'Inactive'}
+ </div>
+ </div>
+
+ {processInfo.pid && (
+ <div className="metrics-tab__card">
+ <div className="metrics-tab__card-header">
+ <h4>Process ID</h4>
+ <span>{processInfo.pid}</span>
+ </div>
+ </div>
+ )}
+
+ {processInfo.memory && (
+ <div className="metrics-tab__card">
+ <div className="metrics-tab__card-header">
+ <h4>Memory</h4>
+ <span>{processInfo.memory}</span>
+ </div>
+ </div>
+ )}
+
+ {processInfo.uptime && (
+ <div className="metrics-tab__card">
+ <div className="metrics-tab__card-header">
+ <h4>Uptime</h4>
+ </div>
+ <div className="metrics-tab__info">{processInfo.uptime}</div>
+ </div>
+ )}
+
+ {processInfo.workers && (
+ <div className="metrics-tab__card">
+ <div className="metrics-tab__card-header">
+ <h4>Workers</h4>
+ <span>{processInfo.workers}</span>
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+ );
+ }
+
+ return (
+ <div className="events-tab__empty">
+ <h3>No metrics available</h3>
+ <p>Start the service to view resource metrics.</p>
+ </div>
+ );
+};
+
+export default MetricsTab;
diff --git a/frontend/src/components/service-detail/PackagesTab.jsx b/frontend/src/components/service-detail/PackagesTab.jsx
new file mode 100644
index 00000000..79d99db8
--- /dev/null
+++ b/frontend/src/components/service-detail/PackagesTab.jsx
@@ -0,0 +1,89 @@
+import React, { useState, useEffect } from 'react';
+import api from '../../services/api';
+import { useToast } from '../../contexts/ToastContext';
+
+const PackagesTab = ({ appId }) => {
+ const toast = useToast();
+ const [packages, setPackages] = useState([]);
+ const [loading, setLoading] = useState(true);
+ const [installing, setInstalling] = useState(false);
+ const [newPackage, setNewPackage] = useState('');
+
+ useEffect(() => {
+ loadPackages();
+ }, [appId]);
+
+ async function loadPackages() {
+ try {
+ const data = await api.getPythonPackages(appId);
+ setPackages(data.packages || []);
+ } catch (err) {
+ console.error('Failed to load packages:', err);
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ async function handleInstall(e) {
+ e.preventDefault();
+ if (!newPackage.trim()) return;
+
+ setInstalling(true);
+ try {
+ await api.installPythonPackages(appId, [newPackage.trim()]);
+ setNewPackage('');
+ loadPackages();
+ } catch (err) {
+ console.error('Failed to install package:', err);
+ } finally {
+ setInstalling(false);
+ }
+ }
+
+ async function handleFreeze() {
+ try {
+ await api.freezePythonRequirements(appId);
+ toast.success('requirements.txt updated');
+ } catch (err) {
+ toast.error('Failed to freeze requirements');
+ }
+ }
+
+ if (loading) {
+ return <div className="loading">Loading packages...</div>;
+ }
+
+ return (
+ <div>
+ <div className="section-header">
+ <h3>Installed Packages</h3>
+ <button className="btn btn-secondary btn-sm" onClick={handleFreeze}>
+ Freeze to requirements.txt
+ </button>
+ </div>
+
+ <form className="install-form" onSubmit={handleInstall}>
+ <input
+ type="text"
+ value={newPackage}
+ onChange={(e) => setNewPackage(e.target.value)}
+ placeholder="Package name (e.g., requests, flask==2.0.0)"
+ />
+ <button type="submit" className="btn btn-primary" disabled={installing}>
+ {installing ? 'Installing...' : 'Install'}
+ </button>
+ </form>
+
+ <div className="packages-list">
+ {packages.map(pkg => (
+ <div key={pkg.name} className="package-item">
+ <span className="package-name">{pkg.name}</span>
+ <span className="package-version">{pkg.version}</span>
+ </div>
+ ))}
+ </div>
+ </div>
+ );
+};
+
+export default PackagesTab;
diff --git a/frontend/src/components/service-detail/SettingsTab.jsx b/frontend/src/components/service-detail/SettingsTab.jsx
new file mode 100644
index 00000000..554680ec
--- /dev/null
+++ b/frontend/src/components/service-detail/SettingsTab.jsx
@@ -0,0 +1,164 @@
+import React, { useState } from 'react';
+import { useNavigate } from 'react-router-dom';
+import api from '../../services/api';
+import { useToast } from '../../contexts/ToastContext';
+
+const SettingsTab = ({ app, deployConfig, onUpdate, onOpenGitModal }) => {
+ const navigate = useNavigate();
+ const toast = useToast();
+ const [deleting, setDeleting] = useState(false);
+ const [environmentType, setEnvironmentType] = useState(app.environment_type || 'standalone');
+ const [savingEnvironment, setSavingEnvironment] = useState(false);
+ const [unlinking, setUnlinking] = useState(false);
+
+ const envLabels = {
+ standalone: 'Standalone',
+ production: 'Production',
+ development: 'Development',
+ staging: 'Staging',
+ };
+
+ async function handleEnvironmentChange(newType) {
+ if (newType === app.environment_type) return;
+
+ setSavingEnvironment(true);
+ try {
+ await api.updateAppEnvironment(app.id, newType);
+ setEnvironmentType(newType);
+ onUpdate();
+ } catch (err) {
+ toast.error('Failed to update environment type');
+ setEnvironmentType(app.environment_type || 'standalone');
+ } finally {
+ setSavingEnvironment(false);
+ }
+ }
+
+ async function handleUnlink() {
+ if (!confirm(`Unlink ${app.name} from its linked application?`)) return;
+
+ setUnlinking(true);
+ try {
+ await api.unlinkApp(app.id);
+ onUpdate();
+ } catch (err) {
+ toast.error('Failed to unlink app');
+ } finally {
+ setUnlinking(false);
+ }
+ }
+
+ async function handleDelete() {
+ if (!confirm(`Delete ${app.name}? This action cannot be undone.`)) return;
+ if (!confirm('Are you sure? This will permanently remove the service.')) return;
+
+ setDeleting(true);
+ try {
+ await api.deleteApp(app.id);
+ navigate('/services');
+ } catch (err) {
+ toast.error('Failed to delete service');
+ setDeleting(false);
+ }
+ }
+
+ return (
+ <div className="svc-settings">
+ {/* Repository Configuration */}
+ <div className="svc-settings__section">
+ <h3 className="svc-settings__section-title">Repository</h3>
+ <div className="card">
+ <div className="settings-row">
+ <div className="settings-label">
+ <span>Connected Repository</span>
+ <span className="settings-hint">
+ {deployConfig
+ ? `${deployConfig.repo_url} (${deployConfig.branch || 'main'})`
+ : 'No repository connected'}
+ </span>
+ </div>
+ <div className="settings-control">
+ <button className="btn btn-secondary" onClick={onOpenGitModal}>
+ {deployConfig ? 'Edit' : 'Connect'}
+ </button>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ {/* Environment Configuration */}
+ <div className="svc-settings__section">
+ <h3 className="svc-settings__section-title">Environment</h3>
+ <div className="card settings-section">
+ <div className="settings-row">
+ <div className="settings-label">
+ <span>Environment Type</span>
+ <span className="settings-hint">
+ {app.has_linked_app
+ ? 'This app is linked. Unlink to change environment type.'
+ : 'Set how this application is used in your workflow.'}
+ </span>
+ </div>
+ <div className="settings-control">
+ {app.has_linked_app ? (
+ <span className={`env-badge env-${app.environment_type}`}>
+ {envLabels[app.environment_type] || app.environment_type}
+ </span>
+ ) : (
+ <select
+ value={environmentType}
+ onChange={(e) => handleEnvironmentChange(e.target.value)}
+ disabled={savingEnvironment}
+ className="settings-select"
+ >
+ <option value="standalone">Standalone</option>
+ <option value="development">Development</option>
+ <option value="staging">Staging</option>
+ <option value="production">Production</option>
+ </select>
+ )}
+ {savingEnvironment && <span className="settings-saving">Saving...</span>}
+ </div>
+ </div>
+
+ {app.has_linked_app && (
+ <div className="settings-row">
+ <div className="settings-label">
+ <span>Linked Application</span>
+ <span className="settings-hint">
+ Unlinking will reset both apps to standalone mode.
+ </span>
+ </div>
+ <div className="settings-control">
+ <button
+ className="btn btn-secondary"
+ onClick={handleUnlink}
+ disabled={unlinking}
+ >
+ {unlinking ? 'Unlinking...' : 'Unlink'}
+ </button>
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+
+ {/* Danger Zone */}
+ <div className="svc-settings__section">
+ <h3 className="svc-settings__section-title">Danger Zone</h3>
+ <div className="card danger-zone">
+ <p>Once you delete a service, there is no going back. All data will be permanently removed.</p>
+ <button
+ className="btn btn-danger"
+ onClick={handleDelete}
+ disabled={deleting}
+ >
+ {deleting ? 'Deleting...' : 'Delete Service'}
+ </button>
+ </div>
+ </div>
+ </div>
+ );
+};
+
+export default SettingsTab;
diff --git a/frontend/src/components/service-detail/ShellTab.jsx b/frontend/src/components/service-detail/ShellTab.jsx
new file mode 100644
index 00000000..69d95bc0
--- /dev/null
+++ b/frontend/src/components/service-detail/ShellTab.jsx
@@ -0,0 +1,130 @@
+import React, { useState, useEffect, useRef } from 'react';
+import api from '../../services/api';
+
+const ShellTab = ({ appId, appName }) => {
+ const [containers, setContainers] = useState([]);
+ const [selectedContainer, setSelectedContainer] = useState(null);
+ const [history, setHistory] = useState([]);
+ const [command, setCommand] = useState('');
+ const [running, setRunning] = useState(false);
+ const [loading, setLoading] = useState(true);
+ const terminalRef = useRef(null);
+
+ useEffect(() => {
+ loadContainers();
+ }, [appId]);
+
+ useEffect(() => {
+ if (terminalRef.current) {
+ terminalRef.current.scrollTop = terminalRef.current.scrollHeight;
+ }
+ }, [history]);
+
+ async function loadContainers() {
+ try {
+ const data = await api.getContainers(true);
+ const appContainers = (data.containers || []).filter(c =>
+ c.Names?.some(n => n.includes(appName)) ||
+ c.Labels?.['com.docker.compose.project'] === appName
+ );
+ setContainers(appContainers);
+ if (appContainers.length > 0 && !selectedContainer) {
+ setSelectedContainer(appContainers[0].Id);
+ }
+ } catch (err) {
+ console.error('Failed to load containers:', err);
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ async function handleExec(e) {
+ e.preventDefault();
+ if (!command.trim() || !selectedContainer) return;
+
+ const cmd = command.trim();
+ setCommand('');
+ setRunning(true);
+ setHistory(prev => [...prev, { type: 'input', text: cmd }]);
+
+ try {
+ const result = await api.execContainer(selectedContainer, cmd);
+ if (result.output) {
+ setHistory(prev => [...prev, { type: 'output', text: result.output }]);
+ }
+ if (result.error) {
+ setHistory(prev => [...prev, { type: 'error', text: result.error }]);
+ }
+ } catch (err) {
+ setHistory(prev => [...prev, { type: 'error', text: err.message || 'Command failed' }]);
+ } finally {
+ setRunning(false);
+ }
+ }
+
+ if (loading) {
+ return <div className="loading">Loading containers...</div>;
+ }
+
+ if (containers.length === 0) {
+ return (
+ <div className="events-tab__empty">
+ <h3>No running containers</h3>
+ <p>Start the service to access the shell.</p>
+ </div>
+ );
+ }
+
+ return (
+ <div className="shell-tab">
+ <div className="shell-tab__container">
+ <div className="shell-tab__header">
+ <span style={{ fontSize: '13px', color: 'var(--text-secondary)' }}>Container Shell</span>
+ {containers.length > 1 && (
+ <select
+ value={selectedContainer || ''}
+ onChange={(e) => setSelectedContainer(e.target.value)}
+ style={{ fontSize: '12px' }}
+ >
+ {containers.map(c => (
+ <option key={c.Id} value={c.Id}>
+ {c.Names?.[0]?.replace(/^\//, '') || c.Id.substring(0, 12)}
+ </option>
+ ))}
+ </select>
+ )}
+ </div>
+
+ <div className="shell-tab__terminal" ref={terminalRef}>
+ {history.length === 0 && (
+ <div style={{ color: '#8b949e' }}>
+ Type a command below to execute it in the container.
+ </div>
+ )}
+ {history.map((line, i) => (
+ <div key={i} className={`shell-tab__line shell-tab__line--${line.type}`}>
+ {line.type === 'input' && '$ '}
+ {line.text}
+ </div>
+ ))}
+ {running && <div style={{ color: '#8b949e' }}>Running...</div>}
+ </div>
+
+ <form className="shell-tab__input-row" onSubmit={handleExec}>
+ <span className="shell-tab__prompt">$</span>
+ <input
+ className="shell-tab__input"
+ type="text"
+ value={command}
+ onChange={(e) => setCommand(e.target.value)}
+ placeholder="Enter command..."
+ disabled={running}
+ autoFocus
+ />
+ </form>
+ </div>
+ </div>
+ );
+};
+
+export default ShellTab;
diff --git a/frontend/src/hooks/useDeployments.js b/frontend/src/hooks/useDeployments.js
new file mode 100644
index 00000000..768f6e2f
--- /dev/null
+++ b/frontend/src/hooks/useDeployments.js
@@ -0,0 +1,72 @@
+import { useState, useEffect, useCallback } from 'react';
+import api from '../services/api';
+
+export function useDeployments(appId) {
+ const [deployments, setDeployments] = useState([]);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState(null);
+
+ const load = useCallback(async () => {
+ if (!appId) return;
+ try {
+ setLoading(true);
+ setError(null);
+
+ // Fetch from both deploy systems in parallel
+ const [buildRes, deployRes] = await Promise.allSettled([
+ api.getDeployments(appId, 20),
+ api.getDeploymentHistory(appId, 20),
+ ]);
+
+ const buildDeploys = buildRes.status === 'fulfilled'
+ ? (buildRes.value.deployments || []).map(d => ({
+ id: d.id || d.version,
+ type: 'build',
+ status: d.status || 'success',
+ version: d.version,
+ commitSha: d.commit_sha || d.git_commit,
+ commitMessage: d.commit_message || d.description,
+ branch: d.branch,
+ trigger: d.trigger || 'manual',
+ duration: d.duration,
+ timestamp: d.created_at || d.timestamp,
+ logs: d.logs,
+ }))
+ : [];
+
+ const gitDeploys = deployRes.status === 'fulfilled'
+ ? (deployRes.value.deployments || []).map(d => ({
+ id: d.id || `deploy-${d.timestamp}`,
+ type: 'deploy',
+ status: d.status || 'success',
+ version: d.version,
+ commitSha: d.commit_sha || d.git_commit,
+ commitMessage: d.commit_message || d.description,
+ branch: d.branch,
+ trigger: d.trigger || (d.auto ? 'push' : 'manual'),
+ duration: d.duration,
+ timestamp: d.created_at || d.timestamp,
+ logs: d.logs,
+ }))
+ : [];
+
+ // Merge and deduplicate by timestamp proximity, sort newest first
+ const all = [...buildDeploys, ...gitDeploys];
+ all.sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp));
+
+ setDeployments(all);
+ } catch (err) {
+ setError(err.message || 'Failed to load deployments');
+ } finally {
+ setLoading(false);
+ }
+ }, [appId]);
+
+ useEffect(() => {
+ load();
+ }, [load]);
+
+ return { deployments, loading, error, reload: load };
+}
+
+export default useDeployments;
diff --git a/frontend/src/hooks/useService.js b/frontend/src/hooks/useService.js
new file mode 100644
index 00000000..a21ea4a3
--- /dev/null
+++ b/frontend/src/hooks/useService.js
@@ -0,0 +1,82 @@
+import { useState, useEffect, useCallback } from 'react';
+import api from '../services/api';
+import { getServiceType, getStatusConfig } from '../utils/serviceTypes';
+
+export function useService(id) {
+ const [service, setService] = useState(null);
+ const [deployConfig, setDeployConfig] = useState(null);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState(null);
+
+ const load = useCallback(async () => {
+ if (!id) return;
+ try {
+ setLoading(true);
+ setError(null);
+
+ const appRes = await api.getApp(id);
+ const app = appRes.app;
+
+ // Fetch deploy config in parallel (non-blocking)
+ let dc = null;
+ try {
+ const dcRes = await api.getDeployConfig(id);
+ if (dcRes.configured) {
+ dc = dcRes.config;
+ }
+ } catch {
+ // Deploy config may not exist for all apps
+ }
+
+ const typeInfo = getServiceType(app.app_type);
+ const statusInfo = getStatusConfig(app.status);
+
+ setService({
+ ...app,
+ typeInfo,
+ statusInfo,
+ isPython: ['flask', 'django'].includes(app.app_type),
+ isDocker: app.app_type === 'docker',
+ isRunning: app.status === 'running',
+ });
+ setDeployConfig(dc);
+ } catch (err) {
+ setError(err.message || 'Failed to load service');
+ } finally {
+ setLoading(false);
+ }
+ }, [id]);
+
+ useEffect(() => {
+ load();
+ }, [load]);
+
+ const performAction = useCallback(async (action) => {
+ if (!id) return;
+ try {
+ if (action === 'start') await api.startApp(id);
+ else if (action === 'stop') await api.stopApp(id);
+ else if (action === 'restart') await api.restartApp(id);
+ await load();
+ } catch (err) {
+ throw err;
+ }
+ }, [id, load]);
+
+ const deleteService = useCallback(async () => {
+ if (!id) return;
+ await api.deleteApp(id);
+ }, [id]);
+
+ return {
+ service,
+ deployConfig,
+ loading,
+ error,
+ reload: load,
+ performAction,
+ deleteService,
+ };
+}
+
+export default useService;
diff --git a/frontend/src/pages/ServiceDetail.jsx b/frontend/src/pages/ServiceDetail.jsx
new file mode 100644
index 00000000..24794741
--- /dev/null
+++ b/frontend/src/pages/ServiceDetail.jsx
@@ -0,0 +1,374 @@
+import React, { useState, useEffect, useRef } from 'react';
+import { useParams, useNavigate, Link } from 'react-router-dom';
+import { useToast } from '../contexts/ToastContext';
+import { useService } from '../hooks/useService';
+import { getTabsForType } from '../utils/serviceTypes';
+import EnvironmentVariables from '../components/EnvironmentVariables';
+import EventsTab from '../components/service-detail/EventsTab';
+import LogsTab from '../components/service-detail/LogsTab';
+import ShellTab from '../components/service-detail/ShellTab';
+import SettingsTab from '../components/service-detail/SettingsTab';
+import MetricsTab from '../components/service-detail/MetricsTab';
+import PackagesTab from '../components/service-detail/PackagesTab';
+import GunicornTab from '../components/service-detail/GunicornTab';
+import CommandsTab from '../components/service-detail/CommandsTab';
+import GitConnectModal from '../components/service-detail/GitConnectModal';
+
+const TAB_LABELS = {
+ events: 'Events',
+ logs: 'Logs',
+ environment: 'Environment',
+ shell: 'Shell',
+ metrics: 'Metrics',
+ packages: 'Packages',
+ gunicorn: 'Gunicorn',
+ commands: 'Commands',
+ settings: 'Settings',
+};
+
+const ServiceDetail = () => {
+ const { id } = useParams();
+ const navigate = useNavigate();
+ const toast = useToast();
+ const { service, deployConfig, loading, error, reload, performAction, deleteService } = useService(id);
+ const [activeTab, setActiveTab] = useState('events');
+ const [showDeployMenu, setShowDeployMenu] = useState(false);
+ const [showMoreMenu, setShowMoreMenu] = useState(false);
+ const [showGitModal, setShowGitModal] = useState(false);
+ const [actionLoading, setActionLoading] = useState(null);
+ const deployMenuRef = useRef(null);
+ const moreMenuRef = useRef(null);
+
+ // Redirect WordPress apps
+ useEffect(() => {
+ if (service && service.app_type === 'wordpress') {
+ navigate(`/wordpress/${id}`, { replace: true });
+ }
+ }, [service, id, navigate]);
+
+ // Close menus on outside click
+ useEffect(() => {
+ const handleClick = (e) => {
+ if (deployMenuRef.current && !deployMenuRef.current.contains(e.target)) {
+ setShowDeployMenu(false);
+ }
+ if (moreMenuRef.current && !moreMenuRef.current.contains(e.target)) {
+ setShowMoreMenu(false);
+ }
+ };
+ document.addEventListener('mousedown', handleClick);
+ return () => document.removeEventListener('mousedown', handleClick);
+ }, []);
+
+ async function handleAction(action) {
+ setActionLoading(action);
+ try {
+ await performAction(action);
+ toast.success(`Service ${action}ed successfully`);
+ } catch (err) {
+ toast.error(`Failed to ${action} service`);
+ } finally {
+ setActionLoading(null);
+ setShowDeployMenu(false);
+ setShowMoreMenu(false);
+ }
+ }
+
+ async function handleDelete() {
+ if (!confirm(`Delete ${service.name}? This action cannot be undone.`)) return;
+ if (!confirm('Are you sure? This will permanently remove the service and all its data.')) return;
+
+ setActionLoading('delete');
+ try {
+ await deleteService();
+ navigate('/services');
+ } catch (err) {
+ toast.error('Failed to delete service');
+ setActionLoading(null);
+ }
+ }
+
+ if (loading) {
+ return <div className="loading">Loading service...</div>;
+ }
+
+ if (error || !service) {
+ return (
+ <div className="empty-state">
+ <h3>Service not found</h3>
+ <p>{error || 'The service you are looking for does not exist.'}</p>
+ <button className="btn btn-primary" onClick={() => navigate('/services')}>
+ Back to Services
+ </button>
+ </div>
+ );
+ }
+
+ const availableTabs = getTabsForType(service.app_type);
+
+ return (
+ <div className="svc-detail">
+ {/* Breadcrumb */}
+ <div className="svc-detail__breadcrumb">
+ <Link to="/services">Services</Link>
+ <span className="svc-detail__breadcrumb-sep">/</span>
+ <span className="svc-detail__breadcrumb-current">{service.name}</span>
+ </div>
+
+ {/* Header */}
+ <div className="svc-detail__header">
+ <div className="svc-detail__header-left">
+ <div
+ className="svc-detail__icon"
+ style={{ backgroundColor: service.typeInfo.bgColor, color: service.typeInfo.color }}
+ >
+ <ServiceIcon type={service.app_type} />
+ </div>
+ <div className="svc-detail__title-block">
+ <div className="svc-detail__title-row">
+ <h1>{service.name}</h1>
+ <span className={`svc-detail__status svc-detail__status--${service.statusInfo.dotClass}`}>
+ <span className="svc-detail__status-dot" />
+ {service.statusInfo.label}
+ </span>
+ <span
+ className="svc-detail__type-badge"
+ style={{ backgroundColor: service.typeInfo.bgColor, color: service.typeInfo.color, borderColor: service.typeInfo.borderColor }}
+ >
+ {service.typeInfo.label}
+ </span>
+ </div>
+ <div className="svc-detail__subtitle">
+ {service.port && <span className="mono">Port {service.port}</span>}
+ {service.port && <span className="svc-detail__sep">&middot;</span>}
+ <span>Created {new Date(service.created_at).toLocaleDateString()}</span>
+ </div>
+ </div>
+ </div>
+
+ <div className="svc-detail__header-actions">
+ {/* Deploy dropdown */}
+ <div className="svc-detail__dropdown" ref={deployMenuRef}>
+ <button
+ className="btn btn-primary"
+ onClick={() => setShowDeployMenu(!showDeployMenu)}
+ >
+ Deploy
+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" style={{ marginLeft: 4 }}>
+ <polyline points="6 9 12 15 18 9"/>
+ </svg>
+ </button>
+ {showDeployMenu && (
+ <div className="svc-detail__dropdown-menu">
+ <button onClick={() => handleAction('restart')} disabled={actionLoading === 'restart'}>
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
+ <polyline points="23 4 23 10 17 10"/>
+ <path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>
+ </svg>
+ Manual Deploy (Restart)
+ </button>
+ {deployConfig && (
+ <button onClick={() => {
+ setShowDeployMenu(false);
+ setActiveTab('events');
+ }}>
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" 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>
+ Deploy Latest Commit
+ </button>
+ )}
+ </div>
+ )}
+ </div>
+
+ {/* Restart button */}
+ {service.isRunning && (
+ <button
+ className="btn btn-secondary"
+ onClick={() => handleAction('restart')}
+ disabled={actionLoading === 'restart'}
+ >
+ {actionLoading === 'restart' ? 'Restarting...' : 'Restart'}
+ </button>
+ )}
+
+ {/* Start/Stop */}
+ {!service.isRunning && (
+ <button
+ className="btn btn-secondary"
+ onClick={() => handleAction('start')}
+ disabled={actionLoading === 'start'}
+ >
+ {actionLoading === 'start' ? 'Starting...' : 'Start'}
+ </button>
+ )}
+
+ {/* Three-dot menu */}
+ <div className="svc-detail__dropdown" ref={moreMenuRef}>
+ <button
+ className="btn btn-ghost btn-icon"
+ onClick={() => setShowMoreMenu(!showMoreMenu)}
+ >
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
+ <circle cx="12" cy="5" r="2"/>
+ <circle cx="12" cy="12" r="2"/>
+ <circle cx="12" cy="19" r="2"/>
+ </svg>
+ </button>
+ {showMoreMenu && (
+ <div className="svc-detail__dropdown-menu svc-detail__dropdown-menu--right">
+ {service.isRunning && (
+ <button onClick={() => handleAction('stop')} disabled={actionLoading === 'stop'}>
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor">
+ <rect x="6" y="6" width="12" height="12"/>
+ </svg>
+ Suspend Service
+ </button>
+ )}
+ {service.port && (
+ <a
+ href={`http://localhost:${service.port}`}
+ target="_blank"
+ rel="noopener noreferrer"
+ onClick={() => setShowMoreMenu(false)}
+ >
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
+ <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>
+ <polyline points="15 3 21 3 21 9"/>
+ <line x1="10" y1="14" x2="21" y2="3"/>
+ </svg>
+ Open in Browser
+ </a>
+ )}
+ <div className="svc-detail__dropdown-divider" />
+ <button
+ className="svc-detail__dropdown-danger"
+ onClick={handleDelete}
+ disabled={actionLoading === 'delete'}
+ >
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
+ <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>
+ Delete Service
+ </button>
+ </div>
+ )}
+ </div>
+ </div>
+ </div>
+
+ {/* Repo Connection Pill */}
+ <div className="svc-detail__repo-bar">
+ {deployConfig ? (
+ <div className="svc-detail__repo-pill" onClick={() => setShowGitModal(true)}>
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" 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>
+ <span className="svc-detail__repo-url">{extractRepoDisplay(deployConfig.repo_url)}</span>
+ <span className="svc-detail__repo-arrow">&rarr;</span>
+ <span className="svc-detail__repo-branch">{deployConfig.branch || 'main'}</span>
+ {deployConfig.auto_deploy && (
+ <span className="svc-detail__auto-deploy-badge">Auto</span>
+ )}
+ </div>
+ ) : (
+ <button className="svc-detail__connect-repo" onClick={() => setShowGitModal(true)}>
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" 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>
+ Connect a repository
+ </button>
+ )}
+ </div>
+
+ {/* Tab Bar */}
+ <div className="svc-detail__tabs">
+ {availableTabs.map(tab => (
+ <button
+ key={tab}
+ className={`svc-detail__tab ${activeTab === tab ? 'svc-detail__tab--active' : ''}`}
+ onClick={() => setActiveTab(tab)}
+ >
+ {TAB_LABELS[tab] || tab}
+ </button>
+ ))}
+ </div>
+
+ {/* Tab Content */}
+ <div className="svc-detail__content">
+ {activeTab === 'events' && <EventsTab appId={service.id} />}
+ {activeTab === 'logs' && <LogsTab app={service} />}
+ {activeTab === 'environment' && <EnvironmentVariables appId={service.id} />}
+ {activeTab === 'shell' && service.isDocker && <ShellTab appId={service.id} appName={service.name} />}
+ {activeTab === 'metrics' && <MetricsTab app={service} />}
+ {activeTab === 'packages' && service.isPython && <PackagesTab appId={service.id} />}
+ {activeTab === 'gunicorn' && service.isPython && <GunicornTab appId={service.id} />}
+ {activeTab === 'commands' && service.isPython && <CommandsTab appId={service.id} appType={service.app_type} />}
+ {activeTab === 'settings' && (
+ <SettingsTab
+ app={service}
+ deployConfig={deployConfig}
+ onUpdate={reload}
+ onOpenGitModal={() => setShowGitModal(true)}
+ />
+ )}
+ </div>
+
+ {/* Git Connect Modal */}
+ {showGitModal && (
+ <GitConnectModal
+ appId={service.id}
+ currentConfig={deployConfig}
+ onClose={() => setShowGitModal(false)}
+ onSave={() => {
+ setShowGitModal(false);
+ reload();
+ }}
+ />
+ )}
+ </div>
+ );
+};
+
+function ServiceIcon({ type }) {
+ switch (type) {
+ case 'docker':
+ return (
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
+ <path d="M13.983 11.078h2.119a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.119a.185.185 0 00-.185.185v1.888c0 .102.083.185.185.185m-2.954-5.43h2.118a.186.186 0 00.186-.186V3.574a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.186m0 2.716h2.118a.187.187 0 00.186-.186V6.29a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.887c0 .102.082.185.185.186m-2.93 0h2.12a.186.186 0 00.184-.186V6.29a.185.185 0 00-.185-.185H8.1a.185.185 0 00-.185.185v1.887c0 .102.083.185.185.186m-2.964 0h2.119a.186.186 0 00.185-.186V6.29a.185.185 0 00-.185-.185H5.136a.186.186 0 00-.186.185v1.887c0 .102.084.185.186.186m5.893 2.715h2.118a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m-2.93 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.083.185.185.185m-2.964 0h2.119a.185.185 0 00.185-.185V9.006a.185.185 0 00-.184-.186h-2.12a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185m-2.92 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.082.185.185.185M23.763 9.89c-.065-.051-.672-.51-1.954-.51-.338.001-.676.03-1.01.087-.248-1.7-1.653-2.53-1.716-2.566l-.344-.199-.226.327c-.284.438-.49.922-.612 1.43-.23.97-.09 1.882.403 2.661-.595.332-1.55.413-1.744.42H.751a.751.751 0 00-.75.748 11.376 11.376 0 00.692 4.062c.545 1.428 1.355 2.48 2.41 3.124 1.18.723 3.1 1.137 5.275 1.137.983.003 1.963-.086 2.93-.266a12.248 12.248 0 003.823-1.389c.98-.567 1.86-1.288 2.61-2.136 1.252-1.418 1.998-2.997 2.553-4.4h.221c1.372 0 2.215-.549 2.68-1.009.309-.293.55-.65.707-1.046l.098-.288z"/>
+ </svg>
+ );
+ case 'flask':
+ case 'django':
+ return (
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
+ <path d="M12 2L2 7l10 5 10-5-10-5z"/>
+ <path d="M2 17l10 5 10-5"/>
+ <path d="M2 12l10 5 10-5"/>
+ </svg>
+ );
+ default:
+ return <span style={{ fontSize: '16px', fontWeight: 'bold' }}>{type?.charAt(0).toUpperCase()}</span>;
+ }
+}
+
+function extractRepoDisplay(url) {
+ if (!url) return '';
+ try {
+ const cleaned = url.replace(/\.git$/, '');
+ const parts = cleaned.split('/');
+ return parts.slice(-2).join('/');
+ } catch {
+ return url;
+ }
+}
+
+export default ServiceDetail;
diff --git a/frontend/src/pages/Services.jsx b/frontend/src/pages/Services.jsx
new file mode 100644
index 00000000..f4d42571
--- /dev/null
+++ b/frontend/src/pages/Services.jsx
@@ -0,0 +1,296 @@
+import React, { useState, useEffect, useMemo } from 'react';
+import { useNavigate, Link } from 'react-router-dom';
+import api from '../services/api';
+import { useToast } from '../contexts/ToastContext';
+import { getServiceType, getStatusConfig, formatRelativeTime } from '../utils/serviceTypes';
+
+const SERVICE_TYPE_OPTIONS = ['all', 'docker', 'flask', 'django', 'php', 'static', 'wordpress'];
+const STATUS_OPTIONS = ['all', 'running', 'stopped'];
+
+const Services = () => {
+ const navigate = useNavigate();
+ const toast = useToast();
+ const [apps, setApps] = useState([]);
+ const [loading, setLoading] = useState(true);
+ const [searchTerm, setSearchTerm] = useState('');
+ const [typeFilter, setTypeFilter] = useState('all');
+ const [statusFilter, setStatusFilter] = useState('all');
+ const [actionLoading, setActionLoading] = useState(null);
+
+ useEffect(() => {
+ loadApps();
+ }, []);
+
+ async function loadApps() {
+ try {
+ const data = await api.getApps();
+ setApps(data.apps || []);
+ } catch (err) {
+ toast.error('Failed to load services');
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ async function handleAction(e, appId, action) {
+ e.stopPropagation();
+ setActionLoading(`${appId}-${action}`);
+ try {
+ if (action === 'start') await api.startApp(appId);
+ else if (action === 'stop') await api.stopApp(appId);
+ else if (action === 'restart') await api.restartApp(appId);
+ await loadApps();
+ } catch (err) {
+ toast.error(`Failed to ${action} service`);
+ } finally {
+ setActionLoading(null);
+ }
+ }
+
+ const filteredApps = useMemo(() => {
+ return apps.filter(app => {
+ if (searchTerm && !app.name.toLowerCase().includes(searchTerm.toLowerCase())) {
+ return false;
+ }
+ if (typeFilter !== 'all' && app.app_type !== typeFilter) {
+ return false;
+ }
+ if (statusFilter !== 'all' && app.status !== statusFilter) {
+ return false;
+ }
+ return true;
+ });
+ }, [apps, searchTerm, typeFilter, statusFilter]);
+
+ const stats = useMemo(() => ({
+ total: apps.length,
+ running: apps.filter(a => a.status === 'running').length,
+ stopped: apps.filter(a => a.status !== 'running').length,
+ }), [apps]);
+
+ if (loading) {
+ return <div className="loading">Loading services...</div>;
+ }
+
+ return (
+ <div className="services-page">
+ <div className="services-page__header">
+ <div>
+ <h1>Services</h1>
+ <p className="services-page__subtitle">
+ {stats.total} services &middot; {stats.running} live
+ </p>
+ </div>
+ <Link to="/templates" className="btn btn-primary">
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
+ <line x1="12" y1="5" x2="12" y2="19"/>
+ <line x1="5" y1="12" x2="19" y2="12"/>
+ </svg>
+ New Service
+ </Link>
+ </div>
+
+ <div className="services-page__filters">
+ <div className="services-page__search">
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
+ <circle cx="11" cy="11" r="8"/>
+ <line x1="21" y1="21" x2="16.65" y2="16.65"/>
+ </svg>
+ <input
+ type="text"
+ placeholder="Search services..."
+ value={searchTerm}
+ onChange={(e) => setSearchTerm(e.target.value)}
+ />
+ </div>
+ <select
+ value={typeFilter}
+ onChange={(e) => setTypeFilter(e.target.value)}
+ className="services-page__filter-select"
+ >
+ {SERVICE_TYPE_OPTIONS.map(opt => (
+ <option key={opt} value={opt}>
+ {opt === 'all' ? 'All Types' : getServiceType(opt).label}
+ </option>
+ ))}
+ </select>
+ <select
+ value={statusFilter}
+ onChange={(e) => setStatusFilter(e.target.value)}
+ className="services-page__filter-select"
+ >
+ {STATUS_OPTIONS.map(opt => (
+ <option key={opt} value={opt}>
+ {opt === 'all' ? 'All Status' : opt.charAt(0).toUpperCase() + opt.slice(1)}
+ </option>
+ ))}
+ </select>
+ </div>
+
+ {filteredApps.length === 0 ? (
+ <div className="services-page__empty">
+ <div className="services-page__empty-icon">
+ <svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" 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>
+ </div>
+ <h3>No services found</h3>
+ <p>{searchTerm || typeFilter !== 'all' || statusFilter !== 'all'
+ ? 'Try adjusting your filters'
+ : 'Deploy your first service to get started'}</p>
+ {!searchTerm && typeFilter === 'all' && statusFilter === 'all' && (
+ <Link to="/templates" className="btn btn-primary">Create Service</Link>
+ )}
+ </div>
+ ) : (
+ <div className="services-page__list">
+ {filteredApps.map(app => {
+ const typeInfo = getServiceType(app.app_type);
+ const statusInfo = getStatusConfig(app.status);
+ const isRunning = app.status === 'running';
+
+ return (
+ <div
+ key={app.id}
+ className="services-page__row"
+ onClick={() => {
+ if (app.app_type === 'wordpress') {
+ navigate(`/wordpress/${app.id}`);
+ } else {
+ navigate(`/services/${app.id}`);
+ }
+ }}
+ >
+ <div className="services-page__row-main">
+ <div
+ className="services-page__type-icon"
+ style={{ backgroundColor: typeInfo.bgColor, color: typeInfo.color }}
+ >
+ <ServiceTypeIcon type={app.app_type} />
+ </div>
+ <div className="services-page__row-info">
+ <div className="services-page__row-name">
+ {app.name}
+ </div>
+ <div className="services-page__row-meta">
+ <span
+ className="services-page__type-badge"
+ style={{ backgroundColor: typeInfo.bgColor, color: typeInfo.color, borderColor: typeInfo.borderColor }}
+ >
+ {typeInfo.label}
+ </span>
+ {app.domain && (
+ <span className="services-page__domain">{app.domain}</span>
+ )}
+ </div>
+ </div>
+ </div>
+
+ <div className="services-page__row-right">
+ <div className={`services-page__status services-page__status--${statusInfo.dotClass}`}>
+ <span className="services-page__status-dot" />
+ {statusInfo.label}
+ </div>
+
+ {app.deploy_repo_url && (
+ <div className="services-page__repo-pill">
+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" 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>
+ {extractRepoName(app.deploy_repo_url)}
+ </div>
+ )}
+
+ {app.last_deploy_at && (
+ <span className="services-page__last-deploy">
+ {formatRelativeTime(app.last_deploy_at)}
+ </span>
+ )}
+
+ <div className="services-page__actions" onClick={e => e.stopPropagation()}>
+ {isRunning ? (
+ <button
+ className="btn btn-ghost btn-sm"
+ onClick={(e) => handleAction(e, app.id, 'restart')}
+ disabled={actionLoading === `${app.id}-restart`}
+ title="Restart"
+ >
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
+ <polyline points="23 4 23 10 17 10"/>
+ <path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>
+ </svg>
+ </button>
+ ) : (
+ <button
+ className="btn btn-ghost btn-sm"
+ onClick={(e) => handleAction(e, app.id, 'start')}
+ disabled={actionLoading === `${app.id}-start`}
+ title="Start"
+ >
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor">
+ <polygon points="5 3 19 12 5 21 5 3"/>
+ </svg>
+ </button>
+ )}
+ </div>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ )}
+ </div>
+ );
+};
+
+function ServiceTypeIcon({ type }) {
+ switch (type) {
+ case 'docker':
+ return (
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">
+ <path d="M13.983 11.078h2.119a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.119a.185.185 0 00-.185.185v1.888c0 .102.083.185.185.185m-2.954-5.43h2.118a.186.186 0 00.186-.186V3.574a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.186m0 2.716h2.118a.187.187 0 00.186-.186V6.29a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.887c0 .102.082.185.185.186m-2.93 0h2.12a.186.186 0 00.184-.186V6.29a.185.185 0 00-.185-.185H8.1a.185.185 0 00-.185.185v1.887c0 .102.083.185.185.186m-2.964 0h2.119a.186.186 0 00.185-.186V6.29a.185.185 0 00-.185-.185H5.136a.186.186 0 00-.186.185v1.887c0 .102.084.185.186.186m5.893 2.715h2.118a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m-2.93 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.083.185.185.185m-2.964 0h2.119a.185.185 0 00.185-.185V9.006a.185.185 0 00-.184-.186h-2.12a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185m-2.92 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.082.185.185.185M23.763 9.89c-.065-.051-.672-.51-1.954-.51-.338.001-.676.03-1.01.087-.248-1.7-1.653-2.53-1.716-2.566l-.344-.199-.226.327c-.284.438-.49.922-.612 1.43-.23.97-.09 1.882.403 2.661-.595.332-1.55.413-1.744.42H.751a.751.751 0 00-.75.748 11.376 11.376 0 00.692 4.062c.545 1.428 1.355 2.48 2.41 3.124 1.18.723 3.1 1.137 5.275 1.137.983.003 1.963-.086 2.93-.266a12.248 12.248 0 003.823-1.389c.98-.567 1.86-1.288 2.61-2.136 1.252-1.418 1.998-2.997 2.553-4.4h.221c1.372 0 2.215-.549 2.68-1.009.309-.293.55-.65.707-1.046l.098-.288z"/>
+ </svg>
+ );
+ case 'flask':
+ case 'django':
+ return (
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
+ <path d="M12 2L2 7l10 5 10-5-10-5z"/>
+ <path d="M2 17l10 5 10-5"/>
+ <path d="M2 12l10 5 10-5"/>
+ </svg>
+ );
+ case 'php':
+ return <span style={{ fontSize: '12px', fontWeight: 700 }}>PHP</span>;
+ case 'static':
+ return (
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
+ <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/>
+ <polyline points="13 2 13 9 20 9"/>
+ </svg>
+ );
+ case 'wordpress':
+ return (
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">
+ <path d="M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2z"/>
+ </svg>
+ );
+ default:
+ return <span style={{ fontSize: '12px', fontWeight: 700 }}>{type?.charAt(0).toUpperCase()}</span>;
+ }
+}
+
+function extractRepoName(url) {
+ if (!url) return '';
+ try {
+ const cleaned = url.replace(/\.git$/, '');
+ const parts = cleaned.split('/');
+ return parts.slice(-2).join('/');
+ } catch {
+ return url;
+ }
+}
+
+export default Services;
diff --git a/frontend/src/styles/main.less b/frontend/src/styles/main.less
index 30a24975..b5a792fe 100644
--- a/frontend/src/styles/main.less
+++ b/frontend/src/styles/main.less
@@ -82,3 +82,5 @@
@import 'pages/_email';
@import 'pages/_setup-wizard';
@import 'pages/_migration-wizard';
+@import 'pages/_services';
+@import 'pages/_service-detail';
diff --git a/frontend/src/styles/pages/_service-detail.less b/frontend/src/styles/pages/_service-detail.less
new file mode 100644
index 00000000..ef33c8f2
--- /dev/null
+++ b/frontend/src/styles/pages/_service-detail.less
@@ -0,0 +1,674 @@
+// ============================================
+// SERVICE DETAIL PAGE
+// ============================================
+
+.svc-detail {
+ // Breadcrumb
+ &__breadcrumb {
+ display: flex;
+ align-items: center;
+ gap: @space-2;
+ margin-bottom: @space-5;
+ font-size: @font-size-sm;
+
+ a {
+ color: @text-tertiary;
+ text-decoration: none;
+
+ &:hover {
+ color: @text-primary;
+ }
+ }
+ }
+
+ &__breadcrumb-sep {
+ color: @text-tertiary;
+ }
+
+ &__breadcrumb-current {
+ color: @text-secondary;
+ font-weight: @font-weight-medium;
+ }
+
+ // Header
+ &__header {
+ display: flex;
+ justify-content: space-between;
+ align-items: flex-start;
+ gap: @space-4;
+ margin-bottom: @space-4;
+ }
+
+ &__header-left {
+ display: flex;
+ align-items: flex-start;
+ gap: @space-4;
+ min-width: 0;
+ }
+
+ &__icon {
+ width: 48px;
+ height: 48px;
+ border-radius: @radius-xl;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+ }
+
+ &__title-block {
+ min-width: 0;
+ }
+
+ &__title-row {
+ display: flex;
+ align-items: center;
+ gap: @space-3;
+ flex-wrap: wrap;
+
+ h1 {
+ font-size: @font-size-2xl;
+ font-weight: @font-weight-bold;
+ color: @text-primary;
+ margin: 0;
+ white-space: nowrap;
+ }
+ }
+
+ &__status {
+ display: inline-flex;
+ align-items: center;
+ gap: @space-1;
+ font-size: @font-size-sm;
+ font-weight: @font-weight-medium;
+ padding: 2px @space-3;
+ border-radius: @radius-full;
+
+ &--live {
+ color: @success;
+ background: @success-bg;
+ }
+
+ &--stopped {
+ color: @text-tertiary;
+ background: @bg-secondary;
+ }
+
+ &--deploying,
+ &--building {
+ color: @warning;
+ background: @warning-bg;
+ }
+
+ &--failed {
+ color: @danger;
+ background: @danger-bg;
+ }
+ }
+
+ &__status-dot {
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: currentColor;
+
+ .svc-detail__status--live & {
+ animation: pulse-dot 2s ease-in-out infinite;
+ }
+
+ .svc-detail__status--deploying &,
+ .svc-detail__status--building & {
+ animation: pulse-dot 1s ease-in-out infinite;
+ }
+ }
+
+ &__type-badge {
+ font-size: @font-size-xs;
+ font-weight: @font-weight-medium;
+ padding: 2px @space-2;
+ border-radius: @radius-full;
+ border: 1px solid;
+ }
+
+ &__subtitle {
+ display: flex;
+ align-items: center;
+ gap: @space-2;
+ margin-top: @space-1;
+ font-size: @font-size-sm;
+ color: @text-tertiary;
+
+ .mono {
+ font-family: @font-mono;
+ }
+ }
+
+ &__sep {
+ color: @text-tertiary;
+ }
+
+ // Header Actions
+ &__header-actions {
+ display: flex;
+ align-items: center;
+ gap: @space-2;
+ flex-shrink: 0;
+ }
+
+ // Dropdown
+ &__dropdown {
+ position: relative;
+ }
+
+ &__dropdown-menu {
+ position: absolute;
+ top: calc(100% + 4px);
+ left: 0;
+ background: @bg-elevated;
+ border: 1px solid @border-default;
+ border-radius: @radius-lg;
+ padding: @space-1;
+ min-width: 200px;
+ z-index: @z-dropdown;
+ box-shadow: @shadow-lg;
+
+ &--right {
+ left: auto;
+ right: 0;
+ }
+
+ button, a {
+ display: flex;
+ align-items: center;
+ gap: @space-2;
+ width: 100%;
+ padding: @space-2 @space-3;
+ background: none;
+ border: none;
+ color: @text-secondary;
+ font-size: @font-size-sm;
+ cursor: pointer;
+ border-radius: @radius-md;
+ text-decoration: none;
+
+ &:hover {
+ background: @bg-hover;
+ color: @text-primary;
+ }
+
+ &:disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
+ }
+ }
+ }
+
+ &__dropdown-divider {
+ height: 1px;
+ background: @border-subtle;
+ margin: @space-1 0;
+ }
+
+ &__dropdown-danger {
+ color: @danger !important;
+
+ &:hover {
+ background: @danger-bg !important;
+ color: @danger !important;
+ }
+ }
+
+ // Repo Bar
+ &__repo-bar {
+ margin-bottom: @space-5;
+ }
+
+ &__repo-pill {
+ display: inline-flex;
+ align-items: center;
+ gap: @space-2;
+ padding: @space-2 @space-3;
+ background: @bg-card;
+ border: 1px solid @border-default;
+ border-radius: @radius-full;
+ font-size: @font-size-sm;
+ color: @text-secondary;
+ cursor: pointer;
+ transition: border-color @transition-fast;
+
+ &:hover {
+ border-color: @accent-primary;
+ }
+ }
+
+ &__repo-url {
+ font-family: @font-mono;
+ font-size: @font-size-xs;
+ }
+
+ &__repo-arrow {
+ color: @text-tertiary;
+ }
+
+ &__repo-branch {
+ font-family: @font-mono;
+ font-size: @font-size-xs;
+ color: @accent-primary;
+ font-weight: @font-weight-medium;
+ }
+
+ &__auto-deploy-badge {
+ font-size: @font-size-xs;
+ padding: 0 @space-1;
+ background: @success-bg;
+ color: @success;
+ border-radius: @radius-sm;
+ font-weight: @font-weight-medium;
+ }
+
+ &__connect-repo {
+ display: inline-flex;
+ align-items: center;
+ gap: @space-2;
+ padding: @space-2 @space-3;
+ background: none;
+ border: 1px dashed @border-default;
+ border-radius: @radius-full;
+ font-size: @font-size-sm;
+ color: @text-tertiary;
+ cursor: pointer;
+ transition: all @transition-fast;
+
+ &:hover {
+ border-color: @accent-primary;
+ color: @accent-primary;
+ }
+ }
+
+ // Tabs
+ &__tabs {
+ display: flex;
+ gap: 0;
+ border-bottom: 1px solid @border-default;
+ margin-bottom: @space-6;
+ overflow-x: auto;
+ }
+
+ &__tab {
+ padding: @space-3 @space-4;
+ background: none;
+ border: none;
+ border-bottom: 2px solid transparent;
+ color: @text-tertiary;
+ font-size: @font-size-sm;
+ font-weight: @font-weight-medium;
+ cursor: pointer;
+ white-space: nowrap;
+ transition: all @transition-fast;
+
+ &:hover {
+ color: @text-secondary;
+ }
+
+ &--active {
+ color: @text-primary;
+ border-bottom-color: @accent-primary;
+ }
+ }
+
+ // Content area
+ &__content {
+ min-height: 400px;
+ }
+}
+
+// ============================================
+// TAB COMPONENT STYLES
+// ============================================
+
+// Events Tab
+.events-tab {
+ &__header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: @space-5;
+
+ h3 {
+ margin: 0;
+ color: @text-primary;
+ }
+ }
+
+ &__timeline {
+ display: flex;
+ flex-direction: column;
+ }
+
+ &__event {
+ display: flex;
+ gap: @space-4;
+ padding: @space-4;
+ border: 1px solid @border-default;
+ border-radius: @radius-lg;
+ background: @bg-card;
+ cursor: pointer;
+ transition: background @transition-fast;
+
+ & + & {
+ margin-top: @space-2;
+ }
+
+ &:hover {
+ background: @bg-hover;
+ }
+
+ &--expanded {
+ background: @bg-elevated;
+ }
+ }
+
+ &__event-status {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ margin-top: 6px;
+ flex-shrink: 0;
+ }
+
+ &__event-body {
+ flex: 1;
+ min-width: 0;
+ }
+
+ &__event-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: flex-start;
+ gap: @space-3;
+ }
+
+ &__event-commit {
+ display: flex;
+ align-items: center;
+ gap: @space-2;
+ }
+
+ &__event-sha {
+ font-family: @font-mono;
+ font-size: @font-size-xs;
+ color: @accent-primary;
+ background: @accent-glow;
+ padding: 1px @space-2;
+ border-radius: @radius-sm;
+ }
+
+ &__event-message {
+ font-size: @font-size-sm;
+ color: @text-primary;
+ font-weight: @font-weight-medium;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+
+ &__event-meta {
+ display: flex;
+ align-items: center;
+ gap: @space-3;
+ margin-top: @space-1;
+ font-size: @font-size-xs;
+ color: @text-tertiary;
+ }
+
+ &__event-badge {
+ font-size: @font-size-xs;
+ font-weight: @font-weight-medium;
+ padding: 1px @space-2;
+ border-radius: @radius-sm;
+ }
+
+ &__event-logs {
+ margin-top: @space-3;
+ padding: @space-3;
+ background: @bg-body;
+ border-radius: @radius-md;
+ max-height: 300px;
+ overflow-y: auto;
+
+ pre {
+ margin: 0;
+ font-family: @font-mono;
+ font-size: @font-size-xs;
+ color: @text-secondary;
+ white-space: pre-wrap;
+ word-break: break-all;
+ }
+ }
+
+ &__empty {
+ text-align: center;
+ padding: @space-12 @space-8;
+ color: @text-tertiary;
+
+ h3 {
+ color: @text-secondary;
+ margin-bottom: @space-2;
+ }
+ }
+}
+
+// Shell Tab
+.shell-tab {
+ &__container {
+ border: 1px solid @border-default;
+ border-radius: @radius-lg;
+ overflow: hidden;
+ }
+
+ &__header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: @space-3 @space-4;
+ background: @bg-elevated;
+ border-bottom: 1px solid @border-default;
+ }
+
+ &__terminal {
+ background: #0d1117;
+ padding: @space-4;
+ min-height: 400px;
+ font-family: @font-mono;
+ font-size: @font-size-sm;
+ color: #e6edf3;
+ overflow-y: auto;
+ max-height: 600px;
+ }
+
+ &__line {
+ line-height: 1.6;
+ white-space: pre-wrap;
+ word-break: break-all;
+
+ &--input {
+ color: #58a6ff;
+ }
+
+ &--error {
+ color: #f85149;
+ }
+ }
+
+ &__input-row {
+ display: flex;
+ align-items: center;
+ gap: @space-2;
+ padding: @space-3 @space-4;
+ background: @bg-card;
+ border-top: 1px solid @border-default;
+ }
+
+ &__prompt {
+ color: @accent-primary;
+ font-family: @font-mono;
+ font-size: @font-size-sm;
+ flex-shrink: 0;
+ }
+
+ &__input {
+ flex: 1;
+ background: none;
+ border: none;
+ color: @text-primary;
+ font-family: @font-mono;
+ font-size: @font-size-sm;
+ outline: none;
+ }
+}
+
+// Metrics Tab
+.metrics-tab {
+ &__grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
+ gap: @space-4;
+ }
+
+ &__card {
+ background: @bg-card;
+ border: 1px solid @border-default;
+ border-radius: @radius-lg;
+ padding: @space-5;
+ }
+
+ &__card-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: @space-3;
+
+ h4 {
+ margin: 0;
+ color: @text-primary;
+ font-size: @font-size-base;
+ }
+
+ span {
+ font-size: @font-size-xl;
+ font-weight: @font-weight-bold;
+ color: @text-primary;
+ }
+ }
+
+ &__bar {
+ height: 8px;
+ background: @bg-secondary;
+ border-radius: @radius-full;
+ overflow: hidden;
+ }
+
+ &__bar-fill {
+ height: 100%;
+ border-radius: @radius-full;
+ transition: width @transition-slow;
+ }
+
+ &__info {
+ margin-top: @space-2;
+ font-size: @font-size-xs;
+ color: @text-tertiary;
+ }
+}
+
+// GitConnectModal
+.git-connect-modal {
+ &__form {
+ display: flex;
+ flex-direction: column;
+ gap: @space-4;
+ }
+
+ &__field {
+ label {
+ display: block;
+ font-size: @font-size-sm;
+ font-weight: @font-weight-medium;
+ color: @text-secondary;
+ margin-bottom: @space-1;
+ }
+
+ input, select, textarea {
+ width: 100%;
+ padding: @space-2 @space-3;
+ background: @bg-card;
+ border: 1px solid @border-default;
+ border-radius: @radius-md;
+ color: @text-primary;
+ font-size: @font-size-sm;
+
+ &:focus {
+ outline: none;
+ border-color: @accent-primary;
+ }
+ }
+
+ textarea {
+ font-family: @font-mono;
+ font-size: @font-size-xs;
+ min-height: 80px;
+ resize: vertical;
+ }
+ }
+
+ &__toggle {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: @space-3;
+ background: @bg-card;
+ border: 1px solid @border-default;
+ border-radius: @radius-md;
+ }
+
+ &__toggle-label {
+ font-size: @font-size-sm;
+ color: @text-secondary;
+
+ span {
+ display: block;
+ font-size: @font-size-xs;
+ color: @text-tertiary;
+ margin-top: 2px;
+ }
+ }
+
+ &__actions {
+ display: flex;
+ justify-content: flex-end;
+ gap: @space-2;
+ margin-top: @space-4;
+ padding-top: @space-4;
+ border-top: 1px solid @border-subtle;
+ }
+}
+
+// Settings Tab within service detail
+.svc-settings {
+ &__section {
+ margin-bottom: @space-6;
+ }
+
+ &__section-title {
+ font-size: @font-size-md;
+ font-weight: @font-weight-semibold;
+ color: @text-primary;
+ margin-bottom: @space-4;
+ }
+}
+
+// Icon-only button
+.btn-icon {
+ padding: @space-2 !important;
+ min-width: auto !important;
+}
diff --git a/frontend/src/styles/pages/_services.less b/frontend/src/styles/pages/_services.less
new file mode 100644
index 00000000..4ea17ace
--- /dev/null
+++ b/frontend/src/styles/pages/_services.less
@@ -0,0 +1,267 @@
+// ============================================
+// SERVICES LIST PAGE
+// ============================================
+
+.services-page {
+ &__header {
+ display: flex;
+ justify-content: space-between;
+ align-items: flex-start;
+ margin-bottom: @space-6;
+
+ h1 {
+ font-size: @font-size-2xl;
+ font-weight: @font-weight-bold;
+ color: @text-primary;
+ margin: 0;
+ }
+ }
+
+ &__subtitle {
+ color: @text-tertiary;
+ font-size: @font-size-sm;
+ margin-top: @space-1;
+ }
+
+ &__filters {
+ display: flex;
+ gap: @space-3;
+ margin-bottom: @space-5;
+ }
+
+ &__search {
+ flex: 1;
+ display: flex;
+ align-items: center;
+ gap: @space-2;
+ background: @bg-card;
+ border: 1px solid @border-default;
+ border-radius: @radius-lg;
+ padding: 0 @space-3;
+ transition: border-color @transition-fast;
+
+ &:focus-within {
+ border-color: @accent-primary;
+ }
+
+ svg {
+ color: @text-tertiary;
+ flex-shrink: 0;
+ }
+
+ input {
+ flex: 1;
+ background: none;
+ border: none;
+ padding: @space-2 0;
+ color: @text-primary;
+ font-size: @font-size-sm;
+ outline: none;
+
+ &::placeholder {
+ color: @text-tertiary;
+ }
+ }
+ }
+
+ &__filter-select {
+ background: @bg-card;
+ border: 1px solid @border-default;
+ border-radius: @radius-lg;
+ padding: @space-2 @space-3;
+ color: @text-secondary;
+ font-size: @font-size-sm;
+ outline: none;
+ cursor: pointer;
+ min-width: 120px;
+
+ &:focus {
+ border-color: @accent-primary;
+ }
+ }
+
+ &__list {
+ display: flex;
+ flex-direction: column;
+ border: 1px solid @border-default;
+ border-radius: @radius-lg;
+ overflow: hidden;
+ }
+
+ &__row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: @space-4 @space-5;
+ background: @bg-card;
+ cursor: pointer;
+ transition: background @transition-fast;
+
+ &:hover {
+ background: @bg-hover;
+ }
+
+ & + & {
+ border-top: 1px solid @border-subtle;
+ }
+ }
+
+ &__row-main {
+ display: flex;
+ align-items: center;
+ gap: @space-3;
+ min-width: 0;
+ flex: 1;
+ }
+
+ &__type-icon {
+ width: 36px;
+ height: 36px;
+ border-radius: @radius-lg;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+ }
+
+ &__row-info {
+ min-width: 0;
+ }
+
+ &__row-name {
+ font-weight: @font-weight-medium;
+ color: @text-primary;
+ font-size: @font-size-base;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+
+ &__row-meta {
+ display: flex;
+ align-items: center;
+ gap: @space-2;
+ margin-top: 2px;
+ }
+
+ &__type-badge {
+ font-size: @font-size-xs;
+ font-weight: @font-weight-medium;
+ padding: 1px @space-2;
+ border-radius: @radius-full;
+ border: 1px solid;
+ line-height: 1.4;
+ }
+
+ &__domain {
+ font-size: @font-size-xs;
+ color: @text-tertiary;
+ font-family: @font-mono;
+ }
+
+ &__row-right {
+ display: flex;
+ align-items: center;
+ gap: @space-4;
+ flex-shrink: 0;
+ }
+
+ &__status {
+ display: flex;
+ align-items: center;
+ gap: @space-2;
+ font-size: @font-size-sm;
+ font-weight: @font-weight-medium;
+ white-space: nowrap;
+
+ &--live {
+ color: @success;
+ }
+
+ &--stopped {
+ color: @text-tertiary;
+ }
+
+ &--deploying,
+ &--building {
+ color: @warning;
+ }
+
+ &--failed {
+ color: @danger;
+ }
+ }
+
+ &__status-dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background: currentColor;
+ flex-shrink: 0;
+
+ .services-page__status--live & {
+ animation: pulse-dot 2s ease-in-out infinite;
+ }
+
+ .services-page__status--deploying &,
+ .services-page__status--building & {
+ animation: pulse-dot 1s ease-in-out infinite;
+ }
+ }
+
+ &__repo-pill {
+ display: flex;
+ align-items: center;
+ gap: @space-1;
+ font-size: @font-size-xs;
+ color: @text-tertiary;
+ background: @bg-secondary;
+ padding: 2px @space-2;
+ border-radius: @radius-full;
+ font-family: @font-mono;
+ max-width: 180px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+
+ svg {
+ flex-shrink: 0;
+ }
+ }
+
+ &__last-deploy {
+ font-size: @font-size-xs;
+ color: @text-tertiary;
+ white-space: nowrap;
+ }
+
+ &__actions {
+ display: flex;
+ gap: @space-1;
+ }
+
+ &__empty {
+ text-align: center;
+ padding: @space-16 @space-8;
+
+ h3 {
+ color: @text-primary;
+ margin: @space-4 0 @space-2;
+ }
+
+ p {
+ color: @text-tertiary;
+ margin-bottom: @space-5;
+ }
+ }
+
+ &__empty-icon {
+ color: @text-tertiary;
+ opacity: 0.5;
+ }
+}
+
+@keyframes pulse-dot {
+ 0%, 100% { opacity: 1; }
+ 50% { opacity: 0.4; }
+}
diff --git a/frontend/src/utils/serviceTypes.js b/frontend/src/utils/serviceTypes.js
new file mode 100644
index 00000000..4625e6b0
--- /dev/null
+++ b/frontend/src/utils/serviceTypes.js
@@ -0,0 +1,125 @@
+const SERVICE_TYPES = {
+ docker: {
+ label: 'Docker',
+ color: '#2496ed',
+ bgColor: 'rgba(36, 150, 237, 0.1)',
+ borderColor: 'rgba(36, 150, 237, 0.2)',
+ icon: 'docker',
+ tabs: ['events', 'logs', 'environment', 'shell', 'metrics', 'settings'],
+ },
+ flask: {
+ label: 'Flask',
+ color: '#fcd34d',
+ bgColor: 'rgba(252, 211, 77, 0.1)',
+ borderColor: 'rgba(252, 211, 77, 0.2)',
+ icon: 'flask',
+ tabs: ['events', 'logs', 'environment', 'packages', 'gunicorn', 'commands', 'metrics', 'settings'],
+ },
+ django: {
+ label: 'Django',
+ color: '#34d399',
+ bgColor: 'rgba(52, 211, 153, 0.1)',
+ borderColor: 'rgba(52, 211, 153, 0.2)',
+ icon: 'django',
+ tabs: ['events', 'logs', 'environment', 'packages', 'gunicorn', 'commands', 'metrics', 'settings'],
+ },
+ php: {
+ label: 'PHP',
+ color: '#777bb4',
+ bgColor: 'rgba(119, 123, 180, 0.1)',
+ borderColor: 'rgba(119, 123, 180, 0.2)',
+ icon: 'php',
+ tabs: ['events', 'logs', 'environment', 'settings'],
+ },
+ static: {
+ label: 'Static',
+ color: '#60a5fa',
+ bgColor: 'rgba(96, 165, 250, 0.1)',
+ borderColor: 'rgba(96, 165, 250, 0.2)',
+ icon: 'static',
+ tabs: ['events', 'environment', 'settings'],
+ },
+ wordpress: {
+ label: 'WordPress',
+ color: '#21759b',
+ bgColor: 'rgba(33, 117, 155, 0.1)',
+ borderColor: 'rgba(33, 117, 155, 0.2)',
+ icon: 'wordpress',
+ tabs: ['events', 'logs', 'environment', 'settings'],
+ },
+};
+
+const STATUS_CONFIG = {
+ running: { label: 'Live', color: '#10b981', dotClass: 'live' },
+ stopped: { label: 'Stopped', color: '#71717a', dotClass: 'stopped' },
+ deploying: { label: 'Deploying', color: '#f59e0b', dotClass: 'deploying' },
+ failed: { label: 'Failed', color: '#ef4444', dotClass: 'failed' },
+ building: { label: 'Building', color: '#3b82f6', dotClass: 'building' },
+};
+
+const DEPLOY_STATUS = {
+ success: { label: 'Live', color: '#10b981' },
+ failed: { label: 'Failed', color: '#ef4444' },
+ in_progress: { label: 'In Progress', color: '#f59e0b' },
+ rolled_back: { label: 'Rolled Back', color: '#71717a' },
+ pending: { label: 'Pending', color: '#3b82f6' },
+};
+
+export function getServiceType(appType) {
+ return SERVICE_TYPES[appType] || {
+ label: appType?.charAt(0).toUpperCase() + appType?.slice(1) || 'Unknown',
+ color: '#a1a1aa',
+ bgColor: 'rgba(161, 161, 170, 0.1)',
+ borderColor: 'rgba(161, 161, 170, 0.2)',
+ icon: 'default',
+ tabs: ['events', 'logs', 'environment', 'settings'],
+ };
+}
+
+export function getStatusConfig(status) {
+ return STATUS_CONFIG[status] || STATUS_CONFIG.stopped;
+}
+
+export function getDeployStatus(status) {
+ return DEPLOY_STATUS[status] || DEPLOY_STATUS.pending;
+}
+
+export function getTabsForType(appType) {
+ const type = getServiceType(appType);
+ return type.tabs;
+}
+
+export function isPythonApp(appType) {
+ return ['flask', 'django'].includes(appType);
+}
+
+export function isDockerApp(appType) {
+ return appType === 'docker';
+}
+
+export function formatRelativeTime(dateString) {
+ if (!dateString) return '';
+ const date = new Date(dateString);
+ const now = new Date();
+ const diffMs = now - date;
+ const diffSec = Math.floor(diffMs / 1000);
+ const diffMin = Math.floor(diffSec / 60);
+ const diffHour = Math.floor(diffMin / 60);
+ const diffDay = Math.floor(diffHour / 24);
+
+ if (diffSec < 60) return 'just now';
+ if (diffMin < 60) return `${diffMin}m ago`;
+ if (diffHour < 24) return `${diffHour}h ago`;
+ if (diffDay < 30) return `${diffDay}d ago`;
+ return date.toLocaleDateString();
+}
+
+export function formatDuration(seconds) {
+ if (!seconds || seconds < 0) return '-';
+ if (seconds < 60) return `${Math.round(seconds)}s`;
+ const min = Math.floor(seconds / 60);
+ const sec = Math.round(seconds % 60);
+ return `${min}m ${sec}s`;
+}
+
+export { SERVICE_TYPES, STATUS_CONFIG, DEPLOY_STATUS };