mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-10 21:30:59 +00:00
feat(dashboard): richer System History & Xray Metrics charts
- Collect disk read/write and network packet-rate metrics on the host sampler - Sparkline: optional 2nd/3rd overlaid series with a colored legend - System History: merge Bandwidth (up/down), Disk I/O (read/write) and Load (1m/5m/15m) into single multi-line tabs - Add a descriptive per-chart title and mobile-only tab icons to both modals - Localize every chart title and tab label across all 13 languages
This commit is contained in:
@@ -32,3 +32,28 @@
|
||||
gap: 4px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.sparkline-legend {
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
right: 8px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 2px 8px;
|
||||
background: color-mix(in srgb, var(--ant-color-bg-elevated) 88%, transparent);
|
||||
border: 1px solid var(--ant-color-border-secondary);
|
||||
border-radius: 999px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
line-height: 16px;
|
||||
pointer-events: none;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.sparkline-legend .extrema-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,13 @@ const DEFAULT_MAX_COLOR = '#fa541c';
|
||||
|
||||
interface SparklineProps {
|
||||
data: number[];
|
||||
data2?: number[];
|
||||
data3?: number[];
|
||||
stroke2?: string;
|
||||
stroke3?: string;
|
||||
name1?: string;
|
||||
name2?: string;
|
||||
name3?: string;
|
||||
labels?: (string | number)[];
|
||||
height?: number;
|
||||
stroke?: string;
|
||||
@@ -56,11 +63,20 @@ interface SparklineProps {
|
||||
interface ChartPoint {
|
||||
index: number;
|
||||
value: number;
|
||||
value2: number;
|
||||
value3: number;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export default function Sparkline({
|
||||
data,
|
||||
data2 = [],
|
||||
data3 = [],
|
||||
stroke2 = '#722ed1',
|
||||
stroke3 = '#a0d911',
|
||||
name1,
|
||||
name2,
|
||||
name3,
|
||||
labels = [],
|
||||
height = 80,
|
||||
stroke = '#008771',
|
||||
@@ -85,28 +101,39 @@ export default function Sparkline({
|
||||
const reactId = useId();
|
||||
const safeId = reactId.replace(/[^a-zA-Z0-9]/g, '');
|
||||
const gradId = `spkGrad-${safeId}`;
|
||||
const gradId2 = `spkGrad2-${safeId}`;
|
||||
const gradId3 = `spkGrad3-${safeId}`;
|
||||
const hasSeries2 = data2.length > 0;
|
||||
const hasSeries3 = data3.length > 0;
|
||||
const multiSeries = hasSeries2 || hasSeries3;
|
||||
|
||||
const points = useMemo<ChartPoint[]>(() => {
|
||||
const n = Math.min(data.length, maxPoints);
|
||||
if (n === 0) return [];
|
||||
const sliceStart = data.length - n;
|
||||
const labelStart = Math.max(0, labels.length - n);
|
||||
const slice2Start = data2.length - n;
|
||||
const slice3Start = data3.length - n;
|
||||
return data.slice(sliceStart).map((value, i) => ({
|
||||
index: i,
|
||||
value: Number(value) || 0,
|
||||
value2: data2.length ? Number(data2[slice2Start + i]) || 0 : 0,
|
||||
value3: data3.length ? Number(data3[slice3Start + i]) || 0 : 0,
|
||||
label: String(labels[labelStart + i] ?? i + 1),
|
||||
}));
|
||||
}, [data, labels, maxPoints]);
|
||||
}, [data, data2, data3, labels, maxPoints]);
|
||||
|
||||
const yDomain = useMemo<[number, number]>(() => {
|
||||
if (valueMax != null) return [valueMin, valueMax];
|
||||
let max = valueMin;
|
||||
for (const p of points) {
|
||||
if (Number.isFinite(p.value) && p.value > max) max = p.value;
|
||||
if (hasSeries2 && Number.isFinite(p.value2) && p.value2 > max) max = p.value2;
|
||||
if (hasSeries3 && Number.isFinite(p.value3) && p.value3 > max) max = p.value3;
|
||||
}
|
||||
if (max <= valueMin) max = valueMin + 1;
|
||||
return [valueMin, max * 1.1];
|
||||
}, [points, valueMin, valueMax]);
|
||||
}, [points, valueMin, valueMax, hasSeries2, hasSeries3]);
|
||||
|
||||
const yTicks = useMemo(() => {
|
||||
if (!showAxes) return undefined;
|
||||
@@ -129,7 +156,7 @@ export default function Sparkline({
|
||||
const fmtTooltip = tooltipFormatter ?? yFormatter;
|
||||
|
||||
const extremaPoints = useMemo(() => {
|
||||
if (!extrema?.show || points.length < 2) return null;
|
||||
if (!extrema?.show || multiSeries || points.length < 2) return null;
|
||||
let minIdx = 0;
|
||||
let maxIdx = 0;
|
||||
for (let i = 1; i < points.length; i++) {
|
||||
@@ -138,7 +165,17 @@ export default function Sparkline({
|
||||
}
|
||||
if (minIdx === maxIdx) return null;
|
||||
return { min: points[minIdx], max: points[maxIdx], minIdx, maxIdx };
|
||||
}, [points, extrema?.show]);
|
||||
}, [points, extrema?.show, multiSeries]);
|
||||
|
||||
const legendItems = useMemo(
|
||||
() =>
|
||||
[
|
||||
{ name: name1, color: stroke },
|
||||
{ name: name2, color: stroke2 },
|
||||
{ name: name3, color: stroke3 },
|
||||
].filter((s, i) => s.name && (i === 0 ? multiSeries : i === 1 ? hasSeries2 : hasSeries3)),
|
||||
[name1, name2, name3, stroke, stroke2, stroke3, multiSeries, hasSeries2, hasSeries3],
|
||||
);
|
||||
|
||||
const fmtExtrema = extrema?.formatter ?? yFormatter;
|
||||
const minColor = extrema?.minColor ?? DEFAULT_MIN_COLOR;
|
||||
@@ -156,6 +193,13 @@ export default function Sparkline({
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{legendItems.length > 0 && (
|
||||
<div className="sparkline-legend" aria-hidden="true">
|
||||
{legendItems.map((s) => (
|
||||
<span key={s.name} className="extrema-item" style={{ color: s.color }}>● {s.name}</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<ResponsiveContainer width="100%" height={height} className="sparkline-svg">
|
||||
<AreaChart
|
||||
data={points}
|
||||
@@ -171,6 +215,14 @@ export default function Sparkline({
|
||||
<stop offset="0%" stopColor={stroke} stopOpacity={fillOpacity} />
|
||||
<stop offset="100%" stopColor={stroke} stopOpacity={0} />
|
||||
</linearGradient>
|
||||
<linearGradient id={gradId2} x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stopColor={stroke2} stopOpacity={fillOpacity} />
|
||||
<stop offset="100%" stopColor={stroke2} stopOpacity={0} />
|
||||
</linearGradient>
|
||||
<linearGradient id={gradId3} x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stopColor={stroke3} stopOpacity={fillOpacity} />
|
||||
<stop offset="100%" stopColor={stroke3} stopOpacity={0} />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
{showGrid && (
|
||||
<CartesianGrid stroke="rgba(128, 128, 140, 0.35)" strokeDasharray="3 4" vertical={false} />
|
||||
@@ -209,9 +261,9 @@ export default function Sparkline({
|
||||
}}
|
||||
labelStyle={{ color: 'var(--ant-color-text-tertiary)', marginBottom: 4, fontSize: 11 }}
|
||||
itemStyle={{ color: 'var(--ant-color-text)', padding: 0, fontWeight: 500 }}
|
||||
formatter={(v) => [fmtTooltip(Number(v) || 0), '']}
|
||||
formatter={(v, name) => [fmtTooltip(Number(v) || 0), multiSeries && typeof name === 'string' ? name : '']}
|
||||
labelFormatter={(label) => (tooltipLabelFormatter ? tooltipLabelFormatter(String(label)) : String(label))}
|
||||
separator=""
|
||||
separator={multiSeries ? ': ' : ''}
|
||||
/>
|
||||
)}
|
||||
{referenceLines?.map((rl, idx) => (
|
||||
@@ -256,6 +308,7 @@ export default function Sparkline({
|
||||
<Area
|
||||
type="monotone"
|
||||
dataKey="value"
|
||||
name={multiSeries ? name1 : undefined}
|
||||
stroke={stroke}
|
||||
strokeWidth={strokeWidth}
|
||||
fill={`url(#${gradId})`}
|
||||
@@ -263,6 +316,32 @@ export default function Sparkline({
|
||||
activeDot={showMarker ? { r: markerRadius, fill: stroke, strokeWidth: 0 } : false}
|
||||
isAnimationActive={false}
|
||||
/>
|
||||
{hasSeries2 && (
|
||||
<Area
|
||||
type="monotone"
|
||||
dataKey="value2"
|
||||
name={name2}
|
||||
stroke={stroke2}
|
||||
strokeWidth={strokeWidth}
|
||||
fill={`url(#${gradId2})`}
|
||||
dot={false}
|
||||
activeDot={showMarker ? { r: markerRadius, fill: stroke2, strokeWidth: 0 } : false}
|
||||
isAnimationActive={false}
|
||||
/>
|
||||
)}
|
||||
{hasSeries3 && (
|
||||
<Area
|
||||
type="monotone"
|
||||
dataKey="value3"
|
||||
name={name3}
|
||||
stroke={stroke3}
|
||||
strokeWidth={strokeWidth}
|
||||
fill={`url(#${gradId3})`}
|
||||
dot={false}
|
||||
activeDot={showMarker ? { r: markerRadius, fill: stroke3, strokeWidth: 0 } : false}
|
||||
isAnimationActive={false}
|
||||
/>
|
||||
)}
|
||||
</AreaChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
|
||||
import { HttpUtil } from '@/utils';
|
||||
import { pauseAnimationsUntilLeave, useTheme } from '@/hooks/useTheme';
|
||||
import { useAllSettings } from '@/api/queries/useAllSettings';
|
||||
import './AppSidebar.css';
|
||||
|
||||
const SIDEBAR_COLLAPSED_KEY = 'isSidebarCollapsed';
|
||||
@@ -121,6 +122,8 @@ export default function AppSidebar() {
|
||||
const { isDark, isUltra, toggleTheme, toggleUltra } = useTheme();
|
||||
const navigate = useNavigate();
|
||||
const { pathname, hash } = useLocation();
|
||||
const { allSetting } = useAllSettings();
|
||||
const showSubFormats = !!(allSetting.subJsonEnable || allSetting.subClashEnable);
|
||||
|
||||
const [collapsed, setCollapsed] = useState<boolean>(() => readCollapsed());
|
||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||
@@ -143,13 +146,18 @@ export default function AppSidebar() {
|
||||
const navItems = useMemo(() => tabs.filter((tab) => tab.icon !== 'logout'), [tabs]);
|
||||
const utilItems = useMemo(() => tabs.filter((tab) => tab.icon === 'logout'), [tabs]);
|
||||
|
||||
const settingsChildren = useMemo<NonNullable<MenuProps['items']>>(() => [
|
||||
{ key: '/settings#general', icon: <SettingOutlined />, label: t('pages.settings.panelSettings') },
|
||||
{ key: '/settings#security', icon: <SafetyOutlined />, label: t('pages.settings.securitySettings') },
|
||||
{ key: '/settings#telegram', icon: <MessageOutlined />, label: t('pages.settings.TGBotSettings') },
|
||||
{ key: '/settings#subscription', icon: <CloudServerOutlined />, label: t('pages.settings.subSettings') },
|
||||
{ key: '/settings#subscription-formats', icon: <CodeOutlined />, label: 'Sub Formats' },
|
||||
], [t]);
|
||||
const settingsChildren = useMemo<NonNullable<MenuProps['items']>>(() => {
|
||||
const children: NonNullable<MenuProps['items']> = [
|
||||
{ key: '/settings#general', icon: <SettingOutlined />, label: t('pages.settings.panelSettings') },
|
||||
{ key: '/settings#security', icon: <SafetyOutlined />, label: t('pages.settings.securitySettings') },
|
||||
{ key: '/settings#telegram', icon: <MessageOutlined />, label: t('pages.settings.TGBotSettings') },
|
||||
{ key: '/settings#subscription', icon: <CloudServerOutlined />, label: t('pages.settings.subSettings') },
|
||||
];
|
||||
if (showSubFormats) {
|
||||
children.push({ key: '/settings#subscription-formats', icon: <CodeOutlined />, label: 'Sub Formats' });
|
||||
}
|
||||
return children;
|
||||
}, [t, showSubFormats]);
|
||||
|
||||
const xrayChildren = useMemo<NonNullable<MenuProps['items']>>(() => [
|
||||
{ key: '/xray#basic', icon: <SettingOutlined />, label: t('pages.xray.basicTemplate') },
|
||||
|
||||
@@ -13,6 +13,13 @@
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.history-chart-title {
|
||||
margin-bottom: 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--ant-color-text);
|
||||
}
|
||||
|
||||
.cpu-chart-wrap {
|
||||
margin: 8px 8px 16px;
|
||||
padding: 16px 18px 18px;
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import type { ReactNode } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Modal, Select, Tabs } from 'antd';
|
||||
import {
|
||||
DashboardOutlined,
|
||||
DatabaseOutlined,
|
||||
DeploymentUnitOutlined,
|
||||
GlobalOutlined,
|
||||
HddOutlined,
|
||||
LineChartOutlined,
|
||||
TeamOutlined,
|
||||
} from '@ant-design/icons';
|
||||
|
||||
import { HttpUtil, SizeFormatter } from '@/utils';
|
||||
import { Sparkline } from '@/components/viz';
|
||||
@@ -17,26 +27,38 @@ interface SystemHistoryModalProps {
|
||||
interface MetricDef {
|
||||
key: string;
|
||||
tab: string;
|
||||
tabKey?: string;
|
||||
title: string;
|
||||
icon: ReactNode;
|
||||
valueMax: number | null;
|
||||
unit: string;
|
||||
stroke: string;
|
||||
key2?: string;
|
||||
stroke2?: string;
|
||||
name1?: string;
|
||||
name2?: string;
|
||||
key3?: string;
|
||||
stroke3?: string;
|
||||
name3?: string;
|
||||
}
|
||||
|
||||
const METRICS: MetricDef[] = [
|
||||
{ key: 'cpu', tab: 'CPU', valueMax: 100, unit: '%', stroke: '' },
|
||||
{ key: 'mem', tab: 'RAM', valueMax: 100, unit: '%', stroke: '#7c4dff' },
|
||||
{ key: 'netUp', tab: 'Net Up', valueMax: null, unit: 'B/s', stroke: '#1890ff' },
|
||||
{ key: 'netDown', tab: 'Net Down', valueMax: null, unit: 'B/s', stroke: '#13c2c2' },
|
||||
{ key: 'online', tab: 'Online', valueMax: null, unit: '', stroke: '#52c41a' },
|
||||
{ key: 'load1', tab: 'Load 1m', valueMax: null, unit: '', stroke: '#fa8c16' },
|
||||
{ key: 'load5', tab: 'Load 5m', valueMax: null, unit: '', stroke: '#f5222d' },
|
||||
{ key: 'load15', tab: 'Load 15m', valueMax: null, unit: '', stroke: '#a0d911' },
|
||||
{ key: 'cpu', tab: 'CPU', title: 'pages.index.historyTitleCpu', icon: <DashboardOutlined />, valueMax: 100, unit: '%', stroke: '' },
|
||||
{ key: 'mem', tab: 'RAM', title: 'pages.index.historyTitleMem', icon: <DatabaseOutlined />, valueMax: 100, unit: '%', stroke: '#7c4dff' },
|
||||
{ key: 'netUp', tab: 'Bandwidth', tabKey: 'pages.index.historyTabBandwidth', title: 'pages.index.historyTitleNetwork', icon: <GlobalOutlined />, valueMax: null, unit: 'B/s', stroke: '#1890ff', key2: 'netDown', stroke2: '#13c2c2', name1: 'Up', name2: 'Down' },
|
||||
{ key: 'pktUp', tab: 'Packets', tabKey: 'pages.index.historyTabPackets', title: 'pages.index.historyTitlePackets', icon: <DeploymentUnitOutlined />, valueMax: null, unit: 'pkt/s', stroke: '#2f54eb', key2: 'pktDown', stroke2: '#36cfc9', name1: 'Up', name2: 'Down' },
|
||||
{ key: 'diskRead', tab: 'Disk I/O', tabKey: 'pages.index.historyTabDisk', title: 'pages.index.historyTitleDisk', icon: <HddOutlined />, valueMax: null, unit: 'B/s', stroke: '#eb2f96', key2: 'diskWrite', stroke2: '#722ed1', name1: 'Read', name2: 'Write' },
|
||||
{ key: 'online', tab: 'Online', tabKey: 'pages.index.historyTabOnline', title: 'pages.index.historyTitleOnline', icon: <TeamOutlined />, valueMax: null, unit: '', stroke: '#52c41a' },
|
||||
{ key: 'load1', tab: 'Load', tabKey: 'pages.index.historyTabLoad', title: 'pages.index.historyTitleLoad', icon: <LineChartOutlined />, valueMax: null, unit: '', stroke: '#fa8c16', key2: 'load5', stroke2: '#f5222d', name1: '1m', name2: '5m', key3: 'load15', stroke3: '#a0d911', name3: '15m' },
|
||||
];
|
||||
|
||||
function unitFormatter(unit: string, activeKey: string): (v: number) => string {
|
||||
if (unit === 'B/s') {
|
||||
return (v) => `${SizeFormatter.sizeFormat(Math.max(0, Number(v) || 0)).replace(/\.\d+/, '')}/s`;
|
||||
}
|
||||
if (unit === 'pkt/s') {
|
||||
return (v) => `${Math.round(Math.max(0, Number(v) || 0)).toLocaleString()}/s`;
|
||||
}
|
||||
if (unit === '%') {
|
||||
return (v) => `${Number(v).toFixed(1)}%`;
|
||||
}
|
||||
@@ -69,6 +91,8 @@ export default function SystemHistoryModal({ open, status, onClose }: SystemHist
|
||||
const [activeKey, setActiveKey] = useState('cpu');
|
||||
const [bucket, setBucket] = useState(2);
|
||||
const [points, setPoints] = useState<number[]>([]);
|
||||
const [points2, setPoints2] = useState<number[]>([]);
|
||||
const [points3, setPoints3] = useState<number[]>([]);
|
||||
const [labels, setLabels] = useState<string[]>([]);
|
||||
const [timestamps, setTimestamps] = useState<number[]>([]);
|
||||
|
||||
@@ -116,15 +140,32 @@ export default function SystemHistoryModal({ open, status, onClose }: SystemHist
|
||||
setLabels(labs);
|
||||
setPoints(vals);
|
||||
setTimestamps(tss);
|
||||
|
||||
const fetchAligned = async (key?: string): Promise<number[]> => {
|
||||
if (!key) return [];
|
||||
const m = await HttpUtil.get(`/panel/api/server/history/${key}/${bucket}`);
|
||||
if (m?.success && Array.isArray(m.obj)) {
|
||||
const byTs = new Map<number, number>();
|
||||
for (const p of m.obj) byTs.set(Number(p.t) || 0, Number(p.v) || 0);
|
||||
return tss.map((ts) => byTs.get(ts) ?? 0);
|
||||
}
|
||||
return [];
|
||||
};
|
||||
setPoints2(await fetchAligned(activeMetric.key2));
|
||||
setPoints3(await fetchAligned(activeMetric.key3));
|
||||
} else {
|
||||
setLabels([]);
|
||||
setPoints([]);
|
||||
setPoints2([]);
|
||||
setPoints3([]);
|
||||
setTimestamps([]);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to fetch history bucket', e);
|
||||
setLabels([]);
|
||||
setPoints([]);
|
||||
setPoints2([]);
|
||||
setPoints3([]);
|
||||
setTimestamps([]);
|
||||
}
|
||||
}, [activeMetric, bucket]);
|
||||
@@ -168,12 +209,26 @@ export default function SystemHistoryModal({ open, status, onClose }: SystemHist
|
||||
onChange={setActiveKey}
|
||||
size="small"
|
||||
className="history-tabs"
|
||||
items={METRICS.map((m) => ({ key: m.key, label: m.tab }))}
|
||||
items={METRICS.map((m) => {
|
||||
const tabLabel = m.tabKey ? t(m.tabKey) : m.tab;
|
||||
return {
|
||||
key: m.key,
|
||||
label: isMobile ? <span title={tabLabel} aria-label={tabLabel}>{m.icon}</span> : tabLabel,
|
||||
};
|
||||
})}
|
||||
/>
|
||||
|
||||
<div className="cpu-chart-wrap">
|
||||
{activeMetric?.title && <div className="history-chart-title">{t(activeMetric.title)}</div>}
|
||||
<Sparkline
|
||||
data={points}
|
||||
data2={activeMetric?.key2 ? points2 : undefined}
|
||||
data3={activeMetric?.key3 ? points3 : undefined}
|
||||
stroke2={activeMetric?.stroke2}
|
||||
stroke3={activeMetric?.stroke3}
|
||||
name1={activeMetric?.name1}
|
||||
name2={activeMetric?.name2}
|
||||
name3={activeMetric?.name3}
|
||||
labels={labels}
|
||||
height={260}
|
||||
stroke={strokeColor}
|
||||
@@ -189,7 +244,7 @@ export default function SystemHistoryModal({ open, status, onClose }: SystemHist
|
||||
valueMax={activeMetric?.valueMax ?? null}
|
||||
yFormatter={yFormatter}
|
||||
tooltipLabelFormatter={tooltipLabelFormatter}
|
||||
extrema={{ show: true, formatter: yFormatter }}
|
||||
extrema={{ show: !activeMetric?.key2, formatter: yFormatter }}
|
||||
/>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import type { ReactNode } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Alert, Modal, Select, Tabs, Tag } from 'antd';
|
||||
import {
|
||||
BlockOutlined,
|
||||
CloudServerOutlined,
|
||||
DatabaseOutlined,
|
||||
DeleteOutlined,
|
||||
EyeOutlined,
|
||||
PauseCircleOutlined,
|
||||
} from '@ant-design/icons';
|
||||
|
||||
import { HttpUtil, Msg, SizeFormatter } from '@/utils';
|
||||
import { Sparkline } from '@/components/viz';
|
||||
@@ -17,6 +26,9 @@ interface XrayMetricsModalProps {
|
||||
interface MetricDef {
|
||||
key: string;
|
||||
tab: string;
|
||||
tabKey: string;
|
||||
title: string;
|
||||
icon: ReactNode;
|
||||
unit: 'B' | 'ns' | 'ms' | '';
|
||||
stroke: string;
|
||||
}
|
||||
@@ -36,12 +48,12 @@ interface ObservatoryTag {
|
||||
}
|
||||
|
||||
const METRICS: MetricDef[] = [
|
||||
{ key: 'xrAlloc', tab: 'Heap', unit: 'B', stroke: '#7c4dff' },
|
||||
{ key: 'xrSys', tab: 'Sys', unit: 'B', stroke: '#1890ff' },
|
||||
{ key: 'xrHeapObjects', tab: 'Objects', unit: '', stroke: '#13c2c2' },
|
||||
{ key: 'xrNumGC', tab: 'GC Count', unit: '', stroke: '#fa8c16' },
|
||||
{ key: 'xrPauseNs', tab: 'GC Pause', unit: 'ns', stroke: '#f5222d' },
|
||||
{ key: OBS_KEY, tab: 'Observatory', unit: 'ms', stroke: '#52c41a' },
|
||||
{ key: 'xrAlloc', tab: 'Heap', tabKey: 'pages.index.xrayTabHeap', title: 'pages.index.xrayTitleHeap', icon: <DatabaseOutlined />, unit: 'B', stroke: '#7c4dff' },
|
||||
{ key: 'xrSys', tab: 'Sys', tabKey: 'pages.index.xrayTabSys', title: 'pages.index.xrayTitleSys', icon: <CloudServerOutlined />, unit: 'B', stroke: '#1890ff' },
|
||||
{ key: 'xrHeapObjects', tab: 'Objects', tabKey: 'pages.index.xrayTabObjects', title: 'pages.index.xrayTitleObjects', icon: <BlockOutlined />, unit: '', stroke: '#13c2c2' },
|
||||
{ key: 'xrNumGC', tab: 'GC Count', tabKey: 'pages.index.xrayTabGcCount', title: 'pages.index.xrayTitleGcCount', icon: <DeleteOutlined />, unit: '', stroke: '#fa8c16' },
|
||||
{ key: 'xrPauseNs', tab: 'GC Pause', tabKey: 'pages.index.xrayTabGcPause', title: 'pages.index.xrayTitleGcPause', icon: <PauseCircleOutlined />, unit: 'ns', stroke: '#f5222d' },
|
||||
{ key: OBS_KEY, tab: 'Observatory', tabKey: 'pages.index.xrayTabObservatory', title: 'pages.index.xrayTitleObservatory', icon: <EyeOutlined />, unit: 'ms', stroke: '#52c41a' },
|
||||
];
|
||||
|
||||
function unitFormatter(unit: string): (v: number) => string {
|
||||
@@ -299,7 +311,13 @@ export default function XrayMetricsModal({ open, onClose }: XrayMetricsModalProp
|
||||
onChange={setActiveKey}
|
||||
size="small"
|
||||
className="history-tabs"
|
||||
items={METRICS.map((m) => ({ key: m.key, label: m.tab }))}
|
||||
items={METRICS.map((m) => {
|
||||
const tabLabel = m.tabKey ? t(m.tabKey) : m.tab;
|
||||
return {
|
||||
key: m.key,
|
||||
label: isMobile ? <span title={tabLabel} aria-label={tabLabel}>{m.icon}</span> : tabLabel,
|
||||
};
|
||||
})}
|
||||
/>
|
||||
|
||||
{isObservatory && (
|
||||
@@ -353,6 +371,7 @@ export default function XrayMetricsModal({ open, onClose }: XrayMetricsModalProp
|
||||
)}
|
||||
|
||||
<div className="cpu-chart-wrap">
|
||||
{activeMetric?.title && <div className="history-chart-title">{t(activeMetric.title)}</div>}
|
||||
<Sparkline
|
||||
data={points}
|
||||
labels={labels}
|
||||
|
||||
Reference in New Issue
Block a user