2019-02-26 04:36:23 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
2019-03-08 04:04:46 +00:00
|
|
|
"github.com/sqshq/sampler/console"
|
2019-02-26 04:36:23 +00:00
|
|
|
ui "github.com/sqshq/termui"
|
|
|
|
)
|
|
|
|
|
2019-03-08 04:04:46 +00:00
|
|
|
type ComponentType rune
|
|
|
|
|
|
|
|
const (
|
|
|
|
TypeRunChart ComponentType = 0
|
|
|
|
TypeBarChart ComponentType = 1
|
|
|
|
TypeTextBox ComponentType = 2
|
|
|
|
TypeAsciiBox ComponentType = 3
|
|
|
|
TypeGauge ComponentType = 4
|
|
|
|
)
|
|
|
|
|
2019-02-26 04:36:23 +00:00
|
|
|
type ComponentConfig struct {
|
2019-03-05 03:25:17 +00:00
|
|
|
Title string `yaml:"title"`
|
|
|
|
RefreshRateMs *int `yaml:"refresh-rate-ms,omitempty"`
|
|
|
|
Position Position `yaml:"position"`
|
|
|
|
Size Size `yaml:"size"`
|
|
|
|
Triggers []TriggerConfig `yaml:"triggers,omitempty"`
|
2019-02-26 04:36:23 +00:00
|
|
|
}
|
|
|
|
|
2019-03-03 19:35:29 +00:00
|
|
|
type TriggerConfig struct {
|
2019-03-03 23:35:32 +00:00
|
|
|
Title string `yaml:"title"`
|
|
|
|
Condition string `yaml:"condition"`
|
|
|
|
Actions *ActionsConfig `yaml:"actions,omitempty"`
|
2019-03-03 19:35:29 +00:00
|
|
|
}
|
|
|
|
|
2019-03-03 23:35:32 +00:00
|
|
|
type ActionsConfig struct {
|
|
|
|
TerminalBell *bool `yaml:"terminal-bell,omitempty"`
|
|
|
|
Sound *bool `yaml:"sound,omitempty"`
|
|
|
|
Visual *bool `yaml:"visual,omitempty"`
|
|
|
|
Script *string `yaml:"script,omitempty"`
|
2019-03-03 19:35:29 +00:00
|
|
|
}
|
|
|
|
|
2019-02-26 04:36:23 +00:00
|
|
|
type GaugeConfig struct {
|
|
|
|
ComponentConfig `yaml:",inline"`
|
|
|
|
Scale *int `yaml:"scale,omitempty"`
|
|
|
|
Color *ui.Color `yaml:"color,omitempty"`
|
|
|
|
Values map[string]string `yaml:"values"`
|
2019-03-08 04:04:46 +00:00
|
|
|
Items []Item `yaml:",omitempty"`
|
2019-02-26 04:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type BarChartConfig struct {
|
|
|
|
ComponentConfig `yaml:",inline"`
|
2019-03-08 04:04:46 +00:00
|
|
|
Scale *int `yaml:"scale,omitempty"`
|
|
|
|
Items []Item `yaml:"items"`
|
2019-02-26 04:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type AsciiBoxConfig struct {
|
|
|
|
ComponentConfig `yaml:",inline"`
|
2019-03-08 04:04:46 +00:00
|
|
|
Item `yaml:",inline"`
|
|
|
|
Font *console.AsciiFont `yaml:"font,omitempty"`
|
2019-02-26 04:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type RunChartConfig struct {
|
|
|
|
ComponentConfig `yaml:",inline"`
|
2019-03-05 03:25:17 +00:00
|
|
|
Legend *LegendConfig `yaml:"legend,omitempty"`
|
|
|
|
Scale *int `yaml:"scale,omitempty"`
|
2019-03-08 04:04:46 +00:00
|
|
|
Items []Item `yaml:"items"`
|
2019-02-26 04:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type LegendConfig struct {
|
|
|
|
Enabled bool `yaml:"enabled"`
|
|
|
|
Details bool `yaml:"details"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Position struct {
|
|
|
|
X int `yaml:"w"`
|
|
|
|
Y int `yaml:"h"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Size struct {
|
|
|
|
X int `yaml:"w"`
|
|
|
|
Y int `yaml:"h"`
|
|
|
|
}
|
|
|
|
|
2019-03-08 04:04:46 +00:00
|
|
|
type Item struct {
|
|
|
|
Label *string `yaml:"label,omitempty"`
|
|
|
|
Script string `yaml:"value"`
|
|
|
|
Color *ui.Color `yaml:"color,omitempty"`
|
|
|
|
}
|
2019-02-26 04:36:23 +00:00
|
|
|
|
|
|
|
type ComponentSettings struct {
|
|
|
|
Type ComponentType
|
|
|
|
Title string
|
|
|
|
Size Size
|
|
|
|
Position Position
|
|
|
|
}
|