diff --git a/src/app/api/deploy/route.ts b/src/app/api/deploy/route.ts index 2478a8b..1297a7d 100644 --- a/src/app/api/deploy/route.ts +++ b/src/app/api/deploy/route.ts @@ -13,13 +13,13 @@ export async function GET(req: NextRequest): Promise { ); } - // const apps = await getApplications(); + // const apps = await getApps(); - const applications = await getDeployments([]); + const apps = await getDeployments([]); return NextResponse.json({ message: "ok", - applications, + apps, }); } diff --git a/src/app/applications/page.tsx b/src/app/applications/page.tsx index 2b71156..c61e2f9 100644 --- a/src/app/applications/page.tsx +++ b/src/app/applications/page.tsx @@ -13,32 +13,29 @@ import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { MoreVertical, Plus, Rocket } from "lucide-react"; import InstallApplicationDialog from "@/components/dialogs/InstallApplication"; -import { getApplications, removeApp } from "@/lib/dockship/application"; +import { getApps, removeApp } from "@/lib/dockship/application"; import RemoveDialog from "@/components/dialogs/Remove"; import DeployAppDialog from "@/components/dialogs/DeployApp"; import { useAsyncInterval } from "@/hooks/use-async"; export default function ApplicationsPage() { - const { value: applications, setValue: setApplications } = useAsyncInterval( + const { value: apps, setValue: setApps } = useAsyncInterval( [], - getApplications, + getApps, 3000 ); const remove = async (appId: string) => { await removeApp(appId); - setApplications((prev) => prev.filter((app) => app.id !== appId)); + setApps((prev) => prev.filter((app) => app.id !== appId)); }; return ( - + {/* Header */}
- {applications.length} apps + {apps.length} apps
- {applications.map((app) => ( + {apps.map((app) => ( {app.name} diff --git a/src/app/deployments/page.tsx b/src/app/deployments/page.tsx index bc93051..ad54567 100644 --- a/src/app/deployments/page.tsx +++ b/src/app/deployments/page.tsx @@ -8,7 +8,7 @@ import { Button } from "@/components/ui/button"; import { Rocket, RotateCcw, Eye, MoreVertical, Plus } from "lucide-react"; import { Application, Deployment } from "@/lib/types"; import { getDeployments } from "@/lib/dockship/deploy"; -import { getApplications } from "@/lib/dockship/application"; +import { getApps } from "@/lib/dockship/application"; import { cn } from "@/lib/utils"; import DeployAppDialog from "@/components/dialogs/DeployApp"; import { useAsync } from "@/hooks/use-async"; @@ -20,23 +20,23 @@ const statusDot = { } as const; export default function DeploymentsPage() { - const { value: applications } = useAsync([], getApplications); + const { value: apps } = useAsync([], getApps); const { value: deployments, loading } = useAsync( [], async () => (await getDeployments()).filter((d) => d !== null), - [applications] + [apps] ); const appNameByContainer = useMemo(() => { const map = new Map(); - for (const app of applications) { + for (const app of apps) { for (const container of app.deployments) { map.set(container, app.name); } } return map; - }, [applications]); + }, [apps]); return ( getDocker(nodes), [ nodes, ]); - const { value: applications } = useAsyncInterval([], getApplications, 3000); + const { value: apps } = useAsyncInterval([], getApps, 3000); const { value: deployments } = useAsyncInterval( [], async () => (await getDeployments()).filter((d) => d !== null), @@ -45,13 +45,13 @@ export default function OverviewPage() { const appNameByContainer = useMemo(() => { const map = new Map(); - for (const app of applications) { + for (const app of apps) { for (const container of app.deployments) { map.set(container, app.name); } } return map; - }, [applications]); + }, [apps]); return ( @@ -59,9 +59,9 @@ export default function OverviewPage() {
app.deployments.length > 0).length + apps.filter((app) => app.deployments.length > 0).length } Deployed`} icon={} /> @@ -111,12 +111,12 @@ export default function OverviewPage() {
{/* Rows */} - {applications.slice(-5).length === 0 ? ( + {apps.slice(-5).length === 0 ? (
No applications yet
) : ( - applications.slice(-5).map((app) => ( + apps.slice(-5).map((app) => (
({ + data={apps.map((app) => ({ label: app.name, value: app.id, }))} diff --git a/src/lib/dockship/application.ts b/src/lib/dockship/application.ts index 479af46..db7c4a4 100644 --- a/src/lib/dockship/application.ts +++ b/src/lib/dockship/application.ts @@ -23,10 +23,10 @@ export async function installApp(name: string, repo: string, nodeId: string) { headers: { Authorization: `ApiKey ${targetNode?.key}` }, } ) - ).data.applications; + ).data.apps; } -export async function getApplications(): Promise { +export async function getApps(): Promise { if (await verifySession()) { throw new Error("Unauthorized"); } @@ -35,7 +35,7 @@ export async function getApplications(): Promise { } export async function getEnv(): Promise> { - const apps = await getApplications(); + const apps = await getApps(); return apps.reduce>((acc, app) => { acc[app.id] = { @@ -56,14 +56,14 @@ export async function setEnv( throw new Error("Unauthorized"); } - const apps = await getApplications(); + const apps = await getApps(); const app = apps.find((app) => app.id === appId); if (!app) throw new Error("App not found"); editApp(appId, { ...app, env: variables }); } export async function removeApp(appId: string) { - const apps = await getApplications(); + const apps = await getApps(); const nextApps = apps.filter((app) => app.id !== appId); @@ -71,7 +71,7 @@ export async function removeApp(appId: string) { } export async function editApp(appId: string, updatedApp: Application) { - const apps = await getApplications(); + const apps = await getApps(); const nextApps = apps.map((app) => (app.id === appId ? updatedApp : app)); diff --git a/src/lib/dockship/deploy.ts b/src/lib/dockship/deploy.ts index 0f6155e..37c27b3 100644 --- a/src/lib/dockship/deploy.ts +++ b/src/lib/dockship/deploy.ts @@ -15,7 +15,7 @@ export async function getDeployments(): Promise<(null | Deployment)[]> { await axios.get(`http://${n.ip}:3000/api/deploy`, { headers: { Authorization: `ApiKey ${n.key}` }, }) - ).data.applications + ).data.apps ) ) ).flat();