forked from ccfos/nightingale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter_chart_group.go
55 lines (40 loc) · 1019 Bytes
/
router_chart_group.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package http
import (
"github.com/gin-gonic/gin"
"github.com/didi/nightingale/v5/models"
)
func chartGroupGets(c *gin.Context) {
objs, err := models.ChartGroupGets(urlParamInt64(c, "id"))
renderData(c, objs, err)
}
type chartGroupForm struct {
Name string `json:"name"`
Weight int `json:"weight"`
}
func chartGroupAdd(c *gin.Context) {
var f chartGroupForm
bind(c, &f)
loginUser(c).MustPerm("dashboard_modify")
d := Dashboard(urlParamInt64(c, "id"))
cg := models.ChartGroup{
DashboardId: d.Id,
Name: f.Name,
Weight: f.Weight,
}
dangerous(cg.Add())
renderData(c, cg, nil)
}
func chartGroupsPut(c *gin.Context) {
var arr []models.ChartGroup
bind(c, &arr)
loginUser(c).MustPerm("dashboard_modify")
for i := 0; i < len(arr); i++ {
dangerous(arr[i].Update("name", "weight"))
}
renderMessage(c, nil)
}
func chartGroupDel(c *gin.Context) {
loginUser(c).MustPerm("dashboard_modify")
cg := models.ChartGroup{Id: urlParamInt64(c, "id")}
renderMessage(c, cg.Del())
}