fix: console viewport sizing and add VNC control toolbar
Fix nested h-screen flexbox layout bug that let the noVNC canvas overflow below the viewport until the browser zoom level was changed (missing min-h-0 on flex children). Also add a fuller console control bar: power menu (reboot/shutdown/hard reset/hard stop), extra-keys menu (Ctrl+Alt+Del, Ctrl+Alt+Backspace, Tab, Esc, Ctrl+Alt+F1-F12), scale toggle, clipboard paste to guest, and console screenshot. Adds a VM hard-reset backend action (qemu status/reset) alongside the existing start/stop/restart/shutdown.
This commit is contained in:
@@ -3949,16 +3949,17 @@ def control_vm(
|
|||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
current_user: User = Depends(get_current_user)
|
current_user: User = Depends(get_current_user)
|
||||||
):
|
):
|
||||||
"""Управление VM (start/stop/restart/shutdown)"""
|
"""Управление VM (start/stop/restart/shutdown/reset)"""
|
||||||
if action not in ['start', 'stop', 'restart', 'shutdown']:
|
if action not in ['start', 'stop', 'restart', 'shutdown', 'reset']:
|
||||||
raise HTTPException(status_code=400, detail="Invalid action")
|
raise HTTPException(status_code=400, detail="Invalid action")
|
||||||
|
|
||||||
# Проверка прав в зависимости от действия
|
# Проверка прав в зависимости от действия
|
||||||
permission_map = {
|
permission_map = {
|
||||||
'start': 'vm:start',
|
'start': 'vm:start',
|
||||||
'stop': 'vm:stop',
|
'stop': 'vm:stop',
|
||||||
'shutdown': 'vm:stop',
|
'shutdown': 'vm:stop',
|
||||||
'restart': 'vm:restart',
|
'restart': 'vm:restart',
|
||||||
|
'reset': 'vm:restart',
|
||||||
}
|
}
|
||||||
if not current_user.has_permission(permission_map[action]):
|
if not current_user.has_permission(permission_map[action]):
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
@@ -4000,6 +4001,9 @@ def control_vm(
|
|||||||
elif action == 'shutdown':
|
elif action == 'shutdown':
|
||||||
upid = client.shutdown_vm(node, vmid)
|
upid = client.shutdown_vm(node, vmid)
|
||||||
success = bool(upid)
|
success = bool(upid)
|
||||||
|
elif action == 'reset':
|
||||||
|
upid = client.reset_vm(node, vmid)
|
||||||
|
success = bool(upid)
|
||||||
else: # restart
|
else: # restart
|
||||||
upid = client.restart_vm(node, vmid)
|
upid = client.restart_vm(node, vmid)
|
||||||
success = bool(upid)
|
success = bool(upid)
|
||||||
@@ -4007,7 +4011,7 @@ def control_vm(
|
|||||||
action_name = 'kill' if action == 'stop' and force else action
|
action_name = 'kill' if action == 'stop' and force else action
|
||||||
if success:
|
if success:
|
||||||
# Immediately update vm_instances cache so page refresh returns correct status
|
# Immediately update vm_instances cache so page refresh returns correct status
|
||||||
expected_status = 'running' if action in ('start', 'restart') else 'stopped'
|
expected_status = 'running' if action in ('start', 'restart', 'reset') else 'stopped'
|
||||||
try:
|
try:
|
||||||
cached_vm = db.query(VMInstance).filter(
|
cached_vm = db.query(VMInstance).filter(
|
||||||
VMInstance.server_id == server_id,
|
VMInstance.server_id == server_id,
|
||||||
@@ -4026,6 +4030,7 @@ def control_vm(
|
|||||||
'start': f"Запуск VM {vm_name or vmid}",
|
'start': f"Запуск VM {vm_name or vmid}",
|
||||||
'stop': f"Остановка VM {vm_name or vmid}",
|
'stop': f"Остановка VM {vm_name or vmid}",
|
||||||
'restart': f"Перезапуск VM {vm_name or vmid}",
|
'restart': f"Перезапуск VM {vm_name or vmid}",
|
||||||
|
'reset': f"Жёсткий сброс VM {vm_name or vmid}",
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
ProxmoxTaskService.register(
|
ProxmoxTaskService.register(
|
||||||
|
|||||||
@@ -41,6 +41,18 @@ class VmMixin:
|
|||||||
logger.error(f"Ошибка перезапуска VM {vmid} на {node}: {e}")
|
logger.error(f"Ошибка перезапуска VM {vmid} на {node}: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def reset_vm(self, node: str, vmid: int) -> Optional[str]:
|
||||||
|
"""Жёсткий сброс VM (аналог кнопки Reset — без ACPI, без остановки/старта заново)."""
|
||||||
|
if not self.proxmox:
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
upid = self.proxmox.nodes(node).qemu(vmid).status.reset.post()
|
||||||
|
return upid if isinstance(upid, str) else None
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Ошибка жёсткого сброса VM {vmid} на {node}: {e}")
|
||||||
|
return None
|
||||||
|
|
||||||
def _wait_vm_stopped(self, node: str, vmid: int, timeout: int) -> bool:
|
def _wait_vm_stopped(self, node: str, vmid: int, timeout: int) -> bool:
|
||||||
"""Опрашивать статус ВМ, пока не 'stopped' или не выйдет timeout секунд."""
|
"""Опрашивать статус ВМ, пока не 'stopped' или не выйдет timeout секунд."""
|
||||||
deadline = time.time() + timeout
|
deadline = time.time() + timeout
|
||||||
|
|||||||
@@ -1,13 +1,63 @@
|
|||||||
import { useEffect, useRef, useState, useCallback } from 'react';
|
import { useEffect, useRef, useState, useCallback } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useParams, useSearchParams } from 'react-router';
|
import { useParams, useSearchParams } from 'react-router';
|
||||||
import { Maximize, Minimize, Keyboard, Loader2 } from 'lucide-react';
|
import {
|
||||||
|
Maximize,
|
||||||
|
Minimize,
|
||||||
|
Keyboard,
|
||||||
|
Loader2,
|
||||||
|
Power,
|
||||||
|
ChevronDown,
|
||||||
|
RotateCw,
|
||||||
|
PowerOff,
|
||||||
|
Zap,
|
||||||
|
Square,
|
||||||
|
ClipboardPaste,
|
||||||
|
Camera,
|
||||||
|
Scan,
|
||||||
|
} from 'lucide-react';
|
||||||
|
import { toast } from 'sonner';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuItem,
|
||||||
|
DropdownMenuSeparator,
|
||||||
|
DropdownMenuSub,
|
||||||
|
DropdownMenuSubContent,
|
||||||
|
DropdownMenuSubTrigger,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
} from '@/components/ui/dropdown-menu';
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from '@/components/ui/dialog';
|
||||||
import { apiClient } from '@/lib/api-client';
|
import { apiClient } from '@/lib/api-client';
|
||||||
import { vmTypeLabel } from '@/lib/format';
|
import { vmTypeLabel } from '@/lib/format';
|
||||||
|
import { usePowerAction } from '@/hooks/use-instances';
|
||||||
import '@xterm/xterm/css/xterm.css';
|
import '@xterm/xterm/css/xterm.css';
|
||||||
|
|
||||||
|
// X11 keysyms используемые доп. клавишами консоли (см. noVNC core/input/keysym.js)
|
||||||
|
const KEYSYM = {
|
||||||
|
BackSpace: 0xff08,
|
||||||
|
Tab: 0xff09,
|
||||||
|
Escape: 0xff1b,
|
||||||
|
Delete: 0xffff,
|
||||||
|
Control_L: 0xffe3,
|
||||||
|
Alt_L: 0xffe9,
|
||||||
|
F1: 0xffbe,
|
||||||
|
} as const;
|
||||||
|
const FKEY_CODES = Array.from({ length: 12 }, (_, i) => ({
|
||||||
|
label: `F${i + 1}`,
|
||||||
|
keysym: KEYSYM.F1 + i,
|
||||||
|
code: `F${i + 1}`,
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
// noVNC and xterm.js will be loaded dynamically
|
// noVNC and xterm.js will be loaded dynamically
|
||||||
// We use dynamic imports for code splitting
|
// We use dynamic imports for code splitting
|
||||||
@@ -23,6 +73,14 @@ interface VNCData {
|
|||||||
auth_ticket?: string;
|
auth_ticket?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface RFBHandle {
|
||||||
|
disconnect: () => void;
|
||||||
|
sendCtrlAltDel: () => void;
|
||||||
|
sendKey: (keysym: number, code: string, down?: boolean) => void;
|
||||||
|
clipboardPasteFrom: (text: string) => void;
|
||||||
|
scaleViewport: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export default function ConsolePage() {
|
export default function ConsolePage() {
|
||||||
const { serverId, vmid } = useParams<{ serverId: string; vmid: string }>();
|
const { serverId, vmid } = useParams<{ serverId: string; vmid: string }>();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
@@ -30,18 +88,25 @@ export default function ConsolePage() {
|
|||||||
const node = searchParams.get('node') || '';
|
const node = searchParams.get('node') || '';
|
||||||
const type = searchParams.get('type') || 'qemu';
|
const type = searchParams.get('type') || 'qemu';
|
||||||
const isSerial = type === 'qemu' && searchParams.get('mode') === 'serial';
|
const isSerial = type === 'qemu' && searchParams.get('mode') === 'serial';
|
||||||
|
// Панель управления питанием/консолью доступна для VNC (qemu, не serial); для
|
||||||
|
// serial и LXC-терминала клавиатура и буфер обмена уже идут через сам xterm.
|
||||||
|
const isVnc = type === 'qemu' && !isSerial;
|
||||||
|
|
||||||
const [status, setStatus] = useState<'connecting' | 'connected' | 'error'>('connecting');
|
const [status, setStatus] = useState<'connecting' | 'connected' | 'error'>('connecting');
|
||||||
const [errorMsg, setErrorMsg] = useState('');
|
const [errorMsg, setErrorMsg] = useState('');
|
||||||
const [isFullscreen, setIsFullscreen] = useState(false);
|
const [isFullscreen, setIsFullscreen] = useState(false);
|
||||||
|
const [scaleToFit, setScaleToFit] = useState(true);
|
||||||
|
const [clipboardOpen, setClipboardOpen] = useState(false);
|
||||||
|
const [clipboardText, setClipboardText] = useState('');
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const rfbRef = useRef<unknown>(null);
|
const rfbRef = useRef<RFBHandle | null>(null);
|
||||||
const termRef = useRef<unknown>(null);
|
const termRef = useRef<unknown>(null);
|
||||||
const wsRef = useRef<WebSocket | null>(null);
|
const wsRef = useRef<WebSocket | null>(null);
|
||||||
const keepaliveRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
const keepaliveRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||||
|
|
||||||
const sid = Number(serverId);
|
const sid = Number(serverId);
|
||||||
const vid = Number(vmid);
|
const vid = Number(vmid);
|
||||||
|
const power = usePowerAction(sid, vid, type, node);
|
||||||
|
|
||||||
// ==================== VNC Console (QEMU) ====================
|
// ==================== VNC Console (QEMU) ====================
|
||||||
const connectVNC = useCallback(async () => {
|
const connectVNC = useCallback(async () => {
|
||||||
@@ -92,7 +157,7 @@ export default function ConsolePage() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
rfb.scaleViewport = true;
|
rfb.scaleViewport = true;
|
||||||
rfb.resizeSession = true;
|
rfb.resizeSession = false;
|
||||||
|
|
||||||
rfb.addEventListener('connect', () => {
|
rfb.addEventListener('connect', () => {
|
||||||
setStatus('connected');
|
setStatus('connected');
|
||||||
@@ -108,7 +173,8 @@ export default function ConsolePage() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
rfbRef.current = rfb;
|
rfbRef.current = rfb as RFBHandle;
|
||||||
|
setScaleToFit(true);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setStatus('error');
|
setStatus('error');
|
||||||
setErrorMsg(err instanceof Error ? err.message : 'Failed to connect');
|
setErrorMsg(err instanceof Error ? err.message : 'Failed to connect');
|
||||||
@@ -253,13 +319,87 @@ export default function ConsolePage() {
|
|||||||
|
|
||||||
// ==================== Send Ctrl+Alt+Del (VNC) ====================
|
// ==================== Send Ctrl+Alt+Del (VNC) ====================
|
||||||
const sendCtrlAltDel = () => {
|
const sendCtrlAltDel = () => {
|
||||||
if (rfbRef.current) {
|
rfbRef.current?.sendCtrlAltDel();
|
||||||
(rfbRef.current as { sendCtrlAltDel: () => void }).sendCtrlAltDel();
|
};
|
||||||
|
|
||||||
|
// ==================== Extra keys (VNC) ====================
|
||||||
|
const sendKeyCombo = (keysym: number, code: string) => {
|
||||||
|
rfbRef.current?.sendKey(keysym, code);
|
||||||
|
};
|
||||||
|
const sendCtrlAltBackspace = () => {
|
||||||
|
const rfb = rfbRef.current;
|
||||||
|
if (!rfb) return;
|
||||||
|
rfb.sendKey(KEYSYM.Control_L, 'ControlLeft', true);
|
||||||
|
rfb.sendKey(KEYSYM.Alt_L, 'AltLeft', true);
|
||||||
|
rfb.sendKey(KEYSYM.BackSpace, 'Backspace', true);
|
||||||
|
rfb.sendKey(KEYSYM.BackSpace, 'Backspace', false);
|
||||||
|
rfb.sendKey(KEYSYM.Alt_L, 'AltLeft', false);
|
||||||
|
rfb.sendKey(KEYSYM.Control_L, 'ControlLeft', false);
|
||||||
|
};
|
||||||
|
const sendCtrlAltF = (keysym: number, code: string) => {
|
||||||
|
const rfb = rfbRef.current;
|
||||||
|
if (!rfb) return;
|
||||||
|
rfb.sendKey(KEYSYM.Control_L, 'ControlLeft', true);
|
||||||
|
rfb.sendKey(KEYSYM.Alt_L, 'AltLeft', true);
|
||||||
|
rfb.sendKey(keysym, code, true);
|
||||||
|
rfb.sendKey(keysym, code, false);
|
||||||
|
rfb.sendKey(KEYSYM.Alt_L, 'AltLeft', false);
|
||||||
|
rfb.sendKey(KEYSYM.Control_L, 'ControlLeft', false);
|
||||||
|
};
|
||||||
|
|
||||||
|
// ==================== Scale toggle (VNC) ====================
|
||||||
|
const toggleScale = () => {
|
||||||
|
const rfb = rfbRef.current;
|
||||||
|
if (!rfb) return;
|
||||||
|
const next = !scaleToFit;
|
||||||
|
rfb.scaleViewport = next;
|
||||||
|
setScaleToFit(next);
|
||||||
|
};
|
||||||
|
|
||||||
|
// ==================== Clipboard → VM (VNC) ====================
|
||||||
|
const sendClipboard = () => {
|
||||||
|
if (!clipboardText) return;
|
||||||
|
rfbRef.current?.clipboardPasteFrom(clipboardText);
|
||||||
|
setClipboardOpen(false);
|
||||||
|
setClipboardText('');
|
||||||
|
};
|
||||||
|
|
||||||
|
// ==================== Screenshot ====================
|
||||||
|
const takeScreenshot = () => {
|
||||||
|
// querySelectorAll + last(): в dev-режиме React StrictMode временно
|
||||||
|
// монтирует RFB дважды, оставляя осиротевший canvas первым в DOM —
|
||||||
|
// актуальный (живой) canvas всегда последний.
|
||||||
|
const canvases = containerRef.current?.querySelectorAll('canvas');
|
||||||
|
const canvas = canvases && canvases.length > 0 ? canvases[canvases.length - 1] : null;
|
||||||
|
if (!canvas) {
|
||||||
|
toast.error(t('console.screenshot_failed'));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.download = `console-${type}-${vmid}-${Date.now()}.png`;
|
||||||
|
link.href = canvas.toDataURL('image/png');
|
||||||
|
link.click();
|
||||||
|
};
|
||||||
|
|
||||||
|
// ==================== Power actions ====================
|
||||||
|
const runPowerAction = (action: 'restart' | 'shutdown' | 'reset' | 'stop', force?: boolean) => {
|
||||||
|
if (
|
||||||
|
(action === 'reset' || (action === 'stop' && force)) &&
|
||||||
|
!window.confirm(action === 'reset' ? t('console.confirm_hard_reset') : t('console.confirm_hard_stop'))
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
power.mutate(
|
||||||
|
{ action, force },
|
||||||
|
{
|
||||||
|
onSuccess: () => toast.success(t('console.action_sent')),
|
||||||
|
onError: (err) => toast.error(err.message || t('console.action_failed')),
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-screen flex-col bg-[#09090B]">
|
<div className="flex h-screen min-h-0 flex-col bg-[#09090B]">
|
||||||
{/* Toolbar */}
|
{/* Toolbar */}
|
||||||
<div className="flex items-center justify-between border-b border-border/30 bg-[#111113] px-3 py-1.5">
|
<div className="flex items-center justify-between border-b border-border/30 bg-[#111113] px-3 py-1.5">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
@@ -281,20 +421,103 @@ export default function ConsolePage() {
|
|||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
{type === 'qemu' && !isSerial && (
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
className="h-7 text-xs text-muted-foreground"
|
|
||||||
onClick={sendCtrlAltDel}
|
|
||||||
>
|
|
||||||
<Keyboard className="mr-1 h-3 w-3" />
|
|
||||||
Ctrl+Alt+Del
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
{isSerial && (
|
{isSerial && (
|
||||||
<Badge variant="secondary" className="text-2xs bg-blue-500/10 text-blue-500">serial</Badge>
|
<Badge variant="secondary" className="text-2xs bg-blue-500/10 text-blue-500">serial</Badge>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Power menu */}
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger render={<Button variant="ghost" size="sm" className="h-7 text-xs text-muted-foreground" />}>
|
||||||
|
<Power className="mr-1 h-3 w-3" />
|
||||||
|
{t('console.power')}
|
||||||
|
<ChevronDown className="ml-1 h-3 w-3" />
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent className="w-56">
|
||||||
|
<DropdownMenuItem onClick={() => runPowerAction('restart')}>
|
||||||
|
<RotateCw className="h-3.5 w-3.5" />
|
||||||
|
{t('console.reboot')}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={() => runPowerAction('shutdown')}>
|
||||||
|
<PowerOff className="h-3.5 w-3.5" />
|
||||||
|
{t('console.shutdown')}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
{type === 'qemu' && (
|
||||||
|
<DropdownMenuItem variant="destructive" onClick={() => runPowerAction('reset')}>
|
||||||
|
<Zap className="h-3.5 w-3.5" />
|
||||||
|
{t('console.hard_reset')}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
)}
|
||||||
|
<DropdownMenuItem variant="destructive" onClick={() => runPowerAction('stop', true)}>
|
||||||
|
<Square className="h-3.5 w-3.5" />
|
||||||
|
{t('console.hard_stop')}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
|
||||||
|
{isVnc && (
|
||||||
|
<>
|
||||||
|
{/* Extra keys menu */}
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger render={<Button variant="ghost" size="sm" className="h-7 text-xs text-muted-foreground" />}>
|
||||||
|
<Keyboard className="mr-1 h-3 w-3" />
|
||||||
|
{t('console.extra_keys')}
|
||||||
|
<ChevronDown className="ml-1 h-3 w-3" />
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent className="w-56">
|
||||||
|
<DropdownMenuItem onClick={sendCtrlAltDel}>{t('console.ctrl_alt_del')}</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={sendCtrlAltBackspace}>{t('console.ctrl_alt_backspace')}</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={() => sendKeyCombo(KEYSYM.Tab, 'Tab')}>Tab</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={() => sendKeyCombo(KEYSYM.Escape, 'Escape')}>Esc</DropdownMenuItem>
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
<DropdownMenuSub>
|
||||||
|
<DropdownMenuSubTrigger>Ctrl+Alt+F1…F12</DropdownMenuSubTrigger>
|
||||||
|
<DropdownMenuSubContent>
|
||||||
|
{FKEY_CODES.map((k) => (
|
||||||
|
<DropdownMenuItem key={k.label} onClick={() => sendCtrlAltF(k.keysym, k.code)}>
|
||||||
|
{k.label}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
))}
|
||||||
|
</DropdownMenuSubContent>
|
||||||
|
</DropdownMenuSub>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
|
||||||
|
{/* Scale toggle */}
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="h-7 w-7 text-muted-foreground"
|
||||||
|
title={scaleToFit ? t('console.actual_size') : t('console.scale_to_fit')}
|
||||||
|
onClick={toggleScale}
|
||||||
|
>
|
||||||
|
<Scan className="h-3.5 w-3.5" />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{/* Clipboard */}
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="h-7 w-7 text-muted-foreground"
|
||||||
|
title={t('console.clipboard')}
|
||||||
|
onClick={() => setClipboardOpen(true)}
|
||||||
|
>
|
||||||
|
<ClipboardPaste className="h-3.5 w-3.5" />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{/* Screenshot */}
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="h-7 w-7 text-muted-foreground"
|
||||||
|
title={t('console.screenshot')}
|
||||||
|
onClick={takeScreenshot}
|
||||||
|
>
|
||||||
|
<Camera className="h-3.5 w-3.5" />
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="icon"
|
size="icon"
|
||||||
@@ -306,8 +529,35 @@ export default function ConsolePage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Dialog open={clipboardOpen} onOpenChange={setClipboardOpen}>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle className="flex items-center gap-2">
|
||||||
|
<ClipboardPaste className="h-4 w-4" /> {t('console.clipboard_title')}
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogDescription>{t('console.clipboard_desc')}</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<textarea
|
||||||
|
value={clipboardText}
|
||||||
|
onChange={(e) => setClipboardText(e.target.value)}
|
||||||
|
placeholder={t('console.clipboard_placeholder')}
|
||||||
|
rows={5}
|
||||||
|
className="w-full min-w-0 resize-none rounded-lg border border-input bg-transparent px-2.5 py-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50"
|
||||||
|
autoFocus
|
||||||
|
/>
|
||||||
|
<DialogFooter>
|
||||||
|
<Button variant="outline" onClick={() => setClipboardOpen(false)}>
|
||||||
|
{t('common.cancel')}
|
||||||
|
</Button>
|
||||||
|
<Button onClick={sendClipboard} disabled={!clipboardText}>
|
||||||
|
{t('console.send')}
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
{/* Console viewport */}
|
{/* Console viewport */}
|
||||||
<div className="relative flex-1">
|
<div className="relative min-h-0 flex-1 overflow-hidden">
|
||||||
{status === 'connecting' && (
|
{status === 'connecting' && (
|
||||||
<div className="absolute inset-0 z-10 flex items-center justify-center bg-[#09090B]">
|
<div className="absolute inset-0 z-10 flex items-center justify-center bg-[#09090B]">
|
||||||
<div className="flex flex-col items-center gap-3 text-muted-foreground">
|
<div className="flex flex-col items-center gap-3 text-muted-foreground">
|
||||||
@@ -340,8 +590,7 @@ export default function ConsolePage() {
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
className="h-full w-full"
|
className="h-full w-full overflow-hidden"
|
||||||
style={{ minHeight: 'calc(100vh - 40px)' }}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1722,7 +1722,28 @@
|
|||||||
"connected": "Connected",
|
"connected": "Connected",
|
||||||
"error": "Error",
|
"error": "Error",
|
||||||
"terminal_closed": "Terminal connection closed",
|
"terminal_closed": "Terminal connection closed",
|
||||||
"terminal_error": "Terminal connection error"
|
"terminal_error": "Terminal connection error",
|
||||||
|
"power": "Power",
|
||||||
|
"reboot": "Reboot",
|
||||||
|
"shutdown": "Shutdown",
|
||||||
|
"hard_reset": "Hard Reset",
|
||||||
|
"hard_stop": "Hard Stop",
|
||||||
|
"confirm_hard_reset": "Hard reset will forcibly reboot the VM without a graceful OS shutdown. Continue?",
|
||||||
|
"confirm_hard_stop": "Hard stop will forcibly kill the VM process without a graceful shutdown. Continue?",
|
||||||
|
"action_sent": "Command sent",
|
||||||
|
"action_failed": "Failed to send command",
|
||||||
|
"extra_keys": "Extra keys",
|
||||||
|
"ctrl_alt_del": "Ctrl+Alt+Del",
|
||||||
|
"ctrl_alt_backspace": "Ctrl+Alt+Backspace",
|
||||||
|
"scale_to_fit": "Scale to fit",
|
||||||
|
"actual_size": "Actual size",
|
||||||
|
"clipboard": "Clipboard",
|
||||||
|
"clipboard_title": "Send text to VM clipboard",
|
||||||
|
"clipboard_desc": "Text will be sent to the guest clipboard via VNC.",
|
||||||
|
"clipboard_placeholder": "Type or paste text to send...",
|
||||||
|
"send": "Send",
|
||||||
|
"screenshot": "Screenshot",
|
||||||
|
"screenshot_failed": "Failed to capture screenshot"
|
||||||
},
|
},
|
||||||
"images": {
|
"images": {
|
||||||
"title": "Images",
|
"title": "Images",
|
||||||
|
|||||||
@@ -1707,7 +1707,28 @@
|
|||||||
"connected": "Подключено",
|
"connected": "Подключено",
|
||||||
"error": "Ошибка",
|
"error": "Ошибка",
|
||||||
"terminal_closed": "Соединение с терминалом закрыто",
|
"terminal_closed": "Соединение с терминалом закрыто",
|
||||||
"terminal_error": "Ошибка соединения с терминалом"
|
"terminal_error": "Ошибка соединения с терминалом",
|
||||||
|
"power": "Питание",
|
||||||
|
"reboot": "Перезагрузить",
|
||||||
|
"shutdown": "Выключить",
|
||||||
|
"hard_reset": "Жёсткий сброс",
|
||||||
|
"hard_stop": "Жёсткая остановка",
|
||||||
|
"confirm_hard_reset": "Жёсткий сброс перезагрузит ВМ без корректного завершения работы ОС. Продолжить?",
|
||||||
|
"confirm_hard_stop": "Жёсткая остановка принудительно завершит процесс ВМ без корректного выключения. Продолжить?",
|
||||||
|
"action_sent": "Команда отправлена",
|
||||||
|
"action_failed": "Не удалось отправить команду",
|
||||||
|
"extra_keys": "Доп. клавиши",
|
||||||
|
"ctrl_alt_del": "Ctrl+Alt+Del",
|
||||||
|
"ctrl_alt_backspace": "Ctrl+Alt+Backspace",
|
||||||
|
"scale_to_fit": "Масштабировать под окно",
|
||||||
|
"actual_size": "Реальный размер",
|
||||||
|
"clipboard": "Буфер обмена",
|
||||||
|
"clipboard_title": "Отправить текст в буфер обмена ВМ",
|
||||||
|
"clipboard_desc": "Текст будет отправлен в буфер обмена гостевой ОС через VNC.",
|
||||||
|
"clipboard_placeholder": "Введите или вставьте текст для отправки...",
|
||||||
|
"send": "Отправить",
|
||||||
|
"screenshot": "Скриншот",
|
||||||
|
"screenshot_failed": "Не удалось сделать скриншот"
|
||||||
},
|
},
|
||||||
"perms": {
|
"perms": {
|
||||||
"role": {
|
"role": {
|
||||||
|
|||||||
Reference in New Issue
Block a user