From bd3ed07a5bdd9e9b75a365c2a9f47b624d6844b3 Mon Sep 17 00:00:00 2001 From: sqshq Date: Sat, 16 Feb 2019 22:18:12 -0500 Subject: [PATCH] carousel palette selection, added default colors --- config.yml | 36 ++++++++++++++++++------------------ config/default.go | 7 ++++--- console/palette.go | 9 ++++++--- data/item.go | 2 +- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/config.yml b/config.yml index 80a24cf..2a05147 100644 --- a/config.yml +++ b/config.yml @@ -1,4 +1,3 @@ -theme: dark runcharts: - title: SEARCH ENGINE RESPONSE TIME (sec) precision: 3 @@ -8,16 +7,17 @@ runcharts: size: w: 30 h: 20 - legend: - enabled: true - details: true items: - - script: curl -o /dev/null -s -w '%{time_total}' https://www.google.com/ - label: GOOGLE - - script: curl -o /dev/null -s -w '%{time_total}' https://search.yahoo.com/ - label: YAHOO - - script: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com/ - label: BING + - label: GOOGLE + script: curl -o /dev/null -s -w '%{time_total}' https://www.google.com + - label: YAHOO + script: curl -o /dev/null -s -w '%{time_total}' https://search.yahoo.com + - label: YANDEX + 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) refresh-rate-ms: 5000 position: @@ -30,12 +30,12 @@ runcharts: enabled: true details: false items: - - script: curl -o /dev/null -s -w '%{time_total}' https://www.google.com/ - label: GOOGLE - - script: curl -o /dev/null -s -w '%{time_total}' https://search.yahoo.com/ - label: YAHOO - - script: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com/ - label: BING + - label: GOOGLE + script: curl -o /dev/null -s -w '%{time_total}' https://www.google.com + - label: YAHOO + script: curl -o /dev/null -s -w '%{time_total}' https://search.yahoo.com + - label: BING + script: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com - title: MONGO COLLECTIONS COUNT position: w: 15 @@ -44,5 +44,5 @@ runcharts: w: 15 h: 10 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()" diff --git a/config/default.go b/config/default.go index 8b1e321..656449a 100644 --- a/config/default.go +++ b/config/default.go @@ -41,17 +41,18 @@ func (c *Config) setDefaultValues() { } func (c *Config) setDefaultLayout() { - + // TODO auto-arrange components } func (c *Config) setDefaultColors() { 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 { 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 } } diff --git a/console/palette.go b/console/palette.go index f757153..c5d096a 100644 --- a/console/palette.go +++ b/console/palette.go @@ -16,10 +16,13 @@ const ( ColorOlive ui.Color = 178 ColorDeepSkyBlue ui.Color = 39 ColorDeepPink ui.Color = 198 + ColorCian ui.Color = 43 + ColorOrange ui.Color = 166 + ColorPurple ui.Color = 129 + ColorGreen ui.Color = 64 ColorDarkGrey ui.Color = 240 ColorWhite ui.Color = 7 ColorBlack ui.Color = 0 - ColorClear ui.Color = -1 ) type Palette struct { @@ -30,9 +33,9 @@ type Palette struct { func GetPalette(theme Theme) Palette { switch theme { 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: - 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: panic(fmt.Sprintf("Following theme is not supported: %v", theme)) } diff --git a/data/item.go b/data/item.go index 1bee9d1..3a3fb47 100644 --- a/data/item.go +++ b/data/item.go @@ -7,8 +7,8 @@ import ( ) type Item struct { - Script string `yaml:"script"` Label string `yaml:"label"` + Script string `yaml:"script"` Color *ui.Color `yaml:"color,omitempty"` }