big ole refactor
This commit is contained in:
@@ -17,10 +17,10 @@ import (
|
||||
)
|
||||
|
||||
// AdminAuditLogsPage renders the full admin dashboard page with audit logs section (GET request)
|
||||
func AdminAuditLogsPage(s *hws.Server, conn *bun.DB) http.Handler {
|
||||
func AdminAuditLogsPage(s *hws.Server, conn *db.DB) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
pageOpts := pageOptsFromQuery(s, w, r)
|
||||
if pageOpts == nil {
|
||||
pageOpts, ok := db.GetPageOpts(s, w, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ func AdminAuditLogsPage(s *hws.Server, conn *bun.DB) http.Handler {
|
||||
var actions []string
|
||||
var resourceTypes []string
|
||||
|
||||
if ok := db.WithReadTx(s, w, r, conn, func(ctx context.Context, tx bun.Tx) (bool, error) {
|
||||
if ok := conn.WithReadTx(s, w, r, func(ctx context.Context, tx bun.Tx) (bool, error) {
|
||||
var err error
|
||||
|
||||
// Get filters from query
|
||||
@@ -73,10 +73,10 @@ func AdminAuditLogsPage(s *hws.Server, conn *bun.DB) http.Handler {
|
||||
}
|
||||
|
||||
// AdminAuditLogsList shows the full audit logs list with filters (POST request for HTMX)
|
||||
func AdminAuditLogsList(s *hws.Server, conn *bun.DB) http.Handler {
|
||||
func AdminAuditLogsList(s *hws.Server, conn *db.DB) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
pageOpts := pageOptsFromForm(s, w, r)
|
||||
if pageOpts == nil {
|
||||
pageOpts, ok := db.GetPageOpts(s, w, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ func AdminAuditLogsList(s *hws.Server, conn *bun.DB) http.Handler {
|
||||
var actions []string
|
||||
var resourceTypes []string
|
||||
|
||||
if ok := db.WithReadTx(s, w, r, conn, func(ctx context.Context, tx bun.Tx) (bool, error) {
|
||||
if ok := conn.WithReadTx(s, w, r, func(ctx context.Context, tx bun.Tx) (bool, error) {
|
||||
var err error
|
||||
|
||||
// Get filters from form
|
||||
@@ -129,16 +129,16 @@ func AdminAuditLogsList(s *hws.Server, conn *bun.DB) http.Handler {
|
||||
}
|
||||
|
||||
// AdminAuditLogsFilter returns only the results container (table + pagination) for HTMX updates
|
||||
func AdminAuditLogsFilter(s *hws.Server, conn *bun.DB) http.Handler {
|
||||
func AdminAuditLogsFilter(s *hws.Server, conn *db.DB) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
pageOpts := pageOptsFromForm(s, w, r)
|
||||
if pageOpts == nil {
|
||||
pageOpts, ok := db.GetPageOpts(s, w, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
var logs *db.List[db.AuditLog]
|
||||
|
||||
if ok := db.WithReadTx(s, w, r, conn, func(ctx context.Context, tx bun.Tx) (bool, error) {
|
||||
if ok := conn.WithReadTx(s, w, r, func(ctx context.Context, tx bun.Tx) (bool, error) {
|
||||
var err error
|
||||
|
||||
// Get filters from form
|
||||
@@ -164,7 +164,7 @@ func AdminAuditLogsFilter(s *hws.Server, conn *bun.DB) http.Handler {
|
||||
}
|
||||
|
||||
// AdminAuditLogDetail shows details for a single audit log entry
|
||||
func AdminAuditLogDetail(s *hws.Server, conn *bun.DB) http.Handler {
|
||||
func AdminAuditLogDetail(s *hws.Server, conn *db.DB) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// Get ID from path
|
||||
idStr := r.PathValue("id")
|
||||
@@ -181,7 +181,7 @@ func AdminAuditLogDetail(s *hws.Server, conn *bun.DB) http.Handler {
|
||||
|
||||
var log *db.AuditLog
|
||||
|
||||
if ok := db.WithReadTx(s, w, r, conn, func(ctx context.Context, tx bun.Tx) (bool, error) {
|
||||
if ok := conn.WithReadTx(s, w, r, func(ctx context.Context, tx bun.Tx) (bool, error) {
|
||||
var err error
|
||||
log, err = db.GetAuditLogByID(ctx, tx, id)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user