Forked from qor/admin
Instantly create a beautiful, cross platform, configurable Admin Interface and API for managing your data in minutes.
For security issues, please send us an email to [email protected] and give us time to respond BEFORE posting as an issue or reporting on public forums.
- Generate Admin Interface for managing data
- RESTFul JSON API
- Association handling
- Search and filtering
- Actions/Batch Actions
- Authentication and Authorization
- Extendability
package main
import (
"fmt"
"net/http"
"github.com/jinzhu/gorm"
_ "github.com/mattn/go-sqlite3"
admin "github.com/TykTechnologies/raava-admin"
)
// Create a GORM-backend model
type User struct {
gorm.Model
Name string
}
// Create another GORM-backend model
type Product struct {
gorm.Model
Name string
Description string
}
func main() {
DB, _ := gorm.Open("sqlite3", "demo.db")
DB.AutoMigrate(&User{}, &Product{})
// Initialize
Admin := admin.New(&admin.AdminConfig{DB: DB})
// Allow to use Admin to manage User, Product
Admin.AddResource(&User{})
Admin.AddResource(&Product{})
// initialize an HTTP request multiplexer
mux := http.NewServeMux()
// Mount admin interface to mux
Admin.MountTo("/admin", mux)
fmt.Println("Listening on: 9000")
http.ListenAndServe(":9000", mux)
}
go run main.go
and visit localhost:9000/admin
to see the result!
- Live Demo http://demo.getqor.com/admin
- Source Code of Live Demo https://github.com/qor/qor-example
To print all registered routes
// adm is a QOR admin instance
adm.GetRouter().PrintRoutes()
QOR was developed before go mod was introduced. So it still support go path while finding its template files. The priority is
- check vendor, if not found
- check $GOPATH/src/github.com/TykTechnologies/raava-admin/views, if still not found
- load view path from $GOPATH/pkg/mod/github.com/TykTechnologies/[email protected]/views. the version would be detected automatically by you go.sum file
So if you want to use the template under the pkg/mod, make sure $GOPATH/src/github.com/TykTechnologies/raava-admin is absent.
Released under the MIT License.
Requires Node.js and Gulp for building frontend files
npm install && npm install -g gulp
- Watch SCSS/JavaScript changes (hot-reload):
gulp
- Build Release files:
gulp release
We need the latest commit hash from raava-admin
repo. You can get it from the GitHub repo, or:
We need to have the latest version of the master
branch
# make sure we are in the correct branch
$ git checkout master
# get the lastest update
$ git pull
# display the hash from the las commit
$ git log -1 --format='%H'
Now that we got the commit hash, we need to move to the local raava
folder and do this
$ go get github.com/TykTechnologies/raava-admin@<commit-hash-here>