-
Notifications
You must be signed in to change notification settings - Fork 7
/
app.go
75 lines (62 loc) · 1.83 KB
/
app.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 admin
import (
"fmt"
"github.com/getevo/evo"
"github.com/getevo/evo/apps/auth"
"github.com/getevo/evo/apps/settings"
"github.com/getevo/evo/lib/fontawesome"
"github.com/getevo/evo/menu"
"github.com/iesreza/jet/v8"
)
// Register register the admin in io apps
func Register() {
fmt.Println("Dashboard Registered")
evo.Register(App{})
}
var db = evo.GetDBO()
//Path to admin app
var Path string
// App admin app struct
type App struct{}
func (App) Pack() {
evo.Pack(Path)
}
var views *jet.Set
var setting Settings
// Register register the app
func (App) Register() {
//Require auth
setting.SessionAge = fmt.Sprint(evo.GetConfig().JWT.Age.Seconds())
Path = evo.GuessAsset(App{})
auth.Register()
views = evo.RegisterView("admin", Path+"/views")
settings.Register("Admin Panel", &setting)
}
// Router setup routers
func (App) Router() {
evo.Get("/admin/login", func(r *evo.Request) {
r.View(nil, "admin.login", "template.login")
})
evo.Get("/admin/dashboard", func(r *evo.Request) {
r.View(nil, "template.default")
})
}
// Permissions setup permissions of app
func (App) Permissions() []evo.Permission {
return []evo.Permission{
{Title: "Login to admin", CodeName: "login", Description: "Able login to admin panel"},
{Title: "Edit own dashboard", CodeName: "dashboard", Description: "Able edit own dashboard otherwise it inherit dashboard assigned by admin"},
}
}
// Menus setup menus
func (App) Menus() []menu.Menu {
return []menu.Menu{
{Title: "Dashboard", Url: "admin/dashboard", Icon: fontawesome.Home},
{Title: "Parent", Url: "admin/dashboard", Icon: fontawesome.SearchPlus, Children: []menu.Menu{
{Title: "Child 1", Url: "admin/dashboard", Icon: fontawesome.Image},
{Title: "Child 2", Url: "admin/dashboard", Icon: fontawesome.Save},
}},
}
}
// WhenReady called after setup all apps
func (App) WhenReady() {}