app

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2020 License: MIT Imports: 23 Imported by: 0

README

wel-app

Documentation

Index

Constants

View Source
const (
	CanvasQuarter = 0.25 // 1/4
	CanvasHalf    = 0.5  // 1/2
	CanvasFull    = 1    // 1/1
)
View Source
const (
	ThresholdLevelInfo    = "info"
	ThresholdLevelWarn    = "warn"
	ThresholdLevelError   = "error"
	ThresholdLevelSuccess = "success"
)

Variables

View Source
var Root = ""

Functions

This section is empty.

Types

type Action

type Action struct {
}

type ActionConfig

type ActionConfig struct {
	Action *Action `yaml:"action" json:"action"`
}

type App

type App struct {
	Id           string `yaml:"id" json:"id"` // distributed by wel.teaos.cn
	Name         string `yaml:"name" json:"name"`
	Description  string `yaml:"description" json:"description"`
	Developer    string `yaml:"developer" json:"developer"`
	Site         string `yaml:"site" json:"site"`
	Version      string `yaml:"version" json:"version"`
	DocumentSite string `yaml:"documentSite" json:"documentSite"`
	SourceSite   string `yaml:"sourceSite" json:"sourceSite"`
	DownloadSite string `yaml:"downloadSite" json:"downloadSite"`
}

func NewApp

func NewApp() *App

type ChartCanvas

type ChartCanvas struct {
	Id          string                `yaml:"id" json:"id"`
	Name        string                `yaml:"name" json:"name"`
	Type        string                `yaml:"type" json:"type"`
	OptionsJSON string                `yaml:"options" json:"options"`
	Chart       charts.ChartInterface `yaml:"chart" json:"chart"`

	WidthPercent  float32 `yaml:"widthPercent" json:"widthPercent"`
	HeightPercent float32 `yaml:"heightPercent" json:"heightPercent"`

	LeftMenu  *charts.Menu `yaml:"leftMenu" json:"leftMenu"`
	RightMenu *charts.Menu `yaml:"rightMenu" json:"rightMenu"`
}

chart canvas

func NewChartCanvas

func NewChartCanvas(id string, name string, widthPercent float32, heightPercent float32) *ChartCanvas

func (*ChartCanvas) Fetch

func (this *ChartCanvas) Fetch(db *dbs.DB) error

func (*ChartCanvas) SetChart

func (this *ChartCanvas) SetChart(chart charts.ChartInterface)

func (*ChartCanvas) SetParam added in v0.0.2

func (this *ChartCanvas) SetParam(param *charts.Param)

type CommandMsg

type CommandMsg struct {
	Id   string
	Code string
	Args map[string]string
}

type Dashboard

type Dashboard struct {
	Id      string         `yaml:"id" json:"id"`
	Version string         `yaml:"version" json:"version"`
	Name    string         `yaml:"name" json:"name"`
	Charts  []*ChartCanvas `yaml:"charts" json:"charts"`
}

func NewDashboard

func NewDashboard(id, version, name string) *Dashboard

func NewDefaultDashboard

func NewDefaultDashboard(version string) *Dashboard

func (*Dashboard) AddChart

func (this *Dashboard) AddChart(canvas *ChartCanvas)

func (*Dashboard) FindChart added in v0.0.2

func (this *Dashboard) FindChart(canvasId string) *ChartCanvas

type Fetcher

type Fetcher func(options map[string]string) (result map[string]string, err error)

type HTTPServer

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

func NewHTTPServer

func NewHTTPServer(wel *Wel, address string) *HTTPServer

func (*HTTPServer) Start

func (this *HTTPServer) Start() error

type Instance

type Instance struct {
	Id       string            `yaml:"id" json:"id"`
	Name     string            `yaml:"name" json:"name"`
	Options  map[string]string `yaml:"options" json:"options"`
	Interval int               `yaml:"interval" json:"interval"` // seconds

	Operations []*Operation `yaml:"operations" json:"operations"`

	Thresholds []*Threshold   `yaml:"thresholds" json:"thresholds"`
	Dashboards []*Dashboard   `yaml:"dashboards" json:"dashboards"`
	Charts     []*ChartCanvas `yaml:"charts" json:"charts"`
}

wel instance

func LoadInstanceFromPath

func LoadInstanceFromPath(path string) (*Instance, error)

load instance from file

func NewInstance

func NewInstance() *Instance

create a new instance

func (*Instance) FindDashboard

func (this *Instance) FindDashboard(dashboardId string) *Dashboard

func (*Instance) Write

func (this *Instance) Write(file string) error

write to a file

type Operation

type Operation struct {
	Code        string `yaml:"code" json:"code"`
	Name        string `yaml:"name" json:"name"`
	Description string `yaml:"description" json:"description"`
	// contains filtered or unexported fields
}

func NewOperation

func NewOperation() *Operation

func (*Operation) Handler

func (this *Operation) Handler() OperationHandler

func (*Operation) OnRun

func (this *Operation) OnRun(handler OperationHandler)

type OperationHandler

type OperationHandler func(options map[string]string) (result string, err error)

type ReplyMsg

type ReplyMsg struct {
	Id     string
	Code   string
	Result interface{}
	Error  string
}

type Threshold

type Threshold struct {
	Expr    string          `yaml:"expr" json:"expr"`
	Level   ThresholdLevel  `yaml:"level" json:"level"`
	Actions []*ActionConfig `yaml:"actions" json:"actions"`
}

func NewThreshold

func NewThreshold() *Threshold

type ThresholdLevel

type ThresholdLevel = string

type Wel

type Wel struct {
	Id          string `yaml:"id" json:"id"`
	Name        string `yaml:"name" json:"name"`
	Description string `yaml:"description" json:"description"`
	Developer   string `yaml:"developer" json:"developer"`
	Version     string `yaml:"version" json:"version"`
	Site        string `yaml:"site" json:"site"`

	Options []options.OptionInterface `yaml:"options" json:"options"`

	Apps       []*App       `yaml:"apps" json:"apps"`
	Operations []*Operation `yaml:"operations" json:"operations"`

	ThresholdTemplates []*Threshold   `yaml:"thresholdTemplates" json:"thresholdTemplates"`
	DashboardTemplates []*Dashboard   `yaml:"dashboardTemplates" json:"dashboardTemplates"`
	ChartTemplates     []*ChartCanvas `yaml:"chartTemplates" json:"chartTemplates"`
	// contains filtered or unexported fields
}

func NewWel

func NewWel() *Wel

func (*Wel) AddAllChartsToDashboard added in v0.0.2

func (this *Wel) AddAllChartsToDashboard(dashboard *Dashboard)

func (*Wel) AddApp

func (this *Wel) AddApp(app ...*App)

func (*Wel) AddChartCanvas added in v0.0.2

func (this *Wel) AddChartCanvas(canvas *ChartCanvas)

func (*Wel) AddChartsToDashboard

func (this *Wel) AddChartsToDashboard(dashboard *Dashboard, chartId ...string)

func (*Wel) AddDashboard

func (this *Wel) AddDashboard(dashboard *Dashboard)

func (*Wel) AddOperation

func (this *Wel) AddOperation(operation ...*Operation)

func (*Wel) AddOption

func (this *Wel) AddOption(option ...options.OptionInterface)

func (*Wel) AddThreshold

func (this *Wel) AddThreshold(thresholdTemplate *Threshold)

func (*Wel) Fetch

func (this *Wel) Fetch(options map[string]string) (result map[string]string, err error)

func (*Wel) FindChart

func (this *Wel) FindChart(chartId string) *ChartCanvas

func (*Wel) FindOperation

func (this *Wel) FindOperation(code string) *Operation

func (*Wel) OnFetch

func (this *Wel) OnFetch(fetcher Fetcher)

func (*Wel) Run

func (this *Wel) Run()

func (*Wel) RunCmd

func (this *Wel) RunCmd(cmd string, args []string, writer io.Writer) error

func (*Wel) ServeHTTP

func (this *Wel) ServeHTTP(address string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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