forms

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ask added in v0.16.0

type Ask struct {
	Prompt    string
	Multiline bool
	Uppercase bool
}

type Config

type Config struct {
	FormsPath  string
	MyCall     string
	Locator    string
	AppVersion string
	LineReader func() string
	UserAgent  string
	GPSd       cfg.GPSdConfig
}

Config passes config options to the forms package

type FormFolder

type FormFolder struct {
	Name      string       `json:"name"`
	Path      string       `json:"path"`
	Version   string       `json:"version"`
	FormCount int          `json:"form_count"`
	Forms     []Template   `json:"forms"`
	Folders   []FormFolder `json:"folders"`
}

FormFolder is a folder with forms. A tree structure with Form leaves and sub-Folder branches

type Manager

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

Manager manages the forms subsystem

func NewManager

func NewManager(conf Config) *Manager

NewManager instantiates the forms manager

func (*Manager) ComposeTemplate added in v0.16.0

func (m *Manager) ComposeTemplate(templatePath string, subject string) (Message, error)

ComposeTemplate composes a message from a template (templatePath) by prompting the user through stdio.

It combines all data needed for the whole template-based message: subject, body, and attachments.

func (*Manager) GetFormDataHandler

func (m *Manager) GetFormDataHandler(w http.ResponseWriter, r *http.Request)

GetFormDataHandler is the counterpart to PostFormDataHandler. Returns the form field values to the frontend

func (*Manager) GetFormTemplateHandler

func (m *Manager) GetFormTemplateHandler(w http.ResponseWriter, r *http.Request)

GetFormTemplateHandler serves a template's HTML form (filled-in with instance values)

func (*Manager) GetFormsCatalogHandler

func (m *Manager) GetFormsCatalogHandler(w http.ResponseWriter, r *http.Request)

GetFormsCatalogHandler reads all forms from config.FormsPath and writes them in the http response as a JSON object graph This lets the frontend present a tree-like GUI for the user to select a form for composing a message

func (*Manager) GetPostedFormData

func (m *Manager) GetPostedFormData(key string) (Message, bool)

GetPostedFormData is similar to GetFormDataHandler, but used when posting the form-based message to the outbox

func (*Manager) PostFormDataHandler

func (m *Manager) PostFormDataHandler(w http.ResponseWriter, r *http.Request)

PostFormDataHandler - When the user is done filling a form, the frontend posts the input fields to this handler, which stores them in a map, so that other browser tabs can read the values back with GetFormDataHandler

func (*Manager) RenderForm

func (m *Manager) RenderForm(data []byte, composeReply bool) (string, error)

RenderForm finds the associated form and returns the filled-in form in HTML given the contents of a form attachment

func (*Manager) UpdateFormTemplates

func (m *Manager) UpdateFormTemplates(ctx context.Context) (UpdateResponse, error)

UpdateFormTemplates handles searching for and installing the latest version of the form templates.

func (*Manager) UpdateFormTemplatesHandler

func (m *Manager) UpdateFormTemplatesHandler(w http.ResponseWriter, r *http.Request)

UpdateFormTemplatesHandler handles API calls to update form templates.

type Message added in v0.16.0

type Message struct {
	To          string      `json:"msg_to"`
	Cc          string      `json:"msg_cc"`
	Subject     string      `json:"msg_subject"`
	Body        string      `json:"msg_body"`
	Attachments []*fbb.File `json:"-"`
	// contains filtered or unexported fields
}

Message represents a concrete message compiled from a template

type Option added in v0.16.0

type Option struct {
	Item  string
	Value string
}

type Select added in v0.16.0

type Select struct {
	Prompt  string
	Options []Option
}

type Template added in v0.16.0

type Template struct {
	// The name of this template.
	Name string `json:"name"`

	// Absolute path to the template file represented by this struct.
	//
	// Note: The web gui uses relative paths, and for these instances the
	// value is set accordingly.
	Path string `json:"template_path"`

	// Absolute path to the optional HTML Form composer (aka "input form").
	InputFormPath string `json:"-"`

	// Absolute path to the optional HTML Form viewer (aka "display form").
	DisplayFormPath string `json:"-"`

	// Absolute path to the optional reply template.
	ReplyTemplatePath string `json:"-"`
}

Template holds information about a Winlink template.

type UpdateResponse

type UpdateResponse struct {
	NewestVersion string `json:"newestVersion"`
	Action        string `json:"action"`
}

UpdateResponse is the API response format for the upgrade forms endpoint

Jump to

Keyboard shortcuts

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