feat: 动态粒度趋势图,支持 auto bucket 选择 + P95 延迟 + 状态条
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import type { DashboardResponse, MetaResponse, TargetMetricsResponse } from "../../shared/api";
|
||||
import type { DashboardResponse, MetaResponse, MetricsBucket, TargetMetricsResponse } from "../../shared/api";
|
||||
|
||||
const queryKeys = {
|
||||
dashboard: () => ["dashboard", "24h", 30] as const,
|
||||
meta: () => ["meta"] as const,
|
||||
metrics: (targetId: string, from: string, to: string, bucket: "1h") =>
|
||||
metrics: (targetId: string, from: string, to: string, bucket: "auto" | MetricsBucket) =>
|
||||
["metrics", targetId, from, to, bucket] as const,
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@ export function useMeta() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useTargetMetrics(targetId: null | string, from: string, to: string, bucket: "1h") {
|
||||
export function useTargetMetrics(targetId: null | string, from: string, to: string, bucket: "auto" | MetricsBucket) {
|
||||
return useQuery({
|
||||
enabled: targetId !== null && !!from && !!to,
|
||||
queryFn: () => {
|
||||
|
||||
@@ -23,7 +23,7 @@ export function useTargetDetail() {
|
||||
? (dashboardData?.targets.find((target) => target.id === selectedTargetId) ?? null)
|
||||
: null;
|
||||
|
||||
const metrics = useTargetMetrics(selectedTargetId, timeFrom, timeTo, "1h");
|
||||
const metrics = useTargetMetrics(selectedTargetId, timeFrom, timeTo, "auto");
|
||||
|
||||
const history = useQuery({
|
||||
enabled: selectedTargetId !== null && !!timeFrom && !!timeTo && activeTab === "history",
|
||||
|
||||
Reference in New Issue
Block a user