Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteDashboardElement(adb *database.AdminDB, oid string, deid string) error
- func DeleteElementHandler(w http.ResponseWriter, r *http.Request)
- func ReadElementHandler(w http.ResponseWriter, r *http.Request)
- func ReadHandler(w http.ResponseWriter, r *http.Request)
- func SQLUpdater(db *database.AdminDB, i *run.Info, h run.BuiltinHelper, curversion int) error
- func StartDashboard(db *database.AdminDB, i *run.Info, h run.BuiltinHelper) error
- func WriteDashboard(adb *database.AdminDB, as string, oid string, elements []DashboardElement) error
- func WriteElementHandler(w http.ResponseWriter, r *http.Request)
- func WriteHandler(w http.ResponseWriter, r *http.Request)
- type CompressedJSON
- type DashboardElement
- type DashboardEvent
- type DashboardProcessor
- func (dp *DashboardProcessor) Fire(e *events.Event)
- func (dp *DashboardProcessor) Query(as string, oid string, eid string, etype string, q []byte) (data []byte, err error)
- func (dp *DashboardProcessor) RunQ(as, oid string, eid string, etype string, q []byte) (*QueryResult, error)
- func (dp *DashboardProcessor) UpdateElement(as string, de *DashboardElement) (chan bool, error)
- type DashboardSettings
- type DashboardType
- type HandlerGetter
- type QueryResult
Constants ¶
const PluginName = "dashboard"
Variables ¶
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
var SQLVersion = 1
Functions ¶
func DeleteDashboardElement ¶
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 ¶
SQLUpdater is in the format expected by Heedy to update the database
func StartDashboard ¶
func WriteDashboard ¶
func WriteElementHandler ¶
func WriteElementHandler(w http.ResponseWriter, r *http.Request)
func WriteHandler ¶
func WriteHandler(w http.ResponseWriter, r *http.Request)
Types ¶
type CompressedJSON ¶
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
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 ¶
type DashboardEvent ¶
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 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 QueryResult ¶
type QueryResult struct { Events *[]DashboardEvent `json:"events,omitempty"` Data CompressedJSON `json:"data"` }