added the wintype option to the form so more rich layouts can be created
This commit is contained in:
@@ -3,7 +3,6 @@ package controllers
|
||||
import (
|
||||
"esdi/cdashdisplay"
|
||||
helper "esdi/helpers"
|
||||
"esdi/telemetry"
|
||||
"esdi/tui/internal/services"
|
||||
"esdi/tui/internal/views"
|
||||
"fmt"
|
||||
@@ -123,6 +122,11 @@ func (lc *LayoutController) parseWindowFormData(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
winTypeInputID, _ := form.WinType.GetCurrentOption()
|
||||
if winTypeInputID == -1 {
|
||||
return nil, fmt.Errorf("no option selected for win type")
|
||||
}
|
||||
|
||||
titleSizeInputID, titleSizeInput := form.TitleSize.GetCurrentOption()
|
||||
if titleSizeInputID == -1 {
|
||||
return nil, fmt.Errorf("no option selected for title size")
|
||||
@@ -163,7 +167,7 @@ func (lc *LayoutController) parseWindowFormData(
|
||||
Height: uint16(heightValue),
|
||||
},
|
||||
Opts: cdashdisplay.UIWindowOpts{
|
||||
WinType: cdashdisplay.WinTypeString, // NOTE: values aren't implemented yet
|
||||
WinType: uint8(winTypeInputID),
|
||||
ShowID: showIDValue,
|
||||
PreviewValue: helper.B32(form.PreviewValue.GetText()),
|
||||
},
|
||||
@@ -192,14 +196,11 @@ func (lc *LayoutController) createWindow() {
|
||||
return
|
||||
}
|
||||
|
||||
lc.Messages <- fmt.Sprintf("pre update w address: %p\n", window)
|
||||
window, err = lc.DevService.CreateWindow(window)
|
||||
if err != nil {
|
||||
lc.Messages <- "failed to create window\n"
|
||||
return
|
||||
}
|
||||
lc.Messages <- fmt.Sprintf("post update w address: %p\n", window)
|
||||
lc.Messages <- fmt.Sprintf("%+v\n", window)
|
||||
|
||||
err = lc.updateFormView(window)
|
||||
if err != nil {
|
||||
@@ -213,16 +214,8 @@ func (lc *LayoutController) createWindow() {
|
||||
// the buttons for that purpuse
|
||||
func (lc *LayoutController) updateFormView(win *cdashdisplay.DesktopUIWindow) error {
|
||||
// OnSuccess we update our form to be an existing window form
|
||||
|
||||
lc.Messages <- fmt.Sprintf("Setting up window:\n%+v\n", win)
|
||||
|
||||
telemFieldID, ok := telemetry.GetFieldID(win.UIData.TelemetryField)
|
||||
if !ok {
|
||||
telemFieldID = 1000
|
||||
}
|
||||
|
||||
lc.Messages <- fmt.Sprintf("field id for: %s is %d\n", win.UIData.TelemetryField, telemFieldID)
|
||||
|
||||
err := lc.LayoutToolView.WindowCreatedSuccessfuly(win)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -230,16 +223,15 @@ func (lc *LayoutController) updateFormView(win *cdashdisplay.DesktopUIWindow) er
|
||||
|
||||
// Set the update window button behaviour
|
||||
formView := lc.LayoutToolView.FormQuickAccess[win.UIData.IDX]
|
||||
lc.Messages <- fmt.Sprintf("QA FORM: %+v\n", lc.LayoutToolView.FormQuickAccess)
|
||||
|
||||
err = SetFormButtonCallback(formView.Form.Form, "Update", func() {
|
||||
lc.Messages <- "pressed update form button\n"
|
||||
window, err := lc.parseWindowFormData(*formView.Form)
|
||||
if err != nil {
|
||||
lc.Messages <- "failed to parse window form data " + err.Error() + "\n"
|
||||
// lc.Messages <- "failed to parse window form data " + err.Error() + "\n"
|
||||
return
|
||||
}
|
||||
lc.Messages <- fmt.Sprintf("window data in form: %v\n", window)
|
||||
// lc.Messages <- fmt.Sprintf("window data in form: %v\n", window)
|
||||
|
||||
window.UIData.IDX = formView.WinID
|
||||
|
||||
@@ -259,7 +251,7 @@ func (lc *LayoutController) updateFormView(win *cdashdisplay.DesktopUIWindow) er
|
||||
return ev
|
||||
})
|
||||
|
||||
lc.App.SetFocus(formView.Form.Form)
|
||||
lc.App.SetFocus(lc.LayoutToolView.LayoutTree.Tree)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -313,12 +305,18 @@ func (lc *LayoutController) updateWindowAction(win *cdashdisplay.DesktopUIWindow
|
||||
}
|
||||
|
||||
func (lc *LayoutController) displayLoadedLayouts() {
|
||||
lc.Logger.Debug("We want to view our layout!")
|
||||
|
||||
for _, w := range lc.DevService.CDash.State.Layout.Windows {
|
||||
lc.Logger.Debug(fmt.Sprintf("updatinf form view for a layout: %+v", w))
|
||||
err := lc.updateFormView(w)
|
||||
if err != nil {
|
||||
lc.Logger.Debug("an error happened viewing our layout")
|
||||
lc.Messages <- "failed to add window to list"
|
||||
}
|
||||
}
|
||||
|
||||
lc.Logger.Debug("If we don't get here it means we somehow hanged the program earlier")
|
||||
}
|
||||
|
||||
func (lc *LayoutController) getCurrentTreeNodeModel() (*tview.TreeNode, int16, error) {
|
||||
|
||||
@@ -34,9 +34,9 @@ func NewCDashDisplayWindowFormView() *CDashDisplayWindowFormView {
|
||||
view.Title = tview.NewInputField().SetLabel("title")
|
||||
view.PreviewValue = tview.NewInputField().SetLabel("preview value")
|
||||
view.ShowID = tview.NewCheckbox().SetLabel("show ID").SetChecked(true)
|
||||
view.WinType = tview.NewDropDown().SetLabel("type").
|
||||
SetOptions([]string{"string", "bar"}, func(s string, id int) {}).
|
||||
SetCurrentOption(0)
|
||||
view.WinType = tview.NewDropDown().SetLabel("Win Type").
|
||||
SetOptions(cdashdisplay.WinTYPES, func(s string, id int) {}).
|
||||
SetCurrentOption(int(cdashdisplay.WinTypeSTRING))
|
||||
|
||||
view.TitleSize = tview.NewDropDown().SetLabel("Title Size").SetCurrentOption(0)
|
||||
for k := range 20 {
|
||||
@@ -127,7 +127,7 @@ func (fv *WindowFormView) SetValues(win *cdashdisplay.DesktopUIWindow) {
|
||||
fv.Form.Title.SetText(win.Title.String())
|
||||
fv.Form.PreviewValue.SetText(win.Opts.PreviewValue.String())
|
||||
fv.Form.ShowID.SetChecked(win.Opts.ShowID == 1)
|
||||
fv.Form.WinType.SetCurrentOption(0) // NOTE: this needs to set the correct option
|
||||
fv.Form.WinType.SetCurrentOption(int(win.Opts.WinType)) // NOTE: this needs to set the correct option
|
||||
fv.Form.TitleSize.SetCurrentOption(int(win.Decor.TitleSize))
|
||||
fv.Form.TextSize.SetCurrentOption(int(win.Decor.TextSize))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user