Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterViewPath(pth string)
- type Action
- type ActionArgument
- type Admin
- func (admin *Admin) AddMenu(menu *Menu)
- func (admin *Admin) AddResource(value interface{}, config ...*Config) *Resource
- func (admin *Admin) AddSearchResrouce(resources ...*Resource)
- func (admin Admin) GetMenu(name string) *Menu
- func (admin Admin) GetMenus() []*Menu
- func (admin *Admin) GetResource(name string) (resource *Resource)
- func (admin *Admin) GetResources() []*Resource
- func (admin *Admin) GetRouter() *Router
- func (admin *Admin) GetSearchResrouces() []*Resource
- func (admin *Admin) MountTo(mountTo string, mux *http.ServeMux)
- func (admin *Admin) NewContext(w http.ResponseWriter, r *http.Request) *Context
- func (admin *Admin) NewResource(value interface{}, config ...*Config) *Resource
- func (admin *Admin) RegisterFuncMap(name string, fc interface{})
- func (admin *Admin) RegisterMetaConfigor(king string, fc func(*Meta))
- func (admin *Admin) RegisterResourceRouters(res *Resource, modes ...string)
- func (admin *Admin) RegisterViewPath(pth string)
- func (admin *Admin) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (admin *Admin) SetAssetFS(assetFS AssetFSInterface)
- func (admin *Admin) SetAuth(auth Auth)
- func (admin *Admin) SetSiteName(siteName string)
- func (admin *Admin) T(context *TM_EC.Context, key string, value string, values ...interface{}) template.HTML
- type AssetFSInterface
- type AssetFileSystem
- type Auth
- type CollectionEditConfig
- type Config
- type Context
- func (context *Context) AllowedActions(actions []*Action, mode string, records ...interface{}) []*Action
- func (context *Context) Asset(layouts ...string) ([]byte, error)
- func (context *Context) Execute(name string, result interface{})
- func (context *Context) Flash(message, typ string)
- func (context *Context) FlashNow(message, typ string)
- func (context *Context) FormattedValueOf(value interface{}, meta *Meta) interface{}
- func (context *Context) FuncMap() template.FuncMap
- func (context *Context) Funcs(funcMaps template.FuncMap) *Context
- func (context *Context) Get(key string) interface{}
- func (context *Context) GetFlashes() []Flash
- func (context *Context) GetScopes() (menus []*scopeMenu)
- func (context *Context) JSON(action string, result interface{})
- func (context *Context) NewResourceContext(name ...interface{}) *Context
- func (context *Context) Pagination() *PaginationResult
- func (context *Context) RawValueOf(value interface{}, meta *Meta) interface{}
- func (context *Context) Render(name string, results ...interface{}) template.HTML
- func (context *Context) Set(key string, value interface{})
- func (context *Context) URLFor(value interface{}, resources ...*Resource) string
- type Controller
- func (ac *Controller) Action(context *Context)
- func (ac *Controller) Asset(context *Context)
- func (ac *Controller) Create(context *Context)
- func (ac *Controller) Dashboard(context *Context)
- func (ac *Controller) Delelte(context *Context)
- func (ac *Controller) Edit(context *Context)
- func (ac *Controller) Index(context *Context)
- func (ac *Controller) New(context *Context)
- func (ac *Controller) SearchCenter(context *Context)
- func (ac *Controller) Show(context *Context)
- func (ac *Controller) Update(context *Context)
- type Filter
- type FilterArgument
- type FilterConfigInterface
- type Flash
- type HasPermissioner
- type I18n
- type Menu
- type Meta
- type MetaConfigInterface
- type Middleware
- type Page
- type Pagination
- type PaginationResult
- type RedactorPlugin
- type Resource
- func (res *Resource) Action(action *Action)
- func (res *Resource) ConvertSectionToMetas(secitons []*Section) []*Meta
- func (res *Resource) ConvertSectionToStrings(sections []*Section) []string
- func (res *Resource) Decode(context *TM_EC.Context, value interface{}) error
- func (res *Resource) EditAttrs(values ...interface{}) []*Section
- func (res *Resource) Filter(filter *Filter)
- func (res *Resource) GetAction(name string) *Action
- func (res Resource) GetAdmin() *Admin
- func (res *Resource) GetFilter() []*Filter
- func (res *Resource) GetMeta(name string) *Meta
- func (res *Resource) GetMetaOrNew(name string) *Meta
- func (res *Resource) GetMetas(attrs []string) []resource.Metaor
- func (res Resource) GetPrimaryValue(request *http.Request) string
- func (res *Resource) GetTheme(name string) ThemeInterface
- func (res *Resource) IndexAttrs(values ...interface{}) []*Section
- func (res *Resource) Meta(meta *Meta) *Meta
- func (res *Resource) NewAttrs(values ...interface{}) []*Section
- func (res Resource) ParamIDName() string
- func (res *Resource) Scope(scope *Scope)
- func (res *Resource) SearchAttrs(columns ...string) []string
- func (res *Resource) ShowAttrs(values ...interface{}) []*Section
- func (res *Resource) SortableAttrs(columns ...string) []string
- func (res *Resource) ToParam() string
- func (res *Resource) UseTheme(theme interface{}) []ThemeInterface
- type ResourceNamer
- type RichEditorConfig
- type RouteConfig
- type Router
- func (r *Router) Delete(path string, handle requestHanlder, config ...RouteConfig)
- func (r *Router) Get(path string, handler requestHanlder, config ...RouteConfig)
- func (r *Router) Mounted() bool
- func (r *Router) Post(path string, handle requestHanlder, config ...RouteConfig)
- func (r *Router) Put(path string, handle requestHanlder, config ...RouteConfig)
- func (r *Router) Use(middleware *Middleware)
- type Scope
- type Searcher
- func (s *Searcher) Filter(filter *Filter, values *resource.MetaValues) *Searcher
- func (s *Searcher) FindMany() (interface{}, error)
- func (s *Searcher) FindOne() (interface{}, error)
- func (s *Searcher) Page(num int) *Searcher
- func (s *Searcher) PerPage(num int) *Searcher
- func (s *Searcher) Scope(names ...string) *Searcher
- type Section
- type SelectManyConfig
- type SelectOneConfig
- func (selectOneConfig *SelectOneConfig) ConfigureECAdminFilter(filter *Filter)
- func (selectOneConfig *SelectOneConfig) ConfigureECMeta(metaor resource.Metaor)
- func (selectOneConfig *SelectOneConfig) FilterValue(filter *Filter, context *Context) interface{}
- func (selectOneConfig SelectOneConfig) GetCollection(value interface{}, context *Context) [][]string
- func (selectOneConfig SelectOneConfig) GetTemplate(context *Context, metaType string) ([]byte, error)
- type SingleEditConfig
- type Theme
- type ThemeInterface
Constants ¶
const HTTPUnprocessableEntity = 422
'HTTPUnprocessableEntity' error status code
Variables ¶
var DisableCompositePrimaryKeyMode = "composite_primary_key:query:disable"
var (
PaginationPageCount = 20
)
Functions ¶
func RegisterViewPath ¶
func RegisterViewPath(pth string)
Types ¶
type Action ¶
type Action struct {
Name string
Label string
Method string
URL func(record interface{}, context *Context) string
URLOpenType string
Visible func(record interface{}, context *Context) bool
Handler func(argument *ActionArgument) error
Modes []string
Resource *Resource
Permission *roles.Permission
}
'Action' action defination
func (Action) HasPermission ¶
'HasPermission' check if current user has permission for the action
type ActionArgument ¶
type ActionArgument struct {
PrimaryValues []string
Context *Context
Argument interface{}
SkipDefaultResponse bool
}
'ActionArgument' action argument that used in handle
func (*ActionArgument) FindSelectedRecords ¶
func (actionArgument *ActionArgument) FindSelectedRecords() []interface{}
'FindSelectedRecords' find selected records when run bulk actions
type Admin ¶
type Admin struct {
SiteName string
Config *TM_EC.Config
I18n I18n
AssetFS AssetFSInterface
Auth Auth
// contains filtered or unexported fields
}
'Admin' is a struct that used to generate admin/api interface
func (*Admin) AddResource ¶
'AddResource' make a model manageable from admin interface
func (*Admin) AddSearchResrouce ¶
func (*Admin) GetResource ¶
'GetResource' get resource with name
func (*Admin) GetResources ¶
'GetResources' get defined resource from admin
func (*Admin) GetSearchResrouces ¶
func (*Admin) MountTo ¶
'MountTo' mount the serice into mux (HTTP request multiplexer) with given path
func (*Admin) NewContext ¶
'NewContext' new admin context
func (*Admin) NewResource ¶
'NewResource' initialize a new ec resource, won't add it to admin, just initialize it
func (*Admin) RegisterFuncMap ¶
'RegisterFuncMap' register view funcs, it could be used in view templates
func (*Admin) RegisterMetaConfigor ¶
'RegisterMetaConfigor' register configor for a kind, it will be called when register those kind of metas
func (*Admin) RegisterResourceRouters ¶
func (*Admin) RegisterViewPath ¶
'RegisterViewPath' register view path for admin
func (*Admin) ServeHTTP ¶
func (admin *Admin) ServeHTTP(w http.ResponseWriter, req *http.Request)
'ServeHTTP' dispatches the handler registered in the matched route
func (*Admin) SetAssetFS ¶
func (admin *Admin) SetAssetFS(assetFS AssetFSInterface)
'SetAssetFS' set AssetFS for admin
func (*Admin) SetSiteName ¶
SetSiteName set site's name, the name will be used as admin HTML title and admin interface will auto load javascripts, stylesheets files based on its value For example, if you named it as `Qor Demo`, admin will look up `qor_demo.js`, `qor_demo.css` in QOR view paths, and load them if found
type AssetFSInterface ¶
type AssetFileSystem ¶
type AssetFileSystem struct {
Paths []string
}
func (*AssetFileSystem) Compile ¶
func (fs *AssetFileSystem) Compile() error
func (*AssetFileSystem) Glob ¶
func (fs *AssetFileSystem) Glob(pattern string) (matches []string, err error)
func (*AssetFileSystem) RegisterPath ¶
func (fs *AssetFileSystem) RegisterPath(pth string) error
type Auth ¶
type Auth interface {
GetCurrentUser(*Context) TM_EC.CurrentUser
LoginURL(*Context) string
LogoutURL(*Context) string
}
'Auth' is an auth interface that used to EC admin if you want to implement an authorization gataway for admin interface, you could implement this interface, and set it to the admin with 'admin.SetAuth(auth)'
type CollectionEditConfig ¶
type CollectionEditConfig struct {
Template string
// contains filtered or unexported fields
}
'CollectionEditConfig' meta configuration used for collection edit
func (*CollectionEditConfig) ConfigureECMeta ¶
func (collecctionEditConfig *CollectionEditConfig) ConfigureECMeta(metaor resource.Metaor)
'collecctionEditConfig' configure collection edit meta
func (CollectionEditConfig) GetTemplate ¶
func (collecctionEditConfig CollectionEditConfig) GetTemplate(context *Context, metaType string) ([]byte, error)
'GetTemplate' get template for collection edit
type Config ¶
type Config struct {
Name string
Menu []string
Invisible bool
Priority int
PageCount int
Singleton bool
Permission *roles.Permission
Themes []ThemeInterface
}
'Config' admin config struct
type Context ¶
type Context struct {
*TM_EC.Context
*Searcher
Flashes []Flash
Resource *Resource
Admin *Admin
Content template.HTML
Action string
Settings map[string]interface{}
Result interface{}
// contains filtered or unexported fields
}
'Context' admin context, which is used for admin controller
func (*Context) AllowedActions ¶
func (context *Context) AllowedActions(actions []*Action, mode string, records ...interface{}) []*Action
'AllowedActions' return allowed actions based on context
func (*Context) FormattedValueOf ¶
'FormattedValueOf' return formatted of a meta for current resource
func (*Context) GetFlashes ¶
'GetFlashes' get flash message for this request
func (*Context) GetScopes ¶
func (context *Context) GetScopes() (menus []*scopeMenu)
'GetScopes' get scopes from current context
func (*Context) NewResourceContext ¶
'NewResourceContext' new resource context
func (*Context) Pagination ¶
func (context *Context) Pagination() *PaginationResult
func (*Context) RawValueOf ¶
'RawValueOf' return raw value of a meta for current resource
type Controller ¶
type Controller struct {
*Admin
// contains filtered or unexported fields
}
func (*Controller) Action ¶
func (ac *Controller) Action(context *Context)
func (*Controller) Asset ¶
func (ac *Controller) Asset(context *Context)
func (*Controller) Create ¶
func (ac *Controller) Create(context *Context)
func (*Controller) Dashboard ¶
func (ac *Controller) Dashboard(context *Context)
func (*Controller) Delelte ¶
func (ac *Controller) Delelte(context *Context)
func (*Controller) Edit ¶
func (ac *Controller) Edit(context *Context)
func (*Controller) Index ¶
func (ac *Controller) Index(context *Context)
func (*Controller) New ¶
func (ac *Controller) New(context *Context)
func (*Controller) SearchCenter ¶
func (ac *Controller) SearchCenter(context *Context)
func (*Controller) Show ¶
func (ac *Controller) Show(context *Context)
func (*Controller) Update ¶
func (ac *Controller) Update(context *Context)
type Filter ¶
type Filter struct {
Name string
Label string
Type string
Operations []string
Resource *Resource
Handler func(*gorm.DB, *FilterArgument) *gorm.DB
Config FilterConfigInterface
}
'Filter' filter definiation
type FilterArgument ¶
type FilterArgument struct {
Value *resource.MetaValues
Resource *Resource
Context *TM_EC.Context
}
'FilterArgument' filter argument that used in handler
type FilterConfigInterface ¶
type FilterConfigInterface interface {
ConfigureECAdminFilter(*Filter)
}
'FilterConfigInterface' filter config interface
type HasPermissioner ¶
type HasPermissioner interface {
HasPermission(roles.PermissionMode, *TM_EC.Context) bool
}
'HasPermissioner' has permission interface
type Menu ¶
type Menu struct {
Name string
Link string
Ancestors []string
Priority int
Permission *roles.Permission
// contains filtered or unexported fields
}
'Menu' ec admin sidebar menus defination
func (*Menu) GetSubMenus ¶
'GetSubMenus' get submenus for a menu
func (Menu) HasPermission ¶
type Meta ¶
type Meta struct {
Name string
Type string
Label string
FieldName string
Setter func(resource interface{}, metaValue *resource.MetaValue, context *TM_EC.Context)
Valuer func(interface{}, *TM_EC.Context) interface{}
FormattedValuer func(interface{}, *TM_EC.Context) interface{}
Resource *Resource
Permission *roles.Permission
Config MetaConfigInterface
Metas []resource.Metaor
Collection interface{}
resource.Meta
// contains filtered or unexported fields
}
'Meta' meta struct definition
func (*Meta) GetResource ¶
'GetResource' get resource from meta
func (Meta) HasPermission ¶
'HasPermission' check has permission or not
func (*Meta) SetPermission ¶
func (meta *Meta) SetPermission(permission *roles.Permission)
'SetPermission' set meta's permission
type MetaConfigInterface ¶
type MetaConfigInterface interface {
resource.MetaConfigInterface
GetTemplate(context *Context, metaType string) ([]byte, error)
}
'MetaConfigInterface' meta config interface
type Middleware ¶
type Middleware struct {
Name string
Handler func(*Context, *Middleware)
// contains filtered or unexported fields
}
'Middleware' is a way to filert a request and response coming into you application
Register new middleware with `admin.GetRouter().Use(Middleware{
Name: "middleware name", // use middleware with same name will overwrite old one
Handler: func(*Context, *Middleware) {
// do something
// run next middleware
middleware.Next(context)
},
})`
It will be called in order, it need to be registered before `admin.MountTo`
func (Middleware) Next ¶
func (middleware Middleware) Next(context *Context)
'Next' will call the next middleware
type Pagination ¶
'Pagination' is used to hold pagination related information when rendering tables
type PaginationResult ¶
type PaginationResult struct {
Pagination Pagination
Pages []Page
}
type RedactorPlugin ¶
type Resource ¶
type Resource struct {
resource.Resource
Config *Config
Metas []*Meta
Actions []*Action
SearchHandler func(keyword string, context *TM_EC.Context) *gorm.DB
// contains filtered or unexported fields
}
'Resource' is the most important thing for EC admin, every model is defined as resource, EC admin will genetate management interface based on it's definition
func (*Resource) ConvertSectionToMetas ¶
'ConvertSectionToMetas' convert section to metas
func (*Resource) ConvertSectionToStrings ¶
'ConvertSectionToStrings' convert section to strings
func (*Resource) GetMetaOrNew ¶
func (*Resource) GetTheme ¶
func (res *Resource) GetTheme(name string) ThemeInterface
func (*Resource) IndexAttrs ¶
func (Resource) ParamIDName ¶
func (*Resource) SearchAttrs ¶
func (*Resource) SortableAttrs ¶
func (*Resource) UseTheme ¶
func (res *Resource) UseTheme(theme interface{}) []ThemeInterface
type ResourceNamer ¶
type ResourceNamer interface {
ResourceName() string
}
'ResourceNamer' is an interface for models that defined methos 'ResourceName'
type RichEditorConfig ¶
type RichEditorConfig struct {
AssetManager *Resource
Plugins []RedactorPlugin
Settings map[string]interface{}
// contains filtered or unexported fields
}
func (*RichEditorConfig) ConfigureECMeta ¶
func (richEditorConfig *RichEditorConfig) ConfigureECMeta(metaor resource.Metaor)
'ConfigureECMeta' configure rich editor meta
type RouteConfig ¶
type RouteConfig struct {
Resource *Resource
Permissioner HasPermissioner
PermissionMode roles.PermissionMode
Values map[interface{}]interface{}
}
'RouteConfig' config for admin routes
type Router ¶
type Router struct {
Prefix string
// contains filtered or unexported fields
}
'Router' contains registered routers
func (*Router) Delete ¶
func (r *Router) Delete(path string, handle requestHanlder, config ...RouteConfig)
'Delete' register a DELETE request handler with the given path
func (*Router) Get ¶
func (r *Router) Get(path string, handler requestHanlder, config ...RouteConfig)
'Get' register a GET request handler with the given path
func (*Router) Post ¶
func (r *Router) Post(path string, handle requestHanlder, config ...RouteConfig)
'Post' register a POST request handler with the given path
func (*Router) Put ¶
func (r *Router) Put(path string, handle requestHanlder, config ...RouteConfig)
'Put' register a PUT request handler with the given path
func (*Router) Use ¶
func (r *Router) Use(middleware *Middleware)
'Use' register a middleware to the router
type Scope ¶
type Scope struct {
Name string
Label string
Group string
Handle func(*gorm.DB, *TM_EC.Context) *gorm.DB
Default bool
}
'Scope' scope definiation
type Searcher ¶
type Searcher struct {
*Context
Pagination Pagination
// contains filtered or unexported fields
}
'Searcher' is used to search results
func (*Searcher) Filter ¶
func (s *Searcher) Filter(filter *Filter, values *resource.MetaValues) *Searcher
'Filter' filter with defined filters, filter with columns value
type Section ¶
'Section' is used to structure forms, it could gruop your fields into sections, to make your form clear & tidy
type SelectManyConfig ¶
type SelectManyConfig struct {
Collection interface{}
SelectionTemplate string
SelectMode string
Select2ResultTemplate template.JS
Select2SelectionTemplate template.JS
RemoteDataResource *Resource
SelectOneConfig
}
'SelectManyConfig' meta configuration used for select many
func (*SelectManyConfig) ConfigureECMeta ¶
func (selectManyConfig *SelectManyConfig) ConfigureECMeta(metaor resource.Metaor)
'ConfigureECMeta' configure select many meta
func (SelectManyConfig) GetTemplate ¶
func (selectManyConfig SelectManyConfig) GetTemplate(context *Context, metaType string) ([]byte, error)
'GetTemplate' get template for selection template
type SelectOneConfig ¶
type SelectOneConfig struct {
Collection interface{}
AllowBlank bool
SelectionTemplate string
SelectMode string
Select2ResultTemplate template.JS
Select2SelectionTemplate template.JS
RemoteDataResource *Resource
// contains filtered or unexported fields
}
'SelectOneConfig' meta configuration used for select one
func (*SelectOneConfig) ConfigureECAdminFilter ¶
func (selectOneConfig *SelectOneConfig) ConfigureECAdminFilter(filter *Filter)
func (*SelectOneConfig) ConfigureECMeta ¶
func (selectOneConfig *SelectOneConfig) ConfigureECMeta(metaor resource.Metaor)
'ConfigureECMeta' configure select one meta
func (*SelectOneConfig) FilterValue ¶
func (selectOneConfig *SelectOneConfig) FilterValue(filter *Filter, context *Context) interface{}
func (SelectOneConfig) GetCollection ¶
func (selectOneConfig SelectOneConfig) GetCollection(value interface{}, context *Context) [][]string
'GetCollection' get collection s from select on meta
func (SelectOneConfig) GetTemplate ¶
func (selectOneConfig SelectOneConfig) GetTemplate(context *Context, metaType string) ([]byte, error)
'GetTemplate' get template for selection template
type SingleEditConfig ¶
type SingleEditConfig struct {
Template string
// contains filtered or unexported fields
}
'SingleEditConfig' meta configuration used for single edit
func (*SingleEditConfig) ConfigureECMeta ¶
func (singleEditConfig *SingleEditConfig) ConfigureECMeta(metaor resource.Metaor)
'ConfigureECMeta' configure single edit meta
func (SingleEditConfig) GetTemplate ¶
func (singleEditConfig SingleEditConfig) GetTemplate(context *Context, metaType string) ([]byte, error)
'GetTemplate' get template for single edit
type Theme ¶
type Theme struct {
Name string
}
'Theme' base theme config struct
func (Theme) ConfigAdminTheme ¶
'ConfigAdminTheme' config theme for admin resource
func (Theme) GetViewPaths ¶
'GetViewPaths' get view paths from theme
type ThemeInterface ¶
type ThemeInterface interface {
GetName() string
GetViewPaths() []string
ConfigAdminTheme(*Resource)
}
'ThemeInterface' theme interface
Source Files
¶
- action.go
- admin.go
- assetfs.go
- auth.go
- composite_primary_key_callback.go
- config.go
- context.go
- controller.go
- filter.go
- flash.go
- func_map.go
- menu.go
- meta.go
- meta_collection_edit.go
- meta_configors.go
- meta_rich_editor.go
- meta_select_many.go
- meta_select_one.go
- meta_single_edit.go
- resource.go
- route.go
- route_handler.go
- scope.go
- searcher.go
- section.go
- theme.go
- utils.go