mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
WIP Security info
This commit is contained in:
parent
59197e8d52
commit
d82c7692be
70
security/widget.go
Normal file
70
security/widget.go
Normal file
@ -0,0 +1,70 @@
|
||||
package security
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
type Widget struct {
|
||||
wtf.BaseWidget
|
||||
View *tview.TextView
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
BaseWidget: wtf.BaseWidget{
|
||||
Name: "Weather",
|
||||
RefreshedAt: time.Now(),
|
||||
RefreshInterval: 5,
|
||||
},
|
||||
}
|
||||
|
||||
widget.addView()
|
||||
go widget.refresher()
|
||||
|
||||
return &widget
|
||||
}
|
||||
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
//data := Fetch()
|
||||
|
||||
widget.View.SetTitle(" 🐼 Security")
|
||||
widget.RefreshedAt = time.Now()
|
||||
|
||||
widget.View.Clear()
|
||||
|
||||
fmt.Fprintf(widget.View, "%s", "cats and dogs")
|
||||
//fmt.Fprintf(widget.View, "%s", widget.contentFrom(data))
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) addView() {
|
||||
view := tview.NewTextView()
|
||||
|
||||
view.SetBorder(true)
|
||||
view.SetDynamicColors(true)
|
||||
view.SetTitle(widget.Name)
|
||||
|
||||
widget.View = view
|
||||
}
|
||||
|
||||
func (widget *Widget) refresher() {
|
||||
tick := time.NewTicker(time.Duration(widget.RefreshInterval) * time.Second)
|
||||
quit := make(chan struct{})
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-tick.C:
|
||||
widget.Refresh()
|
||||
case <-quit:
|
||||
tick.Stop()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
@ -49,7 +49,7 @@ func (widget *Widget) addView() {
|
||||
|
||||
view.SetBorder(true)
|
||||
view.SetDynamicColors(true)
|
||||
view.SetTitle(" Weather ")
|
||||
view.SetTitle(widget.Name)
|
||||
|
||||
widget.View = view
|
||||
}
|
||||
|
5
wtf.go
5
wtf.go
@ -6,6 +6,7 @@ import (
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/bamboohr"
|
||||
"github.com/senorprogrammer/wtf/gcal"
|
||||
"github.com/senorprogrammer/wtf/security"
|
||||
"github.com/senorprogrammer/wtf/status"
|
||||
"github.com/senorprogrammer/wtf/weather"
|
||||
)
|
||||
@ -32,6 +33,9 @@ func main() {
|
||||
cal := gcal.NewWidget()
|
||||
cal.Refresh()
|
||||
|
||||
sec := security.NewWidget()
|
||||
sec.Refresh()
|
||||
|
||||
stat := status.NewWidget()
|
||||
stat.Refresh()
|
||||
|
||||
@ -47,6 +51,7 @@ func main() {
|
||||
grid.AddItem(cal.View, 2, 0, 1, 1, 0, 0, false)
|
||||
grid.AddItem(stat.View, 3, 0, 2, 3, 0, 0, false)
|
||||
grid.AddItem(weather.View, 0, 1, 1, 1, 0, 0, false)
|
||||
grid.AddItem(sec.View, 1, 1, 1, 1, 0, 0, false)
|
||||
|
||||
app := tview.NewApplication()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user