carousel palette selection, added default colors

This commit is contained in:
sqshq 2019-02-16 22:18:12 -05:00
parent 687e6f098e
commit bd3ed07a5b
4 changed files with 29 additions and 25 deletions

View File

@ -1,4 +1,3 @@
theme: dark
runcharts: runcharts:
- title: SEARCH ENGINE RESPONSE TIME (sec) - title: SEARCH ENGINE RESPONSE TIME (sec)
precision: 3 precision: 3
@ -8,16 +7,17 @@ runcharts:
size: size:
w: 30 w: 30
h: 20 h: 20
legend:
enabled: true
details: true
items: items:
- script: curl -o /dev/null -s -w '%{time_total}' https://www.google.com/ - label: GOOGLE
label: GOOGLE script: curl -o /dev/null -s -w '%{time_total}' https://www.google.com
- script: curl -o /dev/null -s -w '%{time_total}' https://search.yahoo.com/ - label: YAHOO
label: YAHOO script: curl -o /dev/null -s -w '%{time_total}' https://search.yahoo.com
- script: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com/ - label: YANDEX
label: BING script: curl -o /dev/null -s -w '%{time_total}' https://yandex.com
- label: BING
script: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com
- label: DDGO
script: curl -o /dev/null -s -w '%{time_total}' https://duckduckgo.com
- title: SEARCH ENGINE RESPONSE TIME 2 (sec) - title: SEARCH ENGINE RESPONSE TIME 2 (sec)
refresh-rate-ms: 5000 refresh-rate-ms: 5000
position: position:
@ -30,12 +30,12 @@ runcharts:
enabled: true enabled: true
details: false details: false
items: items:
- script: curl -o /dev/null -s -w '%{time_total}' https://www.google.com/ - label: GOOGLE
label: GOOGLE script: curl -o /dev/null -s -w '%{time_total}' https://www.google.com
- script: curl -o /dev/null -s -w '%{time_total}' https://search.yahoo.com/ - label: YAHOO
label: YAHOO script: curl -o /dev/null -s -w '%{time_total}' https://search.yahoo.com
- script: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com/ - label: BING
label: BING script: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com
- title: MONGO COLLECTIONS COUNT - title: MONGO COLLECTIONS COUNT
position: position:
w: 15 w: 15
@ -44,5 +44,5 @@ runcharts:
w: 15 w: 15
h: 10 h: 10
items: items:
- script: mongo --quiet --host=localhost blog --eval "db.getCollection('post').find({}).size()" - label: POSTS
label: POSTS script: mongo --quiet --host=localhost blog --eval "db.getCollection('post').find({}).size()"

View File

@ -41,17 +41,18 @@ func (c *Config) setDefaultValues() {
} }
func (c *Config) setDefaultLayout() { func (c *Config) setDefaultLayout() {
// TODO auto-arrange components
} }
func (c *Config) setDefaultColors() { func (c *Config) setDefaultColors() {
palette := console.GetPalette(*c.Theme) palette := console.GetPalette(*c.Theme)
colorsCount := len(palette.Colors)
for i, chart := range c.RunCharts { for _, chart := range c.RunCharts {
for j, item := range chart.Items { for j, item := range chart.Items {
if item.Color == nil { if item.Color == nil {
item.Color = &palette.Colors[i+j] // TODO handle out of range case item.Color = &palette.Colors[j%colorsCount]
chart.Items[j] = item chart.Items[j] = item
} }
} }

View File

@ -16,10 +16,13 @@ const (
ColorOlive ui.Color = 178 ColorOlive ui.Color = 178
ColorDeepSkyBlue ui.Color = 39 ColorDeepSkyBlue ui.Color = 39
ColorDeepPink ui.Color = 198 ColorDeepPink ui.Color = 198
ColorCian ui.Color = 43
ColorOrange ui.Color = 166
ColorPurple ui.Color = 129
ColorGreen ui.Color = 64
ColorDarkGrey ui.Color = 240 ColorDarkGrey ui.Color = 240
ColorWhite ui.Color = 7 ColorWhite ui.Color = 7
ColorBlack ui.Color = 0 ColorBlack ui.Color = 0
ColorClear ui.Color = -1
) )
type Palette struct { type Palette struct {
@ -30,9 +33,9 @@ type Palette struct {
func GetPalette(theme Theme) Palette { func GetPalette(theme Theme) Palette {
switch theme { switch theme {
case ThemeDark: case ThemeDark:
return Palette{Colors: []ui.Color{ColorOlive, ColorDeepSkyBlue, ColorDeepPink, ColorOlive, ColorDeepSkyBlue, ColorDeepPink}} return Palette{Colors: []ui.Color{ColorOlive, ColorDeepSkyBlue, ColorDeepPink, ColorWhite, ColorPurple, ColorCian, ColorOrange, ColorGreen}}
case ThemeLight: case ThemeLight:
return Palette{Colors: []ui.Color{ColorOlive, ColorDeepSkyBlue, ColorDeepPink, ColorOlive, ColorDeepSkyBlue, ColorDeepPink}} return Palette{Colors: []ui.Color{ColorOlive, ColorDeepSkyBlue, ColorDeepPink, ColorWhite, ColorPurple, ColorCian, ColorOrange, ColorGreen}}
default: default:
panic(fmt.Sprintf("Following theme is not supported: %v", theme)) panic(fmt.Sprintf("Following theme is not supported: %v", theme))
} }

View File

@ -7,8 +7,8 @@ import (
) )
type Item struct { type Item struct {
Script string `yaml:"script"`
Label string `yaml:"label"` Label string `yaml:"label"`
Script string `yaml:"script"`
Color *ui.Color `yaml:"color,omitempty"` Color *ui.Color `yaml:"color,omitempty"`
} }