Documentation
¶
Index ¶
- Variables
- func ObjectLink(kind, id string) string
- func RegisterRoutes(r modulekit.Mux, c *Controller, admin func(http.Handler) http.Handler)
- func Wire(d modulekit.Deps) modulekit.Parts
- type Controller
- type Entry
- type Filter
- type Hooks
- type Recorder
- type Repo
- func (r *Repo) Add(ctx context.Context, e Entry) error
- func (r *Repo) Count(ctx context.Context, f Filter) (int, error)
- func (r *Repo) List(ctx context.Context, f Filter, limit, offset int) ([]Entry, int, error)
- func (r *Repo) Purge(ctx context.Context, before time.Time) (int, error)
- func (r *Repo) SaveSettings(ctx context.Context, s Settings) error
- func (r *Repo) Settings(ctx context.Context) (Settings, error)
- type Settings
Constants ¶
This section is empty.
Variables ¶
var Assets embed.FS
Assets - the module's templates/ and static/, built into the binary (modules.Assets, paths.SetModuleAssets): a site runs without the module's source directory.
Functions ¶
func ObjectLink ¶
ObjectLink - the address of an object's own log (?kind=&id=).
func RegisterRoutes ¶
RegisterRoutes registers the log and its settings (behind admin; the handlers check the log's permission).
Types ¶
type Controller ¶
type Controller struct {
*modulekit.BaseController
// contains filtered or unexported fields
}
Controller - the log and its settings.
func NewController ¶
func NewController(base *modulekit.BaseController, repo *Repo, recorder *Recorder, types modulekit.ContentTypeService) *Controller
NewController creates a Controller.
func (*Controller) List ¶
func (c *Controller) List(w http.ResponseWriter, r *http.Request)
List renders GET /admin/reports/action-log: the entries the filter (who, the group, the object, the days; a user's or an object's own) shows, newest first.
func (*Controller) Settings ¶
func (c *Controller) Settings(w http.ResponseWriter, r *http.Request)
Settings renders GET /admin/reports/action-log/settings and saves it (POST): how long entries are kept, the addresses, the groups recorded.
type Entry ¶
type Entry struct {
ID int
At time.Time
Type string
Group string
ActorID int
ActorName string
IP string
Object modulekit.ActionObject
Changes []modulekit.ActionChange
}
Entry - a recorded action: when, its type and group, who (ActorID 0 - nobody signed in; ActorName - their name at the time), from where (IP, "" - not kept), what it was done to and what it changed.
type Filter ¶
type Filter struct {
Actor string
ActorID int
Group string
Object string
ObjectKind string
ObjectID string
From, To time.Time
}
Filter - what the log shows: Actor - a part of who's name, ActorID - one user's actions; Group - one group; Object - a part of the object's name, or its ID; ObjectKind and ObjectID - one object (the content's own log); From, To - the days (zero - no limit).
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
Hooks - the log beside what it's about: the "Log" row of a content's form, the log icon of a user in the admin's list.
func (Hooks) NodeSettings ¶
func (h Hooks) NodeSettings() modulekit.NodeSettings
NodeSettings - the "Log" row of a content's form (a link, nothing saved): for an existing content and a user who may see the log.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder keeps the actions the site records (modulekit.OnAction) while the module is on, as its settings say: the groups turned off aren't kept, nor the address unless asked to.
func NewRecorder ¶
NewRecorder creates a Recorder.
func (*Recorder) Purge ¶
Purge deletes the entries older than the settings keep them - the module's background job.
func (*Recorder) Record ¶
func (r *Recorder) Record(ctx context.Context, e modulekit.ActionEvent)
Record keeps the action e (the listener of modulekit.OnAction). Its failure is logged: the action itself is done.
func (*Recorder) SaveSettings ¶
SaveSettings saves the settings.
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo - the module's tables.
func NewRepo ¶
NewRepo creates a Repo on db, in the repositories' dialect. Its client is the database's own, never a transaction's: an action is recorded in the acting request, maybe inside the core's change, and the log's write isn't part of it - failing (on PostgreSQL a failed statement ends the transaction), it would fail the change.
func (*Repo) List ¶
List returns the entries the filter shows, newest first, a page at a time, with how many there are.
func (*Repo) SaveSettings ¶
SaveSettings saves the module's settings.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ent - the action log module's own ent schema (schema/), its generated client (generated/, go generate) and migration files (migrations/<dialect>/, scripts/migrations_gen.sh writes them), apart from the core's: the module's set of migrations (Schema).
|
Package ent - the action log module's own ent schema (schema/), its generated client (generated/, go generate) and migration files (migrations/<dialect>/, scripts/migrations_gen.sh writes them), apart from the core's: the module's set of migrations (Schema). |
|
schema
Package schema - the action log module's own ent schema: the recorded actions and the module's settings.
|
Package schema - the action log module's own ent schema: the recorded actions and the module's settings. |
|
Package manifest declares the action log module (its registry entry): who did what on the site - content deleted, a role's permissions changed, settings saved, sign-ins.
|
Package manifest declares the action log module (its registry entry): who did what on the site - content deleted, a role's permissions changed, settings saved, sign-ins. |