Skip to content

Commit

Permalink
fix: embedded-dashboards api perm (#2012)
Browse files Browse the repository at this point in the history
  • Loading branch information
710leo committed Jun 25, 2024
1 parent e3042dd commit f529681
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions center/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 16 additions & 1 deletion center/router/router_configs.go
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit f529681

Please sign in to comment.