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.

Enhance dashboard and workflow with real app support

Juan Denis3b59478b7c03
diff --git a/.gitignore b/.gitignore
index d11e7ddf..8c0379fd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,4 +6,5 @@ nul
/frontend/dist
*.tmp
.planning_old
-.mcp.json
\ No newline at end of file
+.mcp.json
+new_templates/
\ No newline at end of file
diff --git a/backend/app/api/system.py b/backend/app/api/system.py
index d78b3045..45577c7c 100644
--- a/backend/app/api/system.py
+++ b/backend/app/api/system.py
@@ -130,6 +130,19 @@ def get_metrics():
return jsonify(metrics), 200
+@system_bp.route('/info', methods=['GET'])
+@jwt_required()
+def get_system_info():
+ """Get system information (hostname, IP, kernel, CPU info)."""
+ current_user_id = get_jwt_identity()
+ user = User.query.get(current_user_id)
+
+ if user.role != 'admin':
+ return jsonify({'error': 'Admin access required'}), 403
+
+ return jsonify(SystemService.get_system_info()), 200
+
+
@system_bp.route('/cpu', methods=['GET'])
@jwt_required()
def get_cpu_metrics():
diff --git a/backend/app/services/system_service.py b/backend/app/services/system_service.py
index d0308104..e52f39e2 100644
--- a/backend/app/services/system_service.py
+++ b/backend/app/services/system_service.py
@@ -46,15 +46,20 @@ class SystemService:
memory = psutil.virtual_memory()
swap = psutil.swap_memory()
+ # Get cached memory (available on Linux)
+ cached = getattr(memory, 'cached', 0)
+
return {
'ram': {
'total': memory.total,
'available': memory.available,
'used': memory.used,
+ 'cached': cached,
'percent': memory.percent,
'total_human': cls.get_size(memory.total),
'available_human': cls.get_size(memory.available),
- 'used_human': cls.get_size(memory.used)
+ 'used_human': cls.get_size(memory.used),
+ 'cached_human': cls.get_size(cached)
},
'swap': {
'total': swap.total,
@@ -131,7 +136,19 @@ class SystemService:
})
interfaces.append(interface)
+ # Wrap I/O stats in 'io' object for frontend compatibility
+ io_stats = {
+ 'bytes_sent': net_io.bytes_sent,
+ 'bytes_recv': net_io.bytes_recv,
+ 'packets_sent': net_io.packets_sent,
+ 'packets_recv': net_io.packets_recv,
+ 'bytes_sent_human': cls.get_size(net_io.bytes_sent),
+ 'bytes_recv_human': cls.get_size(net_io.bytes_recv),
+ }
+
return {
+ 'io': io_stats,
+ # Keep flat values for backwards compatibility
'bytes_sent': net_io.bytes_sent,
'bytes_recv': net_io.bytes_recv,
'packets_sent': net_io.packets_sent,
@@ -161,6 +178,25 @@ class SystemService:
boot_time = datetime.fromtimestamp(psutil.boot_time())
uptime = datetime.now() - boot_time
+ # Get primary IP address
+ ip_address = cls._get_primary_ip()
+
+ # Get kernel version (on Linux, platform.release() gives kernel version)
+ kernel = platform.release()
+
+ # Get CPU model info
+ cpu_model = platform.processor() or 'Unknown'
+ # Try to get more detailed CPU info on Linux
+ if platform.system() == 'Linux':
+ try:
+ with open('/proc/cpuinfo', 'r') as f:
+ for line in f:
+ if line.startswith('model name'):
+ cpu_model = line.split(':')[1].strip()
+ break
+ except Exception:
+ pass
+
return {
'platform': platform.system(),
'platform_release': platform.release(),
@@ -171,9 +207,55 @@ class SystemService:
'python_version': platform.python_version(),
'boot_time': boot_time.isoformat(),
'uptime_seconds': int(uptime.total_seconds()),
- 'uptime_human': cls._format_uptime(uptime)
+ 'uptime_human': cls._format_uptime(uptime),
+ # Additional fields for dashboard
+ 'ip_address': ip_address,
+ 'kernel': kernel,
+ 'cpu': {
+ 'model': cpu_model,
+ 'architecture': platform.machine()
+ }
}
+ @staticmethod
+ def _get_primary_ip():
+ """Get the primary IP address of the server."""
+ import socket
+ try:
+ # Create a socket to determine the primary IP
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ s.settimeout(0)
+ # Connect to a public address (doesn't actually send data)
+ s.connect(('8.8.8.8', 80))
+ ip = s.getsockname()[0]
+ s.close()
+ return ip
+ except Exception:
+ pass
+
+ # Fallback: try to get from network interfaces
+ try:
+ hostname = socket.gethostname()
+ ip = socket.gethostbyname(hostname)
+ if ip != '127.0.0.1':
+ return ip
+ except Exception:
+ pass
+
+ # Last resort: check network interfaces via psutil
+ try:
+ net_if = psutil.net_if_addrs()
+ for name, addrs in net_if.items():
+ if name == 'lo':
+ continue
+ for addr in addrs:
+ if addr.family == socket.AF_INET and not addr.address.startswith('127.'):
+ return addr.address
+ except Exception:
+ pass
+
+ return 'Unknown'
+
@staticmethod
def _format_uptime(delta):
"""Format timedelta to human readable string."""
diff --git a/frontend/dist/index.html b/frontend/dist/index.html
index 9f6f3d5e..20ea11ad 100644
--- a/frontend/dist/index.html
+++ b/frontend/dist/index.html
@@ -6,8 +6,8 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>React Dashboard Template</title>
- <script type="module" crossorigin src="/assets/index-COkwSdPW.js"></script>
- <link rel="stylesheet" crossorigin href="/assets/index-3nNiERFn.css">
+ <script type="module" crossorigin src="/assets/index-MWhhibEj.js"></script>
+ <link rel="stylesheet" crossorigin href="/assets/index-D6I0w7_M.css">
</head>
<body>
diff --git a/frontend/src/components/workflow/nodes/DockerAppNode.jsx b/frontend/src/components/workflow/nodes/DockerAppNode.jsx
index 67cd5edc..998669a1 100644
--- a/frontend/src/components/workflow/nodes/DockerAppNode.jsx
+++ b/frontend/src/components/workflow/nodes/DockerAppNode.jsx
@@ -1,12 +1,13 @@
import React, { memo } from 'react';
import { Handle, Position } from '@xyflow/react';
-import { Server, HardDrive } from 'lucide-react';
+import { Server, Globe, Link, ExternalLink } from 'lucide-react';
const DockerAppNode = ({ data, selected }) => {
const statusClass = data.status || 'stopped';
+ const isReal = data.isReal || data.appId;
return (
- <div className={`workflow-node workflow-node-docker ${selected ? 'selected' : ''}`}>
+ <div className={`workflow-node workflow-node-docker ${selected ? 'selected' : ''} ${isReal ? 'is-real' : ''}`}>
<Handle
type="target"
position={Position.Left}
@@ -18,34 +19,66 @@ const DockerAppNode = ({ data, selected }) => {
<div className="workflow-node-icon node-icon-docker">
<Server size={16} />
</div>
- <span className="workflow-node-type">Docker App</span>
- <div className={`node-status-dot status-${statusClass}`} />
+ <span className="workflow-node-type">
+ {data.appType === 'docker' ? 'App' : data.appType || 'App'}
+ </span>
+ <div className={`node-status-dot status-${statusClass}`} title={statusClass} />
</div>
<div className="workflow-node-body">
<div className="workflow-node-label">{data.name || 'Untitled App'}</div>
- {data.image && (
+ {data.template && (
+ <div className="node-detail node-detail-template">
+ <span className="node-detail-label">Template</span>
+ <span className="node-detail-value">{data.template}</span>
+ </div>
+ )}
+
+ {data.port && (
+ <div className="node-detail node-detail-port">
+ <span className="node-detail-label">Port</span>
+ <span className="node-detail-value node-port-pill">{data.port}</span>
+ </div>
+ )}
+
+ {data.privateUrl && (
+ <div className="node-detail node-detail-private-url">
+ <Link size={12} />
+ <span className="node-detail-value">{data.privateUrl}</span>
+ </div>
+ )}
+
+ {data.domains && data.domains.length > 0 && (
+ <div className="node-domains">
+ {data.domains.slice(0, 2).map((domain, idx) => (
+ <span key={idx} className="node-domain-pill">
+ <Globe size={10} />
+ {domain.name || domain}
+ </span>
+ ))}
+ {data.domains.length > 2 && (
+ <span className="node-domain-more">+{data.domains.length - 2}</span>
+ )}
+ </div>
+ )}
+
+ {/* Legacy support for old image field */}
+ {!data.template && data.image && (
<div className="node-detail node-detail-image">
<span className="node-detail-label">Image</span>
<span className="node-detail-value">{data.image}</span>
</div>
)}
- {data.ports && data.ports.length > 0 && (
+ {/* Legacy support for old ports array */}
+ {!data.port && data.ports && data.ports.length > 0 && (
<div className="node-ports">
{data.ports.map((port, idx) => (
<span key={idx} className="node-port-pill">{port}</span>
))}
</div>
)}
-
- {data.memory && (
- <div className="node-detail node-detail-memory">
- <HardDrive size={12} />
- <span>{data.memory}</span>
- </div>
- )}
</div>
<Handle
diff --git a/frontend/src/components/workflow/panels/DockerAppConfigPanel.jsx b/frontend/src/components/workflow/panels/DockerAppConfigPanel.jsx
index 89b39449..0c99841c 100644
--- a/frontend/src/components/workflow/panels/DockerAppConfigPanel.jsx
+++ b/frontend/src/components/workflow/panels/DockerAppConfigPanel.jsx
@@ -1,16 +1,178 @@
import React, { useState } from 'react';
-import { Server, Plus, Trash2 } from 'lucide-react';
+import { Server, Globe, Link, ExternalLink, Play, Square, RotateCw } from 'lucide-react';
import ConfigPanel from '../ConfigPanel';
+import api from '../../../services/api';
const DockerAppConfigPanel = ({ node, onChange, onClose }) => {
const data = node?.data || {};
+ const isReal = data.isReal || data.appId;
- const [ports, setPorts] = useState(data.ports || []);
+ const [isActioning, setIsActioning] = useState(false);
+ const [actionMessage, setActionMessage] = useState(null);
const handleChange = (field, value) => {
onChange({ ...data, [field]: value });
};
+ // Actions for real apps
+ const handleAction = async (action) => {
+ if (!data.appId) return;
+
+ setIsActioning(true);
+ setActionMessage(null);
+
+ try {
+ let result;
+ switch (action) {
+ case 'start':
+ result = await api.startApp(data.appId);
+ handleChange('status', 'running');
+ break;
+ case 'stop':
+ result = await api.stopApp(data.appId);
+ handleChange('status', 'stopped');
+ break;
+ case 'restart':
+ result = await api.restartApp(data.appId);
+ handleChange('status', 'running');
+ break;
+ default:
+ return;
+ }
+ setActionMessage(`${action} successful`);
+ } catch (error) {
+ setActionMessage(`Failed to ${action}`);
+ } finally {
+ setIsActioning(false);
+ setTimeout(() => setActionMessage(null), 3000);
+ }
+ };
+
+ const openPrivateUrl = () => {
+ if (data.privateUrl) {
+ window.open(data.privateUrl, '_blank');
+ }
+ };
+
+ const openAppDetails = () => {
+ if (data.appId) {
+ window.location.href = `/applications/${data.appId}`;
+ }
+ };
+
+ // Real app panel - shows info and actions
+ if (isReal) {
+ return (
+ <ConfigPanel
+ isOpen={!!node}
+ title="Application"
+ icon={Server}
+ headerColor="#2496ed"
+ onClose={onClose}
+ >
+ <div className="form-group">
+ <label>Name</label>
+ <div className="form-value">{data.name || 'Unknown'}</div>
+ </div>
+
+ <div className="form-group">
+ <label>Status</label>
+ <div className={`form-value status-badge status-${data.status}`}>
+ {data.status || 'unknown'}
+ </div>
+ </div>
+
+ {data.template && (
+ <div className="form-group">
+ <label>Template</label>
+ <div className="form-value">{data.template}</div>
+ </div>
+ )}
+
+ {data.port && (
+ <div className="form-group">
+ <label>Port</label>
+ <div className="form-value">{data.port}</div>
+ </div>
+ )}
+
+ {data.privateUrl && (
+ <div className="form-group">
+ <label>Private URL</label>
+ <div className="form-value form-value-link" onClick={openPrivateUrl}>
+ <Link size={14} />
+ {data.privateUrl}
+ <ExternalLink size={12} />
+ </div>
+ </div>
+ )}
+
+ {data.domains && data.domains.length > 0 && (
+ <div className="form-group">
+ <label>Connected Domains</label>
+ <div className="form-domains">
+ {data.domains.map((domain, idx) => (
+ <div key={idx} className="form-domain-item">
+ <Globe size={14} />
+ <span>{domain.name || domain}</span>
+ {domain.ssl_enabled && (
+ <span className="ssl-badge">SSL</span>
+ )}
+ </div>
+ ))}
+ </div>
+ </div>
+ )}
+
+ <div className="form-group">
+ <label>Actions</label>
+ <div className="action-buttons">
+ <button
+ className="btn btn-sm btn-success"
+ onClick={() => handleAction('start')}
+ disabled={isActioning || data.status === 'running'}
+ >
+ <Play size={14} />
+ Start
+ </button>
+ <button
+ className="btn btn-sm btn-warning"
+ onClick={() => handleAction('stop')}
+ disabled={isActioning || data.status === 'stopped'}
+ >
+ <Square size={14} />
+ Stop
+ </button>
+ <button
+ className="btn btn-sm btn-secondary"
+ onClick={() => handleAction('restart')}
+ disabled={isActioning}
+ >
+ <RotateCw size={14} />
+ Restart
+ </button>
+ </div>
+ {actionMessage && (
+ <div className="action-message">{actionMessage}</div>
+ )}
+ </div>
+
+ <div className="form-group">
+ <button
+ className="btn btn-primary btn-block"
+ onClick={openAppDetails}
+ >
+ <ExternalLink size={14} />
+ Open App Details
+ </button>
+ </div>
+ </ConfigPanel>
+ );
+ }
+
+ // Legacy panel for non-real apps (manual creation)
+ const [ports, setPorts] = useState(data.ports || []);
+
const handleAddPort = () => {
const newPorts = [...ports, ''];
setPorts(newPorts);
@@ -87,7 +249,7 @@ const DockerAppConfigPanel = ({ node, onChange, onClose }) => {
className="btn btn-icon btn-danger-ghost"
onClick={() => handleRemovePort(index)}
>
- <Trash2 size={14} />
+ ×
</button>
</div>
))}
@@ -96,8 +258,7 @@ const DockerAppConfigPanel = ({ node, onChange, onClose }) => {
className="btn btn-secondary btn-sm"
onClick={handleAddPort}
>
- <Plus size={14} />
- Add Port
+ + Add Port
</button>
</div>
<span className="form-hint">Format: host_port:container_port</span>
diff --git a/frontend/src/hooks/useMetrics.js b/frontend/src/hooks/useMetrics.js
index e5f2af88..f8b76989 100644
--- a/frontend/src/hooks/useMetrics.js
+++ b/frontend/src/hooks/useMetrics.js
@@ -1,12 +1,16 @@
-import { useState, useEffect, useCallback } from 'react';
+import { useState, useEffect, useCallback, useRef } from 'react';
import socketService from '../services/socket';
import api from '../services/api';
-export function useMetrics(useWebSocket = true) {
+// Default polling interval in ms (10 seconds)
+const DEFAULT_POLL_INTERVAL = 10000;
+
+export function useMetrics(useWebSocket = true, pollInterval = DEFAULT_POLL_INTERVAL) {
const [metrics, setMetrics] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
const [connected, setConnected] = useState(false);
+ const pollIntervalRef = useRef(null);
const fetchMetrics = useCallback(async () => {
try {
@@ -20,6 +24,22 @@ export function useMetrics(useWebSocket = true) {
}
}, []);
+ // Start polling when not connected via WebSocket
+ const startPolling = useCallback(() => {
+ if (pollIntervalRef.current) return; // Already polling
+ if (pollInterval <= 0) return; // Polling disabled
+
+ pollIntervalRef.current = setInterval(fetchMetrics, pollInterval);
+ }, [fetchMetrics, pollInterval]);
+
+ // Stop polling
+ const stopPolling = useCallback(() => {
+ if (pollIntervalRef.current) {
+ clearInterval(pollIntervalRef.current);
+ pollIntervalRef.current = null;
+ }
+ }, []);
+
useEffect(() => {
// Initial fetch
fetchMetrics();
@@ -31,11 +51,13 @@ export function useMetrics(useWebSocket = true) {
// Set up listeners
const unsubConnect = socketService.on('connected', () => {
setConnected(true);
+ stopPolling(); // Stop polling when WS connects
socketService.subscribeMetrics();
});
const unsubDisconnect = socketService.on('disconnected', () => {
setConnected(false);
+ startPolling(); // Start polling when WS disconnects
});
const unsubMetrics = socketService.on('metrics', (data) => {
@@ -45,21 +67,32 @@ export function useMetrics(useWebSocket = true) {
const unsubError = socketService.on('error', (err) => {
setError(err.message || 'WebSocket error');
+ startPolling(); // Start polling on error
});
+ // Start polling initially (will stop if WS connects)
+ // Give WebSocket 3 seconds to connect before starting poll
+ const pollTimeout = setTimeout(() => {
+ if (!socketService.socket?.connected) {
+ startPolling();
+ }
+ }, 3000);
+
return () => {
+ clearTimeout(pollTimeout);
unsubConnect();
unsubDisconnect();
unsubMetrics();
unsubError();
socketService.unsubscribeMetrics();
+ stopPolling();
};
} else {
- // Polling fallback
- const interval = setInterval(fetchMetrics, 5000);
- return () => clearInterval(interval);
+ // Polling only mode
+ startPolling();
+ return () => stopPolling();
}
- }, [useWebSocket, fetchMetrics]);
+ }, [useWebSocket, fetchMetrics, startPolling, stopPolling]);
return { metrics, loading, error, connected, refresh: fetchMetrics };
}
diff --git a/frontend/src/pages/Dashboard.jsx b/frontend/src/pages/Dashboard.jsx
index c8387fcc..ed5da73e 100644
--- a/frontend/src/pages/Dashboard.jsx
+++ b/frontend/src/pages/Dashboard.jsx
@@ -1,48 +1,77 @@
-import React, { useState, useEffect } from 'react';
+import React, { useState, useEffect, useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import {
Cpu, MemoryStick, HardDrive, Activity,
Plus, RefreshCw, Server, Zap,
- RotateCcw, Database, Layers, Container, Globe, Code
+ RotateCcw, Database, Layers, Container, Globe, Code, Settings
} from 'lucide-react';
import api from '../services/api';
import { useMetrics } from '../hooks/useMetrics';
import MetricsGraph from '../components/MetricsGraph';
+// Refresh interval options in seconds
+const REFRESH_OPTIONS = [
+ { label: 'Off', value: 0 },
+ { label: '5s', value: 5 },
+ { label: '10s', value: 10 },
+ { label: '30s', value: 30 },
+ { label: '1m', value: 60 },
+];
+
const Dashboard = () => {
const navigate = useNavigate();
- const { metrics, loading: metricsLoading, connected } = useMetrics(true);
+ const { metrics, loading: metricsLoading, connected, refresh: refreshMetrics } = useMetrics(true);
const [apps, setApps] = useState([]);
const [services, setServices] = useState([]);
const [dbStatus, setDbStatus] = useState(null);
- const [uptime, setUptime] = useState(null);
- const [serverTime, setServerTime] = useState(null);
const [systemInfo, setSystemInfo] = useState(null);
const [loading, setLoading] = useState(true);
+ const [refreshInterval, setRefreshInterval] = useState(() => {
+ const saved = localStorage.getItem('dashboard_refresh_interval');
+ return saved ? parseInt(saved, 10) : 10; // Default 10 seconds
+ });
+ const [lastUpdate, setLastUpdate] = useState(Date.now());
+ // Load initial data
useEffect(() => {
loadData();
}, []);
+ // Polling fallback when WebSocket is not connected
useEffect(() => {
- if (metrics?.time) {
- setServerTime(metrics.time);
+ if (refreshInterval > 0 && !connected) {
+ const interval = setInterval(() => {
+ refreshMetrics();
+ setLastUpdate(Date.now());
+ }, refreshInterval * 1000);
+ return () => clearInterval(interval);
+ }
+ }, [refreshInterval, connected, refreshMetrics]);
+
+ // Update lastUpdate when metrics change (from WebSocket)
+ useEffect(() => {
+ if (metrics) {
+ setLastUpdate(Date.now());
}
}, [metrics]);
+ // Save refresh interval preference
+ const handleRefreshIntervalChange = useCallback((value) => {
+ setRefreshInterval(value);
+ localStorage.setItem('dashboard_refresh_interval', value.toString());
+ }, []);
+
async function loadData() {
try {
- const [appsData, servicesData, dbData, uptimeData, sysInfoData] = await Promise.all([
+ const [appsData, servicesData, dbData, sysInfoData] = await Promise.all([
api.getApps(),
api.getServicesStatus().catch(() => ({ services: [] })),
- api.getDatabasesStatus().catch(() => null),
- api.getCurrentUptime().catch(() => null),
+ api.getDatabaseStatus().catch(() => null),
api.getSystemInfo().catch(() => null)
]);
setApps(appsData.apps || []);
setServices(servicesData.services || []);
setDbStatus(dbData);
- setUptime(uptimeData);
setSystemInfo(sysInfoData);
} catch (err) {
console.error('Failed to load data:', err);
@@ -51,6 +80,15 @@ const Dashboard = () => {
}
}
+ // Helper to format uptime from seconds
+ function formatUptime(seconds) {
+ if (!seconds) return { days: 0, hours: 0, minutes: 0 };
+ const days = Math.floor(seconds / 86400);
+ const hours = Math.floor((seconds % 86400) / 3600);
+ const minutes = Math.floor((seconds % 3600) / 60);
+ return { days, hours, minutes };
+ }
+
function getStatusClass(status) {
switch (status) {
case 'running': return 'status-active';
@@ -71,10 +109,13 @@ const Dashboard = () => {
}
}
- const uptimeFormatted = uptime?.uptime_formatted || { days: 0, hours: 0, minutes: 0, seconds: 0 };
- const hostname = systemInfo?.hostname || 'server';
- const kernelVersion = systemInfo?.kernel || '-';
- const ipAddress = systemInfo?.ip_address || '-';
+ // Get uptime from metrics.system (updated via WebSocket/polling)
+ const uptimeFormatted = formatUptime(metrics?.system?.uptime_seconds);
+ // Fallback to systemInfo for static data, prefer metrics.system for live data
+ const hostname = metrics?.system?.hostname || systemInfo?.hostname || 'server';
+ const kernelVersion = metrics?.system?.kernel || systemInfo?.kernel || '-';
+ const ipAddress = metrics?.system?.ip_address || systemInfo?.ip_address || '-';
+ const serverTime = metrics?.time;
if (loading && metricsLoading) {
return <div className="loading">Loading dashboard...</div>;
@@ -86,7 +127,7 @@ const Dashboard = () => {
<div className="top-bar">
<div className="server-identity">
<h1>
- <span className="status-dot-live"></span>
+ <span className={`status-dot-live ${connected ? '' : 'disconnected'}`}></span>
{hostname}
</h1>
<div className="server-details">
@@ -103,6 +144,28 @@ const Dashboard = () => {
ZONE: {serverTime?.timezone_id || 'UTC'}
</div>
</div>
+ <div className="refresh-control">
+ <span className={`connection-status ${connected ? 'live' : 'polling'}`}>
+ {connected ? '● LIVE' : '○ POLL'}
+ </span>
+ <select
+ value={refreshInterval}
+ onChange={(e) => handleRefreshIntervalChange(parseInt(e.target.value, 10))}
+ className="refresh-select"
+ title="Auto-refresh interval"
+ >
+ {REFRESH_OPTIONS.map(opt => (
+ <option key={opt.value} value={opt.value}>{opt.label}</option>
+ ))}
+ </select>
+ <button
+ className="btn-refresh"
+ onClick={() => { refreshMetrics(); loadData(); }}
+ title="Refresh now"
+ >
+ <RefreshCw size={14} />
+ </button>
+ </div>
</div>
{/* Grid Container */}
diff --git a/frontend/src/pages/WorkflowBuilder.jsx b/frontend/src/pages/WorkflowBuilder.jsx
index ae3d0149..0f2795bd 100644
--- a/frontend/src/pages/WorkflowBuilder.jsx
+++ b/frontend/src/pages/WorkflowBuilder.jsx
@@ -11,7 +11,7 @@ import {
MiniMap
} from '@xyflow/react';
import '@xyflow/react/dist/style.css';
-import { Server, Database, Globe, Box, Save, FolderOpen, Plus, Download, Play } from 'lucide-react';
+import { Server, Database, Globe, Box, Save, FolderOpen, Plus, RefreshCw, Play, Layout, Eye } from 'lucide-react';
import api from '../services/api';
import WorkflowListModal from '../components/workflow/WorkflowListModal';
import DeploymentProgressModal from '../components/workflow/DeploymentProgressModal';
@@ -50,57 +50,71 @@ const edgeTypes = {
let nodeId = 0;
const getId = () => `node_${nodeId++}`;
-const NodePalette = ({ onAddNode }) => {
+const NodePalette = ({ onAddNode, templates, onAddFromTemplate, existingApps, onAddExistingApp }) => {
+ const [showTemplates, setShowTemplates] = useState(false);
+ const [showExistingApps, setShowExistingApps] = useState(false);
+
return (
<div className="workflow-palette">
<div className="palette-section">
- <div className="palette-header">Compute</div>
+ <div className="palette-header">Add Application</div>
<button
className="palette-item palette-item-docker"
- onClick={() => onAddNode('dockerApp', { name: 'New App', status: 'stopped' })}
- >
- <Server size={16} />
- <span>Docker App</span>
- </button>
- <button
- className="palette-item palette-item-service"
- onClick={() => onAddNode('service', { name: 'New Service', status: 'stopped' })}
+ onClick={() => setShowTemplates(!showTemplates)}
>
- <Box size={16} />
- <span>Service</span>
+ <Plus size={16} />
+ <span>From Template</span>
</button>
- </div>
+ {showTemplates && templates.length > 0 && (
+ <div className="palette-submenu">
+ {templates.map((template) => (
+ <button
+ key={template.id}
+ className="palette-subitem"
+ onClick={() => {
+ onAddFromTemplate(template);
+ setShowTemplates(false);
+ }}
+ >
+ {template.name}
+ </button>
+ ))}
+ </div>
+ )}
+ {showTemplates && templates.length === 0 && (
+ <div className="palette-empty">No templates available</div>
+ )}
- <div className="palette-section">
- <div className="palette-header">Storage</div>
- <button
- className="palette-item palette-item-database"
- onClick={() => onAddNode('database', { name: 'New Database', type: 'mysql', status: 'stopped' })}
- >
- <Database size={16} />
- <span>MySQL</span>
- </button>
- <button
- className="palette-item palette-item-database"
- onClick={() => onAddNode('database', { name: 'New Database', type: 'postgresql', status: 'stopped' })}
- >
- <Database size={16} />
- <span>PostgreSQL</span>
- </button>
- <button
- className="palette-item palette-item-database"
- onClick={() => onAddNode('database', { name: 'New Database', type: 'mongodb', status: 'stopped' })}
- >
- <Database size={16} />
- <span>MongoDB</span>
- </button>
- <button
- className="palette-item palette-item-database"
- onClick={() => onAddNode('database', { name: 'Cache', type: 'redis', status: 'stopped' })}
- >
- <Database size={16} />
- <span>Redis</span>
- </button>
+ {existingApps.length > 0 && (
+ <>
+ <button
+ className="palette-item palette-item-service"
+ onClick={() => setShowExistingApps(!showExistingApps)}
+ >
+ <Server size={16} />
+ <span>Existing App</span>
+ </button>
+ {showExistingApps && (
+ <div className="palette-submenu">
+ {existingApps.map((app) => (
+ <button
+ key={app.id}
+ className="palette-subitem"
+ onClick={() => {
+ onAddExistingApp(app);
+ setShowExistingApps(false);
+ }}
+ >
+ {app.name}
+ <span className={`status-badge status-${app.status}`}>
+ {app.status}
+ </span>
+ </button>
+ ))}
+ </div>
+ )}
+ </>
+ )}
</div>
<div className="palette-section">
@@ -113,6 +127,12 @@ const NodePalette = ({ onAddNode }) => {
<span>Domain</span>
</button>
</div>
+
+ <div className="palette-section palette-section-info">
+ <div className="palette-hint">
+ Tip: Click "Server Overview" to see all your infrastructure with connections
+ </div>
+ </div>
</div>
);
};
@@ -124,17 +144,21 @@ const WorkflowCanvas = () => {
const [selectedNode, setSelectedNode] = useState(null);
const [selectedEdge, setSelectedEdge] = useState(null);
const [connectionError, setConnectionError] = useState(null);
- const { screenToFlowPosition, getViewport, setViewport } = useReactFlow();
+ const { screenToFlowPosition, getViewport, setViewport, fitView } = useReactFlow();
// Workflow state
const [currentWorkflow, setCurrentWorkflow] = useState(null);
const [workflowName, setWorkflowName] = useState('Untitled Workflow');
const [isSaving, setIsSaving] = useState(false);
const [isLoading, setIsLoading] = useState(false);
- const [isImporting, setIsImporting] = useState(false);
const [showLoadModal, setShowLoadModal] = useState(false);
const [saveMessage, setSaveMessage] = useState(null);
+ // Server data state
+ const [templates, setTemplates] = useState([]);
+ const [allApps, setAllApps] = useState([]);
+ const [appsInView, setAppsInView] = useState(new Set());
+
// Deployment state
const [isDeploying, setIsDeploying] = useState(false);
const [showDeployModal, setShowDeployModal] = useState(false);
@@ -143,17 +167,215 @@ const WorkflowCanvas = () => {
const memoizedNodeTypes = useMemo(() => nodeTypes, []);
const memoizedEdgeTypes = useMemo(() => edgeTypes, []);
- // Validate connections before allowing them
- const isValidConnection = useCallback((connection) => {
- return checkValidConnection(connection, nodes);
- }, [nodes]);
-
// Delete edge by ID
const deleteEdge = useCallback((edgeId) => {
setEdges((eds) => eds.filter((e) => e.id !== edgeId));
setSelectedEdge(null);
}, [setEdges]);
+ // Fetch templates on mount
+ useEffect(() => {
+ const fetchTemplates = async () => {
+ try {
+ const response = await api.getTemplates();
+ setTemplates(response.templates || []);
+ } catch (error) {
+ console.error('Failed to fetch templates:', error);
+ }
+ };
+ fetchTemplates();
+ }, []);
+
+ // Fetch all apps for the existing apps list
+ useEffect(() => {
+ const fetchApps = async () => {
+ try {
+ const response = await api.getApps();
+ setAllApps(response.apps || []);
+ } catch (error) {
+ console.error('Failed to fetch apps:', error);
+ }
+ };
+ fetchApps();
+ }, []);
+
+ // Get apps not currently in the view
+ const existingAppsNotInView = useMemo(() => {
+ return allApps.filter(app => !appsInView.has(app.id));
+ }, [allApps, appsInView]);
+
+ // Load server overview - all infrastructure with connections
+ const loadServerOverview = useCallback(async () => {
+ setIsLoading(true);
+ setSaveMessage(null);
+
+ try {
+ const [appsResponse, domainsResponse] = await Promise.all([
+ api.getApps().catch(() => ({ apps: [] })),
+ api.getDomains().catch(() => ({ domains: [] }))
+ ]);
+
+ const apps = appsResponse.apps || [];
+ const domains = domainsResponse.domains || [];
+
+ if (apps.length === 0 && domains.length === 0) {
+ setSaveMessage('No infrastructure found - create an app first!');
+ setTimeout(() => setSaveMessage(null), 4000);
+ setIsLoading(false);
+ return;
+ }
+
+ const importedNodes = [];
+ const importedEdges = [];
+ const appNodeIds = {};
+ const domainNodeIds = {};
+
+ // Layout configuration
+ const GRID_SPACING_X = 320;
+ const GRID_SPACING_Y = 180;
+ const COLS = 3;
+ const DOMAIN_OFFSET_Y = 150;
+
+ // Reset node ID counter
+ nodeId = 0;
+
+ // Create app nodes
+ apps.forEach((app, index) => {
+ const col = index % COLS;
+ const row = Math.floor(index / COLS);
+ const nodeIdStr = getId();
+ appNodeIds[app.id] = nodeIdStr;
+
+ importedNodes.push({
+ id: nodeIdStr,
+ type: 'dockerApp',
+ position: {
+ x: 150 + col * GRID_SPACING_X,
+ y: 200 + row * GRID_SPACING_Y
+ },
+ data: {
+ name: app.name,
+ appId: app.id,
+ status: app.status || 'stopped',
+ port: app.port,
+ appType: app.app_type,
+ template: app.docker_image || app.app_type,
+ privateUrl: app.private_url_enabled ? `/p/${app.private_slug}` : null,
+ domains: app.domains || [],
+ isReal: true
+ }
+ });
+ });
+
+ // Create domain nodes positioned above their connected apps
+ const processedDomains = new Set();
+ apps.forEach((app) => {
+ if (app.domains && app.domains.length > 0) {
+ app.domains.forEach((domain, domIdx) => {
+ if (processedDomains.has(domain.id)) return;
+ processedDomains.add(domain.id);
+
+ const appNodeId = appNodeIds[app.id];
+ const appNode = importedNodes.find(n => n.id === appNodeId);
+ const domainNodeId = getId();
+ domainNodeIds[domain.id] = domainNodeId;
+
+ // Position domain above its app
+ importedNodes.push({
+ id: domainNodeId,
+ type: 'domain',
+ position: {
+ x: appNode.position.x + (domIdx * 80),
+ y: appNode.position.y - DOMAIN_OFFSET_Y
+ },
+ data: {
+ name: domain.name,
+ domainId: domain.id,
+ ssl: domain.ssl_enabled ? 'active' : 'none',
+ dnsStatus: 'propagated',
+ connectedAppId: app.id,
+ isReal: true
+ }
+ });
+
+ // Create edge from domain to app
+ importedEdges.push({
+ id: `edge_${domainNodeId}_${appNodeId}`,
+ source: domainNodeId,
+ target: appNodeId,
+ sourceHandle: 'output',
+ targetHandle: 'input',
+ type: 'connection',
+ animated: true,
+ data: {
+ sourceType: 'domain',
+ targetType: 'dockerApp',
+ connectionType: 'routes',
+ onDelete: deleteEdge
+ }
+ });
+ });
+ }
+ });
+
+ // Add orphan domains (not connected to any app)
+ const orphanDomains = domains.filter(d => !processedDomains.has(d.id));
+ const appsRows = Math.ceil(apps.length / COLS);
+ orphanDomains.forEach((domain, index) => {
+ const col = index % COLS;
+ const row = appsRows + 1 + Math.floor(index / COLS);
+ const domainNodeId = getId();
+
+ importedNodes.push({
+ id: domainNodeId,
+ type: 'domain',
+ position: {
+ x: 150 + col * GRID_SPACING_X,
+ y: 200 + row * GRID_SPACING_Y
+ },
+ data: {
+ name: domain.name,
+ domainId: domain.id,
+ ssl: domain.ssl_enabled ? 'active' : 'none',
+ dnsStatus: 'pending',
+ isOrphan: true,
+ isReal: true
+ }
+ });
+ });
+
+ // Update state
+ setNodes(importedNodes);
+ setEdges(importedEdges);
+ setAppsInView(new Set(apps.map(a => a.id)));
+ setCurrentWorkflow(null);
+ setWorkflowName('Server Overview');
+
+ // Fit view after a short delay
+ setTimeout(() => fitView({ padding: 0.2 }), 100);
+
+ setSaveMessage(`Loaded ${apps.length} apps, ${domains.length} domains`);
+ setTimeout(() => setSaveMessage(null), 3000);
+
+ } catch (error) {
+ console.error('Failed to load server overview:', error);
+ setSaveMessage('Failed to load infrastructure');
+ setTimeout(() => setSaveMessage(null), 3000);
+ } finally {
+ setIsLoading(false);
+ }
+ }, [setNodes, setEdges, deleteEdge, fitView]);
+
+ // Auto-load server overview on mount
+ useEffect(() => {
+ loadServerOverview();
+ }, []);
+
+ // Validate connections before allowing them
+ const isValidConnection = useCallback((connection) => {
+ return checkValidConnection(connection, nodes);
+ }, [nodes]);
+
// Save workflow
const saveWorkflow = useCallback(async () => {
setIsSaving(true);
@@ -161,12 +383,10 @@ const WorkflowCanvas = () => {
try {
const viewport = getViewport();
- // Serialize nodes without onDelete callback
const serializableNodes = nodes.map(({ id, type, position, data }) => ({
id, type, position,
data: { ...data }
}));
- // Serialize edges without onDelete callback
const serializableEdges = edges.map(({ id, source, target, sourceHandle, targetHandle, type, animated, data }) => ({
id, source, target, sourceHandle, targetHandle, type, animated,
data: data ? { sourceType: data.sourceType, targetType: data.targetType, connectionType: data.connectionType } : undefined
@@ -180,14 +400,12 @@ const WorkflowCanvas = () => {
};
if (currentWorkflow) {
- // Update existing workflow
await api.updateWorkflow(currentWorkflow.id, workflowData);
- setSaveMessage('Workflow saved');
+ setSaveMessage('View saved');
} else {
- // Create new workflow
const response = await api.createWorkflow(workflowData);
setCurrentWorkflow(response.workflow);
- setSaveMessage('Workflow created');
+ setSaveMessage('View created');
}
setTimeout(() => setSaveMessage(null), 3000);
@@ -202,24 +420,17 @@ const WorkflowCanvas = () => {
// Load workflow
const loadWorkflow = useCallback((workflow) => {
- if (!workflow) {
- console.error('No workflow provided to load');
- setSaveMessage('No workflow data');
- setTimeout(() => setSaveMessage(null), 3000);
- return;
- }
+ if (!workflow) return;
setIsLoading(true);
setShowLoadModal(false);
try {
- // Restore nodes with recreated data
const loadedNodes = (workflow.nodes || []).map((node) => ({
...node,
data: { ...node.data }
}));
- // Restore edges with onDelete callback
const loadedEdges = (workflow.edges || []).map((edge) => ({
...edge,
data: {
@@ -228,23 +439,26 @@ const WorkflowCanvas = () => {
}
}));
- // Update node ID counter to prevent collisions
const maxNodeId = loadedNodes.reduce((max, node) => {
const numId = parseInt(node.id.replace('node_', ''), 10);
return isNaN(numId) ? max : Math.max(max, numId);
}, 0);
nodeId = maxNodeId + 1;
+ // Track which apps are in view
+ const appIds = new Set();
+ loadedNodes.forEach(node => {
+ if (node.data?.appId) appIds.add(node.data.appId);
+ });
+ setAppsInView(appIds);
+
setNodes(loadedNodes);
setEdges(loadedEdges);
setWorkflowName(workflow.name || 'Untitled Workflow');
setCurrentWorkflow(workflow);
- // Restore viewport
if (workflow.viewport) {
- setTimeout(() => {
- setViewport(workflow.viewport);
- }, 50);
+ setTimeout(() => setViewport(workflow.viewport), 50);
}
setSaveMessage(`Loaded: ${workflow.name}`);
@@ -263,97 +477,73 @@ const WorkflowCanvas = () => {
setNodes([]);
setEdges([]);
setCurrentWorkflow(null);
- setWorkflowName('Untitled Workflow');
+ setWorkflowName('Custom View');
+ setAppsInView(new Set());
nodeId = 0;
}, [setNodes, setEdges]);
- // Import existing infrastructure as nodes
- const importInfrastructure = useCallback(async () => {
- setIsImporting(true);
- setSaveMessage(null);
-
- try {
- // Fetch apps, domains in parallel
- const [appsResponse, domainsResponse] = await Promise.all([
- api.getApps().catch(() => ({ apps: [] })),
- api.getDomains().catch(() => ({ domains: [] }))
- ]);
-
- const apps = appsResponse.apps || [];
- const domains = domainsResponse.domains || [];
+ // Add node from template (placeholder - would create app via API)
+ const addFromTemplate = useCallback((template) => {
+ setSaveMessage(`To create from "${template.name}", use the Applications page`);
+ setTimeout(() => setSaveMessage(null), 4000);
+ }, []);
- if (apps.length === 0 && domains.length === 0) {
- setSaveMessage('No infrastructure found');
- setTimeout(() => setSaveMessage(null), 3000);
- return;
+ // Add existing app to view
+ const addExistingApp = useCallback((app) => {
+ const newNode = {
+ id: getId(),
+ type: 'dockerApp',
+ position: screenToFlowPosition({
+ x: window.innerWidth / 2 - 90,
+ y: window.innerHeight / 2 - 50
+ }),
+ data: {
+ name: app.name,
+ appId: app.id,
+ status: app.status || 'stopped',
+ port: app.port,
+ appType: app.app_type,
+ template: app.docker_image || app.app_type,
+ privateUrl: app.private_url_enabled ? `/p/${app.private_slug}` : null,
+ domains: app.domains || [],
+ isReal: true
}
+ };
- const importedNodes = [];
- const GRID_SPACING_X = 280;
- const GRID_SPACING_Y = 200;
- const COLS = 3;
-
- // Import Docker apps
- apps.forEach((app, index) => {
- const col = index % COLS;
- const row = Math.floor(index / COLS);
- importedNodes.push({
- id: `node_${nodeId++}`,
- type: 'dockerApp',
- position: {
- x: 100 + col * GRID_SPACING_X,
- y: 100 + row * GRID_SPACING_Y
- },
- data: {
- name: app.name,
- image: app.docker_image || 'custom',
- status: app.status === 'running' ? 'running' : 'stopped',
- ports: app.ports || [],
- memory: app.memory_limit || null,
- appId: app.id
- }
- });
- });
-
- // Import Domains (offset below apps)
- const appsRows = Math.ceil(apps.length / COLS);
- domains.forEach((domain, index) => {
- const col = index % COLS;
- const row = appsRows + Math.floor(index / COLS);
- importedNodes.push({
- id: `node_${nodeId++}`,
- type: 'domain',
- position: {
- x: 100 + col * GRID_SPACING_X,
- y: 100 + row * GRID_SPACING_Y
- },
- data: {
- name: domain.domain,
- ssl: domain.ssl_enabled ? 'active' : 'none',
- dnsStatus: domain.dns_verified ? 'propagated' : 'pending',
- domainId: domain.id
- }
- });
+ setNodes((nds) => [...nds, newNode]);
+ setAppsInView((prev) => new Set([...prev, app.id]));
+
+ // Add edges for connected domains if they're in view
+ if (app.domains && app.domains.length > 0) {
+ app.domains.forEach(domain => {
+ // Find if domain node exists
+ const domainNode = nodes.find(n => n.data?.domainId === domain.id);
+ if (domainNode) {
+ const newEdge = {
+ id: `edge_${domainNode.id}_${newNode.id}`,
+ source: domainNode.id,
+ target: newNode.id,
+ sourceHandle: 'output',
+ targetHandle: 'input',
+ type: 'connection',
+ animated: true,
+ data: {
+ sourceType: 'domain',
+ targetType: 'dockerApp',
+ connectionType: 'routes',
+ onDelete: deleteEdge
+ }
+ };
+ setEdges((eds) => [...eds, newEdge]);
+ }
});
-
- // Add imported nodes to existing nodes
- setNodes((nds) => [...nds, ...importedNodes]);
-
- setSaveMessage(`Imported ${apps.length} apps, ${domains.length} domains`);
- setTimeout(() => setSaveMessage(null), 4000);
- } catch (error) {
- console.error('Failed to import infrastructure:', error);
- setSaveMessage('Failed to import');
- setTimeout(() => setSaveMessage(null), 3000);
- } finally {
- setIsImporting(false);
}
- }, [setNodes]);
+ }, [screenToFlowPosition, setNodes, setEdges, nodes, deleteEdge]);
// Deploy workflow
const deployWorkflow = useCallback(async () => {
if (!currentWorkflow) {
- setSaveMessage('Save workflow first');
+ setSaveMessage('Save as custom view first');
setTimeout(() => setSaveMessage(null), 3000);
return;
}
@@ -369,7 +559,6 @@ const WorkflowCanvas = () => {
setDeploymentResults(null);
try {
- // First save the workflow to ensure it's up to date
const viewport = getViewport();
const serializableNodes = nodes.map(({ id, type, position, data }) => ({
id, type, position,
@@ -387,18 +576,15 @@ const WorkflowCanvas = () => {
viewport
});
- // Now deploy
const result = await api.deployWorkflow(currentWorkflow.id);
setDeploymentResults(result);
- // Update nodes with deployed resource IDs
if (result.workflow && result.workflow.nodes) {
const updatedNodes = result.workflow.nodes.map((node) => ({
...node,
data: { ...node.data }
}));
- // Update node ID counter
const maxNodeId = updatedNodes.reduce((max, node) => {
const numId = parseInt(node.id.replace('node_', ''), 10);
return isNaN(numId) ? max : Math.max(max, numId);
@@ -424,14 +610,11 @@ const WorkflowCanvas = () => {
const onConnect = useCallback(
(params) => {
- // Double-check validation on connect
if (checkValidConnection(params, nodes)) {
- // Find source and target node types
const sourceNode = nodes.find(n => n.id === params.source);
const targetNode = nodes.find(n => n.id === params.target);
const connectionType = getConnectionType(sourceNode?.type, targetNode?.type);
- // Create edge with metadata
const newEdge = {
...params,
type: 'connection',
@@ -455,7 +638,6 @@ const WorkflowCanvas = () => {
}, []);
const onConnectEnd = useCallback((event, connectionState) => {
- // Show error if connection was attempted but failed validation
if (connectionState.isValid === false && connectionState.toNode) {
const error = getConnectionError({
source: connectionState.fromNode?.id,
@@ -465,7 +647,6 @@ const WorkflowCanvas = () => {
}, nodes);
if (error) {
setConnectionError(error);
- // Clear error after 3 seconds
setTimeout(() => setConnectionError(null), 3000);
}
}
@@ -503,14 +684,12 @@ const WorkflowCanvas = () => {
setSelectedEdge(null);
}, []);
- // Handle Delete key press for selected edge
const handleKeyDown = useCallback((event) => {
if ((event.key === 'Delete' || event.key === 'Backspace') && selectedEdge) {
deleteEdge(selectedEdge.id);
}
}, [selectedEdge, deleteEdge]);
- // Attach keydown listener
React.useEffect(() => {
document.addEventListener('keydown', handleKeyDown);
return () => document.removeEventListener('keydown', handleKeyDown);
@@ -531,7 +710,6 @@ const WorkflowCanvas = () => {
)
);
- // Update selectedNode reference to reflect changes
setSelectedNode((prev) => prev ? { ...prev, data: newData } : null);
}, [selectedNode, setNodes]);
@@ -567,62 +745,59 @@ const WorkflowCanvas = () => {
className="workflow-name-input"
value={workflowName}
onChange={(e) => setWorkflowName(e.target.value)}
- placeholder="Workflow name..."
+ placeholder="View name..."
/>
{currentWorkflow && (
- <span className="workflow-id-badge">ID: {currentWorkflow.id}</span>
+ <span className="workflow-id-badge">Saved View</span>
)}
</div>
<div className="toolbar-right">
+ <button
+ className="toolbar-btn toolbar-btn-overview"
+ onClick={loadServerOverview}
+ disabled={isLoading}
+ title="Load full server infrastructure"
+ >
+ <Eye size={16} />
+ <span>{isLoading ? 'Loading...' : 'Server Overview'}</span>
+ </button>
<button
className="toolbar-btn"
onClick={newWorkflow}
- title="New Workflow"
+ title="New custom view"
>
<Plus size={16} />
- <span>New</span>
+ <span>New View</span>
</button>
<button
className="toolbar-btn"
onClick={() => setShowLoadModal(true)}
- title="Load Workflow"
+ title="Load saved view"
>
<FolderOpen size={16} />
<span>Load</span>
</button>
- <button
- className="toolbar-btn"
- onClick={importInfrastructure}
- disabled={isImporting}
- title="Import existing apps and domains as nodes"
- >
- <Download size={16} />
- <span>{isImporting ? 'Importing...' : 'Import'}</span>
- </button>
<button
className="toolbar-btn toolbar-btn-primary"
onClick={saveWorkflow}
disabled={isSaving}
- title="Save Workflow"
+ title="Save current view"
>
<Save size={16} />
- <span>{isSaving ? 'Saving...' : 'Save'}</span>
- </button>
- <button
- className="toolbar-btn toolbar-btn-deploy"
- onClick={deployWorkflow}
- disabled={isDeploying || !currentWorkflow || nodes.length === 0}
- title={!currentWorkflow ? 'Save workflow first' : 'Deploy infrastructure'}
- >
- <Play size={16} />
- <span>{isDeploying ? 'Deploying...' : 'Deploy'}</span>
+ <span>{isSaving ? 'Saving...' : 'Save View'}</span>
</button>
</div>
{saveMessage && (
<div className="toolbar-message">{saveMessage}</div>
)}
</div>
- <NodePalette onAddNode={addNode} />
+ <NodePalette
+ onAddNode={addNode}
+ templates={templates}
+ onAddFromTemplate={addFromTemplate}
+ existingApps={existingAppsNotInView}
+ onAddExistingApp={addExistingApp}
+ />
{connectionError && (
<div className="connection-error-toast">
{connectionError}
diff --git a/frontend/src/services/api.js b/frontend/src/services/api.js
index d293f28d..15285ca8 100644
--- a/frontend/src/services/api.js
+++ b/frontend/src/services/api.js
@@ -340,6 +340,10 @@ class ApiService {
return this.request('/system/metrics');
}
+ async getSystemInfo() {
+ return this.request('/system/info');
+ }
+
async getServerTime() {
return this.request('/system/time');
}
diff --git a/frontend/src/styles/pages/_dashboard.less b/frontend/src/styles/pages/_dashboard.less
index be6fd841..fd21b1d3 100644
--- a/frontend/src/styles/pages/_dashboard.less
+++ b/frontend/src/styles/pages/_dashboard.less
@@ -421,3 +421,85 @@
font-size: 1.5rem;
}
}
+
+// --- Refresh Control ---
+.refresh-control {
+ display: flex;
+ align-items: center;
+ gap: @space-3;
+ margin-left: auto;
+ padding-left: @space-4;
+}
+
+.connection-status {
+ font-family: @font-mono;
+ font-size: @font-size-xs;
+ font-weight: @font-weight-semibold;
+ letter-spacing: 0.05em;
+ padding: @space-1 @space-2;
+ border-radius: @radius-sm;
+
+ &.live {
+ color: @success;
+ background: @success-bg;
+ }
+
+ &.polling {
+ color: @warning;
+ background: @warning-bg;
+ }
+}
+
+.refresh-select {
+ background: @bg-hover;
+ border: 1px solid @border-subtle;
+ border-radius: @radius-sm;
+ color: @text-primary;
+ font-family: @font-mono;
+ font-size: @font-size-sm;
+ padding: @space-1 @space-2;
+ cursor: pointer;
+ outline: none;
+
+ &:hover {
+ border-color: @accent-primary;
+ }
+
+ &:focus {
+ border-color: @accent-primary;
+ box-shadow: 0 0 0 2px @accent-glow;
+ }
+}
+
+.btn-refresh {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: @bg-hover;
+ border: 1px solid @border-subtle;
+ border-radius: @radius-sm;
+ color: @text-secondary;
+ padding: @space-2;
+ cursor: pointer;
+ transition: all @transition-fast;
+
+ &:hover {
+ border-color: @accent-primary;
+ color: @accent-primary;
+ background: @accent-glow;
+ }
+}
+
+.status-dot-live.disconnected {
+ background: @warning;
+ box-shadow: 0 0 10px @warning;
+}
+
+@media (max-width: @breakpoint-md) {
+ .refresh-control {
+ width: 100%;
+ justify-content: flex-start;
+ margin-left: 0;
+ padding-left: 0;
+ }
+}
diff --git a/frontend/src/styles/pages/_workflow.less b/frontend/src/styles/pages/_workflow.less
index 45995216..fc3ef533 100644
--- a/frontend/src/styles/pages/_workflow.less
+++ b/frontend/src/styles/pages/_workflow.less
@@ -1578,3 +1578,266 @@
border-radius: 50%;
}
}
+
+// ============================================
+// REAL APP NODE INDICATOR
+// ============================================
+
+.workflow-node.is-real {
+ border-color: @accent-primary;
+
+ .workflow-node-header {
+ background: fade(@accent-primary, 15%);
+ }
+}
+
+// ============================================
+// PALETTE SUBMENU
+// ============================================
+
+.palette-submenu {
+ display: flex;
+ flex-direction: column;
+ gap: @space-1;
+ margin-left: @space-3;
+ margin-bottom: @space-2;
+ padding-left: @space-2;
+ border-left: 2px solid @border-subtle;
+}
+
+.palette-subitem {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: @space-2;
+ padding: @space-2;
+ background: @bg-body;
+ border: 1px solid @border-subtle;
+ border-radius: @radius-sm;
+ color: @text-secondary;
+ font-size: @font-size-xs;
+ cursor: pointer;
+ transition: all @transition-fast;
+
+ &:hover {
+ background: @bg-hover;
+ border-color: @accent-primary;
+ color: @text-primary;
+ }
+
+ .status-badge {
+ font-size: 10px;
+ padding: 1px 6px;
+ }
+}
+
+.palette-empty {
+ padding: @space-2;
+ color: @text-tertiary;
+ font-size: @font-size-xs;
+ font-style: italic;
+}
+
+.palette-section-info {
+ margin-top: auto;
+ padding-top: @space-3;
+ border-top: 1px solid @border-subtle;
+}
+
+.palette-hint {
+ font-size: @font-size-xs;
+ color: @text-tertiary;
+ line-height: 1.4;
+}
+
+// ============================================
+// DOMAIN PILLS IN NODE
+// ============================================
+
+.node-domains {
+ display: flex;
+ flex-wrap: wrap;
+ gap: @space-1;
+ margin-top: @space-2;
+}
+
+.node-domain-pill {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ padding: 2px @space-2;
+ background: fade(@success, 15%);
+ border: 1px solid fade(@success, 30%);
+ border-radius: @radius-full;
+ font-size: 10px;
+ color: @success;
+
+ svg {
+ opacity: 0.7;
+ }
+}
+
+.node-domain-more {
+ font-size: 10px;
+ color: @text-tertiary;
+ padding: 2px @space-1;
+}
+
+// ============================================
+// PRIVATE URL IN NODE
+// ============================================
+
+@color-info: #22d3ee;
+
+.node-detail-private-url {
+ display: flex;
+ align-items: center;
+ gap: @space-1;
+ margin-top: @space-2;
+ padding: @space-1 @space-2;
+ background: fade(@color-info, 10%);
+ border-radius: @radius-sm;
+
+ svg {
+ color: @color-info;
+ flex-shrink: 0;
+ }
+
+ .node-detail-value {
+ font-size: 10px;
+ color: @color-info;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+}
+
+// ============================================
+// SERVER OVERVIEW BUTTON
+// ============================================
+
+.toolbar-btn-overview {
+ background: fade(@color-info, 15%) !important;
+ border-color: fade(@color-info, 30%) !important;
+ color: @color-info !important;
+
+ &:hover:not(:disabled) {
+ background: fade(@color-info, 25%) !important;
+ border-color: @color-info !important;
+ }
+}
+
+// ============================================
+// CONFIG PANEL ENHANCEMENTS
+// ============================================
+
+.form-value {
+ padding: @space-2 @space-3;
+ background: @bg-body;
+ border: 1px solid @border-subtle;
+ border-radius: @radius-md;
+ font-size: @font-size-sm;
+ color: @text-primary;
+
+ &.status-badge {
+ display: inline-flex;
+ padding: @space-1 @space-2;
+ border-radius: @radius-sm;
+ font-size: @font-size-xs;
+ font-weight: @font-weight-medium;
+ text-transform: capitalize;
+ }
+
+ &.status-running {
+ background: @success-bg;
+ border-color: @success-border;
+ color: @success;
+ }
+
+ &.status-stopped {
+ background: @bg-body;
+ border-color: @border-subtle;
+ color: @text-tertiary;
+ }
+
+ &.status-error {
+ background: @danger-bg;
+ border-color: @danger-border;
+ color: @danger;
+ }
+}
+
+.form-value-link {
+ display: flex;
+ align-items: center;
+ gap: @space-2;
+ cursor: pointer;
+ color: @accent-primary;
+
+ &:hover {
+ text-decoration: underline;
+ }
+
+ svg:last-child {
+ opacity: 0.5;
+ margin-left: auto;
+ }
+}
+
+.form-domains {
+ display: flex;
+ flex-direction: column;
+ gap: @space-2;
+}
+
+.form-domain-item {
+ display: flex;
+ align-items: center;
+ gap: @space-2;
+ padding: @space-2;
+ background: @bg-body;
+ border: 1px solid @border-subtle;
+ border-radius: @radius-md;
+ font-size: @font-size-sm;
+
+ svg {
+ color: @success;
+ }
+
+ .ssl-badge {
+ margin-left: auto;
+ padding: 2px 6px;
+ background: @success-bg;
+ border-radius: @radius-sm;
+ font-size: 10px;
+ font-weight: @font-weight-medium;
+ color: @success;
+ }
+}
+
+.action-buttons {
+ display: flex;
+ gap: @space-2;
+ flex-wrap: wrap;
+
+ .btn {
+ flex: 1;
+ min-width: 70px;
+ }
+}
+
+.action-message {
+ margin-top: @space-2;
+ padding: @space-2;
+ background: @success-bg;
+ border: 1px solid @success-border;
+ border-radius: @radius-sm;
+ font-size: @font-size-xs;
+ color: @success;
+ text-align: center;
+}
+
+.btn-block {
+ width: 100%;
+ justify-content: center;
+}