From 1ed4b802aae86f9067a1ed352d7cd83a1fdd3fe1 Mon Sep 17 00:00:00 2001 From: Malte Bauch <malte.bauch@stud.h-da.de> Date: Wed, 28 Oct 2020 19:14:01 +0100 Subject: [PATCH] added GetTitle to some views --- cmd/gosdn-tview/views/commandsListView.go | 11 +++++++++-- cmd/gosdn-tview/views/footerView.go | 3 --- cmd/gosdn-tview/views/mainView.go | 5 +++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cmd/gosdn-tview/views/commandsListView.go b/cmd/gosdn-tview/views/commandsListView.go index c83a516dd..745fd4523 100644 --- a/cmd/gosdn-tview/views/commandsListView.go +++ b/cmd/gosdn-tview/views/commandsListView.go @@ -9,17 +9,19 @@ import ( //CommandListView is an application view to display all the goSDN commands type CommandListView struct { + title string commandsList *tview.List } //NewCommandListView creates a new CommandListView -func NewCommandListView() *CommandListView { +func NewCommandListView(title string) *CommandListView { cv := &CommandListView{ + title: title, commandsList: tview.NewList(), } cv.commandsList. SetBorder(true). - SetTitle("Commands") + SetTitle(cv.title) return cv } @@ -29,6 +31,11 @@ func (cv *CommandListView) GetContent() tview.Primitive { return cv.commandsList } +//GetTitle returns the title of the specific view +func (cv *CommandListView) GetTitle() string { + return cv.title +} + //GetCommands gets all goSDN commands from a command list and creates new //tview.List items for each one of them. The specific gRPC functions are added //as tview.Selected() function diff --git a/cmd/gosdn-tview/views/footerView.go b/cmd/gosdn-tview/views/footerView.go index 09ff7d7dd..b79ce1054 100644 --- a/cmd/gosdn-tview/views/footerView.go +++ b/cmd/gosdn-tview/views/footerView.go @@ -22,9 +22,6 @@ func NewFooterView(app *app.App, conn *grpc.ClientConn) *FooterView { databaseStatusView: NewDatabaseStatusView(app), gRPCStatusView: NewGRPCStatusView(app, conn), } - fw.footerView. - SetBorder(true). - SetTitle("Status") fw.footerView. AddItem(fw.gRPCStatusView.GetContent(), 0, 1, false). diff --git a/cmd/gosdn-tview/views/mainView.go b/cmd/gosdn-tview/views/mainView.go index 51ed950f3..22aa23ed9 100644 --- a/cmd/gosdn-tview/views/mainView.go +++ b/cmd/gosdn-tview/views/mainView.go @@ -23,7 +23,7 @@ func NewMainView(app *app.App, conn *grpc.ClientConn) *MainView { mv := &MainView{ pages: tview.NewPages(), mainGrid: tview.NewGrid(), - commandsListView: NewCommandListView(), + commandsListView: NewCommandListView("commands"), headerView: NewHeaderView(), footerView: NewFooterView(app, conn), } @@ -36,7 +36,8 @@ func NewMainView(app *app.App, conn *grpc.ClientConn) *MainView { AddItem(mv.headerView.GetContent(), 0, 0, 1, 2, 0, 0, false). AddItem(mv.footerView.GetContent(), 2, 0, 1, 2, 0, 0, false) - mv.mainGrid.AddItem(mv.commandsListView.GetContent(), 1, 0, 1, 1, 0, 0, true). + mv.mainGrid. + AddItem(mv.commandsListView.GetContent(), 1, 0, 1, 1, 0, 0, true). AddItem(mv.resultAndInputView.GetContent(), 1, 1, 1, 1, 0, 0, false) mv.pages.AddPage("main", mv.mainGrid, true, true) -- GitLab