dashboard

package
v2.0.0-rc.9 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

templ: version: v0.3.1001

templ: version: v0.3.1001

templ: version: v0.3.1001

Index

Constants

This section is empty.

Variables

View Source
var StaticFS embed.FS

Functions

func AdminAuditLogListPartial

func AdminAuditLogListPartial(entries []cloudstore.DashboardAuditRow, pg Pagination, filter cloudstore.AuditFilter) templ.Component

AdminAuditLogListPartial renders the audit log table with filters and pagination. REQ-409, REQ-410.

func AdminAuditLogPage

func AdminAuditLogPage(displayName string, filter cloudstore.AuditFilter) templ.Component

AdminAuditLogPage renders the admin audit log shell page. The HTMX container triggers loading the list partial on page load. REQ-408. JW2: buildAuditListURL embeds active filter params into the initial hx-get URL so that deep-linking /dashboard/admin/audit-log?contributor=alice preserves filters.

func AdminForbidden

func AdminForbidden() templ.Component

AdminForbidden renders the 403 page for non-admin users.

func AdminHealthPage

func AdminHealthPage(health *cloudstore.DashboardSystemHealth) templ.Component

AdminHealthPage renders the system health detail view. ADAPTED: SystemHealthInfo -> DashboardSystemHealth.

func AdminPage

AdminPage renders the admin dashboard landing with sub-navigation. ADAPTED: SystemHealthInfo -> DashboardSystemHealth; ProjectSyncControl kept.

func AdminProjectsPage

func AdminProjectsPage(controls []cloudstore.ProjectSyncControl) templ.Component

AdminProjectsPage renders organization-level project sync controls. ADAPTED: ProjectSyncControl kept (integrated cloudstore now has it).

func AdminSyncToggleFormPartial

func AdminSyncToggleFormPartial(control cloudstore.ProjectSyncControl) templ.Component

AdminSyncToggleFormPartial renders the HTMX-driven toggle form for a single project.

func BrowserPage

func BrowserPage(projects []string, types []string, activeProject string, search string, activeType string) templ.Component

BrowserPage renders the knowledge browser with subtabs and filter controls.

func ContributorDetailPage

ContributorDetailPage renders contributor detail. ADAPTED: ContributorStat -> DashboardContributorRow. R4-8: displayName parameter removed — it was passed but never used in the template body.

func ContributorsListPartial

func ContributorsListPartial(contributors []cloudstore.DashboardContributorRow, pg Pagination) templ.Component

ContributorsListPartial renders the contributors table + HtmxPaginationBar only (no shell, no outer wrapper). R5-2: used by /dashboard/contributors/list so HTMX pagination works without full-page nav. R6-1: outer <div id="contributors-content"> removed — HTMX swaps innerHTML into the existing

shell div, so re-wrapping in the same ID would create duplicate IDs in the DOM.

func ContributorsPage

func ContributorsPage(search string) templ.Component

ContributorsPage renders the contributors list shell. R6-1: converted to hx-get/load pattern (mirrors ProjectsPage) — the inline table is removed. The outer #contributors-content div triggers an HTMX load of /dashboard/contributors/list.

func DashboardActivityPartial

func DashboardActivityPartial(stats []cloudstore.DashboardProjectRow, pg Pagination) templ.Component

DashboardActivityPartial renders the project activity table, loaded via htmx. ADAPTED: ProjectStat -> DashboardProjectRow; no LastActivity (omit that column).

func DashboardHome

func DashboardHome(username string) templ.Component

DashboardHome renders the main dashboard landing content with project stats. ADAPTED: username comes from Principal.DisplayName() at the call site.

func DashboardStatsPartial

func DashboardStatsPartial(stats []cloudstore.DashboardProjectRow, projects []string) templ.Component

DashboardStatsPartial renders the metric cards loaded via htmx. ADAPTED: ProjectStat -> DashboardProjectRow; no LastActivity field (use Chunks).

func EmptyState

func EmptyState(title string, message string) templ.Component

EmptyState renders a centered empty-state placeholder.

func Handler

func Handler() http.Handler

func HandlerWithStatus

func HandlerWithStatus(provider SyncStatusProvider) http.Handler

func HtmxPaginationBar

func HtmxPaginationBar(pg Pagination, endpoint string, target string, includes string) templ.Component

HtmxPaginationBar is the same but triggers htmx requests instead of full-page navigation. target is the htmx target element (e.g. "#browser-content"), includes are extra hx-include selectors. endpoint must be the bare path WITHOUT a trailing "?" (e.g. "/dashboard/browser/observations"). R4-2: URL format uses "?page=..." not "&page=..." to avoid malformed ?& URLs.

func Layout

func Layout(title string, username string, activeTab string, isAdmin bool, content templ.Component) templ.Component

Layout wraps page content in the base HTML shell with nav, head, and footer. activeTab should be one of: "dashboard", "browser", "projects", "contributors", "admin". ADAPTED: username comes from Principal.DisplayName() at the call site (no context reads).

func LoginPage

func LoginPage(errorMsg string, next string) templ.Component

LoginPage renders the standalone login page (no layout wrapper). ADAPTED: added next string parameter for post-login redirect; token-only form (integrated dashboard uses ENGRAM_CLOUD_TOKEN, not user/password credentials).

func ManagedUserAdministrationNotice

func ManagedUserAdministrationNotice() templ.Component

func ManagedUserDetailPage

func ManagedUserDetailPage(user cloudstore.HumanUser, tokens []cloudstore.PrincipalToken, grants []cloudstore.ProjectGrant, canManageManagedUsers bool) templ.Component

ManagedUserDetailPage renders a single managed user's profile plus its token and project-grant management surfaces. cloud-user-token-management PR4. All mutation forms (enable/disable, token create/revoke, grant create/revoke) post to internal/cloud/cloudserver-owned routes that enforce managed-admin authorization and audit; this page only renders state and links to those routes — it never decides authorization itself.

func ManagedUserTokenCreatedPage

func ManagedUserTokenCreatedPage(user cloudstore.HumanUser, rawToken string, token cloudstore.PrincipalToken) templ.Component

ManagedUserTokenCreatedPage renders the show-once raw token page immediately after token creation. cloud-user-token-management PR4: this is the ONLY place the raw token is ever rendered — token list/detail views only ever receive cloudstore.PrincipalToken values (prefix/metadata, no hash, no raw secret), and this page is reached only as a direct POST response body (never a redirect target), so the raw token never appears in a URL, log line, or browser history entry.

func ManagedUsersListPartial

func ManagedUsersListPartial(users []cloudstore.HumanUser, canManageManagedUsers bool) templ.Component

ManagedUsersListPartial renders only the managed-users table (no shell, no outer wrapper, mirrors the R6-1 no-duplicate-ID convention used by the other list partials). cloud-user-token-management PR4: renders cloud principals / managed human users, NOT contributor analytics — contributors keep their own separate surface at /dashboard/contributors. Managed user lists are not paginated in the MVP: operator-managed accounts are expected to stay small relative to synced contributor volume.

func ManagedUsersPage

func ManagedUsersPage(canManageManagedUsers bool) templ.Component

ManagedUsersPage renders the managed-users shell: a create-user form plus the HTMX-loaded list partial. cloud-user-token-management PR4. Form POST and mutation routes (create/enable/disable/tokens/grants) are owned by internal/cloud/cloudserver, which enforces managed-admin authorization and audit for every mutation; this page only renders the form and outcomes.

func Mount

func Mount(mux *http.ServeMux, cfg MountConfig)
func NavTabs(activeTab string, isAdmin bool) templ.Component

NavTabs renders the navigation tab bar. activeTab should be one of: "dashboard", "browser", "projects", "contributors", "admin".

func ObservationDetailPage

ObservationDetailPage renders the full observation payload with session context. ADAPTED: CloudObservation -> DashboardObservationRow; CloudSession -> DashboardSessionRow.

func ObservationsPartial

func ObservationsPartial(observations []cloudstore.DashboardObservationRow, pg Pagination) templ.Component

ObservationsPartial renders the observations list, loaded as an htmx partial. ADAPTED: CloudObservation -> DashboardObservationRow; composite URL for detail page. R3-1: HtmxPaginationBar added so users have visible page controls in the browser.

func PaginationBar

func PaginationBar(pg Pagination, baseURL string, extraParams map[string]string) templ.Component

PaginationBar renders page navigation controls with a page-size selector. baseURL is the path without query params (e.g. "/dashboard/projects"). extraParams preserves existing query params (project, q, type, etc.).

func ProjectDetailPage

func ProjectDetailPage(project string, stats *cloudstore.DashboardProjectRow, control *cloudstore.ProjectSyncControl) templ.Component

ProjectDetailPage renders the detail view for a single project. ADAPTED: ProjectStat -> DashboardProjectRow; ProjectSyncControl kept.

func ProjectsListPartial

func ProjectsListPartial(stats []cloudstore.DashboardProjectRow, controls map[string]cloudstore.ProjectSyncControl, pg Pagination) templ.Component

ProjectsListPartial renders the project cards grid, loaded via htmx. ADAPTED: ProjectStat -> DashboardProjectRow; ProjectSyncControl kept (now in integrated cloudstore). R4-3: HtmxPaginationBar added so users can navigate beyond the first page.

func ProjectsPage

func ProjectsPage(search string) templ.Component

ProjectsPage renders the projects list view.

func PromptDetailPage

PromptDetailPage renders a prompt detail page. ADAPTED: CloudPrompt -> DashboardPromptRow; CloudSession -> DashboardSessionRow.

func PromptsPartial

func PromptsPartial(prompts []cloudstore.DashboardPromptRow, pg Pagination) templ.Component

PromptsPartial renders the prompts list, loaded as an htmx partial. ADAPTED: CloudPrompt -> DashboardPromptRow; composite URL for detail page. R3-1: HtmxPaginationBar added so users have visible page controls in the browser.

func SessionDetailPage

SessionDetailPage renders a connected session detail surface. ADAPTED: CloudSession -> DashboardSessionRow; CloudObservation -> DashboardObservationRow; CloudPrompt -> DashboardPromptRow.

func SessionsPartial

func SessionsPartial(sessions []cloudstore.DashboardSessionRow, pg Pagination) templ.Component

SessionsPartial renders the sessions list, loaded as an htmx partial. ADAPTED: CloudSessionSummary -> DashboardSessionRow; composite URL for detail page. R3-1: HtmxPaginationBar added so users have visible page controls in the browser.

func StatusBadge

func StatusBadge(label string, variant string) templ.Component

StatusBadge renders a colored status badge. variant should be one of: "success", "warning", "danger", "muted".

Types

type DashboardConfig

type DashboardConfig struct {
	AdminToken string
}

DashboardConfig holds dashboard-specific runtime options.

type DashboardStore

type DashboardStore interface {
	// Existing methods (from cloud-dashboard-parity).
	ListProjects(query string) ([]cloudstore.DashboardProjectRow, error)
	ProjectDetail(project string) (cloudstore.DashboardProjectDetail, error)
	ListContributors(query string) ([]cloudstore.DashboardContributorRow, error)
	ListRecentSessions(project string, query string, limit int) ([]cloudstore.DashboardSessionRow, error)
	ListRecentObservations(project string, query string, limit int) ([]cloudstore.DashboardObservationRow, error)
	ListRecentPrompts(project string, query string, limit int) ([]cloudstore.DashboardPromptRow, error)
	AdminOverview() (cloudstore.DashboardAdminOverview, error)

	// Paginated list methods (from cloud-dashboard-visual-parity).
	ListProjectsPaginated(query string, limit, offset int) ([]cloudstore.DashboardProjectRow, int, error)
	ListRecentObservationsPaginated(project, query, obsType string, limit, offset int) ([]cloudstore.DashboardObservationRow, int, error)
	ListRecentSessionsPaginated(project, query string, limit, offset int) ([]cloudstore.DashboardSessionRow, int, error)
	ListRecentPromptsPaginated(project, query string, limit, offset int) ([]cloudstore.DashboardPromptRow, int, error)
	ListContributorsPaginated(query string, limit, offset int) ([]cloudstore.DashboardContributorRow, int, error)

	// Detail methods.
	GetSessionDetail(project, sessionID string) (cloudstore.DashboardSessionRow, []cloudstore.DashboardObservationRow, []cloudstore.DashboardPromptRow, error)
	GetObservationDetail(project, sessionID, syncID string) (cloudstore.DashboardObservationRow, cloudstore.DashboardSessionRow, []cloudstore.DashboardObservationRow, error)
	GetPromptDetail(project, sessionID, syncID string) (cloudstore.DashboardPromptRow, cloudstore.DashboardSessionRow, []cloudstore.DashboardPromptRow, error)

	// SystemHealth.
	SystemHealth() (cloudstore.DashboardSystemHealth, error)

	// Sync control methods.
	ListProjectSyncControls() ([]cloudstore.ProjectSyncControl, error)
	GetProjectSyncControl(project string) (*cloudstore.ProjectSyncControl, error)
	SetProjectSyncEnabled(project string, enabled bool, updatedBy, reason string) error
	IsProjectSyncEnabled(project string) (bool, error)

	// Batch 6: Connected navigation methods.
	GetContributorDetail(name string) (cloudstore.DashboardContributorRow, []cloudstore.DashboardSessionRow, []cloudstore.DashboardObservationRow, []cloudstore.DashboardPromptRow, error)
	ListDistinctTypes() ([]string, error)

	// Audit log (REQ-409).
	ListAuditEntriesPaginated(ctx context.Context, filter cloudstore.AuditFilter, limit, offset int) ([]cloudstore.DashboardAuditRow, int, error)
}

type ManagedUsersStore

type ManagedUsersStore interface {
	ListHumanUsers(ctx context.Context) ([]cloudstore.HumanUser, error)
}

ManagedUsersStore is the read-only boundary the dashboard package uses to render the Managed Users surface. It is intentionally separate from DashboardStore (contributor/project/session analytics) so managed human users stay distinct from contributor analytics (cloud-user-token-management PR4). Mutations (create/enable/disable/tokens/grants) are owned and policy-gated by internal/cloud/cloudserver, which already enforces managed admin authorization and audit for these operations; the dashboard package only renders outcomes and links to those cloudserver-owned routes.

type MountConfig

type MountConfig struct {
	RequireSession        func(r *http.Request) error
	ValidateLoginToken    func(token string) error
	CreateSessionCookie   func(w http.ResponseWriter, r *http.Request, token string) error
	ClearSessionCookie    func(w http.ResponseWriter, r *http.Request)
	IsAdmin               func(r *http.Request) bool
	CanManageManagedUsers func(r *http.Request) bool
	GetDisplayName        func(r *http.Request) string
	Store                 DashboardStore
	ManagedUsers          ManagedUsersStore
	MaxLoginBodyBytes     int64
	StatusProvider        SyncStatusProvider
}

type Pagination

type Pagination struct {
	Page       int // current page (1-indexed)
	PageSize   int // items per page
	TotalItems int // total rows from COUNT query
	TotalPages int // computed from TotalItems/PageSize
}

Pagination holds everything a templ component needs to render page controls.

func (Pagination) End

func (p Pagination) End() int

End returns the 1-indexed position of the last item on this page.

func (Pagination) HasNext

func (p Pagination) HasNext() bool

HasNext returns true if there is a next page.

func (Pagination) HasPrev

func (p Pagination) HasPrev() bool

HasPrev returns true if there is a previous page.

func (Pagination) Offset

func (p Pagination) Offset() int

Offset returns the SQL OFFSET value for the current page.

func (Pagination) PageNumbers

func (p Pagination) PageNumbers() []int

PageNumbers returns a slice of page numbers to render, with -1 as ellipsis.

func (Pagination) ShowPagination

func (p Pagination) ShowPagination() bool

ShowPagination returns true if the result set exceeds one page.

func (Pagination) Start

func (p Pagination) Start() int

Start returns the 1-indexed position of the first item on this page.

type Principal

type Principal struct {
	// contains filtered or unexported fields
}

Principal represents the authenticated dashboard user. It is a read-only view over MountConfig closures — no context reads for identity are performed inside handlers. Satisfies Design Decision 6.

func (Principal) CanManageManagedUsers

func (p Principal) CanManageManagedUsers() bool

CanManageManagedUsers reports whether this dashboard principal may mutate managed users, tokens, and project grants.

func (Principal) DisplayName

func (p Principal) DisplayName() string

DisplayName returns the display name for this principal. An empty or whitespace-only name falls back to "OPERATOR".

func (Principal) IsAdmin

func (p Principal) IsAdmin() bool

IsAdmin returns whether this principal has admin privileges.

type SyncStatus

type SyncStatus struct {
	Phase                string
	ReasonCode           string
	ReasonMessage        string
	UpgradeStage         string
	UpgradeReasonCode    string
	UpgradeReasonMessage string
}

type SyncStatusProvider

type SyncStatusProvider interface {
	Status() SyncStatus
}

type TemplRuntimePolicy

type TemplRuntimePolicy struct {
	Mode                     string
	RuntimeGenerationAllowed bool
	GenerateCommand          string
}

Jump to

Keyboard shortcuts

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