mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
refreshInterval config added to BambooHR and Status
This commit is contained in:
parent
39cf8c6e1c
commit
b91e1be8df
@ -5,21 +5,29 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
|
"github.com/olebedev/config"
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Widget struct {
|
type Widget struct {
|
||||||
wtf.BaseWidget
|
wtf.BaseWidget
|
||||||
|
|
||||||
|
Config *config.Config
|
||||||
View *tview.TextView
|
View *tview.TextView
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(config *config.Config) *Widget {
|
||||||
|
refreshInterval, err := config.Int("wtf.bamboohr.refreshInterval")
|
||||||
|
if err != nil {
|
||||||
|
refreshInterval = 1
|
||||||
|
}
|
||||||
|
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
BaseWidget: wtf.BaseWidget{
|
BaseWidget: wtf.BaseWidget{
|
||||||
Name: "BambooHR",
|
Name: "BambooHR",
|
||||||
RefreshedAt: time.Now(),
|
RefreshedAt: time.Now(),
|
||||||
RefreshInt: 15,
|
RefreshInt: refreshInterval,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,2 +1,6 @@
|
|||||||
wtf:
|
wtf:
|
||||||
refreshInterval: 1
|
refreshInterval: 1
|
||||||
|
bamboohr:
|
||||||
|
refreshInterval: 900
|
||||||
|
status:
|
||||||
|
refreshInterval: 1
|
||||||
|
@ -5,23 +5,32 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
|
"github.com/olebedev/config"
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Widget struct {
|
type Widget struct {
|
||||||
wtf.BaseWidget
|
wtf.BaseWidget
|
||||||
|
|
||||||
|
Config *config.Config
|
||||||
Current int
|
Current int
|
||||||
View *tview.TextView
|
View *tview.TextView
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(config *config.Config) *Widget {
|
||||||
|
refreshInterval, err := config.Int("wtf.status.refreshInterval")
|
||||||
|
if err != nil {
|
||||||
|
refreshInterval = 1
|
||||||
|
}
|
||||||
|
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
BaseWidget: wtf.BaseWidget{
|
BaseWidget: wtf.BaseWidget{
|
||||||
Name: "Status",
|
Name: "Status",
|
||||||
RefreshedAt: time.Now(),
|
RefreshedAt: time.Now(),
|
||||||
RefreshInt: 1,
|
RefreshInt: refreshInterval,
|
||||||
},
|
},
|
||||||
|
Config: config,
|
||||||
Current: 0,
|
Current: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
wtf.go
7
wtf.go
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
//"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
@ -28,7 +27,7 @@ func loadConfig() *config.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func refresher(stat *status.Widget, app *tview.Application) {
|
func refresher(stat *status.Widget, app *tview.Application) {
|
||||||
refreshInterval, err := Config.Int("wtf.refresh_interval")
|
refreshInterval, err := Config.Int("wtf.refreshInterval")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
refreshInterval = 1
|
refreshInterval = 1
|
||||||
}
|
}
|
||||||
@ -48,7 +47,7 @@ func refresher(stat *status.Widget, app *tview.Application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
bamboo := bamboohr.NewWidget()
|
bamboo := bamboohr.NewWidget(Config)
|
||||||
bamboo.Refresh()
|
bamboo.Refresh()
|
||||||
|
|
||||||
cal := gcal.NewWidget()
|
cal := gcal.NewWidget()
|
||||||
@ -66,7 +65,7 @@ func main() {
|
|||||||
sec := security.NewWidget()
|
sec := security.NewWidget()
|
||||||
sec.Refresh()
|
sec.Refresh()
|
||||||
|
|
||||||
stat := status.NewWidget()
|
stat := status.NewWidget(Config)
|
||||||
stat.Refresh()
|
stat.Refresh()
|
||||||
|
|
||||||
weather := weather.NewWidget()
|
weather := weather.NewWidget()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user