diff --git a/component/asciibox/asciibox.go b/component/asciibox/asciibox.go index c9c4b5c..a96489d 100644 --- a/component/asciibox/asciibox.go +++ b/component/asciibox/asciibox.go @@ -3,6 +3,7 @@ package asciibox import ( fl "github.com/mbndr/figlet4go" "github.com/sqshq/sampler/asset" + "github.com/sqshq/sampler/component" "github.com/sqshq/sampler/config" "github.com/sqshq/sampler/data" ui "github.com/sqshq/termui" @@ -12,6 +13,7 @@ import ( type AsciiBox struct { ui.Block data.Consumer + *component.Alerter text string ascii string style ui.Style @@ -23,6 +25,7 @@ const asciiFontExtension = ".flf" func NewAsciiBox(c config.AsciiBoxConfig) *AsciiBox { + consumer := data.NewConsumer() block := *ui.NewBlock() block.Title = c.Title @@ -38,7 +41,8 @@ func NewAsciiBox(c config.AsciiBoxConfig) *AsciiBox { box := AsciiBox{ Block: block, - Consumer: data.NewConsumer(), + Consumer: consumer, + Alerter: component.NewAlerter(consumer.AlertChannel), style: ui.NewStyle(*c.Color), render: render, options: options, diff --git a/component/barchart/barchart.go b/component/barchart/barchart.go index c744dff..e2aebf4 100644 --- a/component/barchart/barchart.go +++ b/component/barchart/barchart.go @@ -3,6 +3,7 @@ package barchart import ( "fmt" rw "github.com/mattn/go-runewidth" + "github.com/sqshq/sampler/component" "github.com/sqshq/sampler/console" "github.com/sqshq/sampler/data" ui "github.com/sqshq/termui" @@ -18,6 +19,7 @@ const ( type BarChart struct { ui.Block data.Consumer + *component.Alerter bars []Bar scale int maxValue float64 @@ -32,11 +34,13 @@ type Bar struct { } func NewBarChart(title string, scale int) *BarChart { + consumer := data.NewConsumer() block := *ui.NewBlock() block.Title = title chart := BarChart{ Block: block, - Consumer: data.NewConsumer(), + Consumer: consumer, + Alerter: component.NewAlerter(consumer.AlertChannel), bars: []Bar{}, scale: scale, maxValue: -math.MaxFloat64, diff --git a/component/gauge/gauge.go b/component/gauge/gauge.go index 0e1cb15..70f894d 100644 --- a/component/gauge/gauge.go +++ b/component/gauge/gauge.go @@ -2,6 +2,7 @@ package gauge import ( "fmt" + "github.com/sqshq/sampler/component" "github.com/sqshq/sampler/console" "github.com/sqshq/sampler/data" ui "github.com/sqshq/termui" @@ -19,6 +20,7 @@ const ( type Gauge struct { ui.Block data.Consumer + *component.Alerter minValue float64 maxValue float64 curValue float64 @@ -27,13 +29,13 @@ type Gauge struct { } func NewGauge(title string, scale int, color ui.Color) *Gauge { - + consumer := data.NewConsumer() block := *ui.NewBlock() block.Title = title - gauge := Gauge{ Block: block, - Consumer: data.NewConsumer(), + Consumer: consumer, + Alerter: component.NewAlerter(consumer.AlertChannel), scale: scale, color: color, }