1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Add JIRA frame

This commit is contained in:
Chris Cummer
2018-04-01 22:49:38 -07:00
committed by Chris Cummer
parent c856ea3c82
commit 35e7fa0128
2 changed files with 75 additions and 4 deletions

66
jira/widget.go Normal file
View File

@@ -0,0 +1,66 @@
package jira
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: "JIRA",
RefreshedAt: time.Now(),
RefreshInterval: 8,
},
}
widget.addView()
go widget.refresher()
return &widget
}
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Refresh() {
widget.View.SetTitle(" JIRA ")
widget.RefreshedAt = time.Now()
widget.View.Clear()
fmt.Fprintf(widget.View, "%s", "jira")
}
/* -------------------- 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.Hour)
quit := make(chan struct{})
for {
select {
case <-tick.C:
widget.Refresh()
case <-quit:
tick.Stop()
return
}
}
}