diff --git a/center/router/router.go b/center/router/router.go index 2c2cea03a..c204f676d 100644 --- a/center/router/router.go +++ b/center/router/router.go @@ -423,6 +423,9 @@ func (rt *Router) Config(r *gin.Engine) { pages.PUT("/es-index-pattern", rt.auth(), rt.admin(), rt.esIndexPatternPut) pages.DELETE("/es-index-pattern", rt.auth(), rt.admin(), rt.esIndexPatternDel) + pages.GET("/embedded-dashboards", rt.auth(), rt.user(), rt.perm("/embedded-dashboards"), rt.embeddedDashboardsGet) + pages.PUT("/embedded-dashboards", rt.auth(), rt.user(), rt.perm("/embedded-dashboards/put"), rt.embeddedDashboardsPut) + pages.GET("/user-variable-configs", rt.auth(), rt.user(), rt.perm("/help/variable-configs"), rt.userVariableConfigGets) pages.POST("/user-variable-config", rt.auth(), rt.user(), rt.perm("/help/variable-configs"), rt.userVariableConfigAdd) pages.PUT("/user-variable-config/:id", rt.auth(), rt.user(), rt.perm("/help/variable-configs"), rt.userVariableConfigPut) diff --git a/center/router/router_configs.go b/center/router/router_configs.go index 8ed4a69e9..3a92e1898 100644 --- a/center/router/router_configs.go +++ b/center/router/router_configs.go @@ -1,13 +1,16 @@ package router import ( - "github.com/ccfos/nightingale/v6/models" "time" + "github.com/ccfos/nightingale/v6/models" + "github.com/gin-gonic/gin" "github.com/toolkits/pkg/ginx" ) +const EMBEDDEDDASHBOARD = "embedded-dashboards" + func (rt *Router) configsGet(c *gin.Context) { prefix := ginx.QueryStr(c, "prefix", "") limit := ginx.QueryInt(c, "limit", 10) @@ -33,6 +36,18 @@ func (rt *Router) configPutByKey(c *gin.Context) { ginx.NewRender(c).Message(models.ConfigsSetWithUname(rt.Ctx, f.Ckey, f.Cval, username)) } +func (rt *Router) embeddedDashboardsGet(c *gin.Context) { + config, err := models.ConfigsGet(rt.Ctx, EMBEDDEDDASHBOARD) + ginx.NewRender(c).Data(config, err) +} + +func (rt *Router) embeddedDashboardsPut(c *gin.Context) { + var f models.Configs + ginx.BindJSON(c, &f) + username := c.MustGet("username").(string) + ginx.NewRender(c).Message(models.ConfigsSetWithUname(rt.Ctx, EMBEDDEDDASHBOARD, f.Cval, username)) +} + func (rt *Router) configsDel(c *gin.Context) { var f idsForm ginx.BindJSON(c, &f)