Skip to content

Commit

Permalink
基础数据可视化版本确定
Browse files Browse the repository at this point in the history
1.大屏下支持自由拖拽布局 小屏自动回退到固定
2.大屏生成为动态组件 提高首屏加载速度
  • Loading branch information
23233 committed Oct 13, 2020
1 parent b7c19ae commit 5a41a93
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 47 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ sp:"tag(img)"
- [] full test
- [] gorm support
- [] gin support

- [x] dashboard
- [x] simple event monitor
- [x] add spider visit monitor options enable!
Expand Down
88 changes: 44 additions & 44 deletions bindata.go

Large diffs are not rendered by default.

26 changes: 24 additions & 2 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ func AddDashBoard(ctx iris.Context) {
// 编辑图表
func EditDashBoard(ctx iris.Context) {
req := ctx.Values().Get(SvKey).(*DashBoardAddReq)
screenId, _ := ctx.Params().GetUint64("id")
id, err := ctx.Params().GetUint64("rid")
if err != nil {
fastError(err, ctx)
Expand All @@ -450,7 +449,6 @@ func EditDashBoard(ctx iris.Context) {
d.Config = req.Config
d.DataSource = req.DataSource
d.Name = req.Name
d.ScreenId = screenId
aff, err := NowSpAdmin.config.Engine.ID(id).Update(&d)
if err != nil || aff < 1 {
fastError(err, ctx, "更新失败")
Expand All @@ -459,6 +457,30 @@ func EditDashBoard(ctx iris.Context) {
_, _ = ctx.JSON(iris.Map{})
}

// 更新图表位置
func EditDashBoardPosition(ctx iris.Context) {
req := ctx.Values().Get(SvKey).(*DashBoardChangePositionReq)
id, err := ctx.Params().GetUint64("rid")
if err != nil {
fastError(err, ctx)
return
}
var d DashBoard
has, err := NowSpAdmin.config.Engine.ID(id).Get(&d)
if err != nil || has == false {
fastError(err, ctx)
return
}
d.Extra = req.Extra
aff, err := NowSpAdmin.config.Engine.ID(id).Update(&d)
if err != nil || aff < 1 {
fastError(err, ctx, "更新失败")
return
}
_, _ = ctx.JSON(iris.Map{})

}

// 删除图表
func DeleteDashBoard(ctx iris.Context) {
id, err := ctx.Params().GetUint64("rid")
Expand Down
1 change: 1 addition & 0 deletions short.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type DashBoard struct {
Name string `xorm:"varchar(45) notnull" comment:"名称" json:"name"`
ChartType string `xorm:"varchar(40) notnull" comment:"图表类型" json:"chart_type"`
DataSource string `xorm:"text notnull" comment:"数据源" json:"data_source"`
Extra string `xorm:"text" comment:"附加信息" json:"extra"`
Config string `xorm:"text notnull" comment:"配置" json:"config"`
}

Expand Down
1 change: 1 addition & 0 deletions simple_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func (lib *SpAdmin) Router(router iris.Party) {
b.Get("/data_board/{id:uint64}/{rid:uint64}", DashBoardIsSelfMiddleware, GetSingleDashBoard)
b.Post("/data_board/{id:uint64}", sv.Run(new(DashBoardAddReq)), DashBoardIsSelfMiddleware, AddDashBoard)
b.Put("/data_board/{id:uint64}/{rid:uint64}", sv.Run(new(DashBoardAddReq)), DashBoardIsSelfMiddleware, EditDashBoard)
b.Put("/data_board_size/{id:uint64}/{rid:uint64}", sv.Run(new(DashBoardChangePositionReq)), DashBoardIsSelfMiddleware, EditDashBoardPosition)
b.Delete("/data_board/{id:uint64}/{rid:uint64}", DashBoardIsSelfMiddleware, DeleteDashBoard)
b.Post("/data_board_data/{routerName:string}", sv.Run(new(DashBoardGetDataReq)), DashBoardSourceGet)

Expand Down
5 changes: 5 additions & 0 deletions validator_global.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,8 @@ type DashBoardAddReq struct {
Config string `json:"config" form:"config" comment:"图表配置" validate:"required"`
ChartType string `json:"chart_type" form:"chart_type" comment:"图表类型" validate:"required"`
}

// 数据图表位置变更
type DashBoardChangePositionReq struct {
Extra string `json:"extra" form:"extra" comment:"附加信息" validate:"required"`
}

0 comments on commit 5a41a93

Please sign in to comment.