mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Add JIRA frame
This commit is contained in:
parent
c856ea3c82
commit
35e7fa0128
66
jira/widget.go
Normal file
66
jira/widget.go
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
wtf.go
13
wtf.go
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/senorprogrammer/wtf/bamboohr"
|
"github.com/senorprogrammer/wtf/bamboohr"
|
||||||
"github.com/senorprogrammer/wtf/gcal"
|
"github.com/senorprogrammer/wtf/gcal"
|
||||||
"github.com/senorprogrammer/wtf/git"
|
"github.com/senorprogrammer/wtf/git"
|
||||||
|
"github.com/senorprogrammer/wtf/jira"
|
||||||
"github.com/senorprogrammer/wtf/opsgenie"
|
"github.com/senorprogrammer/wtf/opsgenie"
|
||||||
"github.com/senorprogrammer/wtf/security"
|
"github.com/senorprogrammer/wtf/security"
|
||||||
"github.com/senorprogrammer/wtf/status"
|
"github.com/senorprogrammer/wtf/status"
|
||||||
@ -38,6 +39,9 @@ func main() {
|
|||||||
git := git.NewWidget()
|
git := git.NewWidget()
|
||||||
git.Refresh()
|
git.Refresh()
|
||||||
|
|
||||||
|
jira := jira.NewWidget()
|
||||||
|
jira.Refresh()
|
||||||
|
|
||||||
opsgenie := opsgenie.NewWidget()
|
opsgenie := opsgenie.NewWidget()
|
||||||
opsgenie.Refresh()
|
opsgenie.Refresh()
|
||||||
|
|
||||||
@ -51,17 +55,18 @@ func main() {
|
|||||||
weather.Refresh()
|
weather.Refresh()
|
||||||
|
|
||||||
grid := tview.NewGrid()
|
grid := tview.NewGrid()
|
||||||
grid.SetRows(9, 9, 9, 24, 3) // How _high_ the row is, in terminal rows
|
grid.SetRows(9, 9, 9, 9, 15, 3) // How _high_ the row is, in terminal rows
|
||||||
grid.SetColumns(40, 40) // How _wide_ the column is, in terminal columns
|
grid.SetColumns(40, 40) // How _wide_ the column is, in terminal columns
|
||||||
grid.SetBorder(false)
|
grid.SetBorder(false)
|
||||||
|
|
||||||
grid.AddItem(bamboo.View, 0, 0, 2, 1, 0, 0, false)
|
grid.AddItem(bamboo.View, 0, 0, 2, 1, 0, 0, false)
|
||||||
grid.AddItem(cal.View, 2, 0, 2, 1, 0, 0, false)
|
grid.AddItem(cal.View, 2, 0, 3, 1, 0, 0, false)
|
||||||
grid.AddItem(git.View, 0, 2, 3, 1, 0, 0, false)
|
grid.AddItem(git.View, 0, 2, 3, 1, 0, 0, false)
|
||||||
grid.AddItem(weather.View, 0, 1, 1, 1, 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)
|
grid.AddItem(sec.View, 1, 1, 1, 1, 0, 0, false)
|
||||||
grid.AddItem(opsgenie.View, 2, 1, 1, 1, 0, 0, false)
|
grid.AddItem(opsgenie.View, 2, 1, 1, 1, 0, 0, false)
|
||||||
grid.AddItem(stat.View, 4, 0, 3, 3, 0, 0, false)
|
grid.AddItem(jira.View, 3, 1, 1, 1, 0, 0, false)
|
||||||
|
grid.AddItem(stat.View, 5, 0, 3, 3, 0, 0, false)
|
||||||
|
|
||||||
app := tview.NewApplication()
|
app := tview.NewApplication()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user