feat(monitor): F4 自定义监控仪表盘 — mock 桩改真实 CRUD + PromQL 查询渲染
后端: - 新增 model/custom_dashboard.go (monitor_custom_dashboards 表) - 新增 controller/custom_dashboard.go (CRUD + 设默认, 6 路由) - routes.go 注册 /custom-dashboards 路由组 - database.go AutoMigrate 注册 CustomDashboard 前端: - grafana.ts: dashboardApi 从 mock 返回空改为真实 HTTP 调用 - metrics.ts: prometheusProxyApi 新增 query/queryRange 方法 - GrafanaPanelContent.tsx: 从随机 mock 数据改为执行 PromQL 查询 + Recharts LineChart 渲染 graph 类型 + SVG gauge 渲染 gauge 类型 + 数值卡片渲染 stat 类型 + 表格渲染 table 类型 + 30s 自动刷新 + loading/error 状态 + 自动发现默认 Prometheus 数据源 - GrafanaDashboard.tsx: 传递 datasourceUrl 到 GrafanaPanelContent 验证: go build✅ npm build✅ 17/17 集成测试通过 E2E CRUD 全通过
This commit is contained in:
1 parent
7af10097c9
commit
f725ca7cac
11 files changed
+670
-53
No files matched your search
@@ -966,6 +966,18 @@ func Register(r *gin.Engine, db *gorm.DB, log *zap.Logger, cfg *config.Config, c
|
||||
zabbixDSGroup.POST("/test", zabbixDSHandler.TestConnection)
|
||||
}
|
||||
|
||||
// 自定义监控仪表盘 — CRUD + 设默认 // Logan.Li
|
||||
customDashHandler := controller.NewCustomDashboardHandler(db)
|
||||
customDashGroup := authorized.Group("/custom-dashboards")
|
||||
{
|
||||
customDashGroup.GET("", customDashHandler.List)
|
||||
customDashGroup.GET("/:id", customDashHandler.Get)
|
||||
customDashGroup.POST("", customDashHandler.Create)
|
||||
customDashGroup.PUT("/:id", customDashHandler.Update)
|
||||
customDashGroup.DELETE("/:id", customDashHandler.Delete)
|
||||
customDashGroup.POST("/:id/default", customDashHandler.SetDefault)
|
||||
}
|
||||
|
||||
// 凭据管理 — SSH密钥/API Token/密码统一加密管理 // Logan.Li
|
||||
credentialHandlerV2 := controller.NewCredentialHandlerV2(svcs.Credential)
|
||||
credentialHandler := controller.NewCredentialHandler(db, cfg.JWT.Secret) // 仅用于 GetTags/PatchCredential/AssignCredential(待拆分)
|
||||
|
||||
Reference in new issue
Block a user