admin page updates
This commit is contained in:
@@ -69,6 +69,34 @@ func (a *AuditLogFilter) Result(result string) *AuditLogFilter {
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *AuditLogFilter) UserIDs(ids []int) *AuditLogFilter {
|
||||
if len(ids) > 0 {
|
||||
a.In("al.user_id", ids)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *AuditLogFilter) Actions(actions []string) *AuditLogFilter {
|
||||
if len(actions) > 0 {
|
||||
a.In("al.action", actions)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *AuditLogFilter) ResourceTypes(resourceTypes []string) *AuditLogFilter {
|
||||
if len(resourceTypes) > 0 {
|
||||
a.In("al.resource_type", resourceTypes)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *AuditLogFilter) Results(results []string) *AuditLogFilter {
|
||||
if len(results) > 0 {
|
||||
a.In("al.result", results)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *AuditLogFilter) DateRange(start, end int64) *AuditLogFilter {
|
||||
if start > 0 {
|
||||
a.GreaterEqualThan("al.created_at", start)
|
||||
@@ -83,7 +111,7 @@ func (a *AuditLogFilter) DateRange(start, end int64) *AuditLogFilter {
|
||||
func GetAuditLogs(ctx context.Context, tx bun.Tx, pageOpts *PageOpts, filters *AuditLogFilter) (*List[AuditLog], error) {
|
||||
defaultPageOpts := &PageOpts{
|
||||
Page: 1,
|
||||
PerPage: 15,
|
||||
PerPage: 10,
|
||||
Order: bun.OrderDesc,
|
||||
OrderBy: "created_at",
|
||||
}
|
||||
@@ -119,7 +147,7 @@ func GetAuditLogByID(ctx context.Context, tx bun.Tx, id int) (*AuditLog, error)
|
||||
if id <= 0 {
|
||||
return nil, errors.New("id must be positive")
|
||||
}
|
||||
return GetByID[AuditLog](tx, id).Relation("User").Get(ctx)
|
||||
return GetByField[AuditLog](tx, "al.id", id).Relation("User").Get(ctx)
|
||||
}
|
||||
|
||||
// GetUniqueActions retrieves a list of all unique actions in the audit log
|
||||
|
||||
Reference in New Issue
Block a user