Feat: add VPS export functionality and import JSON feature in UI
All checks were successful
Build and Push Docker Images / docker (push) Successful in 28s

This commit is contained in:
jeanotx32
2026-06-02 19:23:54 -04:00
parent f2e5a24b37
commit 2a46fcd13a
7 changed files with 187 additions and 56 deletions

View File

@@ -1,4 +1,4 @@
import { Server, Wifi, WifiOff, Trash2, ChevronDown, ChevronUp, RefreshCw, Cpu, MemoryStick, ArrowUp, ArrowDown, Pencil, BarChart2, CloudDownload } from 'lucide-react'
import { Server, Wifi, WifiOff, Trash2, ChevronDown, ChevronUp, RefreshCw, Cpu, MemoryStick, ArrowUp, ArrowDown, Pencil, BarChart2, CloudDownload, Copy, Check } from 'lucide-react'
import { useState } from 'react'
import ContainerRow from './ContainerRow'
import { tagColor } from './TagInput'
@@ -14,10 +14,17 @@ function formatRam(bytes) {
return `${(bytes / 1024 ** 3).toFixed(1)} GB`
}
export default function VpsCard({ vps, onAction, onLogs, onDelete, onUpdate, onEdit, onStats, onUpdateAgent }) {
export default function VpsCard({ vps, onAction, onLogs, onDelete, onUpdate, onEdit, onStats, onUpdateAgent, onExport }) {
const [collapsed, setCollapsed] = useState(false)
const [updatingProject, setUpdatingProject] = useState(null)
const [updatingAgent, setUpdatingAgent] = useState(false)
const [exported, setExported] = useState(false)
const handleExport = async () => {
await onExport(vps.id)
setExported(true)
setTimeout(() => setExported(false), 2000)
}
const running = vps.containers.filter(c => c.status === 'running').length
const total = vps.containers.length
@@ -78,6 +85,14 @@ export default function VpsCard({ vps, onAction, onLogs, onDelete, onUpdate, onE
</button>
)}
<button
onClick={handleExport}
className={`p-1.5 rounded hover:bg-gray-800 transition-colors ${exported ? 'text-emerald-400' : 'text-gray-500 hover:text-gray-300'}`}
title={exported ? 'Config copiée !' : 'Exporter la config (copier JSON)'}
>
{exported ? <Check size={14} /> : <Copy size={14} />}
</button>
<button
onClick={() => onEdit(vps)}
className="p-1.5 rounded hover:bg-gray-800 text-gray-500 hover:text-gray-300 transition-colors"