-
Notifications
You must be signed in to change notification settings - Fork 1
/
dashboard.go
75 lines (70 loc) · 2.26 KB
/
dashboard.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package official
import (
"fmt"
"html/template"
"github.com/webx-top/db"
"github.com/webx-top/echo"
"github.com/admpub/nging/v5/application/registry/dashboard"
"github.com/admpub/webx/application/dbschema"
modelCustomer "github.com/admpub/webx/application/model/official/customer"
)
func init() {
dashboard.CardRegister(
(&dashboard.Card{
IconName: `fa-users`,
IconColor: `warning`,
Short: `CUSTOMER`,
Name: `客户数量`,
Summary: ``,
}).SetContentGenerator(func(ctx echo.Context) interface{} {
custMdl := modelCustomer.NewCustomer(ctx)
total, _ := custMdl.Count(nil)
agents, _ := custMdl.Count(nil, db.Cond{`agent_level`: db.NotEq(0)})
if agents < 1 {
return total
}
return template.HTML(fmt.Sprintf(`%d <a class="label label-danger" href="%s">%s:%d</a>`, total, `javascript:;`, ctx.T(`代理商`), agents))
}),
(&dashboard.Card{
IconName: `fa-leaf`,
IconColor: `success`,
Short: `ARTICLES`,
Name: `文章数量`,
Summary: ``,
}).SetContentGenerator(func(ctx echo.Context) interface{} {
m := dbschema.NewOfficialCommonArticle(ctx)
n, _ := m.Count(nil)
return n
}),
(&dashboard.Card{
IconName: `fa-comments`,
IconColor: `primary`,
Short: `COMMENT`,
Name: `评论数量`,
Summary: ``,
}).SetContentGenerator(func(ctx echo.Context) interface{} {
m := dbschema.NewOfficialCommonComment(ctx)
total, _ := m.Count(nil)
pendings, _ := m.Count(nil, db.Cond{`display`: `N`})
if pendings < 1 {
return total
}
return template.HTML(fmt.Sprintf(`%d <a class="label label-danger" href="%s">%s:%d</a>`, total, `/official/article/comment/index?display=N`, ctx.T(`待审`), pendings))
}),
(&dashboard.Card{
IconName: `fa-warning`,
IconColor: `danger`,
Short: `COMPLAINT`,
Name: `客户投诉`,
Summary: ``,
}).SetContentGenerator(func(ctx echo.Context) interface{} {
m := dbschema.NewOfficialCommonComplaint(ctx)
total, _ := m.Count(nil)
pendings, _ := m.Count(nil, db.Cond{`process`: `idle`})
if pendings < 1 {
return total
}
return template.HTML(fmt.Sprintf(`%d <a class="label label-danger" href="%s">%s:%d</a>`, total, `/official/customer/complaint/index?process=idle`, ctx.T(`待处理`), pendings))
}),
)
}