feat(instances): add VM/LXC migration, autostart/boot order, protection
- Migrate VMs/LXCs between cluster nodes with live progress tracking - Configure autostart, boot order, startup/shutdown delays, and delete protection from the instance settings tab - Group OS templates by detected OS (Ubuntu, AlmaLinux, etc.) instead of a single "Cloud Images" bucket - Expand native Proxmox backup job management (schedule, compression, retention, guest selection, notifications) - Add ru/en translations for the above
This commit is contained in:
@@ -7,7 +7,7 @@ import { Label } from '@/components/ui/label';
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { useServers, useNodes, useStorages } from '@/hooks/use-nodes';
|
||||
import { useQuickDeployInfo, useDeployVM } from '@/hooks/use-templates';
|
||||
import { useQuickDeployInfo, useDeployVM, useTemplateGroups, useUpdateTemplate } from '@/hooks/use-templates';
|
||||
import { useAvailableLXCTemplates, useDownloadLXCTemplate } from '@/hooks/use-lxc-templates';
|
||||
import type { OSTemplate } from '@/types';
|
||||
import { toast } from 'sonner';
|
||||
@@ -177,3 +177,54 @@ export function DownloadCTDialog({ open, onClose }: { open: boolean; onClose: ()
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
// ==================== Edit template group (category) ====================
|
||||
|
||||
export function EditTemplateDialog({ template, onClose }: { template: OSTemplate | null; onClose: () => void }) {
|
||||
const { t } = useTranslation();
|
||||
const open = !!template;
|
||||
const { data: groups = [] } = useTemplateGroups();
|
||||
const update = useUpdateTemplate();
|
||||
const [groupId, setGroupId] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
if (template) setGroupId(String(template.group_id));
|
||||
}, [template]);
|
||||
|
||||
const submit = () => {
|
||||
if (!template || !groupId) return;
|
||||
update.mutate(
|
||||
{ id: template.id, group_id: Number(groupId) },
|
||||
{
|
||||
onSuccess: () => { toast.success(t('templates.group_updated')); onClose(); },
|
||||
onError: (e: Error) => toast.error(e.message),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={(v) => { if (!v) onClose(); }}>
|
||||
<DialogContent>
|
||||
<DialogHeader><DialogTitle>{t('templates.edit_group')}: {template?.name}</DialogTitle></DialogHeader>
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<Label>{t('templates.group')}</Label>
|
||||
<Select value={groupId} onValueChange={v => { if (v) setGroupId(v); }}>
|
||||
<SelectTrigger className="mt-1 w-full"><SelectValue placeholder={t('templates.select_group')} /></SelectTrigger>
|
||||
<SelectContent className="max-h-72">
|
||||
{groups.map(g => <SelectItem key={g.id} value={String(g.id)}>{g.name}</SelectItem>)}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={onClose}>{t('common.cancel')}</Button>
|
||||
<Button onClick={submit} disabled={update.isPending || !groupId || groupId === String(template?.group_id)}>
|
||||
{update.isPending && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
{t('common.save')}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Monitor, Search, Download, Trash2, Loader2, Rocket, PackagePlus } from 'lucide-react';
|
||||
import { Monitor, Search, Download, Trash2, Loader2, Rocket, PackagePlus, Pencil } from 'lucide-react';
|
||||
import { OsLogo } from './OsLogo';
|
||||
import { DeployDialog, DownloadCTDialog } from './TemplateDialogs';
|
||||
import { DeployDialog, DownloadCTDialog, EditTemplateDialog } from './TemplateDialogs';
|
||||
import type { OSTemplate } from '@/types';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Button } from '@/components/ui/button';
|
||||
@@ -25,6 +25,7 @@ export default function TemplatesPage() {
|
||||
const [importDialogOpen, setImportDialogOpen] = useState(false);
|
||||
const [importServerId, setImportServerId] = useState<string>('');
|
||||
const [deployTpl, setDeployTpl] = useState<OSTemplate | null>(null);
|
||||
const [editTpl, setEditTpl] = useState<OSTemplate | null>(null);
|
||||
const [downloadOpen, setDownloadOpen] = useState(false);
|
||||
|
||||
const { data: groups = [] } = useTemplateGroups();
|
||||
@@ -123,14 +124,25 @@ export default function TemplatesPage() {
|
||||
<p className="text-xs text-muted-foreground">{tpl.group_name}</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="opacity-0 group-hover:opacity-100 transition-opacity h-7 w-7 p-0 text-destructive"
|
||||
onClick={async () => { if (await confirm(t('common.confirm_delete'))) deleteTpl.mutate(tpl.id); }}
|
||||
>
|
||||
<Trash2 className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<div className="flex items-center gap-0.5">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="opacity-0 group-hover:opacity-100 transition-opacity h-7 w-7 p-0"
|
||||
title={t('templates.edit_group')}
|
||||
onClick={() => setEditTpl(tpl)}
|
||||
>
|
||||
<Pencil className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="opacity-0 group-hover:opacity-100 transition-opacity h-7 w-7 p-0 text-destructive"
|
||||
onClick={async () => { if (await confirm(t('common.confirm_delete'))) deleteTpl.mutate(tpl.id); }}
|
||||
>
|
||||
<Trash2 className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<Badge variant={tpl.vm_type === 'lxc' ? 'secondary' : 'default'} className="text-xs">
|
||||
@@ -156,6 +168,7 @@ export default function TemplatesPage() {
|
||||
)}
|
||||
|
||||
<DeployDialog template={deployTpl} onClose={() => setDeployTpl(null)} />
|
||||
<EditTemplateDialog template={editTpl} onClose={() => setEditTpl(null)} />
|
||||
<DownloadCTDialog open={downloadOpen} onClose={() => setDownloadOpen(false)} />
|
||||
|
||||
{/* Import Dialog */}
|
||||
|
||||
Reference in New Issue
Block a user