From 73493d7ef212777e8ea3e7a30601edfe7d16a757 Mon Sep 17 00:00:00 2001 From: markmorado Date: Tue, 18 Aug 2026 23:34:32 +0500 Subject: [PATCH] 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 --- backend/app/api/proxmox/lxc.py | 54 +++++++++++-------- backend/app/appstore/pipeline.py | 37 +++++++------ backend/app/proxmox/client.py | 2 +- .../shared/ActiveTasksIndicator.tsx | 44 +++++++++++++++ frontend/src/features/templates/OsLogo.tsx | 12 ++++- frontend/src/layouts/AppLayout.tsx | 2 + frontend/src/locales/en.json | 5 +- frontend/src/locales/ru.json | 6 ++- 8 files changed, 119 insertions(+), 43 deletions(-) create mode 100644 frontend/src/components/shared/ActiveTasksIndicator.tsx diff --git a/backend/app/api/proxmox/lxc.py b/backend/app/api/proxmox/lxc.py index a041b7d..97fd61c 100644 --- a/backend/app/api/proxmox/lxc.py +++ b/backend/app/api/proxmox/lxc.py @@ -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 задачи создания контейнера") diff --git a/backend/app/appstore/pipeline.py b/backend/app/appstore/pipeline.py index 5867af2..aa6fd7b 100644 --- a/backend/app/appstore/pipeline.py +++ b/backend/app/appstore/pipeline.py @@ -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 создания контейнера") diff --git a/backend/app/proxmox/client.py b/backend/app/proxmox/client.py index 1659a93..ef49e67 100644 --- a/backend/app/proxmox/client.py +++ b/backend/app/proxmox/client.py @@ -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, diff --git a/frontend/src/components/shared/ActiveTasksIndicator.tsx b/frontend/src/components/shared/ActiveTasksIndicator.tsx new file mode 100644 index 0000000..73f340a --- /dev/null +++ b/frontend/src/components/shared/ActiveTasksIndicator.tsx @@ -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 ( + + navigate('/tasks')} + /> + } + > + + {count > 0 && ( + + {count > 99 ? '99+' : count} + + )} + + + {count > 0 + ? t('tasks.active_count', { count }) + : t('tasks.no_active', 'No active tasks')} + + + ); +} diff --git a/frontend/src/features/templates/OsLogo.tsx b/frontend/src/features/templates/OsLogo.tsx index 8ee9349..3ac0f55 100644 --- a/frontend/src/features/templates/OsLogo.tsx +++ b/frontend/src/features/templates/OsLogo.tsx @@ -119,8 +119,16 @@ const OS_MAP: Array<{ keys: string[]; info: OsInfo }> = [ bg: '#294172', fg: '#fff', svg: ( - - + + + + + + + + + + ), }, diff --git a/frontend/src/layouts/AppLayout.tsx b/frontend/src/layouts/AppLayout.tsx index 840aa6f..81c8f13 100644 --- a/frontend/src/layouts/AppLayout.tsx +++ b/frontend/src/layouts/AppLayout.tsx @@ -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() { {theme === 'dark' ? 'Light mode' : 'Dark mode'} + diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 75edc2e..06f94d8 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -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", diff --git a/frontend/src/locales/ru.json b/frontend/src/locales/ru.json index 4fdd6e3..d2003ec 100644 --- a/frontend/src/locales/ru.json +++ b/frontend/src/locales/ru.json @@ -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": "Уведомления",