Newer
Older
package views
import (
"code.fbi.h-da.de/cocsn/gosdn/cmd/gosdn-tview/app"
commands "code.fbi.h-da.de/cocsn/gosdn/cmd/gosdn-tview/grpc"
"github.com/rivo/tview"
"google.golang.org/grpc"
)
//GRPCStatusView is an application view to display the current status of
//the gRPC server (e.g. connected, unavailable,...)
type GRPCStatusView struct {
gRPCStatusView *tview.TextView
}
//NewGRPCStatusView creates a new GRPCStatusView
func NewGRPCStatusView(app *app.App, conn *grpc.ClientConn) *GRPCStatusView {
sv := &GRPCStatusView{
gRPCStatusView: tview.NewTextView(),
}
sv.gRPCStatusView.
SetDynamicColors(true).
SetTextAlign(tview.AlignCenter).
SetRegions(true).
SetBorder(true).
SetTitle("gRPC")
commands.WatchHealth("", app, conn, sv.gRPCStatusView)
//GetContent returns the tview.Primitive belonging to the gRPCStatusView
func (sv *GRPCStatusView) GetContent() tview.Primitive {
return sv.gRPCStatusView
}
//SetContent sets new string content for the gRPCStatusView
func (sv *GRPCStatusView) SetContent(s string) {
sv.gRPCStatusView.Clear()
sv.gRPCStatusView.SetText(s)
}