common

package
v0.0.0-...-5a58481 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CommonConfig    = &ViewCommonConfig{}
	RegisteredViews = map[string]RegisteredView{}
)

Functions

func DeleteViewDefinition

func DeleteViewDefinition(id string) error

DeleteViewDefinition delete a given view def by id from the store

func GenerateViewConfigSpecJson

func GenerateViewConfigSpecJson(v ViewConfig) map[string]interface{}

func RegisterView

func RegisterView(name string, creator RegisteredView)

func SaveViewDefinition

func SaveViewDefinition(definition ViewDefinition) error

SaveViewDefinition saves a view definition to the store

func SetViewCommonConfig

func SetViewCommonConfig(config *ViewCommonConfig)

func TemplateRefresh

func TemplateRefresh(v View)

TemplateRefresh static function to generate a View's template

func ValidateViewConfig

func ValidateViewConfig(v ViewConfig) error

ValidateViewConfig takes a ViewConfig and using the rules defined by "spec" field tags, it validates the configuration

Types

type BaseView

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

func (*BaseView) Init

func (v *BaseView) Init()

func (*BaseView) SetTemplate

func (v *BaseView) SetTemplate(t *compCommon.Template)

func (*BaseView) SetTemplateValue

func (v *BaseView) SetTemplateValue(t compCommon.Template)

func (*BaseView) Stop

func (v *BaseView) Stop()

func (*BaseView) Template

func (v *BaseView) Template() *compCommon.Template

func (*BaseView) TemplateData

func (v *BaseView) TemplateData() map[string]interface{}

func (*BaseView) TemplateString

func (v *BaseView) TemplateString() string

type FieldMetadata

type FieldMetadata struct {
	FieldName string
	Tags      []TagMetadata
	Type      reflect.Type
	Kind      reflect.Kind
	Value     interface{}
}

FieldMetadata the individual key/value pairs defined on a specific field

type RegisteredView

type RegisteredView struct {
	NewConfig func() ViewConfig
	NewView   func(ViewConfig) (View, error)
}

RegisteredView set of generic functions to a create a given View's config and the View itself

type StructMetadata

type StructMetadata struct {
	TypeName string
	Fields   []FieldMetadata
}

StructMetadata the tag metadata related to a specific struct and tag name

type TagMetadata

type TagMetadata struct {
	Key   string
	Value string
}

TagMetadata key/value pair of a tag

type View

type View interface {
	Init()
	Template() *compCommon.Template
	SetTemplate(*compCommon.Template)
	SetTemplateValue(compCommon.Template)
	TemplateString() string
	TemplateData() map[string]interface{}
	Stop()
}

View a structure to describe a layout of components at a given time

type ViewCommonConfig

type ViewCommonConfig struct {
	MatrixRows        int
	MatrixCols        int
	ImageDir          string
	CacheDir          string
	DefaultImageSizeX int
	DefaultImageSizeY int
	DefaultFontSize   int
	DefaultFontColor  string
	DefaultFontStyle  string
	DefaultFontType   string
	Store             *store.Store
}

ViewCommonConfig a set of global application configuration useful for rendering Views

type ViewConfig

type ViewConfig interface{}

ViewConfig type alias to hold raw config definition for a View

type ViewConfigFieldSpec

type ViewConfigFieldSpec struct {
	Field    string
	JsonKey  string
	Type     reflect.Type
	Value    interface{}
	Kind     reflect.Kind
	Required bool
	Min      int
	Max      int
	Label    string
}

type ViewDefinition

type ViewDefinition struct {
	Id     string     `json:"id" spec:"label='View Definition ID',required='true'"`
	Name   string     `json:"name" spec:"label='View Definition Name',required='true'"`
	Type   string     `json:"type" spec:"label='View Type',required='true'"`
	Config ViewConfig `json:"config" spec:"label='View Config',required='true'"`
}

ViewDefinition what defines a View? The Type of View it is and the View's configuration

func GetAllViewDefinitions

func GetAllViewDefinitions() ([]ViewDefinition, error)

GetAllViewDefinitions retrieves all saved view definitions from the store

func GetViewDefinition

func GetViewDefinition(id string) (ViewDefinition, error)

GetViewConfig retrieves a view definition from the store by name

type ViewDefinitionRaw

type ViewDefinitionRaw struct {
	Id     string          `json:"id"`
	Name   string          `json:"name"`
	Type   string          `json:"type"`
	Config json.RawMessage `json:"config"`
}

ViewDefinitionRaw similar to ViewDefinition, but Config is json.RawMessage ([]byte)

Jump to

Keyboard shortcuts

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