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

fixed grpcStatusView

parent 3587d90b
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
......@@ -28,6 +28,10 @@ func (a *App) Stop() {
a.app.Stop()
}
func (a *App) Draw() {
a.app.Draw()
}
func (a *App) SetFocus(v tview.Primitive) {
a.app.SetFocus(v)
}
package views
import (
"fmt"
"time"
"code.fbi.h-da.de/cocsn/gosdn/cmd/gosdn-tview/app"
"github.com/rivo/tview"
"google.golang.org/grpc"
"time"
)
type GoSDNStatusView struct {
statusGoSDNView *tview.TextView
type GRPCStatusView struct {
gRPCStatusView *tview.TextView
}
//TODO: change to grpcStatusView
func NewGoSDNStatusView(conn *grpc.ClientConn) *GoSDNStatusView {
func NewGRPCStatusView(app *app.App, conn *grpc.ClientConn) *GRPCStatusView {
//TODO: change to uses FlexBox if there is more to display in the header
sv := &GoSDNStatusView{
statusGoSDNView: tview.NewTextView(),
sv := &GRPCStatusView{
gRPCStatusView: tview.NewTextView(),
}
sv.statusGoSDNView.
sv.gRPCStatusView.
SetRegions(true).
SetBorder(true).
SetTitle("Status: gRPC")
SetTitle("gRPC")
sv.gRPCStatusView.SetChangedFunc(func() {
app.Draw()
})
go goSDNTicker(sv, conn)
return sv
}
func (sv *GoSDNStatusView) GetContent() tview.Primitive {
return sv.statusGoSDNView
func (sv *GRPCStatusView) GetContent() tview.Primitive {
return sv.gRPCStatusView
}
func (sv *GoSDNStatusView) SetContent(s string) {
sv.statusGoSDNView.Clear()
sv.statusGoSDNView.SetText(s)
func (sv *GRPCStatusView) SetContent(s string) {
sv.gRPCStatusView.Clear()
sv.gRPCStatusView.SetText(s)
}
func goSDNTicker(sv *GoSDNStatusView, conn *grpc.ClientConn) {
func goSDNTicker(sv *GRPCStatusView, conn *grpc.ClientConn) {
ticker := time.NewTicker(5 * time.Second)
sv.statusGoSDNView.SetText("???")
for range ticker.C {
sv.statusGoSDNView.Clear()
fmt.Println(sv)
sv.SetContent(conn.GetState().String())
}
}
......@@ -2,12 +2,12 @@ package views
import "github.com/rivo/tview"
var goSDNAscii string = ` ____ ____ _ _
__ _ ___/ ___|| _ \| \ | |
/ _ |/ _ \___ \| | | | \| |
| (_| | (_) |__) | |_| | |\ |
\__ |\___/____/|____/|_| \_|
|___/ `
var goSDNAscii = ` ____ ____ _ _ _ _ _ _ _ ____ _ _ _
__ _ ___/ ___|| _ \| \ | | | | | | ___ ___| |__ ___ ___| |__ _ _| | ___ | _ \ __ _ _ __ _ __ ___ ___| |_ __ _ __| | |_
/ _ |/ _ \___ \| | | | \| | _____ | |_| |/ _ \ / __| '_ \/ __|/ __| '_ \| | | | |/ _ \ | | | |/ _ | '__| '_ _ \/ __| __/ _ |/ _ | __|
| (_| | (_) |__) | |_| | |\ | |_____| | _ | (_) | (__| | | \__ \ (__| | | | |_| | | __/ | |_| | (_| | | | | | | | \__ \ || (_| | (_| | |_
\__ |\___/____/|____/|_| \_| |_| |_|\___/ \___|_| |_|___/\___|_| |_|\__,_|_|\___| |____/ \__,_|_| |_| |_| |_|___/\__\__,_|\__,_|\__|
|___/ `
type HeaderView struct {
headerFlex *tview.Flex
......
......@@ -12,7 +12,7 @@ type MainView struct {
commandsListView *CommandListView
resultAndInputView *ResultAndInputView
headerView *HeaderView
goSDNStatusView *GoSDNStatusView
goSDNStatusView *GRPCStatusView
}
func NewMainView(app *app.App, conn *grpc.ClientConn) *MainView {
......@@ -22,7 +22,7 @@ func NewMainView(app *app.App, conn *grpc.ClientConn) *MainView {
commandsListView: NewCommandListView(),
resultAndInputView: NewResultAndInputView(),
headerView: NewHeaderView(),
goSDNStatusView: NewGoSDNStatusView(conn),
goSDNStatusView: NewGRPCStatusView(app, conn),
}
mv.commandsListView.GetCommands(app, mv.resultAndInputView, conn)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment