Documentation ¶
Index ¶
- Constants
- Variables
- func AdminPage(order string, asc bool, offset int, limit int, a interface{}, ...) (err error)
- func All(a interface{}) (err error)
- func ClearDB()
- func Count(a interface{}, query interface{}, args ...interface{}) int
- func Delete(a interface{}) (err error)
- func DeleteList(a interface{}, query interface{}, args ...interface{}) (err error)
- func Filter(a interface{}, query interface{}, args ...interface{}) (err error)
- func FilterBuilder(params map[string]interface{}) (query string, args []interface{})
- func GenerateBase32(length int) string
- func GenerateBase64(length int) string
- func Get(a interface{}, query interface{}, args ...interface{}) (err error)
- func GetDB() *gorm.DB
- func GetID(m reflect.Value) uint
- func GetString(a interface{}) string
- func JSONMarshal(v interface{}, safeEncoding bool) ([]byte, error)
- func Logout(r *http.Request)
- func NewModel(modelName string, pointer bool) (reflect.Value, bool)
- func NewModelArray(modelName string, pointer bool) (reflect.Value, bool)
- func Preload(a interface{}, preload ...string) (err error)
- func Register(m ...interface{})
- func RegisterInlines(model interface{}, fk map[string]string)
- func ReturnJSON(w http.ResponseWriter, r *http.Request, v interface{})
- func Save(a interface{}) (err error)
- func SendEmail(to, cc, bcc []string, subject, body string) (err error)
- func StartSecureServer(certFile, keyFile string)
- func StartServer()
- func Tf(path string, lang string, term string, args ...interface{}) string
- func Trail(level int, msg interface{}, i ...interface{})
- func Translate(raw string, lang string, args ...bool) string
- func Update(a interface{}, fieldName string, value interface{}, query string, ...) (err error)
- func UploadImageHandler(w http.ResponseWriter, r *http.Request, session *Session)
- type Action
- func (a Action) Added() Action
- func (a Action) Custom() Action
- func (a Action) Deleted() Action
- func (a Action) LoginDenied() Action
- func (a Action) LoginSuccessful() Action
- func (a Action) Logout() Action
- func (a Action) Modified() Action
- func (a Action) PasswordResetDenied() Action
- func (a Action) PasswordResetRequest() Action
- func (a Action) PasswordResetSuccessful() Action
- func (a Action) Read() Action
- type Choice
- type DBSettings
- type DashboardMenu
- type F
- type GroupPermission
- type HideInDashboarder
- type Language
- type Log
- func (l *Log) ParseRecord(a reflect.Value, modelName string, ID uint, user *User, action Action, ...) (err error)
- func (l *Log) PasswordReset(user string, action Action, r *http.Request) (err error)
- func (l *Log) Save()
- func (l *Log) SignIn(user string, action Action, r *http.Request) (err error)
- func (l Log) String() string
- type Model
- type ModelSchema
- type Session
- type User
- func (u *User) GetActiveSession() *Session
- func (u *User) GetDashboardMenu() (menus []DashboardMenu)
- func (u *User) GetOTP() string
- func (u *User) HasAccess(modelName string) UserPermission
- func (u *User) Login(pass string, otp string) *Session
- func (u *User) Save()
- func (u User) String() string
- func (u User) Validate() (ret map[string]string)
- func (u *User) VerifyOTP(pass string) bool
- type UserGroup
- type UserPermission
Constants ¶
const ( DEBUG = 0 WORKING = 1 INFO = 2 OK = 3 WARNING = 4 ERROR = 5 )
Reporting Levels
const Version = "0.1.0-rc.1"
Version number as per Semantic Versioning 2.0.0 (semver.org)
Variables ¶
var BindIP = ""
BindIP is the IP the application listens to
var CookieTimeout = -1
CookieTimeout is the timeout of a login cookie in seconds
var CustomTranslation = []string{
"uadmin/system",
}
CustomTranslation !
var DebugDB = false
DebugDB prints all SQL statements going to DB
var EmailFrom string
EmailFrom email from
var EmailPassword string
EmailPassword !
var EmailSMTPServer string
EmailSMTPServer !
var EmailSMTPServerPort int
EmailSMTPServerPort !
var EmailUsername string
EmailUsername !
var EncryptKey = []byte{}
EncryptKey is a key for encyption and decryption of data in the DB
var LogAdd = true
LogAdd adds a log when a record is added
var LogDelete = true
LogDelete adds a log when a record is deleted
var LogEdit = true
LogEdit adds a log when a record is edited
var LogRead = false
LogRead adds a log when a record is read
var MaxImageHeight = 600
MaxImageHeight !
var MaxImageWidth = 800
MaxImageWidth !
var MaxUploadFileSize = int64(25 * 1024 * 1024)
MaxUploadFileSize is the maximum upload file size in bytes
var OTPAlgorithm = "sha1"
OTPAlgorithm is the hashing algorithm of OTP
var OTPDigits = 6
OTPDigits is the number of degits for the OTP
var OTPPeriod = uint(30)
OTPPeriod is the number of seconds for the OTP to change
var OTPSkew = uint(5)
OTPSkew is the number of minutes to search around the OTP
var PageLength = 100
PageLength is the list view max number of records
var Port = 8080
Port is the port used for http or https server
var PublicMedia = false
PublicMedia allows public access to media handler without authentication
var ReportTimeStamp = false
ReportTimeStamp set this to true to hav a time stamp in your logs
var ReportingLevel = DEBUG
ReportingLevel is the standard reporting level
var RootURL = "/"
RootURL is where the listener is mapped to
var Salt = ""
Salt is extra salt added to password hashing
var Schema map[string]ModelSchema
Schema is the gblobal schema of the system
var SiteName = "uAdmin"
SiteName is the name of the website that shows on title and dashboard
var Theme = "default"
Theme is the name of the theme used in uAdmin
Functions ¶
func AdminPage ¶
func AdminPage(order string, asc bool, offset int, limit int, a interface{}, query interface{}, args ...interface{}) (err error)
AdminPage !
func Count ¶
func Count(a interface{}, query interface{}, args ...interface{}) int
Count return the count of records in a table based on a filter
func DeleteList ¶
func DeleteList(a interface{}, query interface{}, args ...interface{}) (err error)
DeleteList !
func Filter ¶
func Filter(a interface{}, query interface{}, args ...interface{}) (err error)
Filter fetches records from the database
func FilterBuilder ¶
FilterBuilder chnages a map filter into a query
func GenerateBase32 ¶
GenerateBase32 generates a base64 string of length length
func GenerateBase64 ¶
GenerateBase64 generates a base64 string of length length
func Get ¶
func Get(a interface{}, query interface{}, args ...interface{}) (err error)
Get fetches the first record from the database
func GetString ¶
func GetString(a interface{}) string
GetString returns string representation on an instance of a model
func JSONMarshal ¶
JSONMarshal Generates JSON format from an object
func NewModelArray ¶
NewModelArray creates a new model from a model name
func RegisterInlines ¶
RegisterInlines is a function to register a model as an inline for another model Parameters: ===========
model (struct instance): Is the model that you want to add inlines to. fk (map[interface{}]string): This is a map of the inlines to be added to the model. The map's key is the name of the model of the inline and the value of the map is the foreign key field's name. Example: ======== type Person struct { uadmin.Model Name string } type Card struct { uadmin.Model PersonID uint Person Person }
func main() { ... uadmin.RegisterInlines(Person{}, map[string]string{ "Card": "PersonID", }) ... }
func ReturnJSON ¶
func ReturnJSON(w http.ResponseWriter, r *http.Request, v interface{})
ReturnJSON returns json to the client
func Tf ¶
Tf is a function for translating strings into any given language Parameters: ===========
path (string): This is where to get the translation from. It is in the format of "GROUPNAME/FILENAME" for example: "uadmin/system" lang (string): Is the language code. If empty string is passed we will use the default language. term (string): The term to translate. args (...interface{}): Is a list of args to fill the term with place holders
func Update ¶
func Update(a interface{}, fieldName string, value interface{}, query string, args ...interface{}) (err error)
Update !
func UploadImageHandler ¶
func UploadImageHandler(w http.ResponseWriter, r *http.Request, session *Session)
UploadImageHandler handles files sent from Tiny MCE's photo uploader
Types ¶
type Action ¶
type Action int
Action !
func (Action) PasswordResetDenied ¶
PasswordResetDenied !
func (Action) PasswordResetRequest ¶
PasswordResetRequest !
func (Action) PasswordResetSuccessful ¶
PasswordResetSuccessful !
type DBSettings ¶
type DBSettings struct { Type string // SQLLite, MySQL Name string // File/DB name User string Password string Host string Port int }
DBSettings !
var Database *DBSettings
Database is the active Database settings
type DashboardMenu ¶
type DashboardMenu struct { Model MenuName string `uadmin:"required;list_exclude;multilingual;filter"` URL string `uadmin:"required"` ToolTip string Icon string `uadmin:"image"` Cat string `uadmin:"filter"` Hidden bool `uadmin:"filter"` }
DashboardMenu !
func (DashboardMenu) String ¶
func (m DashboardMenu) String() string
type F ¶
type F struct { Name string DisplayName string Type string TypeName string Value interface{} Help string Max interface{} Min interface{} Format string DefaultValue string Required bool Pattern string PatternMsg string Hidden bool ReadOnly string Searchable bool Filter bool ListDisplay bool FormDisplay bool CategoricalFilter bool Translations []translation Choices []Choice IsMethod bool ErrMsg string ProgressBar map[float64]string LimitChoicesTo func(interface{}, *User) []Choice UploadTo string Encrypt bool }
F is a field
type GroupPermission ¶
type GroupPermission struct { Model DashboardMenu DashboardMenu `uadmin:"required;filter"` DashboardMenuID uint UserGroup UserGroup `uadmin:"required;filter"` UserGroupID uint Read bool Add bool Edit bool Delete bool }
GroupPermission !
func (GroupPermission) HideInDashboard ¶
func (GroupPermission) HideInDashboard() bool
HideInDashboard to return false and auto hide this from dashboard
func (GroupPermission) String ¶
func (g GroupPermission) String() string
type HideInDashboarder ¶
type HideInDashboarder interface {
HideInDashboard() bool
}
HideInDashboarder used to check if a model should be hidden in dashboard
type Language ¶
type Language struct { Model EnglishName string `uadmin:"required;read_only;filter;search"` Name string `uadmin:"required;read_only;filter;search"` Flag string `uadmin:"image;list_exclude"` Code string `uadmin:"filter;read_only;list_exclude"` RTL bool `uadmin:"list_exclude"` Default bool `uadmin:"help:Set as the default language;list_exclude"` Active bool `uadmin:"help:To show this in available languages;filter"` AvailableInGui bool `uadmin:"help:The App is available in this language;read_only"` }
Language !
type Log ¶
type Log struct { Model Username string `uadmin:"filter;read_only"` Action Action `uadmin:"filter;read_only"` TableName string `uadmin:"filter;read_only"` TableID int `uadmin:"filter;read_only"` Activity string `uadmin:"code;read_only" gorm:"type:longtext"` RollBack string `uadmin:"link;"` CreatedAt time.Time `uadmin:"filter;read_only"` }
Log !
func (*Log) ParseRecord ¶
func (l *Log) ParseRecord(a reflect.Value, modelName string, ID uint, user *User, action Action, r *http.Request) (err error)
ParseRecord !
func (*Log) PasswordReset ¶
PasswordReset !
type Model ¶
Model is the standard struct to be embedded in any other struct to make it a model for uadmin
type ModelSchema ¶
type ModelSchema struct { Name string // Name of the Model DisplayName string // Display Name of the model ModelName string // URL ModelID uint Inlines []*ModelSchema InlinesData []listData Fields []F IncludeFormJS []string IncludeListJS []string FormModifier func(*ModelSchema, interface{}, *User) ListModifier func(*ModelSchema, *User) (string, []interface{}) }
ModelSchema for a form
func (ModelSchema) FieldByName ¶
func (s ModelSchema) FieldByName(a string) *F
FieldByName returns a field from a ModelSchema by name or nil if it doen't exist
type Session ¶
type Session struct { Model Key string User User `uadmin:"filter"` UserID uint LoginTime time.Time LastLogin time.Time Active bool `uadmin:"filter"` IP string `uadmin:"filter"` PendingOTP bool `uadmin:"filter"` ExpiresOn *time.Time }
Session !
func IsAuthenticated ¶
IsAuthenticated returns if the http.Request is authenticated or not
func (Session) HideInDashboard ¶
HideInDashboard to return false and auto hide this from dashboard
type User ¶
type User struct { Model Username string `uadmin:"required;filter"` FirstName string `uadmin:"filter"` LastName string `uadmin:"filter"` Password string `uadmin:"required;password;help:To reset password, clear the field and type a new password.;list_exclude"` Email string `uadmin:"email"` Active bool `uadmin:"filter"` Admin bool `uadmin:"filter"` RemoteAccess bool `uadmin:"filter"` UserGroup UserGroup `uadmin:"filter"` UserGroupID uint Photo string `uadmin:"image"` //Language []Language `gorm:"many2many:user_languages" listExclude:"true"` LastLogin *time.Time `uadmin:"read_only"` ExpiresOn *time.Time OTPRequired bool OTPSeed string `uadmin:"list_exclude;hidden;read_only"` }
User !
func GetUserFromRequest ¶
GetUserFromRequest returns a user from a request
func (*User) GetDashboardMenu ¶
func (u *User) GetDashboardMenu() (menus []DashboardMenu)
GetDashboardMenu !
func (*User) Login ¶
Login Logs in user using password and otp. If there is no OTP, just pass an empty string
type UserGroup ¶
UserGroup !
func (*UserGroup) HasAccess ¶
func (u *UserGroup) HasAccess(modelName string) GroupPermission
HasAccess !
type UserPermission ¶
type UserPermission struct { Model DashboardMenu DashboardMenu `gorm:"ForeignKey:DashboardMenuID" required:"true" filter:"true" uadmin:"filter"` DashboardMenuID uint `fk:"true" displayName:"DashboardMenu"` User User `gorm:"ForeignKey:UserID" required:"true" filter:"true" uadmin:"filter"` UserID uint `fk:"true" displayName:"User"` Read bool `uadmin:"filter"` Add bool `uadmin:"filter"` Edit bool `uadmin:"filter"` Delete bool `uadmin:"filter"` }
UserPermission !
func (UserPermission) HideInDashboard ¶
func (UserPermission) HideInDashboard() bool
HideInDashboard to return false and auto hide this from dashboard
func (UserPermission) String ¶
func (u UserPermission) String() string
Source Files ¶
- 404_handler.go
- admin.go
- api_handler.go
- auth.go
- crop_image_handler.go
- dashboard_menu.go
- data.go
- db.go
- delete_handler.go
- encrypt.go
- export.go
- forgot_password_handler.go
- form_handler.go
- generate_translation.go
- get_display_name.go
- get_form_data.go
- get_list_data.go
- get_schema.go
- global.go
- grouppermission.go
- home_handler.go
- language.go
- list_handler.go
- log.go
- login_handler.go
- logout_handler.go
- main_handler.go
- media_handler.go
- model.go
- new_model.go
- otp.go
- password_reset_handler.go
- process_form.go
- process_upload.go
- profile_handler.go
- register.go
- representation.go
- revert_log_handler.go
- schema.go
- send_email.go
- server.go
- session.go
- trail.go
- translation.go
- upload_image_handler.go
- user.go
- usergroup.go
- userpermission.go
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
uadmin
The MIT License (MIT) Copyright (c) 2018 otiai10 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
The MIT License (MIT) Copyright (c) 2018 otiai10 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
docs
|
|
Package helper is a micro package with helper functions for uAdmin
|
Package helper is a micro package with helper functions for uAdmin |