2019-02-01 00:02:34 +00:00
|
|
|
package config
|
|
|
|
|
2019-02-02 04:39:34 +00:00
|
|
|
import (
|
2019-02-02 14:45:53 +00:00
|
|
|
"github.com/sqshq/sampler/console"
|
2019-02-02 04:39:34 +00:00
|
|
|
)
|
2019-02-01 00:02:34 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
defaultRefreshRateMs = 300
|
2019-02-04 04:03:59 +00:00
|
|
|
defaultPrecision = 1
|
2019-02-02 04:39:34 +00:00
|
|
|
defaultTheme = console.ThemeDark
|
2019-02-01 00:02:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (self *Config) setDefaultValues() {
|
|
|
|
|
|
|
|
if len(self.Theme) == 0 {
|
|
|
|
self.Theme = defaultTheme
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, chart := range self.RunCharts {
|
|
|
|
if chart.RefreshRateMs == 0 {
|
|
|
|
chart.RefreshRateMs = defaultRefreshRateMs
|
|
|
|
}
|
2019-02-04 04:03:59 +00:00
|
|
|
if chart.Precision == 0 {
|
|
|
|
chart.Precision = defaultPrecision
|
|
|
|
}
|
2019-02-01 00:02:34 +00:00
|
|
|
self.RunCharts[i] = chart
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (config *Config) setDefaultLayout() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (config *Config) setDefaultColors() {
|
|
|
|
|
2019-02-02 04:39:34 +00:00
|
|
|
palette := console.GetPalette(config.Theme)
|
2019-02-01 00:02:34 +00:00
|
|
|
|
|
|
|
for i, chart := range config.RunCharts {
|
|
|
|
for j, item := range chart.Items {
|
|
|
|
if item.Color == 0 {
|
2019-02-05 03:26:00 +00:00
|
|
|
item.Color = palette.Colors[i+j] // TODO handle out of range case
|
2019-02-01 00:02:34 +00:00
|
|
|
chart.Items[j] = item
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|