Add active tasks indicator, propagate LXC create errors, fix Fedora logo
- Surface a topbar indicator with a live count of active tasks - Propagate exceptions from Proxmox LXC container creation instead of swallowing them, and validate minimum password length - Replace the Fedora catalog icon with the official logo artwork
This commit is contained in:
@@ -12,7 +12,7 @@ from typing import List, Optional
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from fastapi.responses import JSONResponse
|
||||
from loguru import logger
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, field_validator
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ...auth import PermissionChecker
|
||||
@@ -53,6 +53,13 @@ class LXCDeployRequest(BaseModel):
|
||||
ipam_pool_id: Optional[int] = None
|
||||
password: Optional[str] = None
|
||||
ssh_keys: Optional[str] = None
|
||||
|
||||
@field_validator("password")
|
||||
@classmethod
|
||||
def password_min_length(cls, v):
|
||||
if v is not None and len(v) < 5:
|
||||
raise ValueError("Пароль должен содержать не менее 5 символов (требование Proxmox)")
|
||||
return v
|
||||
ssh_key_ids: Optional[List[int]] = None
|
||||
owner_id: Optional[int] = None
|
||||
nameserver: Optional[str] = None
|
||||
@@ -225,26 +232,31 @@ def _do_lxc_deploy(task_id: int, req: LXCDeployRequest, user_id: int, username:
|
||||
_update_task(task_id, "running", f"Создание LXC контейнера VMID {new_vmid}...", 35,
|
||||
vmid=new_vmid, node=deploy_node)
|
||||
net0_str = f"name=eth0,bridge={req.bridge},{ip_config},firewall=1"
|
||||
upid = client.create_lxc_container(
|
||||
node=deploy_node,
|
||||
vmid=new_vmid,
|
||||
ostemplate=req.ostemplate,
|
||||
hostname=req.name,
|
||||
cores=req.cores,
|
||||
memory=req.memory,
|
||||
swap=req.swap,
|
||||
storage=req.storage,
|
||||
rootfs_size=req.disk,
|
||||
net0=net0_str,
|
||||
nameserver=req.nameserver,
|
||||
searchdomain=req.searchdomain,
|
||||
password=req.password,
|
||||
ssh_public_keys=req.ssh_keys,
|
||||
unprivileged=req.unprivileged,
|
||||
start_after_create=False, # we start manually after config
|
||||
onboot=req.onboot,
|
||||
description=f"Created from {req.ostemplate} by {username}",
|
||||
)
|
||||
try:
|
||||
upid = client.create_lxc_container(
|
||||
node=deploy_node,
|
||||
vmid=new_vmid,
|
||||
ostemplate=req.ostemplate,
|
||||
hostname=req.name,
|
||||
cores=req.cores,
|
||||
memory=req.memory,
|
||||
swap=req.swap,
|
||||
storage=req.storage,
|
||||
rootfs_size=req.disk,
|
||||
net0=net0_str,
|
||||
nameserver=req.nameserver,
|
||||
searchdomain=req.searchdomain,
|
||||
password=req.password,
|
||||
ssh_public_keys=req.ssh_keys,
|
||||
unprivileged=req.unprivileged,
|
||||
start_after_create=False, # we start manually after config
|
||||
onboot=req.onboot,
|
||||
description=f"Created from {req.ostemplate} by {username}",
|
||||
)
|
||||
except Exception as e:
|
||||
_update_task(task_id, "failed", "Ошибка создания контейнера", 35,
|
||||
error=f"Proxmox: {e}")
|
||||
return
|
||||
if not upid:
|
||||
_update_task(task_id, "failed", "Ошибка создания контейнера", 35,
|
||||
error="Proxmox не вернул UPID задачи создания контейнера")
|
||||
|
||||
@@ -721,23 +721,26 @@ def poc_install(db: Session, spec: InstallSpec, on_step: StepCb = _noop) -> Inst
|
||||
on_step(f"Создание LXC VMID {vmid} на ноде {node}...", 20)
|
||||
ip_cfg = spec.ip_config or "ip=dhcp"
|
||||
net0 = f"name=eth0,bridge={spec.bridge},{ip_cfg},firewall=1"
|
||||
upid = client.create_lxc_container(
|
||||
node=node,
|
||||
vmid=vmid,
|
||||
ostemplate=spec.ostemplate,
|
||||
hostname=spec.name,
|
||||
cores=spec.cores,
|
||||
memory=spec.memory,
|
||||
swap=spec.swap,
|
||||
storage=spec.storage,
|
||||
rootfs_size=spec.disk,
|
||||
net0=net0,
|
||||
features=spec.features, # nesting=1,keyctl=1 — критично для Docker
|
||||
unprivileged=True,
|
||||
start_after_create=False,
|
||||
description=f"pvemanager-appstore: {spec.name}",
|
||||
nameserver=spec.nameserver or settings.APPSTORE_NAMESERVER,
|
||||
)
|
||||
try:
|
||||
upid = client.create_lxc_container(
|
||||
node=node,
|
||||
vmid=vmid,
|
||||
ostemplate=spec.ostemplate,
|
||||
hostname=spec.name,
|
||||
cores=spec.cores,
|
||||
memory=spec.memory,
|
||||
swap=spec.swap,
|
||||
storage=spec.storage,
|
||||
rootfs_size=spec.disk,
|
||||
net0=net0,
|
||||
features=spec.features, # nesting=1,keyctl=1 — критично для Docker
|
||||
unprivileged=True,
|
||||
start_after_create=False,
|
||||
description=f"pvemanager-appstore: {spec.name}",
|
||||
nameserver=spec.nameserver or settings.APPSTORE_NAMESERVER,
|
||||
)
|
||||
except Exception as e:
|
||||
raise PocError(f"Ошибка создания контейнера: {e}") from e
|
||||
if not upid:
|
||||
raise PocError("Proxmox не вернул UPID создания контейнера")
|
||||
|
||||
|
||||
@@ -2093,7 +2093,7 @@ class ProxmoxClient(VmMixin, LxcMixin, ClusterMixin, StorageMixin, NetworkMixin,
|
||||
raise
|
||||
except Exception as e:
|
||||
logger.error(f"Ошибка создания LXC контейнера {vmid}: {e}")
|
||||
return None
|
||||
raise
|
||||
|
||||
def clone_lxc_container(
|
||||
self,
|
||||
|
||||
44
frontend/src/components/shared/ActiveTasksIndicator.tsx
Normal file
44
frontend/src/components/shared/ActiveTasksIndicator.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
import { useNavigate } from 'react-router';
|
||||
import { ListTodo } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
||||
import { useActiveTaskCount } from '@/hooks/use-tasks';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export default function ActiveTasksIndicator() {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const { data } = useActiveTaskCount();
|
||||
const count = data?.count ?? 0;
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="relative"
|
||||
onClick={() => navigate('/tasks')}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<ListTodo className="h-4 w-4" />
|
||||
{count > 0 && (
|
||||
<Badge
|
||||
variant="default"
|
||||
className="absolute -right-0.5 -top-0.5 h-4 min-w-4 px-1 text-2xs"
|
||||
>
|
||||
{count > 99 ? '99+' : count}
|
||||
</Badge>
|
||||
)}
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
{count > 0
|
||||
? t('tasks.active_count', { count })
|
||||
: t('tasks.no_active', 'No active tasks')}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
@@ -119,8 +119,16 @@ const OS_MAP: Array<{ keys: string[]; info: OsInfo }> = [
|
||||
bg: '#294172',
|
||||
fg: '#fff',
|
||||
svg: (
|
||||
<svg viewBox="0 0 24 24" fill="white" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm4 11h-3v3a1 1 0 0 1-2 0v-3H8a1 1 0 0 1 0-2h3V8a1 1 0 0 1 2 0v3h3a1 1 0 0 1 0 2z" />
|
||||
<svg viewBox="0 0 267 267" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M 266.62575,133.50613 C 266.62575,59.98128 207.02222,0.37583 133.49792,0.37583 C 60.00668,0.37583 0.42639,59.93123 0.37425,133.41225 L 0.37425,236.4333 C 0.4138,253.11763 13.94545,266.62417 30.64027,266.62417 L 133.55192,266.62417 C 207.05167,266.59532 266.62575,207.01142 266.62575,133.50613" fill="#294172"/>
|
||||
<path d="M 77.126289,142.09756 C 77.126289,142.09756 124.97104,142.09756 124.97104,142.09756 C 124.97104,142.09756 124.97104,189.94234 124.97104,189.94234 C 124.97104,216.35263 103.53659,237.78707 77.126289,237.78707 C 50.715979,237.78707 29.28153,216.35263 29.28153,189.94234 C 29.28153,163.53203 50.715979,142.09756 77.126289,142.09756 z" fill="none" stroke="#3c6eb4" strokeWidth="29.21"/>
|
||||
<use transform="matrix(-1,0,0,-1,249.71151,284.2882)" xlinkHref="#fedora-in"/>
|
||||
<path d="M 139.6074,127.52923 L 139.6074,189.87541 C 139.6074,224.37943 111.63203,252.35541 77.12679,252.35541 C 71.89185,252.35541 68.1703,251.7644 63.32444,250.49771 C 56.25849,248.64859 50.48398,242.85518 50.48158,236.1166 C 50.48158,227.97147 56.39394,222.0467 65.23187,222.0467 C 69.43824,222.0467 70.96454,222.85435 77.12679,222.85435 C 95.3184,222.85435 110.07443,208.11916 110.10634,189.92756 L 110.10634,161.27099 C 110.10634,158.70324 108.01971,156.62274 105.44767,156.62274 L 83.78246,156.61846 C 75.71034,156.61846 69.18845,150.18003 69.18845,142.0858 C 69.18414,133.94124 75.77725,127.52923 83.93653,127.52923" fill="#ffffff"/>
|
||||
<use transform="matrix(-1,0,0,-1,249.71152,284.28821)" xlinkHref="#fedora-free"/>
|
||||
<defs>
|
||||
<path d="M 77.126289,142.09756 C 77.126289,142.09756 124.97104,142.09756 124.97104,142.09756 C 124.97104,142.09756 124.97104,189.94234 124.97104,189.94234 C 124.97104,216.35263 103.53659,237.78707 77.126289,237.78707 C 50.715979,237.78707 29.28153,216.35263 29.28153,189.94234 C 29.28153,163.53203 50.715979,142.09756 77.126289,142.09756 z" id="fedora-in" fill="none" stroke="#3c6eb4" strokeWidth="29.21"/>
|
||||
<path d="M 139.6074,127.52923 L 139.6074,189.87541 C 139.6074,224.37943 111.63203,252.35541 77.12679,252.35541 C 71.89185,252.35541 68.1703,251.7644 63.32444,250.49771 C 56.25849,248.64859 50.48398,242.85518 50.48158,236.1166 C 50.48158,227.97147 56.39394,222.0467 65.23187,222.0467 C 69.43824,222.0467 70.96454,222.85435 77.12679,222.85435 C 95.3184,222.85435 110.07443,208.11916 110.10634,189.92756 L 110.10634,161.27099 C 110.10634,158.70324 108.01971,156.62274 105.44767,156.62274 L 83.78246,156.61846 C 75.71034,156.61846 69.18845,150.18003 69.18845,142.0858 C 69.18414,133.94124 75.77725,127.52923 83.93653,127.52923" id="fedora-free" fill="#ffffff"/>
|
||||
</defs>
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -33,6 +33,7 @@ import { useGlobalRealtimeSync } from '@/hooks/use-realtime-sync';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import NotificationsDropdown from '@/components/shared/NotificationsDropdown';
|
||||
import ActiveTasksIndicator from '@/components/shared/ActiveTasksIndicator';
|
||||
import CommandPalette from '@/components/shared/CommandPalette';
|
||||
import MinimizedOpsTray from '@/components/shared/MinimizedOpsTray';
|
||||
import { navGroups, canSeeNavItem } from '@/lib/nav-items';
|
||||
@@ -275,6 +276,7 @@ function TopBar() {
|
||||
<TooltipContent>{theme === 'dark' ? 'Light mode' : 'Dark mode'}</TooltipContent>
|
||||
</Tooltip>
|
||||
|
||||
<ActiveTasksIndicator />
|
||||
<NotificationsDropdown />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -1690,7 +1690,10 @@
|
||||
"server": "Server",
|
||||
"node": "Node",
|
||||
"started": "Started",
|
||||
"progress": "Progress"
|
||||
"progress": "Progress",
|
||||
"active_count_one": "{{count}} active task",
|
||||
"active_count_other": "{{count}} active tasks",
|
||||
"no_active": "No active tasks"
|
||||
},
|
||||
"notifications": {
|
||||
"title": "Notifications",
|
||||
|
||||
@@ -1675,7 +1675,11 @@
|
||||
"server": "Сервер",
|
||||
"node": "Узел",
|
||||
"started": "Запущено",
|
||||
"progress": "Прогресс"
|
||||
"progress": "Прогресс",
|
||||
"active_count_one": "{{count}} активная задача",
|
||||
"active_count_few": "{{count}} активные задачи",
|
||||
"active_count_many": "{{count}} активных задач",
|
||||
"no_active": "Нет активных задач"
|
||||
},
|
||||
"notifications": {
|
||||
"title": "Уведомления",
|
||||
|
||||
Reference in New Issue
Block a user