webapp

package
v0.29.4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version   = "dev"
	BuildDate = ""
)

Version info - can be set at build time with -ldflags

View Source
var AppRoutes = []RouteConfig{
	{Path: "/", Render: func() app.UI { return &HomePage{} }},
	{Path: "/browse", Render: func() app.UI { return &BrowsePage{} }},
	{Path: "/ingest", Render: func() app.UI { return &IngestPage{} }},
	{Path: "/clean", Render: func() app.UI { return &CleanPage{} }},
	{Path: "/search", Render: func() app.UI { return &SearchPage{} }},
	{Path: "/wordcloud", Render: func() app.UI { return &WordCloudPage{} }},
	{Path: "/jobs", Render: func() app.UI { return &JobsPage{} }},
	{Path: "/about", Render: func() app.UI { return &AboutPage{} }},
	{Path: "/manuallog", Render: func() app.UI { return &ManualLogPage{} }},
	{
		Path:   "/edit/",
		Render: func() app.UI { return &EditPage{} },
		MatchFunc: func(path string) bool {
			return len(path) > 6 && path[:6] == "/edit/"
		},
	},
}

AppRoutes defines all application routes and their corresponding pages

Functions

func BuildAPIURL

func BuildAPIURL(path string) string

BuildAPIURL constructs a full API URL from a path Example: BuildAPIURL("/api/documents/latest") -> "http://backend:8000/api/documents/latest" or just "/api/documents/latest" if using relative URLs

func GetAPIBaseURL

func GetAPIBaseURL() string

GetAPIBaseURL returns the configured API base URL It reads from window.godocsConfig.apiURL if available, otherwise falls back to empty string (relative URLs)

func Handler

func Handler() http.Handler

Handler returns an HTTP handler for the web app

func Log added in v0.23.0

func Log(ctx app.Context, level LogLevel, message string, attrs map[string]interface{})

Log sends a structured log message to the backend using slog-compatible format This function encapsulates the slog interface for frontend logging

func LogDebug added in v0.23.0

func LogDebug(ctx app.Context, message string, attrs map[string]interface{})

LogDebug logs a debug message with structured attributes

func LogError added in v0.23.0

func LogError(ctx app.Context, message string, attrs map[string]interface{})

LogError logs an error message with structured attributes

func LogInfo added in v0.23.0

func LogInfo(ctx app.Context, message string, attrs map[string]interface{})

LogInfo logs an info message with structured attributes

func LogWarn added in v0.23.0

func LogWarn(ctx app.Context, message string, attrs map[string]interface{})

LogWarn logs a warning message with structured attributes

func ManualLog added in v0.27.8

func ManualLog(ctx app.Context)

Log sends a structured log message to the backend using slog-compatible format This function encapsulates the slog interface for frontend logging

func RegisterRoutes added in v0.28.3

func RegisterRoutes()

RegisterRoutes registers all application routes

Types

type AboutInfo

type AboutInfo struct {
	Version       string `json:"version"`
	OCRConfigured bool   `json:"ocrConfigured"`
	OCRPath       string `json:"ocrPath"`
	DatabaseType  string `json:"databaseType"`
	DatabaseHost  string `json:"databaseHost"`
	DatabasePort  string `json:"databasePort"`
	DatabaseName  string `json:"databaseName"`
	IsEphemeral   bool   `json:"isEphemeral"`
	IngressPath   string `json:"ingressPath"`
	DocumentPath  string `json:"documentPath"`
	LogLevel      string `json:"logLevel"`
}

AboutInfo represents the about information from the API

type AboutPage

type AboutPage struct {
	app.Compo
	// contains filtered or unexported fields
}

AboutPage displays information about the application

func (*AboutPage) OnMount

func (a *AboutPage) OnMount(ctx app.Context)

OnMount is called when the component is mounted

func (*AboutPage) Render

func (a *AboutPage) Render() app.UI

Render renders the about page

type App

type App struct {
	app.Compo
}

App is the root component of the application

func (*App) Render

func (a *App) Render() app.UI

Render renders the app

type BrowsePage

type BrowsePage struct {
	app.Compo
	// contains filtered or unexported fields
}

BrowsePage displays the document file tree

func (*BrowsePage) OnMount

func (b *BrowsePage) OnMount(ctx app.Context)

OnMount is called when the component is mounted

func (*BrowsePage) Render

func (b *BrowsePage) Render() app.UI

Render renders the browse page

type CleanPage

type CleanPage struct {
	app.Compo
	// contains filtered or unexported fields
}

CleanPage allows users to clean the database by removing orphaned entries

func (*CleanPage) Render

func (c *CleanPage) Render() app.UI

Render renders the clean page

type Dimension added in v0.22.1

type Dimension struct {
	ID          int              `json:"id"`
	Name        string           `json:"name"`
	DisplayName string           `json:"display_name"`
	Values      []DimensionValue `json:"values"`
}

Dimension represents a dimension with its values

type DimensionValue added in v0.22.1

type DimensionValue struct {
	ID          int    `json:"id"`
	Value       string `json:"value"`
	DisplayName string `json:"display_name"`
	Color       string `json:"color"`
}

DimensionValue represents a dimension value

type Document

type Document struct {
	StormID      int    `json:"StormID"`
	Name         string `json:"Name"`
	Path         string `json:"Path"`
	IngressTime  string `json:"IngressTime"`
	Folder       string `json:"Folder"`
	Hash         string `json:"Hash"`
	ULID         string `json:"ULID"`
	DocumentType string `json:"DocumentType"`
	FullText     string `json:"FullText"`
	URL          string `json:"URL"`
	ThumbnailURL string `json:"thumbnailURL,omitempty"`
}

Document represents a document from the API

type DocumentCard

type DocumentCard struct {
	app.Compo
	Document Document
}

DocumentCard displays a single document card

func (*DocumentCard) Render

func (d *DocumentCard) Render() app.UI

Render renders the document card

type EditPage added in v0.22.1

type EditPage struct {
	app.Compo
	// contains filtered or unexported fields
}

EditPage allows editing document tags and dimensions

func (*EditPage) OnNav added in v0.22.1

func (e *EditPage) OnNav(ctx app.Context)

OnNav is called when navigating to this page

func (*EditPage) Render added in v0.22.1

func (e *EditPage) Render() app.UI

Render renders the edit page

type FileSystem

type FileSystem struct {
	FileSystem []FileTreeNode `json:"fileSystem"`
	Error      string         `json:"error"`
}

FileSystem represents the API response

type FileTreeNode

type FileTreeNode struct {
	ID           string   `json:"id"`
	ULID         string   `json:"ulid"`
	Name         string   `json:"name"`
	Size         int64    `json:"size"`
	ModDate      string   `json:"modDate"`
	Openable     bool     `json:"openable"`
	ParentID     string   `json:"parentID"`
	IsDir        bool     `json:"isDir"`
	ChildrenIDs  []string `json:"childrenIDs"`
	FullPath     string   `json:"fullPath"`
	FileURL      string   `json:"fileURL"`
	ThumbnailURL string   `json:"thumbnailURL,omitempty"`
}

FileTreeNode represents a node in the file tree

type HomePage

type HomePage struct {
	app.Compo
	// contains filtered or unexported fields
}

HomePage displays the latest documents with pagination

func (*HomePage) OnMount

func (h *HomePage) OnMount(ctx app.Context)

OnMount is called when the component is mounted

func (*HomePage) Render

func (h *HomePage) Render() app.UI

Render renders the home page

type IngestPage

type IngestPage struct {
	app.Compo
	// contains filtered or unexported fields
}

IngestPage allows users to trigger the ingestion process manually

func (*IngestPage) Render

func (i *IngestPage) Render() app.UI

Render renders the ingest page

type Job

type Job struct {
	ID          string `json:"id"`
	Type        string `json:"type"`
	Status      string `json:"status"`
	Progress    int    `json:"progress"`
	CurrentStep string `json:"currentStep"`
	TotalSteps  int    `json:"totalSteps"`
	Message     string `json:"message"`
	Error       string `json:"error,omitempty"`
	Result      string `json:"result,omitempty"`
	CreatedAt   string `json:"createdAt"`
	UpdatedAt   string `json:"updatedAt"`
	StartedAt   string `json:"startedAt,omitempty"`
	CompletedAt string `json:"completedAt,omitempty"`
}

Job represents a background job

type JobsPage

type JobsPage struct {
	app.Compo
	// contains filtered or unexported fields
}

JobsPage displays and manages background jobs

func (*JobsPage) OnDismount

func (j *JobsPage) OnDismount()

OnDismount is called when the component is unmounted

func (*JobsPage) OnMount

func (j *JobsPage) OnMount(ctx app.Context)

OnMount is called when the component is mounted

func (*JobsPage) Render

func (j *JobsPage) Render() app.UI

Render renders the jobs page

type LogLevel added in v0.23.0

type LogLevel string

LogLevel represents log severity levels matching slog

const (
	LogLevelDebug LogLevel = "debug"
	LogLevelInfo  LogLevel = "info"
	LogLevelWarn  LogLevel = "warn"
	LogLevelError LogLevel = "error"
)

type ManualLogPage added in v0.27.8

type ManualLogPage struct {
	app.Compo
	// contains filtered or unexported fields
}

AboutPage displays information about the application

func (*ManualLogPage) OnMount added in v0.28.4

func (m *ManualLogPage) OnMount(ctx app.Context)

OnMount is called when the ManualLogPage component is mounted

func (*ManualLogPage) Render added in v0.28.2

func (a *ManualLogPage) Render() app.UI

Render renders ManualLog page just to say we were here

type NavBar struct {
	app.Compo
	// contains filtered or unexported fields
}

NavBar is the navigation bar component

func (n *NavBar) OnDismount()

OnDismount is called when the component is unmounted

func (n *NavBar) OnMount(ctx app.Context)

OnMount is called when the component is mounted

func (n *NavBar) Render() app.UI

Render renders the navigation bar

type NotFoundPage

type NotFoundPage struct {
	app.Compo
}

NotFoundPage displays a 404 error message

func (*NotFoundPage) OnNav added in v0.27.1

func (p *NotFoundPage) OnNav(ctx app.Context)

OnNav is called when this page is navigated to

func (*NotFoundPage) Render

func (p *NotFoundPage) Render() app.UI

Render renders the 404 page

type PaginatedResponse

type PaginatedResponse struct {
	Documents   []Document `json:"documents"`
	Page        int        `json:"page"`
	PageSize    int        `json:"pageSize"`
	TotalCount  int        `json:"totalCount"`
	TotalPages  int        `json:"totalPages"`
	HasNext     bool       `json:"hasNext"`
	HasPrevious bool       `json:"hasPrevious"`
}

PaginatedResponse represents the paginated API response

type RouteConfig added in v0.28.3

type RouteConfig struct {
	Path      string
	Render    func() app.UI
	MatchFunc func(path string) bool // Optional: custom path matching logic
}

RouteConfig defines a route and its render function

type SearchPage

type SearchPage struct {
	app.Compo
	// contains filtered or unexported fields
}

SearchPage provides full-text search functionality

func (*SearchPage) OnMount

func (s *SearchPage) OnMount(ctx app.Context)

OnMount is called when the component is mounted

func (*SearchPage) Render

func (s *SearchPage) Render() app.UI

Render renders the search page

type SearchResultItem

type SearchResultItem struct {
	app.Compo
	Node FileTreeNode
}

SearchResultItem displays a single search result

func (*SearchResultItem) Render

func (s *SearchResultItem) Render() app.UI

Render renders the search result item

type Sidebar struct {
	app.Compo
	// contains filtered or unexported fields
}

Sidebar is the left sidebar menu component

func (*Sidebar) OnMount

func (s *Sidebar) OnMount(ctx app.Context)

OnMount is called when the component is mounted

func (*Sidebar) OnNav

func (s *Sidebar) OnNav(ctx app.Context)

OnNav is called when navigation occurs

func (*Sidebar) Render

func (s *Sidebar) Render() app.UI

Render renders the sidebar

type Tag added in v0.22.1

type Tag struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Color       string `json:"color"`
	Description string `json:"description"`
}

Tag represents a tag from the API

type WordCloudMetadata

type WordCloudMetadata struct {
	LastCalculation    string `json:"lastCalculation"`
	TotalDocsProcessed int    `json:"totalDocsProcessed"`
	TotalWordsIndexed  int    `json:"totalWordsIndexed"`
	Version            int    `json:"version"`
}

WordCloudMetadata contains metadata about the word cloud

type WordCloudPage

type WordCloudPage struct {
	app.Compo
	// contains filtered or unexported fields
}

WordCloudPage displays a word cloud of the most frequent words

func (*WordCloudPage) OnMount

func (w *WordCloudPage) OnMount(ctx app.Context)

OnMount is called when the component is mounted

func (*WordCloudPage) Render

func (w *WordCloudPage) Render() app.UI

Render renders the word cloud page

type WordCloudResponse

type WordCloudResponse struct {
	Words    []WordFrequency    `json:"words"`
	Metadata *WordCloudMetadata `json:"metadata"`
	Count    int                `json:"count"`
}

WordCloudResponse is the API response structure

type WordFrequency

type WordFrequency struct {
	Word      string `json:"word"`
	Frequency int    `json:"frequency"`
}

WordFrequency represents a word and its frequency

Jump to

Keyboard shortcuts

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