|
package gf |
|
|
|
import ( |
|
"net/http" |
|
"os" |
|
|
|
|
|
_ "github.com/GoAdminGroup/go-admin/adapter/gf" |
|
|
|
_ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql" |
|
|
|
_ "github.com/GoAdminGroup/go-admin/modules/db/drivers/postgres" |
|
|
|
_ "github.com/GoAdminGroup/go-admin/modules/db/drivers/sqlite" |
|
|
|
_ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mssql" |
|
|
|
"github.com/GoAdminGroup/themes/adminlte" |
|
|
|
"github.com/GoAdminGroup/go-admin/engine" |
|
"github.com/GoAdminGroup/go-admin/modules/config" |
|
"github.com/GoAdminGroup/go-admin/modules/language" |
|
"github.com/GoAdminGroup/go-admin/plugins/admin" |
|
"github.com/GoAdminGroup/go-admin/plugins/admin/modules/table" |
|
"github.com/GoAdminGroup/go-admin/template" |
|
"github.com/GoAdminGroup/go-admin/template/chartjs" |
|
"github.com/GoAdminGroup/go-admin/tests/tables" |
|
"github.com/gogf/gf/frame/g" |
|
) |
|
|
|
func internalHandler() http.Handler { |
|
s := g.Server(8103) |
|
|
|
eng := engine.Default() |
|
|
|
adminPlugin := admin.NewAdmin(tables.Generators).AddDisplayFilterXssJsFilter() |
|
|
|
template.AddComp(chartjs.NewChart()) |
|
|
|
adminPlugin.AddGenerator("user", tables.GetUserTable) |
|
|
|
if err := eng.AddConfigFromJSON(os.Args[len(os.Args)-1]). |
|
AddPlugins(adminPlugin). |
|
Use(s); err != nil { |
|
panic(err) |
|
} |
|
|
|
eng.HTML("GET", "/admin", tables.GetContent) |
|
|
|
return s |
|
} |
|
|
|
func NewHandler(dbs config.DatabaseList, gens table.GeneratorList) http.Handler { |
|
|
|
s := g.Server(8103) |
|
|
|
eng := engine.Default() |
|
adminPlugin := admin.NewAdmin(gens) |
|
|
|
if err := eng.AddConfig(&config.Config{ |
|
Databases: dbs, |
|
UrlPrefix: "admin", |
|
Store: config.Store{ |
|
Path: "./uploads", |
|
Prefix: "uploads", |
|
}, |
|
Language: language.EN, |
|
IndexUrl: "/", |
|
Debug: true, |
|
ColorScheme: adminlte.ColorschemeSkinBlack, |
|
}). |
|
AddPlugins(adminPlugin).Use(s); err != nil { |
|
panic(err) |
|
} |
|
|
|
template.AddComp(chartjs.NewChart()) |
|
|
|
eng.HTML("GET", "/admin", tables.GetContent) |
|
|
|
return s |
|
} |
|
|