Coder Social home page Coder Social logo

goadmingroup / go-admin Goto Github PK

View Code? Open in Web Editor NEW
7.8K 141.0 1.3K 51.9 MB

A golang framework helps gopher to build a data visualization and admin panel in ten minutes

Home Page: https://www.go-admin.com

License: Apache License 2.0

Go 78.90% JavaScript 1.15% CSS 8.91% Makefile 0.25% TSQL 9.87% PLpgSQL 0.84% Dockerfile 0.07%
golang adminlte admin dataviz datavisualization gin beego

go-admin's Introduction

go-admin

the missing golang data admin panel builder tool.

Documentation | 中文文档 | 中文介绍 | DEMO | 中文DEMO | Twitter | Forum

Build Status Go Report Card golang discord telegram license

Inspired by laravel-admin

Preface

GoAdmin is a toolkit to help you build a data visualization admin panel for your golang app.

Online demo: https://demo.go-admin.com

Quick follow up example: https://github.com/GoAdminGroup/example

GoAdmin+vue example: https://github.com/GoAdminGroup/goadmin-vue-example

interface

Features

  • 🚀 Fast: build a production admin panel app in ten minutes.
  • 🎨 Theming: beautiful ui themes supported(default adminlte, more themes are coming.)
  • 🔢 Plugins: many plugins to use(more useful and powerful plugins are coming.)
  • Rbac: out of box rbac auth system.
  • ⚙️ Frameworks: support most of the go web frameworks.

Translation

We need your help: GoAdminGroup/docs#1

Who is using

Comment the issue to tell us.

How to

Following three steps to run it.

$ mkdir new_project && cd new_project
$ go install github.com/GoAdminGroup/adm@latest
$ adm init web

Step 1: import sql

Step 2: create main.go

main.go

package main

import (
	"github.com/gin-gonic/gin"
	_ "github.com/GoAdminGroup/go-admin/adapter/gin"
	_ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
	"github.com/GoAdminGroup/go-admin/engine"
	"github.com/GoAdminGroup/go-admin/plugins/admin"
	"github.com/GoAdminGroup/go-admin/modules/config"
	"github.com/GoAdminGroup/themes/adminlte"
	"github.com/GoAdminGroup/go-admin/template"
	"github.com/GoAdminGroup/go-admin/template/chartjs"
	"github.com/GoAdminGroup/go-admin/template/types"
	"github.com/GoAdminGroup/go-admin/examples/datamodel"
	"github.com/GoAdminGroup/go-admin/modules/language"
)

func main() {
	r := gin.Default()

	eng := engine.Default()

	// global config
	cfg := config.Config{
		Databases: config.DatabaseList{
			"default": {
				Host:         "127.0.0.1",
				Port:         "3306",
				User:         "root",
				Pwd:          "root",
				Name:         "goadmin",
				MaxIdleConns: 50,
				MaxOpenConns: 150,
				ConnMaxLifetime: time.Hour,
				Driver:       "mysql",
			},
        	},
		UrlPrefix: "admin",
		// STORE is important. And the directory should has permission to write.
		Store: config.Store{
		    Path:   "./uploads", 
		    Prefix: "uploads",
		},
		Language: language.EN,
		// debug mode
		Debug: true,
		// log file absolute path
		InfoLogPath: "/var/logs/info.log",
		AccessLogPath: "/var/logs/access.log",
		ErrorLogPath: "/var/logs/error.log",
		ColorScheme: adminlte.ColorschemeSkinBlack,
	}

	// add component chartjs
	template.AddComp(chartjs.NewChart())

	_ = eng.AddConfig(&cfg).
		AddGenerators(datamodel.Generators).
	        // add generator, first parameter is the url prefix of table when visit.
    	        // example:
    	        //
    	        // "user" => http://localhost:9033/admin/info/user
    	        //		
		AddGenerator("user", datamodel.GetUserTable).
		Use(r)
	
	// customize your pages
	eng.HTML("GET", "/admin", datamodel.GetContent)

	_ = r.Run(":9033")
}

More framework examples: https://github.com/GoAdminGroup/go-admin/tree/master/examples

Step 3: run

GO111MODULE=on go run main.go

visit: http://localhost:9033/admin

account: admin password: admin

A super simple example here

See the docs for more details.

Backers

Your support will help me do better! [Become a backer]

Contribution

here for contribution guide

here to join into the develop team

join telegram

go-admin's People

Contributors

afansv avatar chenhg5 avatar chicknsoup avatar code206 avatar dependabot-preview[bot] avatar dependabot-support avatar eavesmy avatar embraceuu avatar eugeneradionov avatar fr05t1k avatar fym201 avatar jasonhonor avatar kataras avatar laijinhang avatar peteluo avatar phanletrunghieu avatar raulfortes avatar realpy avatar riley817 avatar romutchio avatar sanrentai avatar sean- avatar skanger avatar ssnnow avatar sup8 avatar theromis avatar wayyoungboy avatar wisarmy avatar zhangyangziwo avatar zhyt1985 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-admin's Issues

go-admin cli error: no tables

im run admincli generate, and got error no tables.

C:\Users\Dimas\go\src>admincli generate
�[H�[2JGoAdmin CLI v1.0.0
? choose a driver mysql
? sql address 127.0.0.1
? sql port 3306
? sql username root
? sql password
? sql database name godmin

�[31mgo-admin cli error: no tables�[0m

admincli is very broken

I've been having some headaches with generating templates and I'm honestly not having fun.. I will have some commits pushed to get admincli generating good templates..

mysql table name or fields should use a semicolon

If you use some mysql qualified name, you will cause a mysql 1064 error.

Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit,mission_req,type,id from contract where id > 0 order by id desc LIMIT ? OF' at line 1 

近期开发项

近期正在使用go-admin做一个后台,需要补充一些功能,大致开发计划如下

1.实现对不可编辑字段的处理(除file/iconpicker类型外 已完成)
对于标记为不可编辑的字段,前端应显示为不可修改,后端应禁止提交

2.Table修改为interface,以方便定制开发 (已完成)
将Table定义为接口可以方便用户自定义数据处理逻辑,以适应更加复杂的需要(如:多数据源、复杂关联查询、nosql数据源等)

3.将Row传递给FieldValueFun,以方便根据其它字段定制显示内容(已完成)
将整行数据传给字段处理函数,可以方便处理函数根据数据上下文定制显示内容,很多情况下某个字段在客户端展示的结果需要结合其它字段进行判断

4.列表页字段增加Hide参数(已完成)
有些数据字段在客户端并不需要展示,但在处理函数需要用到

5.筛选项支持使用选择列表

6. 筛选项支持直接在列表页显示

#34

Can't join slack

Click join slack link, it need Enter your workspace’s Slack URL.

[Proposal] Adding Chi Router Support

Adding Chi Router Support:
chi is a lightweight, idiomatic and composable router for building Go HTTP services. It's especially good at helping you write large REST API services that are kept maintainable as your project grows and changes. chi is built on the new context package introduced in Go 1.7 to handle signaling, cancelation and request-scoped values across a handler chain.
https://github.com/go-chi/chi

websocket 问题

你好,感谢你的项目,最近把你的项目用与展示一个小的相关数据项目,在增加了示例仪表盘页面 ,怎么在里面websocket 推送功能,主要是监控服务器的 cpu 内存指标,以及指定程序的相关运行状态,就相当于一个简单的实时监控功能

error msg is not clear

错误信息提示不明显;
1、新增用户报错,但是数据库 增加了一条新的记录;
add new user error,but new info has been stored in goadmin_users;
2、点击查看 管理-用户 报一下错误;
click admin->users,error:
[GIN] 2019/08/02 - 15:56:03 | 500 | 1m16s | ::1 | GET /admin/info/manager?_pjax=%23pjax-container
INFO[5301] [GoAdmin] 200 GET /admin/info/manager
ERRO[5301] interface conversion: interface {} is nil, not string

demo在linux下运行正常,但是在mac下一直报错

[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:	export GIN_MODE=release
 - using code:	gin.SetMode(gin.ReleaseMode)

panic: interface conversion: interface {} is int64, not *interface {}

goroutine 1 [running]:
github.com/chenhg5/go-admin/modules/db/converter.SetResultValue(0xc0001b51e0, 0xc000164c7c, 0x4, 0x47e24c0, 0xc000172e20, 0x0, 0x0)
	/Users/liu/gofile/src/github.com/chenhg5/go-admin/modules/db/converter/sql.go:213 +0x22eb
github.com/chenhg5/go-admin/modules/db/performer.Query(0xc0003c80c0, 0x4936789, 0x39, 0xc0003f2ee0, 0x1, 0x1, 0x203000, 0x203000, 0xc0003fe600, 0xc0001b52e0)
	/Users/liu/gofile/src/github.com/chenhg5/go-admin/modules/db/performer/performer.go:56 +0x384
github.com/chenhg5/go-admin/modules/db/mysql.(*Mysql).Query(0x56e4680, 0x4936789, 0x39, 0xc0003f2ee0, 0x1, 0x1, 0x4890960, 0xa, 0xc0001b5380, 0x80)
	/Users/liu/gofile/src/github.com/chenhg5/go-admin/modules/db/mysql/mysql.go:112 +0x9c
github.com/chenhg5/go-admin/modules/db.Query(0x4936789, 0x39, 0xc0003f2ee0, 0x1, 0x1, 0x1, 0x0, 0x4894020, 0xc000196310)
	/Users/liu/gofile/src/github.com/chenhg5/go-admin/modules/db/connection.go:38 +0x150
github.com/chenhg5/go-admin/plugins/admin/models.GetRolesTable(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/liu/gofile/src/github.com/chenhg5/go-admin/plugins/admin/models/generators.go:376 +0xbb
github.com/chenhg5/go-admin/plugins/admin/models.InitTableList()
	/Users/liu/gofile/src/github.com/chenhg5/go-admin/plugins/admin/models/table.go:22 +0x112
github.com/chenhg5/go-admin/plugins/admin.(*Admin).InitPlugin(0xc0003ca140)
	/Users/liu/gofile/src/github.com/chenhg5/go-admin/plugins/admin/admin.go:39 +0x4c5
github.com/chenhg5/go-admin/engine.(*Engine).AddPlugins(0xc0001b5ea8, 0xc0001b5e88, 0x2, 0x2, 0x491a58f)
	/Users/liu/gofile/src/github.com/chenhg5/go-admin/engine/engine.go:43 +0x65
main.main()
	/Users/liu/gofile/src/github.com/chenhg5/go-admin/demo/main.go:48 +0x237
exit status 2

mac使用sqlite报错

可登录,进入用户、角色、权限、菜单、操作日志都报错
{"code":500,"msg":"interface conversion: interface {} is string, not []uint8"}

plugins⁩/admin/⁨models⁩/table.go 461
columns[key] = string(model["name"].([]uint8))
改为 columns[key] = string(model["name"].(string))
可浏览了

module declares its path as

  • According to the readme
  • Report this error when running:
go/src/go-admin via 🐹 v1.13.1
➜ ll
total 8
-rw-r--r--  1 linovo  staff   1.6K 10 13 13:07 main.go

go/src/go-admin via 🐹 v1.13.1
➜ go run main.go
go: github.com/GoAdminGroup/go-admin/adapter/gin: github.com/GoAdminGroup/[email protected]: parsing go.mod:
	module declares its path as: github.com/chenhg5/go-admin
	        but was required as: github.com/GoAdminGroup/go-admin

go/src/go-admin via 🐹 v1.13.1 took 6s
➜

@chenhg5

FormType: form.SelectSingle bug.

{
			Head:     "状态",
			Field:    "state",
			TypeName: db.Varchar,
			Default:  "",
			Editable: true,
			FormType: form.SelectSingle,
			FilterFn: func(model types.RowModel) interface{} {
				return []string{model.Value}
			},
			Options: []map[string]string{
				{
					"field": "待审核",
					"value": common.WITHDRAWAL_STATE_WAIT_FOR_AUDIT,
				},{
					"field": "不通过",
					"value": common.WITHDRAWAL_STATE_UNAPPROVED,
				},
				{
					"field": "审核通过待转账",
					"value": common.WITHDRAWAL_STATE_WAIT_FOR_TX,
				},
				{
					"field": "转账失败",
					"value": common.WITHDRAWAL_STATE_TRANSFER_FAIL,
				},{
					"field": "审核通过",
					"value": common.WITHDRAWAL_STATE_APPROVED,
				},
				{
					"field": "转账失败,数据回滚",
					"value": common.WITHDRAWAL_STATE_ROLLBACK,
				},
			},
		}

Like the code above, set formType to form.SelectSingle. In theory, there should be only one specific option selected on the edit page, but on the selectBox on the page, there are sometimes two and sometimes three.

go get no Go files in

go get -v -u github.com/chenhg5/go-admin
github.com/chenhg5/go-admin (download)
package github.com/chenhg5/go-admin: no Go files in /Volumes/Data/Work/golang/src/github.com/chenhg5/go-admin

角色管理 权限不能更新

在测试中发现 角色管理模块,在给 operator 增加了 “” 权限后保存,再次修改取消“” 权限,虽然能保存成功,但是数据库不更新。

Dependabot can't resolve your Go dependency files

Dependabot can't resolve your Go dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

go: verifying github.com/kataras/[email protected]+incompatible/go.mod: checksum mismatch
	downloaded: h1:ki9XPua5SyAJbIxDdsssxevgGrbpBmmvoQmo/A0IodY=
	go.sum:     h1:KavHkm44uIT02MlheYqn0L8ZGpWhI34qhlknGmWEfHU=

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

GoAdmin Users Feedback 👨🏻‍💻👩🏻‍💻

We appreciate you support if you or your organization is using GoAdmin. You are welcome to leave replies about your product and organization here, which could became the confidence of maintiners, communication and undecided watchers. And we may display your use case in our README.md and homepage if you allow.

Recommended reply format:

- Product:
- Company or Organization: (if ok)
- Link: (if ok)
- Screenshot: (if any)

此处用于收集 GoAdmin 的社区用户的使用案例,如果你在你的公司/组织或个人项目中使用了GoAdmin,欢迎在此留言。你的反馈会给社区成员更多信息和更强的信心。同时我们会将您的使用案例放在我们的README.md或官网主页,如果您觉得可以的话。

推荐回复格式:

- 产品:
- 公司或组织:(如果可以)
- 链接:(如果可以)
- 截图:(如果可以)

无关回复会定期删除。

same error catch twice?

/admin/info/user
ERRO[1425] Error 1146: Table 'goadmin.users' doesn't exist
ERRO[1425] goroutine 167 [running]:
...
[GIN] 2019/08/02 - 14:52:09 | 500 | 1m43s | ::1 | GET /admin/info/user?_pjax=%23pjax-container
INFO[1427] [GoAdmin] 200 GET /admin/info/user
ERRO[1427] Error 1146: Table 'goadmin.users' doesn't exist
ERRO[1427] goroutine 167 [running]:

新创建管理员的管理员不能登录

password 没有 EncodePassword
manager.go
import "github.com/chenhg5/go-admin/modules/auth"

21 "password": dataList["password"][0],
改为 "password": auth.EncodePassword([]byte(dataList["password"][0])),

问题解决

[Proposal] rename ExcuFun to FilterFn to make it easier to understand

Idea

Let's rename ExcuFun to FilterFunc or FilterFn because it is too hard to guess what is this function and what does it must do.
The same logic can be applicable for FieldValueFun => FieldFilterFn

type FieldValueFun func(value RowModel) interface{}

type Field struct {
	ExcuFun   FieldValueFun
	Field     string
	TypeName  string
	Head      string
	JoinTable []Join
	Sortable  bool
	Filter    bool
	Hide      bool
}

多个AreaChart生成js代码报错

当添加多个AreaChart的时候,生成的js代码会多次生成
let salesChartCanvas = $('#{{.ID}}').get(0).getContext('2d');

页面会报错
uncaught SyntaxError: Identifier 'salesChartCanvas' has already been declared

密码加密没加盐?

如题:

func EncodePassword(pwd []byte) string {
	hash := sha256.New()
	hash.Write(pwd)
	md := hash.Sum(nil)
	return hex.EncodeToString(md)
}

sql拼接错误

plugins/admin/controller/show.go
wheres += key + " = ? and"
少一个空格,导致多个查询条件Sql报错
应该是
wheres += key + " = ? and "

一个gin的例子,运行看起来像这样

go run main.go 
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:	export GIN_MODE=release
 - using code:	gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /uploads/*filepath        --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (3 handlers)
[GIN-debug] HEAD   /uploads/*filepath        --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (3 handlers)
[GIN-debug] GET    /admin/login              --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] POST   /admin/signin             --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] GET    /admin/install            --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] POST   /admin/install/database/check --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] GET    /admin/assets/Ionicons/css/ionicons.css --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
...
[GIN-debug] GET    /admin/logout             --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] GET    /admin/menu               --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] POST   /admin/menu/delete        --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] POST   /admin/menu/new           --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] POST   /admin/menu/edit          --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] GET    /admin/menu/edit/show     --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] POST   /admin/menu/order         --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] GET    /admin/info/:prefix       --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] GET    /admin/info/:prefix/edit  --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] GET    /admin/info/:prefix/new   --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] POST   /admin/edit/:prefix       --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] POST   /admin/delete/:prefix     --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] POST   /admin/new/:prefix        --> github.com/chenhg5/go-admin/adapter/gin.(*Gin).Use.func1 (3 handlers)
[GIN-debug] Listening and serving HTTP on :5678
[GIN] 2019/03/12 - 05:49:46 | 404 |        16.7µs |      172.17.0.1 | GET      /admin
[GIN] 2019/03/12 - 05:49:51 | 404 |        14.1µs |      172.17.0.1 | GET      /admin

几个建议

1、将插件的模板文件放在自己的插件目录下面,比如admin插件的模板文件可以放在插件下面
2、支持模块化开发,比如开发一个博客模块,这个模块下面有后台的发布页面和前台的显示页面,都在这一个模块目录下面
3、支持数据库的填充功能,比如开发一个插件,这个插件有自己的数据库表,如果有填充功能,就可以不用使用手动导入sql文件了

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.