activity

package module
v0.0.0-...-1901d52 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2019 License: MIT Imports: 12 Imported by: 0

README

Activity

Activity is dependant on QOR Admin. It provides QOR Admin with an activity tracking feature for any Resource.

Applying Activity to a Resource will add Comment and Track data/state changes within the QOR Admin interface.

GoDoc

Usage

import "github.com/kisrobot/admin"

func main() {
  Admin := admin.New(&qor.Config{DB: db})
  order := Admin.AddResource(&models.Order{})

  // Register Activity for Order resource
  activity.Register(order)
}

The above code snippet will add an activity tracking feature to the Order resource in a hypothetical project, which would look a bit like the screenshot below in QOR Admin:

License

Released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateActivity

func CreateActivity(context *admin.Context, activity *QorActivity, result interface{}) error

CreateActivity creates an activity for this context

func GetActivitiesCount

func GetActivitiesCount(context *admin.Context, result interface{}, types ...string) int

GetActivitiesCount get activities's count for selected types

func Register

func Register(res *admin.Resource)

Register register activity feature for an qor resource

Types

type QorActivity

type QorActivity struct {
	gorm.Model
	Action       string
	Content      string `sql:"size:5000"`
	Note         string `sql:"size:2000"`
	Type         string
	ResourceType string
	ResourceID   string
	CreatorName  string
	audited.AuditedModel
}

QorActivity default model used to save resource's activities

func GetActivities

func GetActivities(context *admin.Context, result interface{}, types ...string) ([]QorActivity, error)

GetActivities get activities for selected types

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL