prago

package module
v0.0.0-...-af4d9b3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 69 Imported by: 0

README

Prago - simple Go framework

Prago is simple web framework fo Go language I am using for my projects.

https://www.odchazel.com

Documentation

Overview

Package prago is MVC framework for go

Index

Constants

View Source
const (
	StyleAccented = "accented"
	StyleCreate   = "create"
	StyleDestroy  = "destroy"
)

Variables

View Source
var ErrItemNotFound = errors.New("item not found")

ErrItemNotFound is returned when no item is found

View Source
var ErrWrongWhereFormat = errors.New("wrong where format")

ErrWrongWhereFormat is returned when where query has a bad format

Functions

func IsEmailValid

func IsEmailValid(email string) bool

func IsPhoneNumberValid

func IsPhoneNumberValid(phone string) bool

func MultirelationArrayToString

func MultirelationArrayToString(in []int64) string

func MultirelationStringToArray

func MultirelationStringToArray(in string) (ret []int64)

func MultirelationStringToMap

func MultirelationStringToMap(in string) (ret map[int64]bool)

func Must

func Must(err error)

func Unlocalized

func Unlocalized(name string) func(string) string

Types

type API

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

func (*API) Handler

func (api *API) Handler(handler func(request *Request)) *API

func (*API) HandlerJSON

func (api *API) HandlerJSON(handler func(request *Request) any) *API

TODO: Deprecated

func (*API) Method

func (api *API) Method(method string) *API

func (*API) Permission

func (api *API) Permission(permission Permission) *API

type Accordion

type Accordion struct {
	Icon string
	Name string
	Text template.HTML
}

type Action

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

Action represents action

func (*Action) Board

func (action *Action) Board(board *Board) *Action

func (*Action) Icon

func (action *Action) Icon(icon string) *Action

func (*Action) Method

func (action *Action) Method(method string) *Action

func (*Action) Name

func (action *Action) Name(name func(string) string) *Action

func (*Action) Permission

func (action *Action) Permission(permission Permission) *Action

func (*Action) StyleAccented

func (action *Action) StyleAccented() *Action

func (*Action) StyleCreate

func (action *Action) StyleCreate() *Action

func (*Action) StyleDestroy

func (action *Action) StyleDestroy() *Action

type Activity

type Activity struct {
	ID           int64
	ResourceID   string
	User         int64
	ActivityType string
}

type Aggregation

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

func (*Aggregation) Count

func (agg *Aggregation) Count() *Aggregation

func (*Aggregation) Get

func (agg *Aggregation) Get() ([]int64, error)

func (*Aggregation) Max

func (agg *Aggregation) Max(fieldName string) *Aggregation

func (*Aggregation) Min

func (agg *Aggregation) Min(fieldName string) *Aggregation

func (*Aggregation) Sum

func (agg *Aggregation) Sum(fieldName string) *Aggregation

type App

type App struct {
	UsersResource *Resource

	FilesResource *Resource

	MainBoard *Board

	InitializationAfterServerStart func()

	Is2faEnabled bool

	GetTrackingUUIDFunc func(request *Request) string

	AI *pragoai.Client
	// contains filtered or unexported fields
}

func New

func New(appName, version string) *App

New creates App structure for prago app

func NewTesting

func NewTesting(t *testing.T, initHandler func(app *App)) *App

func (*App) ActionForm

func (app *App) ActionForm(url string, formGenerator func(form *Form, request *Request), validator func(fv FormValidation, request *Request)) *Action

func (*App) ActionPlain

func (app *App) ActionPlain(url string, handler func(request *Request)) *Action

func (*App) ActionResourceForm

func (app *App) ActionResourceForm[T any](url string, formGenerator func(form *Form, request *Request), validation func(fv FormValidation, request *Request)) *Action

func (*App) ActionResourceItemForm

func (app *App) ActionResourceItemForm[T any](
	url string,
	formGenerator func(item *T, form *Form, request *Request),
	validation func(item *T, fv FormValidation, request *Request),
) *Action

func (*App) ActionResourceItemPlain

func (app *App) ActionResourceItemPlain[T any](url string, fn func(item *T, request *Request)) *Action

func (*App) ActionResourceItemUI

func (app *App) ActionResourceItemUI[T any](url string, contentSource func(item *T, request *Request) template.HTML) *Action

func (*App) ActionResourceMultipleItemsForm

func (app *App) ActionResourceMultipleItemsForm[T any](
	url string,
	formGenerator func(items []*T, form *Form, request *Request),
	validation func(items []*T, fv FormValidation, request *Request),
) *Action

func (*App) ActionResourcePlain

func (app *App) ActionResourcePlain[T any](url string, handler func(request *Request)) *Action

func (*App) ActionResourceUI

func (app *App) ActionResourceUI[T any](url string, content func(request *Request) template.HTML) *Action

func (*App) ActionUI

func (app *App) ActionUI(url string, content func(request *Request) template.HTML) *Action

func (*App) AddCSS

func (app *App) AddCSS(fn func() string)

func (*App) AddCustomDateRange

func (app *App) AddCustomDateRange(tm [2]time.Time)

func (*App) AddCustomSearchFunction

func (app *App) AddCustomSearchFunction(fn func(q string, userData UserData) []*CustomSearchResult)

func (*App) AddDeleteValidation

func (app *App) AddDeleteValidation[T any](fn func(item *T, validation Validation, userData UserData))

func (*App) AddDevStaticFiles

func (app *App) AddDevStaticFiles(path string)

AddDevStaticFiles adds path for public files for development and publish them in server's root

func (*App) AddDevelopmentPath

func (app *App) AddDevelopmentPath(path string)

func (*App) AddEnum

func (app *App) AddEnum(name string, items []*Enum)

func (*App) AddEnumShort

func (app *App) AddEnumShort(name string, items [][2]string)

func (*App) AddHelp

func (app *App) AddHelp(url string, permission Permission, name func(string) string, icon string, content func(request *Request) template.HTML)

func (*App) AddHelpMarkdown

func (app *App) AddHelpMarkdown(url string, permission Permission, name string, icon string, markdownText string)

func (*App) AddItemStatistic

func (app *App) AddItemStatistic[T any](name func(string) string, permission Permission, statHandler func(item *T) string)

func (*App) AddJavascript

func (app *App) AddJavascript(fn func() string)

func (*App) AddLessDevelopmentPaths

func (app *App) AddLessDevelopmentPaths(sourcePath, targetPath string)

AddLessDevelopmentPaths compiles less files in sourcePath into targetPath in development mode

func (*App) AddManagerOfRole

func (app *App) AddManagerOfRole(whoRole, whomRole string)

func (*App) AddResourceCustomSearchFunction

func (app *App) AddResourceCustomSearchFunction[T any](fn func(q string, userData UserData) []*T)

func (*App) AddRole

func (app *App) AddRole(roleID string, roleName func(string) string, permissions []Permission) *App

AddRole adds role to admin

func (*App) AddSassDevelopmentPaths

func (app *App) AddSassDevelopmentPaths(sourcePath, targetPath string)

func (*App) AddServerSetup

func (app *App) AddServerSetup(fn func(*http.Server))

func (*App) AddStaticFiles

func (app *App) AddStaticFiles(f fs.FS, pathPrefix string)

AddStaticFiles add filesystem of public files and publish them in server's root

func (*App) AddTemplatesDevelopmentPath

func (app *App) AddTemplatesDevelopmentPath(templates *Templates, watchPath string, matchPatterns ...string)

func (*App) AddTypeScriptDevelopmentPath

func (app *App) AddTypeScriptDevelopmentPath(path string)

AddTypeScriptDevelopmentPath automatically runs compilation of .tsc file in development mode

func (*App) AddUpdateValidation

func (app *App) AddUpdateValidation[T any](fn func(item *T, validation Validation, userData UserData))

func (*App) BaseColor

func (app *App) BaseColor(hue int64, saturation float64, lightness float64) *App

func (*App) BaseURL

func (app *App) BaseURL() string

func (*App) BeforeAction

func (app *App) BeforeAction(fn func(request *Request) bool)

AddBeforeAction adds action which is executed before main router action is called

func (*App) Cached

func (app *App) Cached[T any](name string, createFn func() T) T

func (*App) CachedPermanent

func (app *App) CachedPermanent[T any](name string, duration time.Duration, createFn func() T) T

func (*App) CheckDeleteValidation

func (app *App) CheckDeleteValidation[T any](item *T, user UserData) ([]ValidationError, bool)

func (*App) CheckUpdateValidation

func (app *App) CheckUpdateValidation[T any](item *T, user UserData) ([]ValidationError, bool)

func (*App) ClearCache

func (app *App) ClearCache()

func (*App) Create

func (app *App) Create[T any](item *T) error

func (*App) CreateContext

func (app *App) CreateContext[T any](ctx context.Context, item *T) error

func (*App) DB

func (app *App) DB() *sql.DB

func (*App) Delete

func (app *App) Delete[T any](id int64) error

func (*App) DeleteContext

func (app *App) DeleteContext[T any](ctx context.Context, id int64) error

func (*App) DevelopmentMode

func (app *App) DevelopmentMode() bool

DevelopmentMode returns if app is running in development mode

func (*App) ForEach

func (app *App) ForEach[T any](ctx context.Context, filter map[string][]string, handler func(*T) error) error

func (*App) FormFilter

func (app *App) FormFilter(id string) *FormFilter

func (*App) GenerateCSRFToken

func (app *App) GenerateCSRFToken(userID int64) string

func (*App) GetAdminTemplates

func (app *App) GetAdminTemplates() *Templates

func (*App) GetAllUsers

func (app *App) GetAllUsers() (ret []UserData)

func (*App) GetBeaconCount

func (app *App) GetBeaconCount(beaconName, pageURL, val1, val2, val3 string) int64

func (*App) GetCDNVideoURL

func (app *App) GetCDNVideoURL(uuid string) string

func (*App) GetCachedUserEmail

func (app *App) GetCachedUserEmail(id int64) string

func (*App) GetEnumName

func (app *App) GetEnumName(request *Request, typeID string, typeValue string) string

func (*App) GetFiles

func (app *App) GetFiles(ctx context.Context, ids string) []*File

func (*App) GetImages

func (app *App) GetImages(ids string) (ret []*Image)

func (*App) GetItemVersion

func (app *App) GetItemVersion[T any](item *T) int64

func (*App) GetMailingDataHTML

func (app *App) GetMailingDataHTML(locale string, fn func(*MailingData)) string

func (*App) GetPhotoGalleryImageData

func (app *App) GetPhotoGalleryImageData(idsStr string) (ret []*PhotoGalleryImage)

func (*App) GetUserData

func (app *App) GetUserData(id int64) *userData

func (*App) GetUserName

func (app *App) GetUserName(id int64) string

func (*App) GetVersionString

func (app *App) GetVersionString() string

func (*App) GoogleKey

func (app *App) GoogleKey() string

func (*App) Handle

func (app *App) Handle(method, path string, action func(request *Request), constraints ...Constraint)

Get creates new route for GET request

func (*App) HandlePage

func (app *App) HandlePage(url string, handler func(request *Request, pageData *PageData), constraints ...Constraint)

func (*App) HandlePageWithValidation

func (app *App) HandlePageWithValidation(url string, handler func(request *Request, pageData *PageData), formValidation func(fv FormValidation, request *Request), constraints ...Constraint)

func (*App) HandleSimple

func (app *App) HandleSimple(path string, handler func(*PageDataSimple))

func (*App) HandleSimpleWithValidation

func (app *App) HandleSimpleWithValidation(path string, handler func(*PageDataSimple), formValidation func(fv FormValidation, request *Request))

func (*App) Icon

func (app *App) Icon(icon string) *App

func (*App) IconURL

func (app *App) IconURL() string

func (*App) Info

func (app *App) Info() AppInfo

func (*App) InstallDatabase

func (app *App) InstallDatabase(rootPassword, codeName string) error

func (*App) InternalBeacon

func (app *App) InternalBeacon(typ, val1, val2, val3 string)

func (*App) ListenActivity

func (app *App) ListenActivity(handler func(Activity))

ListenActivity listens to all changes in app's administration

func (*App) Log

func (app *App) Log() *logger

Log returns logger structure

func (app *App) Logo(logo []byte) *App

Logo sets application public path to logo

func (*App) Mailing

func (app *App) Mailing(locale string, fn func(*MailingData)) error

func (*App) Name

func (app *App) Name(name func(string) string) *App

Name sets localized human name to app

func (*App) NewAPI

func (app *App) NewAPI(url string) *API

func (*App) NewEmail

func (app *App) NewEmail() *Email

func (*App) NewForm

func (app *App) NewForm(action string) *Form

NewForm creates new form

func (*App) NewMCPTool

func (app *App) NewMCPTool[T any](name, description string, handler func(request *Request, input T) (any, error)) *MCPTool

NewMCPTool přidá nástroj do MCP serveru aplikace. Vstup T musí být struktura, její JSON schéma se odvodí z tagů json a ai (případně prago-name). Handler běží v kontextu přihlášeného uživatele.

func (*App) NewNotification

func (app *App) NewNotification(name string) *Notification

NewNotification creates notification

func (*App) NewResource

func (app *App) NewResource[T any]() *Resource

func (*App) NewResourceAPI

func (app *App) NewResourceAPI[T any](url string) *API

func (*App) NewResourceAPIJSON

func (app *App) NewResourceAPIJSON[T any](url string, handler func(request *Request, item *T) any) *API

func (*App) NewSetting

func (app *App) NewSetting(id string, permission Permission) *Setting

func (*App) NewTable

func (app *App) NewTable() *Table

func (*App) NewWriter

func (app *App) NewWriter[T any](templates *Templates, templateName string) *Writer[T]

func (*App) Permission

func (app *App) Permission(permission Permission) *App

Permission adds permission to admin

func (*App) PopupForm

func (app *App) PopupForm(url string, formGenerator func(form *Form, request *Request), validation func(fv FormValidation, request *Request)) *Action

func (*App) PreviewURLFunction

func (app *App) PreviewURLFunction[T any](fn func(*T) string)

func (*App) Query

func (app *App) Query[T any]() *QueryData[T]

func (*App) RandomizationString

func (app *App) RandomizationString() string

func (*App) ReplaceContext

func (app *App) ReplaceContext[T any](ctx context.Context, item *T) error

func (*App) Run

func (app *App) Run()

func (*App) SetAfterRequestServedHandler

func (app *App) SetAfterRequestServedHandler(fn func(*Request))

func (*App) SetIcons

func (app *App) SetIcons(iconsFS embed.FS, prefix string)

func (*App) SetLogHandler

func (app *App) SetLogHandler(fn func(string, string))

func (*App) Suggestions

func (app *App) Suggestions(permission Permission, contextFields []string, handler func(sr SuggestionsRequest) *SuggestionsResponse) *SuggestionsCustom

func (*App) TemporaryCache

func (app *App) TemporaryCache[T any]() *TemporaryCacheData[T]

func (*App) TestUserData

func (app *App) TestUserData(role string) UserData

func (*App) Update

func (app *App) Update[T any](item *T) error

func (*App) UpdatePartial

func (app *App) UpdatePartial[T any](item *T, fields []string) error

func (*App) UploadFile

func (app *App) UploadFile(fileHeader *multipart.FileHeader, request *Request, description string) (*File, error)

func (*App) UploadFileFromURL

func (app *App) UploadFileFromURL(ctx context.Context, fileURL string, userID int64, description string) (*File, error)

type AppInfo

type AppInfo struct {
	CodeName string
	Name     func(string) string
	Version  string
}

type Beacon

type Beacon struct {
	ID int64 `prago-order-desc:"true"`

	Name    string
	PageURL string

	Value1Str string `prago-type:"text"`
	Value2Str string `prago-type:"text"`
	Value3Str string `prago-type:"text"`

	Value1Int int64

	UserUUID  string
	UserAgent string

	CreatedAt time.Time
	UpdatedAt time.Time
}

func (*Beacon) UpdateInt

func (beacon *Beacon) UpdateInt()

type BeaconRequest

type BeaconRequest struct {
	Name    string
	PageURL string

	Value1Str string
	Value2Str string
	Value3Str string
}

type Board

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

func (*Board) AddChild

func (parent *Board) AddChild(url string, name func(string) string, icon string) *Board

func (*Board) AddDashboard

func (board *Board) AddDashboard(name func(string) string) *Dashboard

type BoxHeader

type BoxHeader struct {
	Style              string
	Image              string
	Icon               string
	DescriptionsBefore []string
	Name               string
	DescriptionsAfter  []string

	Buttons []*Button
}

type Button

type Button struct {
	Icon     string
	Name     string
	URL      string
	OnClick  template.JS
	Title    string
	Selected bool
	Style    string
	Priority int64
}

func (*Button) ButtonColor

func (btn *Button) ButtonColor() string

func (Button) GetTitle

func (btn Button) GetTitle() string

func (*Button) SafeURL

func (btn *Button) SafeURL() template.URL

func (*Button) StyleAccented

func (btn *Button) StyleAccented() *Button

func (*Button) StyleCreate

func (btn *Button) StyleCreate() *Button

func (*Button) StyleDestroy

func (btn *Button) StyleDestroy() *Button

type Constraint

type Constraint func(context.Context, url.Values) bool

type CustomSearchResult

type CustomSearchResult struct {
	URL      string
	Prename  string
	Name     string
	Priority int64
}

type DBConnectConfig

type DBConnectConfig struct {
	Name     string `json:"name"`
	User     string `json:"user"`
	Password string `json:"password"`
}

func GetDBConnectConfig

func GetDBConnectConfig(codeName string) (*DBConnectConfig, error)

type Dashboard

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

func (*Dashboard) AddFigure

func (dashboard *Dashboard) AddFigure(name func(string) string, permission Permission) *dashboardFigure

func (*Dashboard) AddFormItemOptions

func (dashboard *Dashboard) AddFormItemOptions(id, name string, options [][2]string)

func (*Dashboard) AddTable

func (group *Dashboard) AddTable(tableFn func(request *Request) *Table, permission Permission) *dashboardTable

func (*Dashboard) AddTimeline

func (dashboard *Dashboard) AddTimeline(name func(string) string, permission Permission, dataSource func(tdr *TimelineDataRequest) float64) *Timeline

type DashboardFormItem

type DashboardFormItem struct {
	ID       string
	Name     string
	Template string
	Value    string
	Options  [][2]string
}

type Email

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

func (*Email) Attachement

func (email *Email) Attachement(filename string, content []byte) *Email

func (*Email) From

func (email *Email) From(name, emailAddress string) *Email

func (*Email) HTMLContent

func (email *Email) HTMLContent(content string) *Email

func (*Email) Send

func (email *Email) Send() error

func (*Email) Subject

func (email *Email) Subject(subject string) *Email

func (*Email) TextContent

func (email *Email) TextContent(content string) *Email

func (*Email) To

func (email *Email) To(name, emailAddress string) *Email

type Enum

type Enum struct {
	ID                string
	Name              func(string) string
	DescriptionBefore func(string) string
	DescriptionAfter  func(string) string
	Icon              string
	Color             string
	Style             string
}

func (*Enum) GetName

func (enum *Enum) GetName(locale string) string

type Field

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

func (*Field) Description

func (field *Field) Description(description func(string) string) *Field

func (*Field) FilterByPrefix

func (field *Field) FilterByPrefix() *Field

func (*Field) FixStringValue

func (field *Field) FixStringValue(fn func(string) string) *Field

func (*Field) FormContentGenerator

func (field *Field) FormContentGenerator(fn func(item *FormItem) template.HTML) *Field

func (*Field) GetManuallySetPluralName

func (field *Field) GetManuallySetPluralName(locale string) string

func (*Field) GetName

func (field *Field) GetName(locale string) string

func (*Field) HelpURL

func (field *Field) HelpURL(url string) *Field

func (*Field) Name

func (field *Field) Name(name func(string) string) *Field

func (*Field) PreventPasswordManager

func (field *Field) PreventPasswordManager(prevent bool) *Field

func (*Field) Searchable

func (field *Field) Searchable(isSearchable bool) *Field

func (*Field) SetFormFilter

func (field *Field) SetFormFilter(filter *FormFilter) *Field

func (*Field) SuggestionsCustom

func (field *Field) SuggestionsCustom(customSuggestion *SuggestionsCustom) *Field

func (*Field) TextOver

func (field *Field) TextOver(textOver func(string) string) *Field

func (*Field) UnitAfter

func (field *Field) UnitAfter(unit string) *Field

func (*Field) UnitBefore

func (field *Field) UnitBefore(unit string) *Field

func (*Field) Validation

func (field *Field) Validation(fn func(fieldVal any, userData UserData) error)

func (*Field) Wide

func (field *Field) Wide(isWide bool) *Field

type File

type File struct {
	ID          int64  `prago-order-desc:"true"`
	UID         string `prago-unique:"true" prago-type:"cdnfile"`
	Name        string `prago-can-edit:"nobody"`
	Description string `prago-type:"text"`
	User        int64  `prago-type:"relation" prago-can-edit:"nobody"`
	Width       int64  `prago-can-edit:"nobody"`
	Height      int64  `prago-can-edit:"nobody"`
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

File is structure representing files in admin

func (*File) GetExactSize

func (f *File) GetExactSize(width, height int) string

func (*File) GetGiant

func (f *File) GetGiant() string

func (*File) GetLarge

func (f *File) GetLarge() string

func (*File) GetMedium

func (f *File) GetMedium() string

func (*File) GetOriginal

func (f *File) GetOriginal() string

func (*File) GetSmall

func (f *File) GetSmall() string

func (*File) IsImage

func (f *File) IsImage() bool

type Form

type Form struct {
	Action                 string
	Icon                   string
	Title                  string
	DescriptionsBefore     []string
	DescriptionsAfter      []string
	Items                  []*FormItem
	Valid                  bool
	CSRFToken              string
	HTMLAfter              template.HTML
	AutosubmitFirstTime    bool
	AutosubmitOnDataChange bool
	ScriptPaths            []string
	ItemVersion            int64
	BoxHeader              *BoxHeader
	// contains filtered or unexported fields
}

Form represents admin form

func (*Form) AddCAPTCHA

func (form *Form) AddCAPTCHA(name, description string) *FormItem

AddCAPTCHA to form

func (*Form) AddCSRFToken

func (form *Form) AddCSRFToken(request *Request) *Form

func (*Form) AddCheckbox

func (form *Form) AddCheckbox(name, description string) *FormItem

AddCheckbox to form

func (*Form) AddDatePicker

func (form *Form) AddDatePicker(name, description string) *FormItem

AddDatePicker to form

func (*Form) AddDateRange

func (form *Form) AddDateRange(name, description string, from, to time.Time) *FormItem

func (*Form) AddDateTimePicker

func (form *Form) AddDateTimePicker(name, description string) *FormItem

func (*Form) AddDeleteSubmit

func (form *Form) AddDeleteSubmit(description string) *FormItem

AddDeleteSubmit to form

func (*Form) AddEmail

func (form *Form) AddEmail(name, description string) *FormItem

AddEmail to form

func (*Form) AddFile

func (form *Form) AddFile(name, description string) *FormItem

AddFile to form

func (*Form) AddHidden

func (form *Form) AddHidden(name string) *FormItem

AddHidden to form

func (*Form) AddItem

func (form *Form) AddItem(item *FormItem)

AddItem adds form item

func (*Form) AddNumber

func (form *Form) AddNumber(name, description string) *FormItem

func (*Form) AddPassword

func (form *Form) AddPassword(name, description string) *FormItem

AddPassword to form

func (*Form) AddRadio

func (form *Form) AddRadio(name, description string, values [][2]string) *FormItem

func (*Form) AddRadioOptions

func (form *Form) AddRadioOptions(name, description string, options []*FormOption) *FormItem

func (*Form) AddRelation

func (form *Form) AddRelation(name, description string, relatedResourceID string) *FormItem

func (*Form) AddRelationMultiple

func (form *Form) AddRelationMultiple(name, description string, relatedResourceID string) *FormItem

func (*Form) AddSelect

func (form *Form) AddSelect(name, description string, values [][2]string) *FormItem

func (*Form) AddSelectOptions

func (form *Form) AddSelectOptions(name, description string, options []*FormOption) *FormItem

func (*Form) AddSubmit

func (form *Form) AddSubmit(description string) *FormItem

AddSubmit to form

func (*Form) AddText

func (form *Form) AddText(name, description string) *FormItem

AddText to form

func (*Form) AddTextarea

func (form *Form) AddTextarea(name, description string) *FormItem

AddTextarea to form

func (*Form) BindData

func (form *Form) BindData(params url.Values)

BindData to form

func (*Form) Description

func (form *Form) Description(text string)

func (*Form) GetBoxHeader

func (form *Form) GetBoxHeader() *BoxHeader

func (*Form) HeaderIcon

func (form *Form) HeaderIcon() string

func (*Form) HeaderName

func (form *Form) HeaderName() string

type FormFilter

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

func (*FormFilter) Is

func (filter *FormFilter) Is(name string, value any) *FormFilter

func (*FormFilter) Where

func (filter *FormFilter) Where(condition string, values ...any) *FormFilter

type FormItem

type FormItem struct {
	ID                 string
	Icon               string
	Name               string
	Description        string
	DescriptionsBefore []string
	DescriptionsAfter  []string
	Placeholder        string
	Required           bool
	Focused            bool
	Readonly           bool
	HiddenName         bool
	Hidden             bool
	Template           string
	Value              string
	Data               any

	Style string
	Color string

	Content template.HTML

	TextOver string

	UUID string

	Autocomplete string
	InputMode    string

	HelpURL string

	FileMultiple bool
	FileAccept   string

	FormFilterID string

	SuggestionsCustom *SuggestionsCustom

	IsWide                 bool
	PreventPasswordManager bool

	UnitBefore string
	UnitAfter  string
	// contains filtered or unexported fields
}

FormItem represents item of form

func (*FormItem) DateRangeFrom

func (fi *FormItem) DateRangeFrom() string

func (*FormItem) DateRangeTo

func (fi *FormItem) DateRangeTo() string

func (*FormItem) GetColor

func (fi *FormItem) GetColor() string

func (*FormItem) GetContent

func (fi *FormItem) GetContent() template.HTML

func (*FormItem) SetContent

func (fi *FormItem) SetContent(content template.HTML) *FormItem

func (*FormItem) SetCustomSuggestion

func (fi *FormItem) SetCustomSuggestion(suggestionCustom *SuggestionsCustom) *FormItem

func (*FormItem) SetDescription

func (fi *FormItem) SetDescription(description string) *FormItem

func (*FormItem) SetDescriptionsAfter

func (fi *FormItem) SetDescriptionsAfter(after []string) *FormItem

func (*FormItem) SetDescriptionsBefore

func (fi *FormItem) SetDescriptionsBefore(before []string) *FormItem

func (*FormItem) SetFocused

func (fi *FormItem) SetFocused() *FormItem

func (*FormItem) SetFormFilter

func (fi *FormItem) SetFormFilter(formFilter *FormFilter) *FormItem

func (*FormItem) SetIcon

func (fi *FormItem) SetIcon(icon string) *FormItem

func (*FormItem) SetReadonly

func (fi *FormItem) SetReadonly() *FormItem

func (*FormItem) SetTextOver

func (fi *FormItem) SetTextOver(textOver string) *FormItem

func (*FormItem) SetUUID

func (fi *FormItem) SetUUID() *FormItem

func (*FormItem) SetUnitAfter

func (fi *FormItem) SetUnitAfter(unit string) *FormItem

func (*FormItem) SetUnitBefore

func (fi *FormItem) SetUnitBefore(unit string) *FormItem

func (*FormItem) SetValue

func (fi *FormItem) SetValue(value string) *FormItem

type FormOption

type FormOption struct {
	ID                string
	Name              string
	DescriptionBefore string
	DescriptionAfter  string
	TextAfter         string
	Color             string
	Icon              string
	Style             string
	ImageURL          string
	Button            *Button
	//Google Fonts family name (e.g. "Playfair Display"), option name is rendered in this font
	Font string
}

func (*FormOption) FontURL

func (fo *FormOption) FontURL() string

func (*FormOption) GetColor

func (fo *FormOption) GetColor() string

type FormTaskActivity

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

func (*FormTaskActivity) Context

func (fta *FormTaskActivity) Context() context.Context

func (*FormTaskActivity) Description

func (fta *FormTaskActivity) Description(description string)

func (*FormTaskActivity) Progress

func (fta *FormTaskActivity) Progress(finishedSoFar, total int64)

func (*FormTaskActivity) TableCells

func (fta *FormTaskActivity) TableCells(cells ...*TableCell)

type FormTaskView

type FormTaskView struct {
	Description  string
	Progress     float64
	ProgressText string
	Finished     bool
	IsError      bool
}

type FormValidation

type FormValidation interface {
	AddError(err string)
	AddOK(err string)
	AddItemError(key, err string)
	Valid() bool
	Redirect(string)
	AfterContent(template.HTML)
	RunTask(*Request, func(*FormTaskActivity) error)
	Data(any)
	PopupFormURL(string)
}

type Image

type Image struct {
	UUID             string
	ImageName        string
	ImageDescription string
	ViewURL          string
	EditURL          string
	ThumbURL         string
	GiantURL         string

	Metadata [][2]string
}

type ListFilterResponse

type ListFilterResponse struct {
	ID   string
	Name string
}

type MCPTool

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

MCPTool je nástroj, který aplikace vystavuje přes MCP endpoint /admin/api/mcp. Uvidí ho jen uživatelé s oprávněním nastaveným přes Permission.

func (*MCPTool) Permission

func (tool *MCPTool) Permission(permission Permission) *MCPTool

func (*MCPTool) ReadOnly

func (tool *MCPTool) ReadOnly() *MCPTool

ReadOnly označí nástroj, že nic nemění.

type MailingData

type MailingData struct {
	App     *App
	BaseURL string
	LogoURL string
	AppName string

	FromEmail string
	FromName  string

	Tos []*MailingRecipient

	Subject string

	PreName  string
	Name     string
	PostName string

	Images []*File

	Description template.HTML

	Text template.HTML

	Sections []*MailingDataSection

	Button *Button

	FooterDescription template.HTML
}

func (*MailingData) AddRecipient

func (md *MailingData) AddRecipient(name, email string) *MailingData

func (*MailingData) AddSection

func (md *MailingData) AddSection(name, text string) *MailingDataSection

type MailingDataSection

type MailingDataSection struct {
	Name  string
	Text  string
	Table *Table
	Code  string
}

type MailingRecipient

type MailingRecipient struct {
	Name  string
	Email string
}
type MenuItem struct {
	Icon         string
	Image        string
	Name         string
	URL          string
	Subitems     []*MenuItem
	Selected     bool
	Expanded     bool
	SortPriority int64
	NoSearch     bool
	Style        string
}
func (item *MenuItem) IsSelectedOrExpanded() bool

type Notification

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

NotificationItem represents item for notification

func (*Notification) Flash

func (n *Notification) Flash(request *Request) error

func (*Notification) Push

func (n *Notification) Push(userID int64)

func (*Notification) SetDescription

func (n *Notification) SetDescription(description string) *Notification

SetDescription sets description to notification item

func (*Notification) SetImage

func (n *Notification) SetImage(image string) *Notification

func (*Notification) SetPreName

func (n *Notification) SetPreName(preName string) *Notification

SetPreName sets prefix name to notification item

func (*Notification) SetPrimaryAction

func (n *Notification) SetPrimaryAction(name string, fn func()) *Notification

func (*Notification) SetProgress

func (n *Notification) SetProgress(progress *float64) *Notification

SetProgress sets description to notification item

func (*Notification) SetSecondaryAction

func (n *Notification) SetSecondaryAction(name string, fn func()) *Notification

func (*Notification) SetStyleFail

func (n *Notification) SetStyleFail() *Notification

SetTypeFail sets notification item type to fail

func (*Notification) SetStyleSuccess

func (n *Notification) SetStyleSuccess() *Notification

SetTypeSuccess sets notification item type to success

func (*Notification) SetURL

func (n *Notification) SetURL(url string) *Notification

type PageData

type PageData struct {
	Language  string
	Version   string
	GoogleKey string

	LogoHref     string
	LogoImageURL string

	CSSPaths        []string
	JavascriptPaths []string

	Icon  string
	Style string
	Name  string
	App   *App

	AllowSearch bool

	SearchQuery string

	Breadcrumbs *breadcrumbs

	ErrorMessage *pageMessage

	PageContent template.HTML

	MenuItems []*MenuItem

	FooterItems []template.HTML

	BoxHeader *BoxHeader

	Form *Form
	List *list

	Views []*View

	Pagination []*paginationItem

	BoardView *boardView

	NotificationsData string
	HTTPCode          int
	Hue               int64

	AnalyticsCode template.HTML
}

func (*PageData) AddMenuItem

func (pd *PageData) AddMenuItem(item *MenuItem) *PageData

func (*PageData) AddView

func (pd *PageData) AddView(view *View) *PageData

func (*PageData) GetBreadcrumbs

func (pd *PageData) GetBreadcrumbs() *breadcrumbs

func (*PageData) GetIconAndStyle

func (pd *PageData) GetIconAndStyle() (string, string)

func (*PageData) GetIconColor

func (page *PageData) GetIconColor() string

func (*PageData) GetTitle

func (pd *PageData) GetTitle() string

type PageDataSimple

type PageDataSimple struct {
	Request *Request

	BackButtons []*Button

	PreName  string
	Name     string
	PostName string

	BannerImageID string

	Sections []*SimpleSection

	Description template.HTML
	Text        template.HTML

	Form func(*Form)

	PrimaryButton *Button

	AnalyticsCode template.HTML

	FooterText template.HTML

	HTTPCode int
}

func (*PageDataSimple) BackButton

func (pds *PageDataSimple) BackButton(btn *Button)

type Permission

type Permission string

Permission for access

type PhotoGalleryImage

type PhotoGalleryImage struct {
	URL   string
	UUID  string
	Title string
}

type Preview

type Preview struct {
	ID          int64
	Image       string
	ImageID     string
	Icon        string
	Style       string
	URL         string
	Name        string
	Description string
}

func (Preview) GetIconColor

func (preview Preview) GetIconColor() string

type QueryData

type QueryData[T any] struct {
	// contains filtered or unexported fields
}

func (*QueryData[T]) Aggregation

func (q *QueryData[T]) Aggregation() *Aggregation

func (*QueryData[T]) Context

func (q *QueryData[T]) Context(ctx context.Context) *QueryData[T]

func (*QueryData[T]) Count

func (q *QueryData[T]) Count() (int64, error)

func (*QueryData[T]) Debug

func (q *QueryData[T]) Debug() *QueryData[T]

func (*QueryData[T]) First

func (q *QueryData[T]) First() *T

func (*QueryData[T]) ID

func (q *QueryData[T]) ID(id any) *T

func (*QueryData[T]) In

func (q *QueryData[T]) In(name string, value any) *QueryData[T]

func (*QueryData[T]) Is

func (q *QueryData[T]) Is(name string, value any) *QueryData[T]

func (*QueryData[T]) Limit

func (q *QueryData[T]) Limit(limit int64) *QueryData[T]

func (*QueryData[T]) List

func (q *QueryData[T]) List() []*T

func (*QueryData[T]) Offset

func (q *QueryData[T]) Offset(offset int64) *QueryData[T]

func (*QueryData[T]) Order

func (q *QueryData[T]) Order(order string) *QueryData[T]

func (*QueryData[T]) OrderDesc

func (q *QueryData[T]) OrderDesc(order string) *QueryData[T]

func (*QueryData[T]) Where

func (q *QueryData[T]) Where(condition string, values ...any) *QueryData[T]

type Request

type Request struct {
	Written              bool
	ResponseStatus       int
	ResponseTemplateName string
	// contains filtered or unexported fields
}

Request represents structure for http request

func (*Request) AddFlashMessage

func (request *Request) AddFlashMessage(message string)

func (*Request) Authorize

func (request *Request) Authorize(permission Permission) bool

func (*Request) CreateWithLog

func (request *Request) CreateWithLog[T any](item *T) error

func (*Request) DeleteUserPreference

func (request *Request) DeleteUserPreference(name string)

func (*Request) DeleteWithLog

func (request *Request) DeleteWithLog[T any](item *T) error

func (*Request) Duration

func (request *Request) Duration() time.Duration

func (*Request) Email

func (request *Request) Email() string

func (*Request) GetUserPreference

func (request *Request) GetUserPreference(name string) *string

func (*Request) Locale

func (request *Request) Locale() string

func (*Request) Name

func (request *Request) Name() string

func (Request) Param

func (request Request) Param(name string) string

func (Request) Params

func (request Request) Params() url.Values

Params returns url.Values of request

func (*Request) ParseDateRange

func (request *Request) ParseDateRange(itemID string) *[2]time.Time

func (*Request) Phone

func (request *Request) Phone() string

func (*Request) Redirect

func (request *Request) Redirect(url string)

Redirect redirects request to new url

func (Request) Request

func (request Request) Request() *http.Request

Request returns underlying http.Request

func (Request) Response

func (request Request) Response() http.ResponseWriter

Response returns underlying http.ResponseWriter

func (*Request) Role

func (request *Request) Role() string

func (*Request) SetUserPreference

func (request *Request) SetUserPreference(name string, value string)

func (*Request) UpdateWithLog

func (request *Request) UpdateWithLog[T any](item *T) error

func (*Request) UserID

func (request *Request) UserID() int64

UserID returns id of logged in user, returns 0 if no user is logged

func (*Request) WriteHTML

func (request *Request) WriteHTML(statusCode int, templates *Templates, templateName string, data any)

WriteHTML renders HTML view with HTTP code

func (*Request) WriteJSON

func (request *Request) WriteJSON(statusCode int, data any)

WriteJSON renders JSON with HTTP code

type Resource

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

func (*Resource) Board

func (resource *Resource) Board(board *Board) *Resource

func (*Resource) Dashboard

func (resource *Resource) Dashboard(name func(string) string) *Dashboard

func (*Resource) DefaultValue

func (resource *Resource) DefaultValue(fieldName string, fn func(request *Request) string) *Resource

func (*Resource) Field

func (resource *Resource) Field(name string) *Field

func (*Resource) Icon

func (resource *Resource) Icon(icon string) *Resource

func (*Resource) ItemsPerPage

func (resource *Resource) ItemsPerPage(itemsPerPage int64) *Resource

func (*Resource) Name

func (resource *Resource) Name(singularName, pluralName func(string) string) *Resource

func (*Resource) PermissionCreate

func (resource *Resource) PermissionCreate(permission Permission) *Resource

func (*Resource) PermissionDelete

func (resource *Resource) PermissionDelete(permission Permission) *Resource

func (*Resource) PermissionExport

func (resource *Resource) PermissionExport(permission Permission) *Resource

func (*Resource) PermissionUpdate

func (resource *Resource) PermissionUpdate(permission Permission) *Resource

func (*Resource) PermissionView

func (resource *Resource) PermissionView(permission Permission) *Resource

type Setting

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

func (*Setting) DefaultValue

func (setting *Setting) DefaultValue(defaultValue string) *Setting

func (*Setting) GetValue

func (setting *Setting) GetValue() string

func (*Setting) Name

func (setting *Setting) Name(name func(string) string) *Setting

func (*Setting) ValueChangeCallback

func (setting *Setting) ValueChangeCallback(fn func()) *Setting

type SimpleSection

type SimpleSection struct {
	Icon        string
	Name        string
	Description string
	Text        template.HTML
	LogoURL     string

	Table *Table

	PrimaryButton *Button
	Buttons       []*Button

	Accordions []*Accordion
}

type Suggestion

type Suggestion struct {
	ID          string
	Image       string
	URL         string
	Name        string
	Description string

	SetValues map[string]string
}

type SuggestionsCustom

type SuggestionsCustom struct {
	UUID string

	ContextFields string
	// contains filtered or unexported fields
}

type SuggestionsRequest

type SuggestionsRequest struct {
	CustomUUID    string
	Resource      string
	Q             string
	Filter        string
	ContextValues map[string]string
}

type SuggestionsResponse

type SuggestionsResponse struct {
	Message     string
	Suggestions []*Suggestion
	Buttons     []*Button
}

func SuggestionsResponseFromArray

func SuggestionsResponseFromArray(in []string) *SuggestionsResponse

type Table

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

func (*Table) AddFooterText

func (t *Table) AddFooterText(text string)

func (*Table) AddTable

func (table *Table) AddTable() *Table

func (*Table) Cell

func (table *Table) Cell(item any) *TableCell

func (*Table) ExecuteHTML

func (t *Table) ExecuteHTML() template.HTML

TODO execute right into response

func (*Table) ExportXLSX

func (t *Table) ExportXLSX(writer io.Writer) error

func (*Table) Header

func (table *Table) Header(items ...string) *Table

func (*Table) Javascript

func (table *Table) Javascript(javascript template.JS) *Table

func (*Table) Row

func (table *Table) Row(items ...*TableCell) *Table

func (*Table) ToExcelFile

func (table *Table) ToExcelFile() ([]byte, error)

type TableCell

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

func Cell

func Cell(item any) *TableCell

func (*TableCell) AsyncDataURL

func (cell *TableCell) AsyncDataURL(url string) *TableCell

func (*TableCell) Button

func (cell *TableCell) Button(btn *Button) *TableCell

func (*TableCell) CSSClass

func (cell *TableCell) CSSClass(class string) *TableCell

func (*TableCell) Center

func (cell *TableCell) Center() *TableCell

func (*TableCell) Checkbox

func (cell *TableCell) Checkbox(name string, checked bool) *TableCell

func (*TableCell) Colspan

func (cell *TableCell) Colspan(i int64) *TableCell

func (*TableCell) DescriptionAfter

func (cell *TableCell) DescriptionAfter(description string) *TableCell

func (*TableCell) DescriptionBefore

func (cell *TableCell) DescriptionBefore(description string) *TableCell

func (*TableCell) Files

func (cell *TableCell) Files(app *App, fileIDs string) *TableCell

func (*TableCell) Green

func (cell *TableCell) Green() *TableCell

func (*TableCell) Header

func (cell *TableCell) Header() *TableCell

func (*TableCell) Nowrap

func (cell *TableCell) Nowrap() *TableCell

func (*TableCell) Orange

func (cell *TableCell) Orange() *TableCell

func (*TableCell) Pre

func (cell *TableCell) Pre() *TableCell

func (*TableCell) Progress

func (cell *TableCell) Progress(progress float64) *TableCell

func (*TableCell) Red

func (cell *TableCell) Red() *TableCell

func (*TableCell) Right

func (cell *TableCell) Right() *TableCell

func (*TableCell) Rowspan

func (cell *TableCell) Rowspan(i int64) *TableCell

func (*TableCell) Style

func (cell *TableCell) Style(style template.CSS) *TableCell

func (*TableCell) TextAfter

func (cell *TableCell) TextAfter(text string) *TableCell

func (*TableCell) Textarea

func (cell *TableCell) Textarea(value string) *TableCell

func (*TableCell) URL

func (cell *TableCell) URL(link string) *TableCell

type TableCellAsyncData

type TableCellAsyncData struct {
	DescriptionsBefore []string
	Text               string
	DescriptionsAfter  []string

	Green  bool
	Orange bool
	Red    bool
}

type Templates

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

func NewTemplates

func NewTemplates() *Templates

func (*Templates) Execute

func (templates *Templates) Execute(wr io.Writer, name string, data any) error

func (*Templates) ExecuteToHTML

func (templates *Templates) ExecuteToHTML(templateName string, data any) template.HTML

func (*Templates) ExecuteToString

func (templates *Templates) ExecuteToString(templateName string, data any) string

func (*Templates) Function

func (templates *Templates) Function(name string, f any)

func (*Templates) SetFilesystem

func (templates *Templates) SetFilesystem(fsys fs.FS, patterns ...string) error

type TemporaryCacheData

type TemporaryCacheData[T any] struct {
	// contains filtered or unexported fields
}

func (TemporaryCacheData[T]) GetItemByID

func (tc TemporaryCacheData[T]) GetItemByID(id int64) *T

type Timeline

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

func (*Timeline) Center

func (timeline *Timeline) Center() *Timeline

func (*Timeline) FilterName

func (timeline *Timeline) FilterName(key string, fn func(request *Request, value string) (string, string)) *Timeline

func (*Timeline) Future

func (timeline *Timeline) Future() *Timeline

func (*Timeline) OptionsForm

func (timeline *Timeline) OptionsForm(fn func(request *Request, form *Form)) *Timeline

func (*Timeline) Unit

func (timeline *Timeline) Unit(unit func(string) string) *Timeline

type TimelineDataFilter

type TimelineDataFilter struct {
	KeyName   string
	ValueName string
}

type TimelineDataRequest

type TimelineDataRequest struct {
	From    time.Time
	To      time.Time
	Options map[string]string
	Request *Request
}

func (*TimelineDataRequest) Context

func (tdr *TimelineDataRequest) Context() context.Context

type TimelineRequest

type TimelineRequest struct {
	UUID       string
	DateStr    string
	Width      int64
	ValueCache map[string]float64
	Alignment  string
	Options    map[string]string
}

type UserData

type UserData interface {
	Name() string
	Locale() string
	Email() string
	Phone() string
	Authorize(Permission) bool
	UserID() int64
	Role() string
}

type Validation

type Validation interface {
	AddError(err string)
	AddItemError(key, err string)
	Valid() bool
}

type ValidationError

type ValidationError struct {
	OK    bool
	Field string
	Text  string
}

type View

type View struct {
	Icon     string
	Name     string
	SubNames []string

	ViewContent *ViewContent

	Buttons []*Button

	Relation *viewRelationItem
}

type ViewContent

type ViewContent struct {
	Empty bool

	Icon string
	Name string

	Color string
	Style string

	ContentHTML template.HTML

	Previews    []*Preview
	CDNFileData *cdnFileData

	Images       []*Image
	ImagesSimple []*Image

	PlaceData string

	VideoURL string

	Accordions []*Accordion

	Buttons []*Button
}

func (*ViewContent) HasNameOrIcon

func (vfc *ViewContent) HasNameOrIcon() bool

func (*ViewContent) IconColor

func (vfc *ViewContent) IconColor() string

func (*ViewContent) IsEmpty

func (vf *ViewContent) IsEmpty() bool

type Writer

type Writer[T any] struct {
	// contains filtered or unexported fields
}

func (*Writer[T]) After

func (w *Writer[T]) After(fn func(request *Request, item *T)) *Writer[T]

func (*Writer[T]) Before

func (w *Writer[T]) Before(fn func(request *Request, item *T)) *Writer[T]

func (*Writer[T]) GET

func (w *Writer[T]) GET(path string, handler func(request *Request, item *T), constraints ...Constraint)

func (*Writer[T]) POST

func (w *Writer[T]) POST(path string, handler func(request *Request, item *T), constraints ...Constraint)

Source Files

Directories

Path Synopsis
pragoai module
pragobleve module

Jump to

Keyboard shortcuts

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