mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-12 00:19:40 +08:00
- 新增 JVM 持续监控仪表盘、图表、状态卡和详情面板 - 统一概览、资源浏览、审计页面的 JVM 工作台布局 - Sidebar 和 TabManager 支持监控入口、诊断入口兜底和上下文切换 - 补充前端状态模型、展示文案和组件回归测试
78 lines
2.1 KiB
TypeScript
78 lines
2.1 KiB
TypeScript
import type { JVMCapability } from "../types";
|
|
import {
|
|
JVM_RUNTIME_MODES,
|
|
resolveJVMModeMeta,
|
|
type JVMRuntimeMode,
|
|
} from "./jvmRuntimePresentation";
|
|
|
|
export type JVMMonitoringActionDescriptor = {
|
|
key: string;
|
|
title: string;
|
|
providerMode: JVMRuntimeMode;
|
|
};
|
|
|
|
export type JVMDiagnosticActionDescriptor = {
|
|
key: string;
|
|
title: string;
|
|
transport: "agent-bridge" | "arthas-tunnel";
|
|
};
|
|
|
|
const normalizeMonitoringMode = (value: unknown): JVMRuntimeMode | null => {
|
|
const mode = String(value || "").trim().toLowerCase();
|
|
return JVM_RUNTIME_MODES.includes(mode as JVMRuntimeMode)
|
|
? (mode as JVMRuntimeMode)
|
|
: null;
|
|
};
|
|
|
|
export const buildJVMMonitoringActionDescriptors = (
|
|
connectionId: string,
|
|
capabilities: Array<Pick<JVMCapability, "mode"> & Partial<Pick<JVMCapability, "canBrowse">>>,
|
|
): JVMMonitoringActionDescriptor[] => {
|
|
const id = String(connectionId || "").trim();
|
|
if (!id) {
|
|
return [];
|
|
}
|
|
|
|
const seen = new Set<JVMRuntimeMode>();
|
|
const descriptors: JVMMonitoringActionDescriptor[] = [];
|
|
|
|
capabilities.forEach((capability) => {
|
|
if (capability.canBrowse === false) {
|
|
return;
|
|
}
|
|
const providerMode = normalizeMonitoringMode(capability.mode);
|
|
if (!providerMode || seen.has(providerMode)) {
|
|
return;
|
|
}
|
|
seen.add(providerMode);
|
|
|
|
descriptors.push({
|
|
key: `${id}-jvm-monitoring-${providerMode}`,
|
|
title: `持续监控 · ${resolveJVMModeMeta(providerMode).label}`,
|
|
providerMode,
|
|
});
|
|
});
|
|
|
|
return descriptors;
|
|
};
|
|
|
|
export const buildJVMDiagnosticActionDescriptor = (
|
|
connectionId: string,
|
|
diagnostic: { enabled?: boolean; transport?: unknown } | undefined,
|
|
): JVMDiagnosticActionDescriptor | null => {
|
|
const id = String(connectionId || "").trim();
|
|
if (!id || diagnostic?.enabled !== true) {
|
|
return null;
|
|
}
|
|
|
|
const transport =
|
|
String(diagnostic.transport || "").trim() === "arthas-tunnel"
|
|
? "arthas-tunnel"
|
|
: "agent-bridge";
|
|
return {
|
|
key: `${id}-jvm-diagnostic`,
|
|
title: `诊断增强 · ${transport === "arthas-tunnel" ? "Arthas Tunnel" : "Agent Bridge"}`,
|
|
transport,
|
|
};
|
|
};
|