Skip to content
Snippets Groups Projects
Commit c1957eeb authored by Malte Bauch's avatar Malte Bauch
Browse files

changed to use pages for resultAndInputView

core is working -> now we need the more advanced grpc calls
parent c2db13c4
No related branches found
No related tags found
3 merge requests!90Develop,!59Resolve "Simple ncurse-alike cli to manage gosdn",!53V.0.1.0 Codename Threadbare
Pipeline #52914 passed
......@@ -15,10 +15,8 @@ func main() {
app := app.NewApp()
mainView := views.NewMainView(app, conn)
addPNDView := views.NewAddPNDView(app)
app.SetRoot(mainView)
app.AddPage("PND", addPNDView)
app.Run()
defer app.Stop()
......
......@@ -13,6 +13,10 @@ func NewAddPNDView(app *app.App) *AddPNDView {
pndv := &AddPNDView{
addPNDView: tview.NewForm(),
}
pndv.addPNDView.
SetBorder(true).
SetTitle("Add new PND")
pndv.addPNDView.
AddInputField("Name", "", 20, nil, nil).
AddInputField("description", "", 20, nil, nil).
......
......@@ -30,7 +30,8 @@ func (cv *CommandListView) GetCommands(app *app.App, rv *ResultAndInputView,
conn *grpc.ClientConn) {
//TODO: create own command in grpc -> commands
cv.commandsList.AddItem("AddPND", "closes the application", '!', func() {
app.SwitchPage("PND")
rv.ChangeContentView("addPND")
app.SetFocus(rv.GetContent())
})
for i, command := range commands.CommandList {
......@@ -39,6 +40,7 @@ func (cv *CommandListView) GetCommands(app *app.App, rv *ResultAndInputView,
AddItem(command.Name, command.Description, rune('a'+i), func() {
r := f(conn)
rv.SetContent(r)
rv.ChangeContentView("result")
})
}
......
......@@ -20,7 +20,7 @@ func NewMainView(app *app.App, conn *grpc.ClientConn) *MainView {
pages: tview.NewPages(),
mainGrid: tview.NewGrid(),
commandsListView: NewCommandListView(),
resultAndInputView: NewResultAndInputView(),
resultAndInputView: NewResultAndInputView(app),
headerView: NewHeaderView(),
footerView: NewFooterView(app, conn),
}
......
package views
import (
"code.fbi.h-da.de/cocsn/gosdn/cmd/gosdn-tview/app"
"github.com/rivo/tview"
)
type ResultAndInputView struct {
resultAndInputView *tview.TextView
pages *tview.Pages
resultView *tview.TextView
pndInputView *AddPNDView
}
func NewResultAndInputView() *ResultAndInputView {
func NewResultAndInputView(app *app.App) *ResultAndInputView {
rv := &ResultAndInputView{
resultAndInputView: tview.NewTextView(),
pages: tview.NewPages(),
pndInputView: NewAddPNDView(app),
resultView: tview.NewTextView(),
}
rv.resultAndInputView.
rv.resultView.
SetDynamicColors(true).
SetRegions(true).
SetScrollable(true).
SetTitle("Result").
SetBorder(true)
rv.pages.
AddPage("result", rv.resultView, true, true).
AddPage("addPND", rv.pndInputView.GetContent(), true, false)
return rv
}
func (rv *ResultAndInputView) GetContent() tview.Primitive {
return rv.resultAndInputView
return rv.pages
}
func (rv *ResultAndInputView) ChangeContentView(s string) {
rv.pages.SwitchToPage(s)
}
func (rv *ResultAndInputView) SetContent(s string) {
rv.resultAndInputView.Clear()
rv.resultAndInputView.SetText(s)
rv.resultView.Clear()
rv.resultView.SetText(s)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment