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 import APIRouter, Depends, HTTPException, status
|
||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel, field_validator
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from ...auth import PermissionChecker
|
from ...auth import PermissionChecker
|
||||||
@@ -53,6 +53,13 @@ class LXCDeployRequest(BaseModel):
|
|||||||
ipam_pool_id: Optional[int] = None
|
ipam_pool_id: Optional[int] = None
|
||||||
password: Optional[str] = None
|
password: Optional[str] = None
|
||||||
ssh_keys: 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
|
ssh_key_ids: Optional[List[int]] = None
|
||||||
owner_id: Optional[int] = None
|
owner_id: Optional[int] = None
|
||||||
nameserver: Optional[str] = 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,
|
_update_task(task_id, "running", f"Создание LXC контейнера VMID {new_vmid}...", 35,
|
||||||
vmid=new_vmid, node=deploy_node)
|
vmid=new_vmid, node=deploy_node)
|
||||||
net0_str = f"name=eth0,bridge={req.bridge},{ip_config},firewall=1"
|
net0_str = f"name=eth0,bridge={req.bridge},{ip_config},firewall=1"
|
||||||
upid = client.create_lxc_container(
|
try:
|
||||||
node=deploy_node,
|
upid = client.create_lxc_container(
|
||||||
vmid=new_vmid,
|
node=deploy_node,
|
||||||
ostemplate=req.ostemplate,
|
vmid=new_vmid,
|
||||||
hostname=req.name,
|
ostemplate=req.ostemplate,
|
||||||
cores=req.cores,
|
hostname=req.name,
|
||||||
memory=req.memory,
|
cores=req.cores,
|
||||||
swap=req.swap,
|
memory=req.memory,
|
||||||
storage=req.storage,
|
swap=req.swap,
|
||||||
rootfs_size=req.disk,
|
storage=req.storage,
|
||||||
net0=net0_str,
|
rootfs_size=req.disk,
|
||||||
nameserver=req.nameserver,
|
net0=net0_str,
|
||||||
searchdomain=req.searchdomain,
|
nameserver=req.nameserver,
|
||||||
password=req.password,
|
searchdomain=req.searchdomain,
|
||||||
ssh_public_keys=req.ssh_keys,
|
password=req.password,
|
||||||
unprivileged=req.unprivileged,
|
ssh_public_keys=req.ssh_keys,
|
||||||
start_after_create=False, # we start manually after config
|
unprivileged=req.unprivileged,
|
||||||
onboot=req.onboot,
|
start_after_create=False, # we start manually after config
|
||||||
description=f"Created from {req.ostemplate} by {username}",
|
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:
|
if not upid:
|
||||||
_update_task(task_id, "failed", "Ошибка создания контейнера", 35,
|
_update_task(task_id, "failed", "Ошибка создания контейнера", 35,
|
||||||
error="Proxmox не вернул UPID задачи создания контейнера")
|
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)
|
on_step(f"Создание LXC VMID {vmid} на ноде {node}...", 20)
|
||||||
ip_cfg = spec.ip_config or "ip=dhcp"
|
ip_cfg = spec.ip_config or "ip=dhcp"
|
||||||
net0 = f"name=eth0,bridge={spec.bridge},{ip_cfg},firewall=1"
|
net0 = f"name=eth0,bridge={spec.bridge},{ip_cfg},firewall=1"
|
||||||
upid = client.create_lxc_container(
|
try:
|
||||||
node=node,
|
upid = client.create_lxc_container(
|
||||||
vmid=vmid,
|
node=node,
|
||||||
ostemplate=spec.ostemplate,
|
vmid=vmid,
|
||||||
hostname=spec.name,
|
ostemplate=spec.ostemplate,
|
||||||
cores=spec.cores,
|
hostname=spec.name,
|
||||||
memory=spec.memory,
|
cores=spec.cores,
|
||||||
swap=spec.swap,
|
memory=spec.memory,
|
||||||
storage=spec.storage,
|
swap=spec.swap,
|
||||||
rootfs_size=spec.disk,
|
storage=spec.storage,
|
||||||
net0=net0,
|
rootfs_size=spec.disk,
|
||||||
features=spec.features, # nesting=1,keyctl=1 — критично для Docker
|
net0=net0,
|
||||||
unprivileged=True,
|
features=spec.features, # nesting=1,keyctl=1 — критично для Docker
|
||||||
start_after_create=False,
|
unprivileged=True,
|
||||||
description=f"pvemanager-appstore: {spec.name}",
|
start_after_create=False,
|
||||||
nameserver=spec.nameserver or settings.APPSTORE_NAMESERVER,
|
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:
|
if not upid:
|
||||||
raise PocError("Proxmox не вернул UPID создания контейнера")
|
raise PocError("Proxmox не вернул UPID создания контейнера")
|
||||||
|
|
||||||
|
|||||||
@@ -2093,7 +2093,7 @@ class ProxmoxClient(VmMixin, LxcMixin, ClusterMixin, StorageMixin, NetworkMixin,
|
|||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Ошибка создания LXC контейнера {vmid}: {e}")
|
logger.error(f"Ошибка создания LXC контейнера {vmid}: {e}")
|
||||||
return None
|
raise
|
||||||
|
|
||||||
def clone_lxc_container(
|
def clone_lxc_container(
|
||||||
self,
|
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',
|
bg: '#294172',
|
||||||
fg: '#fff',
|
fg: '#fff',
|
||||||
svg: (
|
svg: (
|
||||||
<svg viewBox="0 0 24 24" fill="white" xmlns="http://www.w3.org/2000/svg">
|
<svg viewBox="0 0 267 267" 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" />
|
<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>
|
</svg>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import { useGlobalRealtimeSync } from '@/hooks/use-realtime-sync';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useQueryClient } from '@tanstack/react-query';
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
import NotificationsDropdown from '@/components/shared/NotificationsDropdown';
|
import NotificationsDropdown from '@/components/shared/NotificationsDropdown';
|
||||||
|
import ActiveTasksIndicator from '@/components/shared/ActiveTasksIndicator';
|
||||||
import CommandPalette from '@/components/shared/CommandPalette';
|
import CommandPalette from '@/components/shared/CommandPalette';
|
||||||
import MinimizedOpsTray from '@/components/shared/MinimizedOpsTray';
|
import MinimizedOpsTray from '@/components/shared/MinimizedOpsTray';
|
||||||
import { navGroups, canSeeNavItem } from '@/lib/nav-items';
|
import { navGroups, canSeeNavItem } from '@/lib/nav-items';
|
||||||
@@ -275,6 +276,7 @@ function TopBar() {
|
|||||||
<TooltipContent>{theme === 'dark' ? 'Light mode' : 'Dark mode'}</TooltipContent>
|
<TooltipContent>{theme === 'dark' ? 'Light mode' : 'Dark mode'}</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
|
<ActiveTasksIndicator />
|
||||||
<NotificationsDropdown />
|
<NotificationsDropdown />
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -1690,7 +1690,10 @@
|
|||||||
"server": "Server",
|
"server": "Server",
|
||||||
"node": "Node",
|
"node": "Node",
|
||||||
"started": "Started",
|
"started": "Started",
|
||||||
"progress": "Progress"
|
"progress": "Progress",
|
||||||
|
"active_count_one": "{{count}} active task",
|
||||||
|
"active_count_other": "{{count}} active tasks",
|
||||||
|
"no_active": "No active tasks"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"title": "Notifications",
|
"title": "Notifications",
|
||||||
|
|||||||
@@ -1675,7 +1675,11 @@
|
|||||||
"server": "Сервер",
|
"server": "Сервер",
|
||||||
"node": "Узел",
|
"node": "Узел",
|
||||||
"started": "Запущено",
|
"started": "Запущено",
|
||||||
"progress": "Прогресс"
|
"progress": "Прогресс",
|
||||||
|
"active_count_one": "{{count}} активная задача",
|
||||||
|
"active_count_few": "{{count}} активные задачи",
|
||||||
|
"active_count_many": "{{count}} активных задач",
|
||||||
|
"no_active": "Нет активных задач"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"title": "Уведомления",
|
"title": "Уведомления",
|
||||||
|
|||||||
Reference in New Issue
Block a user