added alerter to all components
This commit is contained in:
parent
cf68e2a654
commit
ff24a2d64e
|
@ -3,6 +3,7 @@ package asciibox
|
||||||
import (
|
import (
|
||||||
fl "github.com/mbndr/figlet4go"
|
fl "github.com/mbndr/figlet4go"
|
||||||
"github.com/sqshq/sampler/asset"
|
"github.com/sqshq/sampler/asset"
|
||||||
|
"github.com/sqshq/sampler/component"
|
||||||
"github.com/sqshq/sampler/config"
|
"github.com/sqshq/sampler/config"
|
||||||
"github.com/sqshq/sampler/data"
|
"github.com/sqshq/sampler/data"
|
||||||
ui "github.com/sqshq/termui"
|
ui "github.com/sqshq/termui"
|
||||||
|
@ -12,6 +13,7 @@ import (
|
||||||
type AsciiBox struct {
|
type AsciiBox struct {
|
||||||
ui.Block
|
ui.Block
|
||||||
data.Consumer
|
data.Consumer
|
||||||
|
*component.Alerter
|
||||||
text string
|
text string
|
||||||
ascii string
|
ascii string
|
||||||
style ui.Style
|
style ui.Style
|
||||||
|
@ -23,6 +25,7 @@ const asciiFontExtension = ".flf"
|
||||||
|
|
||||||
func NewAsciiBox(c config.AsciiBoxConfig) *AsciiBox {
|
func NewAsciiBox(c config.AsciiBoxConfig) *AsciiBox {
|
||||||
|
|
||||||
|
consumer := data.NewConsumer()
|
||||||
block := *ui.NewBlock()
|
block := *ui.NewBlock()
|
||||||
block.Title = c.Title
|
block.Title = c.Title
|
||||||
|
|
||||||
|
@ -38,7 +41,8 @@ func NewAsciiBox(c config.AsciiBoxConfig) *AsciiBox {
|
||||||
|
|
||||||
box := AsciiBox{
|
box := AsciiBox{
|
||||||
Block: block,
|
Block: block,
|
||||||
Consumer: data.NewConsumer(),
|
Consumer: consumer,
|
||||||
|
Alerter: component.NewAlerter(consumer.AlertChannel),
|
||||||
style: ui.NewStyle(*c.Color),
|
style: ui.NewStyle(*c.Color),
|
||||||
render: render,
|
render: render,
|
||||||
options: options,
|
options: options,
|
||||||
|
|
|
@ -3,6 +3,7 @@ package barchart
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
rw "github.com/mattn/go-runewidth"
|
rw "github.com/mattn/go-runewidth"
|
||||||
|
"github.com/sqshq/sampler/component"
|
||||||
"github.com/sqshq/sampler/console"
|
"github.com/sqshq/sampler/console"
|
||||||
"github.com/sqshq/sampler/data"
|
"github.com/sqshq/sampler/data"
|
||||||
ui "github.com/sqshq/termui"
|
ui "github.com/sqshq/termui"
|
||||||
|
@ -18,6 +19,7 @@ const (
|
||||||
type BarChart struct {
|
type BarChart struct {
|
||||||
ui.Block
|
ui.Block
|
||||||
data.Consumer
|
data.Consumer
|
||||||
|
*component.Alerter
|
||||||
bars []Bar
|
bars []Bar
|
||||||
scale int
|
scale int
|
||||||
maxValue float64
|
maxValue float64
|
||||||
|
@ -32,11 +34,13 @@ type Bar struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBarChart(title string, scale int) *BarChart {
|
func NewBarChart(title string, scale int) *BarChart {
|
||||||
|
consumer := data.NewConsumer()
|
||||||
block := *ui.NewBlock()
|
block := *ui.NewBlock()
|
||||||
block.Title = title
|
block.Title = title
|
||||||
chart := BarChart{
|
chart := BarChart{
|
||||||
Block: block,
|
Block: block,
|
||||||
Consumer: data.NewConsumer(),
|
Consumer: consumer,
|
||||||
|
Alerter: component.NewAlerter(consumer.AlertChannel),
|
||||||
bars: []Bar{},
|
bars: []Bar{},
|
||||||
scale: scale,
|
scale: scale,
|
||||||
maxValue: -math.MaxFloat64,
|
maxValue: -math.MaxFloat64,
|
||||||
|
|
|
@ -2,6 +2,7 @@ package gauge
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/sqshq/sampler/component"
|
||||||
"github.com/sqshq/sampler/console"
|
"github.com/sqshq/sampler/console"
|
||||||
"github.com/sqshq/sampler/data"
|
"github.com/sqshq/sampler/data"
|
||||||
ui "github.com/sqshq/termui"
|
ui "github.com/sqshq/termui"
|
||||||
|
@ -19,6 +20,7 @@ const (
|
||||||
type Gauge struct {
|
type Gauge struct {
|
||||||
ui.Block
|
ui.Block
|
||||||
data.Consumer
|
data.Consumer
|
||||||
|
*component.Alerter
|
||||||
minValue float64
|
minValue float64
|
||||||
maxValue float64
|
maxValue float64
|
||||||
curValue float64
|
curValue float64
|
||||||
|
@ -27,13 +29,13 @@ type Gauge struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGauge(title string, scale int, color ui.Color) *Gauge {
|
func NewGauge(title string, scale int, color ui.Color) *Gauge {
|
||||||
|
consumer := data.NewConsumer()
|
||||||
block := *ui.NewBlock()
|
block := *ui.NewBlock()
|
||||||
block.Title = title
|
block.Title = title
|
||||||
|
|
||||||
gauge := Gauge{
|
gauge := Gauge{
|
||||||
Block: block,
|
Block: block,
|
||||||
Consumer: data.NewConsumer(),
|
Consumer: consumer,
|
||||||
|
Alerter: component.NewAlerter(consumer.AlertChannel),
|
||||||
scale: scale,
|
scale: scale,
|
||||||
color: color,
|
color: color,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue