configuration improvements
This commit is contained in:
parent
58e4638bbc
commit
4df2939d3f
|
@ -89,7 +89,7 @@ func (b *BarChart) reselectMaxValue() {
|
||||||
func (b *BarChart) Draw(buf *ui.Buffer) {
|
func (b *BarChart) Draw(buf *ui.Buffer) {
|
||||||
b.Block.Draw(buf)
|
b.Block.Draw(buf)
|
||||||
|
|
||||||
barWidth := (b.Inner.Dx() - 2*barIndent) / len(b.bars)
|
barWidth := int(math.Ceil(float64(b.Inner.Dx()-2*barIndent-len(b.bars)*barIndent) / float64(len(b.bars))))
|
||||||
barXCoordinate := b.Inner.Min.X + barIndent
|
barXCoordinate := b.Inner.Min.X + barIndent
|
||||||
|
|
||||||
labelStyle := ui.NewStyle(console.ColorWhite)
|
labelStyle := ui.NewStyle(console.ColorWhite)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
minDimension = 3
|
minDimension = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
type Component struct {
|
type Component struct {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"github.com/sqshq/sampler/config"
|
"github.com/sqshq/sampler/config"
|
||||||
"github.com/sqshq/sampler/console"
|
"github.com/sqshq/sampler/console"
|
||||||
ui "github.com/sqshq/termui"
|
ui "github.com/sqshq/termui"
|
||||||
|
"math"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Layout struct {
|
type Layout struct {
|
||||||
|
@ -30,7 +31,7 @@ const (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
columnsCount = 80
|
columnsCount = 80
|
||||||
rowsCount = 55
|
rowsCount = 40
|
||||||
statusbarHeight = 1
|
statusbarHeight = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -204,15 +205,15 @@ func (l *Layout) getSelectedComponent() *Component {
|
||||||
|
|
||||||
func (l *Layout) Draw(buffer *ui.Buffer) {
|
func (l *Layout) Draw(buffer *ui.Buffer) {
|
||||||
|
|
||||||
columnWidth := float64(l.GetRect().Dx()) / columnsCount
|
columnWidth := float64(l.GetRect().Dx()) / float64(columnsCount)
|
||||||
rowHeight := float64(l.GetRect().Dy()-statusbarHeight) / rowsCount
|
rowHeight := float64(l.GetRect().Dy()-statusbarHeight) / float64(rowsCount)
|
||||||
|
|
||||||
for _, component := range l.Components {
|
for _, component := range l.Components {
|
||||||
|
|
||||||
x1 := float64(component.Position.X) * columnWidth
|
x1 := math.Floor(float64(component.Position.X) * columnWidth)
|
||||||
y1 := float64(component.Position.Y) * rowHeight
|
y1 := math.Floor(float64(component.Position.Y) * rowHeight)
|
||||||
x2 := x1 + float64(component.Size.X)*columnWidth
|
x2 := x1 + math.Floor(float64(component.Size.X))*columnWidth
|
||||||
y2 := y1 + float64(component.Size.Y)*rowHeight
|
y2 := y1 + math.Floor(float64(component.Size.Y))*rowHeight
|
||||||
|
|
||||||
component.Drawable.SetRect(int(x1), int(y1), int(x2), int(y2))
|
component.Drawable.SetRect(int(x1), int(y1), int(x2), int(y2))
|
||||||
component.Drawable.Draw(buffer)
|
component.Drawable.Draw(buffer)
|
||||||
|
|
75
config.yml
75
config.yml
|
@ -5,7 +5,7 @@ runcharts:
|
||||||
h: 0
|
h: 0
|
||||||
size:
|
size:
|
||||||
w: 53
|
w: 53
|
||||||
h: 22
|
h: 16
|
||||||
scale: 3
|
scale: 3
|
||||||
items:
|
items:
|
||||||
- label: GOOGLE
|
- label: GOOGLE
|
||||||
|
@ -14,31 +14,16 @@ runcharts:
|
||||||
value: curl -o /dev/null -s -w '%{time_total}' https://search.yahoo.com
|
value: curl -o /dev/null -s -w '%{time_total}' https://search.yahoo.com
|
||||||
- label: BING
|
- label: BING
|
||||||
value: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com
|
value: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com
|
||||||
- title: SEARCH ENGINE RESPONSE TIME 2 (sec)
|
|
||||||
refresh-rate-ms: 5000
|
|
||||||
position:
|
|
||||||
w: 53
|
|
||||||
h: 0
|
|
||||||
size:
|
|
||||||
w: 27
|
|
||||||
h: 22
|
|
||||||
legend:
|
|
||||||
enabled: true
|
|
||||||
details: false
|
|
||||||
items:
|
|
||||||
- label: GOOGLE
|
|
||||||
value: curl -o /dev/null -s -w '%{time_total}' https://www.google.com
|
|
||||||
- label: YAHOO
|
|
||||||
value: curl -o /dev/null -s -w '%{time_total}' https://search.yahoo.com
|
|
||||||
- label: BING
|
|
||||||
value: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com
|
|
||||||
- title: MONGO COLLECTIONS COUNT
|
- title: MONGO COLLECTIONS COUNT
|
||||||
position:
|
position:
|
||||||
w: 26
|
w: 53
|
||||||
h: 23
|
h: 0
|
||||||
size:
|
size:
|
||||||
w: 27
|
w: 27
|
||||||
h: 17
|
h: 8
|
||||||
|
legend:
|
||||||
|
enabled: true
|
||||||
|
details: false
|
||||||
scale: 0
|
scale: 0
|
||||||
items:
|
items:
|
||||||
- label: ACTIVE
|
- label: ACTIVE
|
||||||
|
@ -50,10 +35,10 @@ barcharts:
|
||||||
refresh-rate-ms: 1000
|
refresh-rate-ms: 1000
|
||||||
position:
|
position:
|
||||||
w: 0
|
w: 0
|
||||||
h: 23
|
|
||||||
size:
|
|
||||||
w: 26
|
|
||||||
h: 17
|
h: 17
|
||||||
|
size:
|
||||||
|
w: 53
|
||||||
|
h: 12
|
||||||
scale: 0
|
scale: 0
|
||||||
items:
|
items:
|
||||||
- label: NEW
|
- label: NEW
|
||||||
|
@ -69,44 +54,44 @@ barcharts:
|
||||||
gauges:
|
gauges:
|
||||||
- title: YEAR PROGRESS
|
- title: YEAR PROGRESS
|
||||||
position:
|
position:
|
||||||
w: 0
|
w: 53
|
||||||
h: 41
|
h: 8
|
||||||
size:
|
size:
|
||||||
w: 26
|
w: 27
|
||||||
h: 3
|
h: 2
|
||||||
values:
|
values:
|
||||||
cur: date +%j
|
cur: date +%j
|
||||||
max: echo 365
|
max: echo 365
|
||||||
min: echo 0
|
min: echo 0
|
||||||
- title: DAY PROGRESS
|
- title: DAY PROGRESS
|
||||||
position:
|
position:
|
||||||
w: 0
|
w: 53
|
||||||
h: 41
|
h: 10
|
||||||
size:
|
size:
|
||||||
w: 26
|
w: 27
|
||||||
h: 3
|
h: 2
|
||||||
values:
|
values:
|
||||||
cur: date +%H
|
cur: date +%H
|
||||||
max: echo 24
|
max: echo 24
|
||||||
min: echo 0
|
min: echo 0
|
||||||
- title: HOUR PROGRESS
|
- title: HOUR PROGRESS
|
||||||
position:
|
position:
|
||||||
w: 0
|
w: 53
|
||||||
h: 44
|
h: 12
|
||||||
size:
|
size:
|
||||||
w: 26
|
w: 27
|
||||||
h: 3
|
h: 2
|
||||||
values:
|
values:
|
||||||
cur: date +%M
|
cur: date +%M
|
||||||
max: echo 60
|
max: echo 60
|
||||||
min: echo 0
|
min: echo 0
|
||||||
- title: MINUTE PROGRESS
|
- title: MINUTE PROGRESS
|
||||||
position:
|
position:
|
||||||
w: 0
|
w: 53
|
||||||
h: 47
|
h: 14
|
||||||
size:
|
size:
|
||||||
w: 26
|
w: 27
|
||||||
h: 3
|
h: 2
|
||||||
values:
|
values:
|
||||||
cur: date +%S
|
cur: date +%S
|
||||||
max: echo 60
|
max: echo 60
|
||||||
|
@ -115,17 +100,17 @@ asciiboxes:
|
||||||
- title: LOCAL TIME
|
- title: LOCAL TIME
|
||||||
position:
|
position:
|
||||||
w: 53
|
w: 53
|
||||||
h: 23
|
h: 17
|
||||||
size:
|
size:
|
||||||
w: 27
|
w: 27
|
||||||
h: 8
|
h: 5
|
||||||
value: date +%r
|
value: date +%r
|
||||||
- title: UTC TIME
|
- title: UTC TIME
|
||||||
position:
|
position:
|
||||||
w: 53
|
w: 53
|
||||||
h: 31
|
h: 22
|
||||||
size:
|
size:
|
||||||
w: 27
|
w: 27
|
||||||
h: 9
|
h: 7
|
||||||
value: env TZ=UTC date +%r
|
value: env TZ=UTC date +%r
|
||||||
font: 3d
|
font: 3d
|
||||||
|
|
|
@ -40,9 +40,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, ColorWhite, ColorGreen, ColorOrange, ColorCian, ColorPurple}}
|
return Palette{Colors: []ui.Color{ColorOlive, ColorDeepSkyBlue, ColorDeepPink, ColorWhite, ColorGrey, ColorGreen, ColorOrange, ColorCian, ColorPurple}}
|
||||||
case ThemeLight:
|
case ThemeLight:
|
||||||
return Palette{Colors: []ui.Color{ColorOlive, ColorDeepSkyBlue, ColorDeepPink, ColorWhite, ColorGreen, ColorOrange, ColorCian, ColorPurple}}
|
return Palette{Colors: []ui.Color{ColorOlive, ColorDeepSkyBlue, ColorDeepPink, ColorWhite, ColorGrey, ColorGreen, ColorOrange, ColorCian, ColorPurple}}
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("Following theme is not supported: %v", theme))
|
panic(fmt.Sprintf("Following theme is not supported: %v", theme))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue