dashboard

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const PluginName = "dashboard"

Variables

View Source
var Handler = func() *chi.Mux {
	m := chi.NewMux()

	m.Get("/object/dashboard", ReadHandler)
	m.Post("/object/dashboard", WriteHandler)
	m.Get("/object/dashboard/{element_id}", ReadElementHandler)
	m.Patch("/object/dashboard/{element_id}", WriteElementHandler)
	m.Delete("/object/dashboard/{element_id}", DeleteElementHandler)

	m.NotFound(rest.NotFoundHandler)
	m.MethodNotAllowed(rest.NotFoundHandler)

	return m
}()

Handler is the global router for the timeseries API

View Source
var SQLVersion = 1

Functions

func DeleteDashboardElement

func DeleteDashboardElement(adb *database.AdminDB, oid string, deid string) error

func DeleteElementHandler

func DeleteElementHandler(w http.ResponseWriter, r *http.Request)

func ReadElementHandler

func ReadElementHandler(w http.ResponseWriter, r *http.Request)

func ReadHandler

func ReadHandler(w http.ResponseWriter, r *http.Request)

ReadDashboard reads the entire dashboard

func SQLUpdater

func SQLUpdater(db *database.AdminDB, i *run.Info, h run.BuiltinHelper, curversion int) error

SQLUpdater is in the format expected by Heedy to update the database

func StartDashboard

func StartDashboard(db *database.AdminDB, i *run.Info, h run.BuiltinHelper) error

func WriteDashboard

func WriteDashboard(adb *database.AdminDB, as string, oid string, elements []DashboardElement) error

func WriteElementHandler

func WriteElementHandler(w http.ResponseWriter, r *http.Request)

func WriteHandler

func WriteHandler(w http.ResponseWriter, r *http.Request)

Types

type CompressedJSON

type CompressedJSON types.JSONText

func (CompressedJSON) MarshalJSON

func (j CompressedJSON) MarshalJSON() ([]byte, error)

func (*CompressedJSON) Scan

func (j *CompressedJSON) Scan(src interface{}) error

Scan stores the src in *j. No validation is done.

func (*CompressedJSON) UnmarshalJSON

func (j *CompressedJSON) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *j to a copy of data

func (CompressedJSON) Value

func (j CompressedJSON) Value() (driver.Value, error)

Value returns j as a value. This does a validating unmarshal into another RawMessage. If j is invalid json, it returns an error.

type DashboardElement

type DashboardElement struct {
	ID       string `json:"id,omitempty" db:"element_id"`
	ObjectID string `json:"object_id,omitempty" db:"object_id"`
	Index    *int   `json:"index,omitempty" db:"element_index"`

	Type     string `json:"type,omitempty" db:"type"`
	OnDemand *bool  `json:"on_demand,omitempty" db:"on_demand"`

	Title    *string         `json:"title,omitempty"`
	Query    *types.JSONText `json:"query,omitempty"`
	Data     *CompressedJSON `json:"data,omitempty"`
	Settings *types.JSONText `json:"settings,omitempty"`

	// Internal variable
	Outdated bool `json:"-"`
}

func ReadDashboard

func ReadDashboard(adb *database.AdminDB, as string, oid string, include_query bool) ([]DashboardElement, error)

ReadDashboard returns the full dashboard data

func ReadDashboardElement

func ReadDashboardElement(adb *database.AdminDB, as string, oid string, deid string, include_query bool) (*DashboardElement, error)

type DashboardEvent

type DashboardEvent struct {
	ObjectID string `json:"object" db:"event_object_id"`
	Event    string `json:"event"`
}

type DashboardProcessor

type DashboardProcessor struct {
	ADB *database.AdminDB

	Types map[string]*DashboardType

	// The actively waiting dashboards are set here
	sync.Mutex
	// contains filtered or unexported fields
}

The DashboardProcessor is a global object that handles all background tasks that happen with dashboards

var Dashboard *DashboardProcessor

Dashboard is a global variable that is initialized with NewDashboardProcessor when the plugin is set up

func NewDashboardProcessor

func NewDashboardProcessor(db *database.AdminDB, p *assets.Plugin, h HandlerGetter) (*DashboardProcessor, error)

func (*DashboardProcessor) Fire

func (dp *DashboardProcessor) Fire(e *events.Event)

Fire handles events

func (*DashboardProcessor) Query

func (dp *DashboardProcessor) Query(as string, oid string, eid string, etype string, q []byte) (data []byte, err error)

Query performs a dashboard query as user/app "as" for element etype, with query q Query always returns valid bytes, even if there is an error - in that case it returns json error response

func (*DashboardProcessor) RunQ

func (dp *DashboardProcessor) RunQ(as, oid string, eid string, etype string, q []byte) (*QueryResult, error)

func (*DashboardProcessor) UpdateElement

func (dp *DashboardProcessor) UpdateElement(as string, de *DashboardElement) (chan bool, error)

type DashboardSettings

type DashboardSettings struct {
	Types map[string]struct {
		API            string                 `mapstructure:"api"`
		QuerySchema    map[string]interface{} `mapstructure:"query_schema"`
		FrontendSchema map[string]interface{} `mapstructure:"frontend_schema"`
	} `mapstructure:"types"`
}

type DashboardType

type DashboardType struct {
	URI            string
	Handler        http.Handler
	QuerySchema    *gojsonschema.Schema
	FrontendSchema *gojsonschema.Schema
}

func (DashboardType) Validate

func (dt DashboardType) Validate(de *DashboardElement) error

type HandlerGetter

type HandlerGetter interface {
	GetHandler(uri string) (http.Handler, error)
}

type QueryResult

type QueryResult struct {
	Events *[]DashboardEvent `json:"events,omitempty"`
	Data   CompressedJSON    `json:"data"`
}

Jump to

Keyboard shortcuts

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