Documentation
¶
Index ¶
- func Env(envName string, defaultValue string) (value string)
- func H3hash(s string) string
- func JSONBind(c *gin.Context, ret interface{}) bool
- func PackagePath() string
- func PostBind(c *gin.Context, ret interface{}) bool
- func Wait()
- type GroupsList
- type LangQ
- type Menu
- type Module
- type ModuleList
- type ModuleSettings
- type NotifyStruct
- type Panel
- type Rights
- type Settings
- type Simple
- type Users
- func (u *Users) Add(user UsersStruct) error
- func (u *Users) AddFrom(data interface{}) (uint64, error)
- func (u *Users) CacheLength() int
- func (u *Users) Clear(id uint64, login string)
- func (u *Users) Get(id uint64) (user *UsersStruct, exists bool)
- func (u *Users) GetByLogin(login string) (user *UsersStruct, exists bool)
- func (u *Users) GetByLoginTo(login string, user interface{}) (exists bool)
- func (u *Users) GetDummyUser() *UsersStruct
- func (u *Users) GetFromContextTo(c *gin.Context, user interface{}) (exists bool)
- func (u *Users) GetTo(id uint64, user interface{}) (exists bool)
- func (u *Users) Length() int
- func (u *Users) LoadUser(id uint64)
- func (u *Users) Save(user *UsersStruct) error
- func (u *Users) SaveFrom(data interface{}) error
- func (u *Users) Validate(user *UsersStruct) error
- type UsersStruct
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PackagePath ¶
func PackagePath() string
PackagePath returns file path of Summer package location
Types ¶
type GroupsList ¶ added in v1.5.1
GroupsList data struct
func (*GroupsList) Add ¶ added in v1.5.1
func (g *GroupsList) Add(name string, actions ...string)
Add new group
func (*GroupsList) Get ¶ added in v1.5.1
func (g *GroupsList) Get(names ...string) (actions []string)
Get actions by group names
type Menu ¶
type Menu struct {
Title string
Order int
Parent *Menu
Link string
// contains filtered or unexported fields
}
Menu struct
type Module ¶
type Module struct {
*Panel
Collection *mgo.Collection
Settings *ModuleSettings
}
Module struct
func (*Module) GetSettings ¶
func (m *Module) GetSettings() *ModuleSettings
GetSettings needs for correct settings getting from module struct
func (*Module) Websockets ¶
Websockets is default module's websockets method
type ModuleList ¶ added in v1.5.11
ModuleList struct
func (*ModuleList) Get ¶ added in v1.5.11
func (m *ModuleList) Get(name string) (module Simple, exists bool)
Get one module by name
func (*ModuleList) GetList ¶ added in v1.5.11
func (m *ModuleList) GetList() map[string]Simple
GetList returns modules list
type ModuleSettings ¶
type ModuleSettings struct {
Name string // string identifier of module (must be unique)
Title string // visible module name
Menu *Menu // parent menu (panel.MainMenu, panel.DropMenu etc.)
MenuOrder int
MenuTitle string
PageRouteName string // used to build page path: /{Path}/{module.PageRouteName}
AjaxRouteName string // used to build ajax path: /{Path}/ajax/{module.PageRouteName}/*method
SocketsRouteName string // used to build websocket path: /{Path}/websocket/{module.PageRouteName}/*method
CollectionName string // MongoDB collection name
TemplateName string // template in views folder
Icon string // module icon in title
GroupTo Simple // add module like tab to another module
GroupTitle string // tab title
Rights Rights // access rights required to access this page
DisableAuth bool // the page can be viewed for unauthorised visitors
OriginTemplate bool // do not use Footer and Header wraps in template render
RouterGroup *gin.RouterGroup
AjaxRouterGroup *gin.RouterGroup
WsRouterGroup *gin.RouterGroup
// contains filtered or unexported fields
}
ModuleSettings struct
type NotifyStruct ¶ added in v1.5.7
type NotifyStruct struct {
ID uint64 `json:"id" bson:"_id"`
UserID uint64 `json:"userId" bson:"userId"`
Title string `json:"title" bson:"title" binding:"required,min=3"`
Text string `json:"text" bson:"text"`
Created uint `json:"-" bson:"created"`
Updated uint `json:"-" bson:"updated"`
Deleted bool `json:"-" bson:"deleted"`
Demo bool
}
NotifyStruct data struct
type Panel ¶
type Panel struct {
Settings
// RootMenu is zerro-level menu
RootMenu *Menu
// MainMenu is main admin-panel menu
MainMenu *Menu
// DropMenu is top user dropdown menu
DropMenu *Menu
// Groups
Groups *GroupsList
// Modules
Modules *ModuleList
// Users
Users *Users
AI ai.AI
// contains filtered or unexported fields
}
Panel struct
func (*Panel) AddModule ¶
func (panel *Panel) AddModule(settings *ModuleSettings, s Simple) Simple
AddModule provide adding new module to Panel
func (*Panel) AddOpenPage ¶ added in v1.5.12
func (panel *Panel) AddOpenPage(name string, title string, menu *Menu, originTemplate ...bool) Simple
AddOpenPage provide adding simple page without authorization
type Rights ¶ added in v1.5.1
type Rights struct {
Groups []string `form:"groups" json:"groups" bson:"groups"`
Actions []string `form:"actions" json:"actions" bson:"actions"`
}
Rights data struct
type Settings ¶
type Settings struct {
Port uint
Title string
DefaultPage string
AuthSalt string
AuthPrefix string // prefix for cookies names
AuthSkipIP bool // disable using IP as salt for cookie hash generation
Path string // URL path of panel - "/" by default
Views string // file path of ./templates directory
ViewsDoT string // file path of doT.js templates directory
Files string // file path of ./files directory
DBName string // MongoDB database name
UsersCollection string // collection for panel's users
NotifyCollection string // collection for panel's notifications
AICollection string // collection for AUTO_INCREMENT
Debug bool // show `gin` debugging messages
Vars map[string]interface{} // variables, that can be used in templates {{var "variableName"}}
TFuncMap template.FuncMap // `gin` template functions
MakeEngineFn func(*gin.Engine) // Engine make callback
MakeRouterGroupFn func(*gin.RouterGroup) // RouterGroup make callback
FirstStart func() // function called after first user creation
DisableAuth bool // if TRUE - without summer auth
DisableFirstStart bool // if TRUE - without first user creating (FirstStart function don't called)
JS []string // external JS resources
CSS []string // external CSS resources
RouterGroup *gin.RouterGroup
Engine *gin.Engine
HashDBFn func(login, password, authSalt string) string
HashCookieFn func(login, password, authSalt, ip, userAgent string) string
DelayStart bool
}
Settings intended for data transmission into the Create method of package
type Simple ¶
type Simple interface {
Page(c *gin.Context)
Ajax(c *gin.Context)
Websockets(c *gin.Context)
GetSettings() *ModuleSettings
// contains filtered or unexported methods
}
Simple module interface
type Users ¶ added in v1.5.1
Users struct
func (*Users) Add ¶ added in v1.5.11
func (u *Users) Add(user UsersStruct) error
Add new user from struct
func (*Users) CacheLength ¶ added in v1.6.8
CacheLength return len of users array
func (*Users) Get ¶ added in v1.6.1
func (u *Users) Get(id uint64) (user *UsersStruct, exists bool)
Get returns user struct by id
func (*Users) GetByLogin ¶ added in v1.5.11
func (u *Users) GetByLogin(login string) (user *UsersStruct, exists bool)
GetByLogin returns user struct by login
func (*Users) GetByLoginTo ¶ added in v1.6.15
GetByLoginTo returns user data by login
func (*Users) GetDummyUser ¶ added in v1.6.8
func (u *Users) GetDummyUser() *UsersStruct
GetDummyUser returns empty user
func (*Users) GetFromContextTo ¶ added in v1.6.15
GetFromContextTo returns user from context
func (*Users) Validate ¶ added in v1.6.8
func (u *Users) Validate(user *UsersStruct) error
Validate user data
type UsersStruct ¶
type UsersStruct struct {
ID uint64 `form:"id" json:"id" bson:"_id"`
Login string `form:"login" json:"login" bson:"login" valid:"required,min(3)"`
Name string `form:"name" json:"name" bson:"name" valid:"max(200)"`
Notice string `form:"notice" json:"notice" bson:"notice" valid:"max(1000)"`
// Is Root-user? Similar as Rights.Groups = ["root"]
Root bool `form:"-" json:"-" bson:"root"`
// Information field, if needs auth by email set Login == Email
Email string `form:"email" json:"email" bson:"email" valid:"email"`
// sha512 hash of password (but from form can be received string password value)
Password string `form:"password" json:"-" bson:"password" valid:"min(5)"`
// from form can be received string password value)
Password2 string `form:"password2" json:"-" bson:"password2"`
// Default user language (Information field)
Lang string `form:"lang" json:"lang" bson:"lang" valid:"max(3)"`
// Times of creating or editing (or loading from mongoDB)
Created int64 `form:"-" json:"created" bson:"created"`
Updated int64 `form:"-" json:"updated" bson:"updated"`
Loaded int64 `form:"-" json:"-" bson:"-"`
// Fields for users auth limitation
Disabled bool `form:"-" json:"disabled" bson:"disabled"`
Deleted bool `form:"-" json:"deleted" bson:"deleted"`
// User access rights (summer.Rights)
Rights Rights `json:"rights" bson:"rights"`
// IP control fields (coming soon)
LastIP uint32 `form:"-" json:"lastIP" bson:"lastIP"`
IP uint32 `form:"-" json:"-" bson:"ip"`
StringIP string `form:"-" json:"ip" bson:"-"`
// custom data map
Settings map[string]interface{} `form:"-" json:"settings" bson:"settings"`
// user without authentication
Demo bool `form:"-" json:"demo" bson:"-"`
}
UsersStruct data struct

