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 database nodes to WorkflowBuilder canvas

Juan Denisd72dae65ac36
diff --git a/frontend/dist/index.html b/frontend/dist/index.html
index 20ea11ad..70f2f172 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-MWhhibEj.js"></script>
- <link rel="stylesheet" crossorigin href="/assets/index-D6I0w7_M.css">
+ <script type="module" crossorigin src="/assets/index-BpLdi01Q.js"></script>
+ <link rel="stylesheet" crossorigin href="/assets/index-BwDVuCDb.css">
</head>
<body>
diff --git a/frontend/src/pages/WorkflowBuilder.jsx b/frontend/src/pages/WorkflowBuilder.jsx
index 0f2795bd..1dba9206 100644
--- a/frontend/src/pages/WorkflowBuilder.jsx
+++ b/frontend/src/pages/WorkflowBuilder.jsx
@@ -218,6 +218,18 @@ const WorkflowCanvas = () => {
const apps = appsResponse.apps || [];
const domains = domainsResponse.domains || [];
+ // Fetch databases for each Docker app in parallel
+ const appDatabasePromises = apps
+ .filter(app => app.app_type === 'docker')
+ .map(app => api.getAppDatabases(app.id).catch(() => ({ databases: [] })));
+ const appDatabaseResults = await Promise.all(appDatabasePromises);
+
+ // Create a map of app_id to databases
+ const appDatabasesMap = {};
+ apps.filter(app => app.app_type === 'docker').forEach((app, index) => {
+ appDatabasesMap[app.id] = appDatabaseResults[index]?.databases || [];
+ });
+
if (apps.length === 0 && domains.length === 0) {
setSaveMessage('No infrastructure found - create an app first!');
setTimeout(() => setSaveMessage(null), 4000);
@@ -344,6 +356,59 @@ const WorkflowCanvas = () => {
});
});
+ // Create database nodes below apps that have databases
+ const DATABASE_OFFSET_Y = 180;
+ let databaseCount = 0;
+ apps.forEach((app) => {
+ const databases = appDatabasesMap[app.id] || [];
+ if (databases.length > 0) {
+ const appNodeId = appNodeIds[app.id];
+ const appNode = importedNodes.find(n => n.id === appNodeId);
+
+ databases.forEach((db, dbIdx) => {
+ const dbNodeId = getId();
+ databaseCount++;
+
+ // Position database below its app
+ importedNodes.push({
+ id: dbNodeId,
+ type: 'database',
+ position: {
+ x: appNode.position.x + (dbIdx * 200),
+ y: appNode.position.y + DATABASE_OFFSET_Y
+ },
+ data: {
+ name: db.database || db.name || 'Database',
+ type: db.type || 'mysql',
+ host: db.container || db.host || 'localhost',
+ port: db.port || '3306',
+ status: 'running',
+ connectedAppId: app.id,
+ containerName: db.container,
+ isReal: true
+ }
+ });
+
+ // Create edge from app's database handle to database node
+ importedEdges.push({
+ id: `edge_${appNodeId}_${dbNodeId}`,
+ source: appNodeId,
+ target: dbNodeId,
+ sourceHandle: 'database',
+ targetHandle: 'input',
+ type: 'connection',
+ animated: true,
+ data: {
+ sourceType: 'dockerApp',
+ targetType: 'database',
+ connectionType: 'uses',
+ onDelete: deleteEdge
+ }
+ });
+ });
+ }
+ });
+
// Update state
setNodes(importedNodes);
setEdges(importedEdges);
@@ -354,7 +419,8 @@ const WorkflowCanvas = () => {
// Fit view after a short delay
setTimeout(() => fitView({ padding: 0.2 }), 100);
- setSaveMessage(`Loaded ${apps.length} apps, ${domains.length} domains`);
+ const dbMessage = databaseCount > 0 ? `, ${databaseCount} databases` : '';
+ setSaveMessage(`Loaded ${apps.length} apps, ${domains.length} domains${dbMessage}`);
setTimeout(() => setSaveMessage(null), 3000);
} catch (error) {
diff --git a/frontend/src/styles/layout/_main-content.less b/frontend/src/styles/layout/_main-content.less
index e8f99b58..be929bcc 100644
--- a/frontend/src/styles/layout/_main-content.less
+++ b/frontend/src/styles/layout/_main-content.less
@@ -21,6 +21,12 @@
margin-left: 0;
padding: @space-5;
}
+
+ // Remove padding for fullscreen pages (workflow builder)
+ &:has(.workflow-page.fullscreen) {
+ padding: 0;
+ overflow: hidden;
+ }
}
// Top bar (page header)