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

Configuration used throughout the app

This commit is contained in:
Chris Cummer
2018-04-04 14:30:05 -07:00
committed by Chris Cummer
parent 45d88c6700
commit c3f1d7ee36
13 changed files with 102 additions and 83 deletions

View File

@@ -1,18 +0,0 @@
package bamboohr
import (
//"time"
)
// TODO Move this into the client. Why is it separate?
//func Fetch() []Item {
//client := NewClient()
//result := client.Away("timeOff", today(), today())
//return result
//}
//func today() string {
//localNow := time.Now().Local()
//return localNow.Format("2006-01-02")
//}

View File

@@ -10,26 +10,21 @@ import (
"github.com/senorprogrammer/wtf/wtf"
)
var Config *config.Config
type Widget struct {
wtf.BaseWidget
Config *config.Config
View *tview.TextView
View *tview.TextView
}
func NewWidget(config *config.Config) *Widget {
refreshInterval, err := config.Int("wtf.bamboohr.refreshInterval")
if err != nil {
refreshInterval = 1
}
func NewWidget() *Widget {
widget := Widget{
BaseWidget: wtf.BaseWidget{
Name: "BambooHR",
RefreshedAt: time.Now(),
RefreshInt: refreshInterval,
RefreshInt: Config.UInt("wtf.bamboohr.refreshInterval", 900),
},
Config: config,
}
widget.addView()
@@ -41,7 +36,7 @@ func NewWidget(config *config.Config) *Widget {
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Refresh() {
url, _ := widget.Config.String("wtf.bamboohr.url")
url, _ := Config.String("wtf.bamboohr.url")
client := NewClient(url)
items := client.Away("timeOff", wtf.Today(), wtf.Today())