Page Modules
Page customization needs to call the engine's Content method, which needs to return an object types.Panel
The following is the definition of types.Panel:
1
type Panel struct {
2
Content template.HTML
3
Title string
4
Description string
5
Url string
6
}
Copied!
Corresponding ui, you can see the following picture:
Could not load image

How to use

1
package datamodel
2
3
import (
4
"github.com/GoAdminGroup/go-admin/modules/config"
5
template2 "github.com/GoAdminGroup/go-admin/template"
6
"github.com/GoAdminGroup/go-admin/template/types"
7
"html/template"
8
)
9
10
func GetContent() (types.Panel, error) {
11
12
components := template2.Get(config.Get().THEME)
13
colComp := components.Col()
14
15
infobox := components.InfoBox().
16
SetText("CPU TRAFFIC").
17
SetColor("blue").
18
SetNumber("41,410").
19
SetIcon("ion-ios-gear-outline").
20
GetContent()
21
22
var size = map[string]string{"md": "3", "sm": "6", "xs": "12"}
23
infoboxCol1 := colComp.SetSize(size).SetContent(infobox).GetContent()
24
row1 := components.Row().SetContent(infoboxCol1).GetContent()
25
26
return types.Panel{
27
Content: row1,
28
Title: "Dashboard",
29
Description: "this is a example",
30
}, nil
31
}
Copied!

Col

A col is type of ColAttribute, has three methods:
1
type ColAttribute interface {
2
SetSize(value map[string]string) ColAttribute
3
SetContent(value template.HTML) ColAttribute
4
GetContent() template.HTML
5
}
Copied!
About the size,example is map[string]string{"md": "3", "sm": "6", "xs": "12"}

Row

A row is type of RowAttribute, has two methods:
1
type RowAttribute interface {
2
SetContent(value template.HTML) RowAttribute
3
GetContent() template.HTML
4
}
Copied!
Last modified 1yr ago
Copy link