Shortened applictions for apps in code

This commit is contained in:
2026-01-03 19:51:39 +01:00
parent b39f32d006
commit 1a1dc90c01
7 changed files with 32 additions and 35 deletions
+3 -3
View File
@@ -13,13 +13,13 @@ export async function GET(req: NextRequest): Promise<NextResponse> {
);
}
// const apps = await getApplications();
// const apps = await getApps();
const applications = await getDeployments([]);
const apps = await getDeployments([]);
return NextResponse.json({
message: "ok",
applications,
apps,
});
}
+7 -10
View File
@@ -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 (
<DashboardLayout
title="Applications"
subtitle="Manage installed applications"
>
<DashboardLayout title="Applications" subtitle="Manage dockship applications">
{/* Header */}
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-6">
<div className="flex flex-wrap items-center gap-2">
<Badge>{applications.length} apps</Badge>
<Badge>{apps.length} apps</Badge>
</div>
<InstallApplicationDialog>
<Button size="sm" className="gap-2 w-full sm:w-auto">
@@ -47,7 +44,7 @@ export default function ApplicationsPage() {
</InstallApplicationDialog>
</div>
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
{applications.map((app) => (
{apps.map((app) => (
<Card key={app.id}>
<CardHeader>
<CardTitle>{app.name}</CardTitle>
+5 -5
View File
@@ -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<string, string>();
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 (
<DashboardLayout
+8 -8
View File
@@ -26,7 +26,7 @@ import {
NodeLiveData,
} from "@/lib/types";
import { getDocker } from "@/lib/dockship/docker";
import { getApplications } from "@/lib/dockship/application";
import { getApps } from "@/lib/dockship/application";
import { cn } from "@/lib/utils";
import { getDeployments } from "@/lib/dockship/deploy";
import { useAsync, useAsyncInterval } from "@/hooks/use-async";
@@ -36,7 +36,7 @@ export default function OverviewPage() {
const { value: dockerNodes } = useAsync([], async () => 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<string, string>();
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 (
<DashboardLayout title="Overview" subtitle="System status and metrics">
@@ -59,9 +59,9 @@ export default function OverviewPage() {
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-4 mb-6">
<StatCard
title="Applications"
value={applications.length}
value={apps.length}
subtitle={`${
applications.filter((app) => app.deployments.length > 0).length
apps.filter((app) => app.deployments.length > 0).length
} Deployed`}
icon={<Box className="w-4 h-4" />}
/>
@@ -111,12 +111,12 @@ export default function OverviewPage() {
</div>
{/* Rows */}
{applications.slice(-5).length === 0 ? (
{apps.slice(-5).length === 0 ? (
<div className="py-6 text-sm text-muted-foreground text-center">
No applications yet
</div>
) : (
applications.slice(-5).map((app) => (
apps.slice(-5).map((app) => (
<div
key={app.id}
className="