Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package views
import (
"fmt"
"time"
"github.com/rivo/tview"
"google.golang.org/grpc"
)
type GoSDNStatusView struct {
statusGoSDNView *tview.TextView
}
//TODO: change to grpcStatusView
func NewGoSDNStatusView(conn *grpc.ClientConn) *GoSDNStatusView {
//TODO: change to uses FlexBox if there is more to display in the header
sv := &GoSDNStatusView{
statusGoSDNView: tview.NewTextView(),
}
sv.statusGoSDNView.
SetRegions(true).
SetBorder(true).
SetTitle("Status: gRPC")
go goSDNTicker(sv, conn)
return sv
}
func (sv *GoSDNStatusView) GetContent() tview.Primitive {
return sv.statusGoSDNView
}
func (sv *GoSDNStatusView) SetContent(s string) {
sv.statusGoSDNView.Clear()
sv.statusGoSDNView.SetText(s)
}
func goSDNTicker(sv *GoSDNStatusView, conn *grpc.ClientConn) {
ticker := time.NewTicker(5 * time.Second)
sv.statusGoSDNView.SetText("???")
for range ticker.C {
sv.statusGoSDNView.Clear()
fmt.Println(sv)
}
}