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

WTF-400 Move name and configKey values from widget to settings

This commit is contained in:
Chris Cummer
2019-04-17 17:16:26 -07:00
parent d174bd1497
commit b50c762dab
93 changed files with 351 additions and 237 deletions

View File

@@ -7,20 +7,23 @@ import (
"github.com/wtfutil/wtf/cfg"
)
type Settings struct {
Common *cfg.Common
const configKey = "bamboohr"
APIKey string
Subdomain string
type Settings struct {
common *cfg.Common
apiKey string
subdomain string
}
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
localConfig, _ := ymlConfig.Get("wtf.mods.bamboohr")
func NewSettingsFromYAML(name string, ymlConfig *config.Config) *Settings {
localConfig, _ := ymlConfig.Get("wtf.mods." + configKey)
settings := Settings{
Common: cfg.NewCommonSettingsFromYAML(ymlConfig),
APIKey: localConfig.UString("apiKey", os.Getenv("WTF_BAMBOO_HR_TOKEN")),
Subdomain: localConfig.UString("subdomain", os.Getenv("WTF_BAMBOO_HR_SUBDOMAIN")),
common: cfg.NewCommonSettingsFromYAML(name, configKey, ymlConfig),
apiKey: localConfig.UString("apiKey", os.Getenv("WTF_BAMBOO_HR_TOKEN")),
subdomain: localConfig.UString("subdomain", os.Getenv("WTF_BAMBOO_HR_SUBDOMAIN")),
}
return &settings

View File

@@ -17,7 +17,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, "BambooHR", "bamboohr", false),
TextWidget: wtf.NewTextWidget(app, settings.common.Name, settings.common.ConfigKey, false),
settings: settings,
}
@@ -30,8 +30,8 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
func (widget *Widget) Refresh() {
client := NewClient(
APIURI,
widget.settings.APIKey,
widget.settings.Subdomain,
widget.settings.apiKey,
widget.settings.subdomain,
)
todayItems := client.Away(