fix(ui): исправить доступность оболочки и проверку состояния сервера
This commit is contained in:
1 parent
1a9966ec95
commit
c343ce62c8
25 files changed
+78
-21
No files matched your search
@@ -9,7 +9,7 @@ import { cn } from "@/lib/utils"
|
||||
import { useDataSource } from "@/lib/data-source"
|
||||
import { filters, pingProbes, servers } from "@/lib/data"
|
||||
import type { SidebarCountsDto } from "@/lib/sidebar-badges"
|
||||
import { resolveApiUrl } from "@/shared/api/http-client"
|
||||
import { getBackendHealth } from "@/shared/api/backend-health"
|
||||
|
||||
import {can,ensureAuthConfig} from "@/lib/auth"
|
||||
import {getSidebarCounts} from "@/shared/api/sidebar-counts"
|
||||
@@ -66,9 +66,9 @@ function MetricCell({ metric }: { metric: MonitorMetric }) {
|
||||
>
|
||||
{metric.icon}
|
||||
</div>
|
||||
<span className="text-muted-foreground truncate text-[11px]">{metric.label}</span>
|
||||
<span className="text-muted-foreground min-w-0 break-words text-[11px]">{metric.label}</span>
|
||||
</div>
|
||||
<span className="shrink-0 text-xs font-semibold tabular-nums" style={{ color }}>
|
||||
<span className="text-foreground shrink-0 text-xs font-semibold tabular-nums">
|
||||
{metric.value}
|
||||
<span className="text-muted-foreground ml-0.5 text-[10px] font-normal">{metric.unit}</span>
|
||||
</span>
|
||||
@@ -92,7 +92,7 @@ export function SystemMonitorPopover() {
|
||||
controller?.abort();controller=new AbortController();const request=++revision,signal=controller.signal
|
||||
const publish=(patch:Partial<NonNullable<typeof snapshot>>)=>{if(cancelled||request!==revision)return;setSnapshot(previous=>({...((previous?.source===source?previous:null)??{source,healthOk:null,counts:null,receivedAt:null,countsError:null}),...patch}))}
|
||||
await Promise.allSettled([
|
||||
(async()=>{try{const response=await fetch(resolveApiUrl(backendUrl,"/health"),{signal:AbortSignal.any([signal,AbortSignal.timeout(3000)]),cache:"no-store"});const raw=await response.json();publish({healthOk:response.ok&&raw?.status==="ok"})}catch{publish({healthOk:false})}})(),
|
||||
(async()=>{try{await getBackendHealth(backendUrl,signal);publish({healthOk:true})}catch{publish({healthOk:false})}})(),
|
||||
(async()=>{await ensureAuthConfig();if(cancelled||request!==revision)return;if(!can("mm:dashboard:read")){publish({counts:null,countsError:"Нет доступа к сводке"});return}try{const result=await getSidebarCounts(backendUrl,AbortSignal.any([signal,AbortSignal.timeout(30_000)]));if(can("mm:dashboard:read"))publish({counts:result,receivedAt:new Date().toISOString(),countsError:null})}catch{publish({countsError:"Сводка не обновлена; показан последний успешный снимок, если он есть."})}})(),
|
||||
])
|
||||
}
|
||||
@@ -183,7 +183,7 @@ export function SystemMonitorPopover() {
|
||||
<Badge
|
||||
variant={spiking ? "destructive-light" : apiOk?"success-light":"outline"}
|
||||
size="xs"
|
||||
className="h-4 px-1.5 text-[10px]"
|
||||
className={cn("h-4 px-1.5 text-[10px]",apiOk&&"text-emerald-700 dark:text-emerald-400",spiking&&"text-red-700 dark:text-red-400")}
|
||||
>
|
||||
{spiking?"Нет связи":apiOk?"API доступен":"Нет данных"}
|
||||
</Badge>
|
||||
|
||||
Reference in new issue
Block a user