Added the default sim config variable
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"sync/atomic"
|
||||
|
||||
"esdi/config"
|
||||
"esdi/providers"
|
||||
"esdi/telemetry"
|
||||
"esdi/tui/internal/services"
|
||||
"esdi/tui/internal/views"
|
||||
@@ -28,6 +30,13 @@ func NewStreamingCtrl(
|
||||
serCDash *services.CDashService,
|
||||
serTelem *services.TelemetryService,
|
||||
) *StreamingCtrl {
|
||||
// NOTE: looks sus
|
||||
providerList := []providers.Provider{}
|
||||
for _, item := range providers.Providers {
|
||||
providerList = append(providerList, item)
|
||||
}
|
||||
streamView := views.NewStreamToolView(providerList, config.GetCfg().DefaultSim)
|
||||
|
||||
ctrl := &StreamingCtrl{
|
||||
Controller: base,
|
||||
Service: serCDash,
|
||||
@@ -35,7 +44,7 @@ func NewStreamingCtrl(
|
||||
Messages: make(chan string, 10),
|
||||
Internal: make(chan string, 10),
|
||||
Run: false,
|
||||
StreamView: views.NewStreamToolView(),
|
||||
StreamView: streamView,
|
||||
isRunning: false,
|
||||
}
|
||||
|
||||
|
||||
@@ -28,16 +28,23 @@ type StreamOptionsView struct {
|
||||
UpdateBtn *tview.Button
|
||||
}
|
||||
|
||||
func NewStreamOptionsView() *StreamOptionsView {
|
||||
func NewStreamOptionsView(providerList []providers.Provider, defaultProvider string,
|
||||
) *StreamOptionsView {
|
||||
sov := &StreamOptionsView{}
|
||||
|
||||
sov.Form = tview.NewForm()
|
||||
sov.Form.SetTitle("Stream Options").SetBorder(true)
|
||||
|
||||
defaultIdx := 0
|
||||
sov.SimDropdown = tview.NewDropDown().SetLabel("SIM").SetCurrentOption(0)
|
||||
for _, prov := range providers.Providers {
|
||||
for k, prov := range providerList {
|
||||
sov.SimDropdown.AddOption(prov.Name, func() {})
|
||||
|
||||
if prov.Name == defaultProvider {
|
||||
defaultIdx = k
|
||||
}
|
||||
}
|
||||
sov.SimDropdown.SetCurrentOption(defaultIdx)
|
||||
sov.Form.AddFormItem(sov.SimDropdown)
|
||||
|
||||
// Inject callback on the controller
|
||||
@@ -93,8 +100,8 @@ type StreamToolView struct {
|
||||
Visualizer *StreamVisualizerView
|
||||
}
|
||||
|
||||
func NewStreamToolView() *StreamToolView {
|
||||
optionsView := NewStreamOptionsView()
|
||||
func NewStreamToolView(providerList []providers.Provider, defaultProvider string) *StreamToolView {
|
||||
optionsView := NewStreamOptionsView(providerList, defaultProvider)
|
||||
visualizerView := NewStreamVisualizerView()
|
||||
flex := tview.NewFlex().SetDirection(tview.FlexColumn)
|
||||
flex.SetTitle("Streaming Tool")
|
||||
|
||||
Reference in New Issue
Block a user