Documentation
¶
Index ¶
- func AttendedThisWeekStudentIDs(gdb *gorm.DB, courseID uint, weekStart, endOfDay time.Time) map[uint]bool
- func BuildJobsServiceError(err error) (string, string)
- func BuildStatsServiceError(err error) (string, string)
- func LoadBuildJob(client *grading.Client, id string) (grading.Job, string)
- func LoadTutorPanelData(gdb *gorm.DB, courseID string) ([]db.Tutor, map[uint]int64, error)
- func MethodBadgeClass(method string) string
- func ResolveTutorID(tutors []db.Tutor, requested string) (uint, bool)
- func TutorGroupsFragmentURL(c db.Course, query string) string
- func TutorGroupsQuery(p TutorGroupsParams, extra map[string]string) string
- func WarningsCount(ws []config.ConfigWarning, severities ...string) int
- func WeekStartOfDay(startOfDay time.Time) time.Time
- type DashHealthData
- type DashboardCourse
- type DashboardData
- type DashboardDeadline
- type ForgejoErrorSource
- type ForgejoErrorStats
- type Handler
- func (h *Handler) AccountAPIKeyCreate(c *echo.Context) error
- func (h *Handler) AccountAPIKeyDelete(c *echo.Context) error
- func (h *Handler) AdminAPIKeyDelete(c *echo.Context) error
- func (h *Handler) AttendanceAddRowFragmentHandler(c *echo.Context) error
- func (h *Handler) AttendanceAddSearchFragmentHandler(c *echo.Context) error
- func (h *Handler) AttendanceManageFragmentHandler(c *echo.Context) error
- func (h *Handler) AttendanceToggleFragmentHandler(c *echo.Context) error
- func (h *Handler) AuditLogDetailFragmentHandler(c *echo.Context) error
- func (h *Handler) AuditLogFragmentHandler(c *echo.Context) error
- func (h *Handler) BuildJobDetailFragmentHandler(c *echo.Context) error
- func (h *Handler) BuildJobsFragmentHandler(c *echo.Context) error
- func (h *Handler) BuildStatsFragmentHandler(c *echo.Context) error
- func (h *Handler) CourseAccessFormHandler(c *echo.Context) error
- func (h *Handler) CourseAccessGrantHandler(c *echo.Context) error
- func (h *Handler) CourseAccessRevokeHandler(c *echo.Context) error
- func (h *Handler) CourseArchiveHandler(c *echo.Context) error
- func (h *Handler) CourseCreateHandler(c *echo.Context) error
- func (h *Handler) CourseDeleteHandler(c *echo.Context) error
- func (h *Handler) CourseEditFormHandler(c *echo.Context) error
- func (h *Handler) CourseNewFormHandler(c *echo.Context) error
- func (h *Handler) CoursePermanentDeleteFormHandler(c *echo.Context) error
- func (h *Handler) CoursePermanentDeleteHandler(c *echo.Context) error
- func (h *Handler) CourseReposAddHandler(c *echo.Context) error
- func (h *Handler) CourseReposRemoveHandler(c *echo.Context) error
- func (h *Handler) CourseRestoreFormHandler(c *echo.Context) error
- func (h *Handler) CourseRestoreHandler(c *echo.Context) error
- func (h *Handler) CourseUpdateHandler(c *echo.Context) error
- func (h *Handler) CoursesFragmentHandler(c *echo.Context) error
- func (h *Handler) DashHealthRunAllHandler(c *echo.Context) error
- func (h *Handler) DashSystemFragmentHandler(c *echo.Context) error
- func (h *Handler) DashWarningsFragmentHandler(c *echo.Context) error
- func (h *Handler) ExerciseCreateHandler(c *echo.Context) error
- func (h *Handler) ExerciseDeleteFormHandler(c *echo.Context) error
- func (h *Handler) ExerciseDeleteHandler(c *echo.Context) error
- func (h *Handler) ExerciseEditFormHandler(c *echo.Context) error
- func (h *Handler) ExerciseNewFormHandler(c *echo.Context) error
- func (h *Handler) ExerciseUpdateHandler(c *echo.Context) error
- func (h *Handler) ExercisesAllFragmentHandler(c *echo.Context) error
- func (h *Handler) ExercisesFragmentHandler(c *echo.Context) error
- func (h *Handler) ForgejoRequestDetailFragmentHandler(c *echo.Context) error
- func (h *Handler) ForgejoRequestsFragmentHandler(c *echo.Context) error
- func (h *Handler) HTTPRequestDetailFragmentHandler(c *echo.Context) error
- func (h *Handler) HTTPRequestsFragmentHandler(c *echo.Context) error
- func (h *Handler) HealthCheckRunHandler(c *echo.Context) error
- func (h *Handler) HealthChecksFragmentHandler(c *echo.Context) error
- func (h *Handler) HealthErrorsFragmentHandler(c *echo.Context) error
- func (h *Handler) HealthResourcesFragmentHandler(c *echo.Context) error
- func (h *Handler) HealthRunAllHandler(c *echo.Context) error
- func (h *Handler) HealthScheduledTasksFragmentHandler(c *echo.Context) error
- func (h *Handler) OrphanOrgsConfirmHandler(c *echo.Context) error
- func (h *Handler) OrphanOrgsForceDeleteHandler(c *echo.Context) error
- func (h *Handler) OrphanOrgsFragmentHandler(c *echo.Context) error
- func (h *Handler) SettingsBodyHandler(c *echo.Context) error
- func (h *Handler) SettingsSaveHandler(c *echo.Context) error
- func (h *Handler) StudentRemoveHandler(c *echo.Context) error
- func (h *Handler) StudentsFormHandler(c *echo.Context) error
- func (h *Handler) TaskRunHandler(c *echo.Context) error
- func (h *Handler) TasksFragmentHandler(c *echo.Context) error
- func (h *Handler) TutorAddTutorModalFragmentHandler(c *echo.Context) error
- func (h *Handler) TutorAssignHandler(c *echo.Context) error
- func (h *Handler) TutorAssignStudentsHandler(c *echo.Context) error
- func (h *Handler) TutorAssignmentFragmentHandler(c *echo.Context) error
- func (h *Handler) TutorAutoDistributeHandler(c *echo.Context) error
- func (h *Handler) TutorPanelFragmentHandler(c *echo.Context) error
- func (h *Handler) TutorUnassignHandler(c *echo.Context) error
- func (h *Handler) UserDeleteSessionsFragmentHandler(c *echo.Context) error
- func (h *Handler) UserDetailFragmentHandler(c *echo.Context) error
- func (h *Handler) UserDisplayNameFragmentHandler(c *echo.Context) error
- func (h *Handler) UserRoleFragmentHandler(c *echo.Context) error
- func (h *Handler) UserSearchHandler(c *echo.Context) error
- func (h *Handler) UsersFragmentHandler(c *echo.Context) error
- type HealthPageData
- type HealthSystemData
- type OrphanOrgRow
- type StaffDashboardData
- type TutorGroupsData
- type TutorGroupsParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttendedThisWeekStudentIDs ¶
func AttendedThisWeekStudentIDs(gdb *gorm.DB, courseID uint, weekStart, endOfDay time.Time) map[uint]bool
AttendedThisWeekStudentIDs returns the student IDs with a participation record in the course between weekStart and endOfDay, regardless of which tutor logged it. One bulk query; used to render the weekly cap in the attendance lists.
func BuildJobsServiceError ¶
BuildJobsServiceError returns the card title and message for a build jobs query failure. A missing service is reported as not configured; anything else is reported as unreachable. Shared by the page and fragment handlers.
func BuildStatsServiceError ¶
BuildStatsServiceError returns the card title and message for a build stats query failure, mirroring BuildJobsServiceError.
func LoadBuildJob ¶
LoadBuildJob fetches one build job for the staff detail page and the builds overview modal. A non-empty reason describes why the job is unavailable: no id, no configured client, not found, or unreachable. Both entry points share this helper so they render the same notice for the same failure.
func LoadTutorPanelData ¶
LoadTutorPanelData loads the course's tutors (users preloaded) and the per-tutor student counts used by the tutor panel. Exported so the page handler can reuse it for the initial server-side render.
func MethodBadgeClass ¶
MethodBadgeClass maps an HTTP method to a daisyUI badge colour.
func ResolveTutorID ¶
ResolveTutorID returns the selected tutor ID: the requested one when it belongs to the course, otherwise the first tutor by id. ok is false when the course has no tutors.
func TutorGroupsFragmentURL ¶
TutorGroupsFragmentURL returns the main fragment URL plus the given groups-tab query string.
func TutorGroupsQuery ¶
func TutorGroupsQuery(p TutorGroupsParams, extra map[string]string) string
TutorGroupsQuery builds the query string for groups-tab fragment requests: tab, selected tutor, both searches, and both page numbers. Empty searches are omitted so URLs stay short. extra adds or overrides single params.
func WarningsCount ¶
func WarningsCount(ws []config.ConfigWarning, severities ...string) int
WarningsCount counts the warnings whose severity is in the given list. Used to count only warning and error severities, excluding info.
Types ¶
type DashHealthData ¶
type DashHealthData struct {
Summary health.Summary
Checks []health.Result
LastSweep time.Time
Beszel *health.BeszelSnapshot
Errors24h ForgejoErrorStats
Warnings []config.ConfigWarning
ActiveWarnings int
HasData bool
}
DashHealthData carries the health-check snapshot, Beszel metrics and Forgejo error stats for the dashboard system panel. Every field stays empty when health is not configured or has not run yet. Warnings is the merged list of config and runtime warnings, activeWarnings counts only the warning and error severities.
type DashboardCourse ¶
type DashboardCourse struct {
ID uint
Name string
Semester string
AllowJoin bool
StudentCount int64
}
DashboardCourse is one course row shown on a dashboard, with its student count.
type DashboardData ¶
type DashboardData struct {
Stats api.StatsResponse
Config *config.Config
Now time.Time
CurrentSemester string
Deadlines []DashboardDeadline
UngradedCount int64
CurrentCourses []DashboardCourse
Health DashHealthData
}
DashboardData holds everything the admin dashboard renders: the aggregate stats, config-based health info, upcoming deadlines, the grading backlog and the courses of the current semester.
func LoadDashboardData ¶
func LoadDashboardData(gdb *gorm.DB, stats api.StatsResponse, cfg *config.Config, healthRunner *health.Runner) DashboardData
LoadDashboardData assembles the admin dashboard data. Stats are computed by the caller (api.ComputeStats) so this loader only touches the database for the dashboard-specific queries. The health argument may be nil.
type DashboardDeadline ¶
type DashboardDeadline struct {
ExerciseID uint
ExerciseName string
CourseID uint
CourseName string
CourseSemester string
End time.Time
}
DashboardDeadline is one exercise deadline shown on a dashboard, with its course for context.
type ForgejoErrorSource ¶
ForgejoErrorSource is one call-site label with its error count.
type ForgejoErrorStats ¶
type ForgejoErrorStats struct {
Window string
Total int64
ServerErrors int64
NetworkErrors int64
TopSources []ForgejoErrorSource
}
ForgejoErrorStats aggregates Forgejo request outcomes over a time window.
func LoadForgejoErrorStats ¶
LoadForgejoErrorStats aggregates error counts for the forgejo_requests rows created within the given window ending at now. ServerErrors counts status codes >= 500, NetworkErrors counts rows with a transport error, and TopSources is the per-source error count, worst three first.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves HTML fragments for htmx-driven page sections. Each method returns a templ component rendered as HTML, not a full page, just the swap target. Routes are registered under /admin/fragments.
func NewHandler ¶
func (*Handler) AttendanceAddRowFragmentHandler ¶
AttendanceAddRowFragmentHandler returns the attendance row for one student of the course so the tutor can mark them present. The row uses the guest flow: only the acting tutor's own participation row is read or modified, and an empty replacement of the search results is sent out-of-band so the same student cannot be added twice. When the student already attended the course this week with any tutor, the row is rendered with the cap badge and a disabled present button, so adding it is a no-op. Students of the tutor's own group are rejected because they are already listed.
func (*Handler) AttendanceAddSearchFragmentHandler ¶
AttendanceAddSearchFragmentHandler returns the candidate list for the "add student" search on the manual attendance page. It matches students of the course by display name or short name (preferred_username) and excludes students already listed or already capped: the tutor's own group, and students who already attended the course this week with any tutor.
func (*Handler) AttendanceManageFragmentHandler ¶
AttendanceManageFragmentHandler returns the attendance management body (search + student table) for htmx swap. Only students assigned to the calling tutor are shown.
func (*Handler) AttendanceToggleFragmentHandler ¶
AttendanceToggleFragmentHandler handles POST /admin/fragments/attendance/toggle. Toggles a student's attendance or presented status for today. Returns the updated row HTML. Lookups and mutations are scoped to the acting tutor, so a participation row created by another tutor is never modified. A student can attend at most one tutorial per week per course regardless of tutor: before creating a new row, the handler checks for any participation of that student in the current week (Monday based) and refuses with a re-rendered row when one exists.
func (*Handler) AuditLogDetailFragmentHandler ¶
AuditLogDetailFragmentHandler returns the modal body for a single audit log entry.
func (*Handler) AuditLogFragmentHandler ¶
AuditLogFragmentHandler returns the #audit-log-table fragment for htmx swap.
func (*Handler) BuildJobDetailFragmentHandler ¶
BuildJobDetailFragmentHandler returns the modal body for a single build job. The Detail button in the builds table loads it into #build_job_detail_body and opens the dialog. Failures render the unavailable notice with status 200 so the modal shows the reason instead of an empty body or a failed htmx swap.
func (*Handler) BuildJobsFragmentHandler ¶
BuildJobsFragmentHandler returns the #builds-body fragment for htmx swap. Invalid filter values render an inline error in the table region with status 200 so htmx swaps it in; a missing or unreachable build service renders the warning card instead of an error, so the page stays navigable.
func (*Handler) BuildStatsFragmentHandler ¶
BuildStatsFragmentHandler returns the #build-stats-body fragment for htmx swap. Invalid filter values render an inline error with status 200 so htmx swaps it in; a missing or unreachable build service renders the warning card instead of an error. The stats query covers every job matching the filters.
func (*Handler) CourseAccessFormHandler ¶
CourseAccessFormHandler handles GET /admin/fragments/courses/:id/access. Returns the course access modal body for the course.
func (*Handler) CourseAccessGrantHandler ¶
CourseAccessGrantHandler handles POST /admin/fragments/courses/:id/access. Gives the selected staff user access to the course; the Forgejo hook adds the user to the course tutors team. Idempotent: re-granting an existing pair is a no-op that still re-renders the modal body. Returns the refreshed modal body.
func (*Handler) CourseAccessRevokeHandler ¶
CourseAccessRevokeHandler handles DELETE /admin/fragments/courses/:id/access/:userID. Removes a course access grant. A missing grant is reported as 404. Returns the refreshed modal body.
func (*Handler) CourseArchiveHandler ¶
CourseArchiveHandler returns the archive-course confirmation modal body.
func (*Handler) CourseCreateHandler ¶
CourseCreateHandler handles POST /admin/fragments/courses/new. Validates, creates the course, records audit, and returns the create form again (reset to empty) so the modal is ready for the next create. Fires course-saved so the table refreshes. On validation failure returns the form with errors populated and HTTP 422.
func (*Handler) CourseDeleteHandler ¶
CourseDeleteHandler handles DELETE .../. Archives (soft-deletes) the course, fires course-saved, returns the refreshed table.
func (*Handler) CourseEditFormHandler ¶
CourseEditFormHandler returns an edit-course form modal body, pre-filled with the course's current values.
func (*Handler) CourseNewFormHandler ¶
CourseNewFormHandler returns an empty create-course form modal body.
func (*Handler) CoursePermanentDeleteFormHandler ¶
CoursePermanentDeleteFormHandler returns the permanent-delete confirmation modal body.
func (*Handler) CoursePermanentDeleteHandler ¶
CoursePermanentDeleteHandler handles DELETE .../permanent. Hard-deletes an already-archived course. Requires the confirm form field to match the course label. Fires course-saved, returns the refreshed table.
func (*Handler) CourseReposAddHandler ¶
CourseReposAddHandler handles POST .../settings/course_repos/add. Parses the current form, appends an empty spec, re-renders the form.
func (*Handler) CourseReposRemoveHandler ¶
CourseReposRemoveHandler handles POST .../settings/course_repos/remove. Parses the current form, removes the spec at remove_index, re-renders.
func (*Handler) CourseRestoreFormHandler ¶
CourseRestoreFormHandler returns the restore-course confirmation modal body.
func (*Handler) CourseRestoreHandler ¶
CourseRestoreHandler handles POST .../restore. Restores the course, fires course-saved, returns the refreshed table.
func (*Handler) CourseUpdateHandler ¶
CourseUpdateHandler handles PUT /admin/fragments/courses/:id/edit. Validates, updates, records audit, returns the edit form refreshed. Fires course-saved so the table refreshes.
func (*Handler) CoursesFragmentHandler ¶
CoursesFragmentHandler returns the #courses-table fragment for htmx swap. Triggered by filter changes, pagination, and the course-saved event. Staff see only the courses they own; admins see all.
func (*Handler) DashHealthRunAllHandler ¶
DashHealthRunAllHandler runs every health check and returns the refreshed system panel. Fires HX-Trigger:dash-health-refresh so any sibling listeners pick up fresh data too.
func (*Handler) DashSystemFragmentHandler ¶
DashSystemFragmentHandler returns the refreshed dashboard system panel. Triggered by the 60s panel poll, the dash-health-refresh event, and the panel's own refresh button.
func (*Handler) DashWarningsFragmentHandler ¶
DashWarningsFragmentHandler returns the refreshed warnings banner at the top of the admin dashboard. Triggered by the 60s banner poll and the dash-health-refresh event fired by the system panel's run-all button. Renders an empty swap when there are no active warnings.
func (*Handler) ExerciseCreateHandler ¶
ExerciseCreateHandler handles POST /admin/fragments/courses/:id/exercises/new.
func (*Handler) ExerciseDeleteFormHandler ¶
ExerciseDeleteFormHandler returns the delete confirmation modal body.
func (*Handler) ExerciseDeleteHandler ¶
ExerciseDeleteHandler handles DELETE /admin/fragments/exercises/:eid.
func (*Handler) ExerciseEditFormHandler ¶
ExerciseEditFormHandler returns a pre-filled edit-exercise form modal body.
func (*Handler) ExerciseNewFormHandler ¶
ExerciseNewFormHandler returns an empty create-exercise form modal body.
func (*Handler) ExerciseUpdateHandler ¶
ExerciseUpdateHandler handles PUT /admin/fragments/exercises/:eid/edit.
func (*Handler) ExercisesAllFragmentHandler ¶
ExercisesAllFragmentHandler returns the #exercises-all-table fragment (rows + pagination + empty state) for htmx swap. Triggered by filter changes and pagination. Staff see only exercises in courses they own; admins see all.
func (*Handler) ExercisesFragmentHandler ¶
ExercisesFragmentHandler returns the #exercises-tree fragment for htmx swap.
func (*Handler) ForgejoRequestDetailFragmentHandler ¶
ForgejoRequestDetailFragmentHandler returns the modal body for a single Forgejo request entry.
func (*Handler) ForgejoRequestsFragmentHandler ¶
ForgejoRequestsFragmentHandler returns the #forgejo-requests-table fragment.
func (*Handler) HTTPRequestDetailFragmentHandler ¶
HTTPRequestDetailFragmentHandler returns the modal body for a single inbound request entry.
func (*Handler) HTTPRequestsFragmentHandler ¶
HTTPRequestsFragmentHandler returns the #http-requests-body fragment: the chart card plus the request table, so filtering and pagination refresh both together.
func (*Handler) HealthCheckRunHandler ¶
HealthCheckRunHandler runs one health check by name and returns the refreshed table. Fires HX-Trigger:health-refresh so the Beszel and error cards pick up fresh data too.
func (*Handler) HealthChecksFragmentHandler ¶
HealthChecksFragmentHandler returns the #health-checks table fragment. Triggered by the 30s poll and the health-refresh event.
func (*Handler) HealthErrorsFragmentHandler ¶
HealthErrorsFragmentHandler returns the Forgejo error stats card content wrapper.
func (*Handler) HealthResourcesFragmentHandler ¶
HealthResourcesFragmentHandler returns the Beszel card content wrapper. The wrapper itself carries the poll attributes, so it swaps itself out.
func (*Handler) HealthRunAllHandler ¶
HealthRunAllHandler runs every health check and returns the refreshed table. Fires HX-Trigger:health-refresh like the single-check run.
func (*Handler) HealthScheduledTasksFragmentHandler ¶
HealthScheduledTasksFragmentHandler returns the scheduled task card.
func (*Handler) OrphanOrgsConfirmHandler ¶
OrphanOrgsConfirmHandler returns the force-delete confirmation modal body for the orgs selected via the checkboxes. Rejects protected orgs.
func (*Handler) OrphanOrgsForceDeleteHandler ¶
OrphanOrgsForceDeleteHandler handles the confirmed force delete. Re-reads the current classification from the database so protected orgs cannot be deleted by a stale or hand-crafted form submission, runs the repo-then-org deletion for each selected org, records an audit entry, and returns the refreshed table with a per-org result summary.
func (*Handler) OrphanOrgsFragmentHandler ¶
OrphanOrgsFragmentHandler returns the orphan orgs table fragment.
func (*Handler) SettingsBodyHandler ¶
SettingsBodyHandler returns the settings page body with current setting values loaded.
func (*Handler) SettingsSaveHandler ¶
SettingsSaveHandler handles PUT /admin/fragments/settings/:key. Saves the setting value, records audit, and returns the refreshed settings body.
func (*Handler) StudentRemoveHandler ¶
StudentRemoveHandler handles DELETE .../students/:userID. Removes the student, returns the refreshed students modal body.
func (*Handler) StudentsFormHandler ¶
StudentsFormHandler returns the students modal body for a course.
func (*Handler) TaskRunHandler ¶
TaskRunHandler starts a task and returns the refreshed table.
func (*Handler) TasksFragmentHandler ¶
TasksFragmentHandler returns the unified tasks table fragment.
func (*Handler) TutorAddTutorModalFragmentHandler ¶
TutorAddTutorModalFragmentHandler returns the add-tutor modal body (the user filter form plus the initially empty results list) for htmx swap into the modal shell's body div. Triggered by the Add tutor button in the tutors tab.
func (*Handler) TutorAssignHandler ¶
TutorAssignHandler handles POST /admin/fragments/courses/:id/tutors with user_id. Assigns the user as tutor and returns the refreshed user list (the normal swap target inside the add-tutor modal, with a success or error message) plus, out-of-band, the tutor list behind the modal re-rendered so the newly added tutor shows up there. Duplicates are tolerated (the tutor is already assigned).
func (*Handler) TutorAssignStudentsHandler ¶
TutorAssignStudentsHandler handles POST /admin/fragments/courses/:id/tutor-assignment/assign. Form values: user_id (single user id, optional) or repeated student values (checkbox list, optional; user_id wins if both are present), plus the tutor target: bulk_tutor_id (bulk bar select) or row_tutor_id (per-row select) when the body carries target=students from the students table, otherwise tutor_id ("none" clears the assignment). The students-table UI names its selects differently from the tutor_id filter field that the filter form also sends, so the two never collide. Assigns or clears the tutor for the listed students and re-renders the main fragment with a success or error alert.
func (*Handler) TutorAssignmentFragmentHandler ¶
TutorAssignmentFragmentHandler returns the main tutor-assignment fragment (tutor panel + tab bar + active tab content) for htmx swap. Triggered by tab switches and after mutations that re-render the whole view. Staff see only courses they own (enforced via manageCourseGuard).
When the request targets only the students table (filter form and pagination swap #students-table), only the table fragment is returned so the filter inputs keep focus and text while typing or paging.
func (*Handler) TutorAutoDistributeHandler ¶
TutorAutoDistributeHandler handles POST /admin/fragments/courses/:id/tutor-assignment/auto-distribute. Distributes the unassigned students across the course's tutors and re-renders the main fragment with a success or error alert.
func (*Handler) TutorPanelFragmentHandler ¶
TutorPanelFragmentHandler returns the tutor list fragment (TutorPanelList inside #tutors-panel) for htmx swap.
func (*Handler) TutorUnassignHandler ¶
TutorUnassignHandler handles DELETE /admin/fragments/courses/:id/tutors/:userID. In one transaction the tutor's students are unassigned (tutor_id set to NULL) before the tutor row is deleted, mirroring the API layer. Returns the refreshed tutor list.
func (*Handler) UserDeleteSessionsFragmentHandler ¶
UserDeleteSessionsFragmentHandler handles the "Force logout" button in the detail modal: deletes OIDC sessions, records audit, returns the refreshed modal body. Fires HX-Trigger:user-updated so the table re-fetches.
func (*Handler) UserDetailFragmentHandler ¶
UserDetailFragmentHandler returns the modal body for a single user. The eye button in the table loads this into #user_detail_body and opens the dialog.
func (*Handler) UserDisplayNameFragmentHandler ¶
UserDisplayNameFragmentHandler handles the display-name input in the detail modal: validates the submitted value, stores it in users.name, records audit, syncs the Forgejo full name, and returns the refreshed modal body. The IdP-provided users.oidc_name is never written here. An empty value clears the display name so rendering falls back to the IdP name.
func (*Handler) UserRoleFragmentHandler ¶
UserRoleFragmentHandler handles the role <select> in the detail modal: updates the user's global role, records audit, returns the refreshed modal body. Fires HX-Trigger:user-updated so the table re-fetches. Rejects unknown role values.
func (*Handler) UserSearchHandler ¶
UserSearchHandler returns the add-tutor modal's user list (filtered, paginated add-candidate list) for htmx swap. Triggered by the filter form's keyup/submit. Renders results only when at least one filter is non-empty; otherwise the hint text. Excludes users who are already tutors of the queried course (course_id query param).
func (*Handler) UsersFragmentHandler ¶
UsersFragmentHandler returns the #users-table fragment (rows + pagination + empty state) for htmx swap. Triggered by filter changes, pagination, and the user-updated event (after a mutation in the detail modal).
type HealthPageData ¶
type HealthPageData struct {
Checks []health.Result
Summary health.Summary
Beszel *health.BeszelSnapshot
BeszelConfigured bool
System HealthSystemData
Config *config.Config
Warnings []config.ConfigWarning
InternalKeyUses map[string]time.Time
ScheduledTasks []tasks.Snapshot
Errors1h ForgejoErrorStats
Errors24h ForgejoErrorStats
}
HealthPageData holds everything the admin health page renders. The page handler assembles it once; the fragments re-fetch their own slices on each htmx poll.
type HealthSystemData ¶
type HealthSystemData struct {
GoVersion string
UptimeSec int64
ServerTime time.Time
Timezone string
DBHost string
DBPort string
DBName string
AdminEmail string
OIDCIssuer string
OIDCRedirect string
ForgejoURL string
ForgejoTLSVerify bool
BuildAPIURL string
RetentionAudit int
RetentionReq int
RetentionHTTP int
GradingLookback string
SessionSecure bool
SessionSameSite string
ProdMode bool
}
HealthSystemData describes the orchestration process plus the static configuration rows the page shows in the collapsed config card.
type OrphanOrgRow ¶
type OrphanOrgRow struct {
Name string
// RepoCount is the number of repositories in the org.
RepoCount int
// Status classifies the org against the course table.
Status forgejo.OrphanOrgStatus
}
OrphanOrgRow is one Forgejo org on the orphan-orgs admin page.
func LoadOrphanOrgRows ¶
func LoadOrphanOrgRows(gdb *gorm.DB) ([]OrphanOrgRow, error)
LoadOrphanOrgRows lists all Forgejo orgs, classifies each against all courses (including soft-deleted ones), and fetches the repo count per org. Used by the page handler and the fragment handler.
func (OrphanOrgRow) Deletable ¶
func (r OrphanOrgRow) Deletable() bool
Deletable reports whether this org may be force-deleted (no matching course, active or archived).
type StaffDashboardData ¶
type StaffDashboardData struct {
Stats api.StaffStatsResponse
Now time.Time
Deadlines []DashboardDeadline
UngradedCount int64
Courses []DashboardCourse
}
StaffDashboardData holds everything the staff dashboard renders: stats scoped to the caller, their deadlines and the courses they own.
func LoadStaffDashboardData ¶
func LoadStaffDashboardData(gdb *gorm.DB, stats api.StaffStatsResponse, userID string) StaffDashboardData
LoadStaffDashboardData assembles the staff dashboard data for one staff member: their owned courses plus courses granted to them via course_accesses.
type TutorGroupsData ¶
type TutorGroupsData struct {
TutorID uint
Assigned api.CourseStudentListResult
Unassigned api.CourseStudentListResult
}
TutorGroupsData holds everything TutorGroupsTab renders: the resolved tutor plus the two paginated student lists.
func LoadTutorGroupsData ¶
func LoadTutorGroupsData(gdb *gorm.DB, courseID uint, p TutorGroupsParams) (TutorGroupsData, error)
LoadTutorGroupsData loads the assigned list for the selected tutor and the unassigned pool for the groups tab. Assignments are sorted by student name; the unassigned pool keeps the API default order.
type TutorGroupsParams ¶
type TutorGroupsParams struct {
TutorID uint
QAssigned string
QUnassigned string
PageAssigned int
PageUnassigned int
}
TutorGroupsParams holds the tutor-groups-tab filter state: the selected tutor, the two search strings, and the independent pagination state of the assigned and unassigned lists. TutorID is 0 when no tutor is selected (only possible while the course has no tutors).
func ParseTutorGroupsParams ¶
func ParseTutorGroupsParams(c *echo.Context) TutorGroupsParams
ParseTutorGroupsParams extracts the groups-tab params from the query string.
func TutorGroupsParamsFromPost ¶
func TutorGroupsParamsFromPost(c *echo.Context) TutorGroupsParams
TutorGroupsParamsFromPost extracts the groups-tab params from an htmx POST body. It falls back to the URL query when the body does not carry the tab=groups marker (the groups assign buttons always include it).
func (TutorGroupsParams) TutorIDString ¶
func (p TutorGroupsParams) TutorIDString() string
TutorIDString returns the selected tutor ID in its URL/form string form, or an empty string when unset.
Source Files
¶
- api_keys_handlers.go
- attendance_handlers.go
- audit_log_handlers.go
- build_job_handlers.go
- builds_handlers.go
- course_access.go
- courses.go
- dashboard.go
- dashboard_system.go
- exercises.go
- exercises_all.go
- health.go
- helpers.go
- http_requests_handlers.go
- orphan_orgs.go
- settings_handlers.go
- tasks_handlers.go
- tasks_helpers.go
- tutor_assignment.go
- users.go