forked from ngaut/sqltop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
overview.go
39 lines (32 loc) · 800 Bytes
/
overview.go
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
package main
import (
"fmt"
"strings"
ui "github.com/gizak/termui/v3"
)
type OverviewController struct {
grid *TextGrid
}
func newOverviewController() *OverviewController {
return &OverviewController{
grid: newTextGrid(0, 0, 3),
}
}
func (c *OverviewController) Render() {
c.grid.Render()
}
func (c *OverviewController) OnResize(payload ui.Resize) {
c.grid.OnResize(payload)
}
func (c *OverviewController) UpdateData() {
var sb strings.Builder
fmt.Fprintf(&sb, "sqltop version 0.1\n")
if totalProcess, ok := Stat().Load(TOTAL_PROCESSES); ok {
fmt.Fprintf(&sb, "Processes: %d total, running %d ", totalProcess, totalProcess)
}
if usingDBs, ok := Stat().Load(USING_DBS); ok {
fmt.Fprintf(&sb, "using DB: %d ", usingDBs)
}
sb.WriteString("\n")
c.grid.SetText(sb.String())
}