mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 00:54:23 +00:00
Change InstanceCard buttons to icons
This commit is contained in:
@@ -2,14 +2,16 @@ import { Button } from '@/components/ui/button'
|
|||||||
import { Badge } from '@/components/ui/badge'
|
import { Badge } from '@/components/ui/badge'
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
||||||
import { Instance } from '@/types/instance'
|
import { Instance } from '@/types/instance'
|
||||||
import { useInstances } from '@/hooks/useInstances'
|
import { Edit, FileText, Play, Square, Trash2 } from 'lucide-react'
|
||||||
|
|
||||||
interface InstanceCardProps {
|
interface InstanceCardProps {
|
||||||
instance: Instance
|
instance: Instance
|
||||||
|
startInstance: (name: string) => void
|
||||||
|
stopInstance: (name: string) => void
|
||||||
|
deleteInstance: (name: string) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
function InstanceCard({ instance }: InstanceCardProps) {
|
function InstanceCard({ instance, startInstance, stopInstance, deleteInstance }: InstanceCardProps) {
|
||||||
const { startInstance, stopInstance, deleteInstance } = useInstances()
|
|
||||||
|
|
||||||
const handleStart = () => {
|
const handleStart = () => {
|
||||||
startInstance(instance.name)
|
startInstance(instance.name)
|
||||||
@@ -25,6 +27,16 @@ function InstanceCard({ instance }: InstanceCardProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleEdit = () => {
|
||||||
|
// Logic for editing the instance (e.g., open a modal)
|
||||||
|
console.log(`Edit instance: ${instance.name}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleLogs = () => {
|
||||||
|
// Logic for viewing logs (e.g., open a logs page)
|
||||||
|
console.log(`View logs for instance: ${instance.name}`)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader className="pb-3">
|
<CardHeader className="pb-3">
|
||||||
@@ -37,33 +49,53 @@ function InstanceCard({ instance }: InstanceCardProps) {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-1">
|
||||||
{!instance.running ? (
|
<Button
|
||||||
<Button
|
size="sm"
|
||||||
size="sm"
|
variant="outline"
|
||||||
onClick={handleStart}
|
onClick={handleStart}
|
||||||
className="flex-1"
|
disabled={instance.running}
|
||||||
>
|
title="Start instance"
|
||||||
Start
|
>
|
||||||
</Button>
|
<Play className="h-4 w-4" />
|
||||||
) : (
|
</Button>
|
||||||
<Button
|
|
||||||
size="sm"
|
<Button
|
||||||
variant="outline"
|
size="sm"
|
||||||
onClick={handleStop}
|
variant="outline"
|
||||||
className="flex-1"
|
onClick={handleStop}
|
||||||
>
|
disabled={!instance.running}
|
||||||
Stop
|
title="Stop instance"
|
||||||
</Button>
|
>
|
||||||
)}
|
<Square className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="outline"
|
||||||
|
onClick={handleEdit}
|
||||||
|
title="Edit instance"
|
||||||
|
>
|
||||||
|
<Edit className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="outline"
|
||||||
|
onClick={handleLogs}
|
||||||
|
title="View logs"
|
||||||
|
>
|
||||||
|
<FileText className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
onClick={handleDelete}
|
onClick={handleDelete}
|
||||||
disabled={instance.running}
|
disabled={instance.running}
|
||||||
|
title="Delete instance"
|
||||||
>
|
>
|
||||||
Delete
|
<Trash2 className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useInstances } from '@/hooks/useInstances'
|
|||||||
import InstanceCard from '@/components/InstanceCard'
|
import InstanceCard from '@/components/InstanceCard'
|
||||||
|
|
||||||
function InstanceList() {
|
function InstanceList() {
|
||||||
const { instances, loading, error } = useInstances()
|
const { instances, loading, error, startInstance, stopInstance, deleteInstance } = useInstances()
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
@@ -46,6 +46,9 @@ function InstanceList() {
|
|||||||
<InstanceCard
|
<InstanceCard
|
||||||
key={instance.name}
|
key={instance.name}
|
||||||
instance={instance}
|
instance={instance}
|
||||||
|
startInstance={startInstance}
|
||||||
|
stopInstance={stopInstance}
|
||||||
|
deleteInstance={deleteInstance}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user