fix: полный продакшен-фикс dashboard retention и timeseries по fix37

This commit is contained in:
2026-05-09 16:18:08 +05:00
parent 44c01d39d0
commit b6c86009e6
6 changed files with 35 additions and 33 deletions
+16 -22
View File
@@ -52,7 +52,7 @@
</template>
<div v-loading="timeseriesLoading" class="chart-grid">
<el-empty
v-if="!timeseriesLoading && (timeseries.traffic?.length || 0) === 0"
v-if="!timeseriesLoading && !hasTrafficData"
:description="$t('dashboard.noTrafficData')"
class="chart-empty"
/>
@@ -62,7 +62,7 @@
</el-card>
<el-card shadow="never" class="mt-3">
<template #header>{{ $t("dashboard.topPeers24h") }}</template>
<template #header>{{ $t("dashboard.topPeersRange", { range }) }}</template>
<el-table :data="topPeers" size="small">
<el-table-column prop="name" :label="$t('peer.name')" />
<el-table-column prop="download" :label="$t('dashboard.download')">
@@ -96,7 +96,6 @@ import VChart from "vue-echarts";
import { dashboardSecurityApi, dashboardSummaryApi, dashboardTimeseriesApi, dashboardTopPeersApi } from "@/api/dashboard";
import { DashboardSummaryVo, DashboardTimeseriesVo, DashboardTopPeerVo, SecurityRiskVo } from "@/api/dashboard/types";
import { formatBytes } from "@/utils/byte";
import { timestampToDateTime } from "@/utils/time";
use([CanvasRenderer, LineChart, GridComponent, TooltipComponent, LegendComponent, DataZoomComponent, TitleComponent]);
@@ -164,14 +163,6 @@ const loadDashboard = async () => {
}
};
const systemXAxisLabels = computed(() => {
const allTs = new Set<number>();
for (const item of timeseries.value.system || []) {
allTs.add(item.ts);
}
return Array.from(allTs).sort((a, b) => a - b);
});
const trafficDownloadData = computed(() =>
(timeseries.value.traffic || []).map((item) => [item.ts, item.download || 0])
);
@@ -180,15 +171,19 @@ const trafficUploadData = computed(() =>
(timeseries.value.traffic || []).map((item) => [item.ts, item.upload || 0])
);
const hasTrafficData = computed(() =>
(timeseries.value.traffic || []).some((item) => (item.download || 0) > 0 || (item.upload || 0) > 0)
);
const hasSingleTrafficPoint = computed(() => (timeseries.value.traffic || []).length === 1);
const systemMap = computed(() => {
const m = new Map<number, { cpu: number; mem: number }>();
for (const item of timeseries.value.system || []) {
m.set(item.ts, { cpu: item.cpu || 0, mem: item.mem || 0 });
}
return m;
});
const systemCpuData = computed(() =>
(timeseries.value.system || []).map((item) => [item.ts, item.cpu || 0])
);
const systemMemData = computed(() =>
(timeseries.value.system || []).map((item) => [item.ts, item.mem || 0])
);
const trafficChartOption = computed(() => ({
title: { text: t("dashboard.trafficSeriesChart"), left: "left", textStyle: { fontSize: 14, fontWeight: 600 } },
@@ -237,9 +232,8 @@ const systemChartOption = computed(() => ({
grid: { left: 30, right: 20, top: 50, bottom: 50, containLabel: true },
dataZoom: [{ type: "inside" }, { type: "slider", height: 16, bottom: 10 }],
xAxis: {
type: "category",
type: "time",
boundaryGap: false,
data: systemXAxisLabels.value.map((ts) => timestampToDateTime(ts)),
},
yAxis: {
type: "value",
@@ -253,14 +247,14 @@ const systemChartOption = computed(() => ({
type: "line",
smooth: true,
showSymbol: false,
data: systemXAxisLabels.value.map((ts) => systemMap.value.get(ts)?.cpu || 0),
data: systemCpuData.value,
},
{
name: t("dashboard.ram"),
type: "line",
smooth: true,
showSymbol: false,
data: systemXAxisLabels.value.map((ts) => systemMap.value.get(ts)?.mem || 0),
data: systemMemData.value,
},
],
}));