import AppLayout from '@/Layouts/AppLayout';
import { Head, router } from '@inertiajs/react';
import { motion } from 'framer-motion';
import { Box, Play, Square, RotateCcw, Trash2, Terminal, BarChart2, Plus } from 'lucide-react';
import { GlassCard, StatCard } from '@/Components/ui/GlassCard';
import { StatusBadge } from '@/Components/ui/StatusBadge';
import { Button } from '@/Components/ui/Button';
import { DataTable } from '@/Components/ui/DataTable';
import { useState } from 'react';
import { cn } from '@/lib/utils';
export default function ContainerIndex({ containers, endpoints }) {
const [actionLoading, setActionLoading] = useState(null);
const [selectedEndpoint, setSelectedEndpoint] = useState(null);
const action = (containerId, act) => {
setActionLoading(`${containerId}-${act}`);
router.post(`/containers/${containerId}/action`, { action: act }, {
onFinish: () => setActionLoading(null),
});
};
const filtered = selectedEndpoint
? (containers.data ?? []).filter(c => c.endpoint_id === selectedEndpoint)
: (containers.data ?? []);
const columns = [
{ header: 'Container', accessor: 'name', render: row => (
)},
{ header: 'Status', accessor: 'state', render: row => },
{ header: 'Ports', key: 'ports', render: row => (
{(row.ports ?? []).slice(0, 3).map((p, i) => (
{p.PublicPort ? `${p.PublicPort}:${p.PrivatePort}` : p.PrivatePort}
))}
{(row.ports ?? []).length > 3 && +{row.ports.length - 3}}
)},
{ header: '', key: 'actions', render: row => (
e.stopPropagation()}>
{row.state === 'running' ? (
<>
>
) : (
)}
)},
];
const running = (containers.data ?? []).filter(c => c.state === 'running').length;
const stopped = (containers.data ?? []).filter(c => c.state !== 'running').length;
return (
Containers
Manage Docker containers across all endpoints
{/* Endpoint filter tabs */}
{endpoints?.length > 0 && (
{endpoints.map(e => (
))}
)}
router.visit(`/containers/${row.id}`)}
emptyMessage="No containers found. Add a Docker endpoint to get started."
/>
);
}