From ae13d52665969fef251982250aa3b1b927c1648c Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Sat, 7 Apr 2018 14:20:21 -0700 Subject: [PATCH] Enabled half-measure: widgets won't run if disabled (still need to not display) --- bamboohr/widget.go | 4 ++++ config.yml | 2 +- gcal/widget.go | 4 ++++ git/widget.go | 4 ++++ github/widget.go | 4 ++++ jira/widget.go | 4 ++++ newrelic/widget.go | 4 ++++ opsgenie/widget.go | 4 ++++ security/widget.go | 4 ++++ status/widget.go | 4 ++++ weather/widget.go | 4 ++++ wtf/text_widget.go | 2 +- 12 files changed, 42 insertions(+), 2 deletions(-) diff --git a/bamboohr/widget.go b/bamboohr/widget.go index f3ae9782..390346eb 100644 --- a/bamboohr/widget.go +++ b/bamboohr/widget.go @@ -29,6 +29,10 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { + if widget.Enabled == false { + return + } + url, _ := Config.String("wtf.bamboohr.url") client := NewClient(url) diff --git a/config.yml b/config.yml index 3d44f29b..6ad02103 100644 --- a/config.yml +++ b/config.yml @@ -68,7 +68,7 @@ wtf: height: refreshInterval: 21600 security: - enabled: true + enabled: false position: top: left: diff --git a/gcal/widget.go b/gcal/widget.go index 93273472..d80ff581 100644 --- a/gcal/widget.go +++ b/gcal/widget.go @@ -31,6 +31,10 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { + if widget.Enabled == false { + return + } + events, _ := Fetch() widget.View.SetTitle(" 🍿 Calendar ") diff --git a/git/widget.go b/git/widget.go index 25352ec0..e9d8e348 100644 --- a/git/widget.go +++ b/git/widget.go @@ -31,6 +31,10 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { + if widget.Enabled == false { + return + } + data := Fetch() title := fmt.Sprintf("[green]%s[white]\n", data["repo"][0]) diff --git a/github/widget.go b/github/widget.go index 06b349f4..44a57cda 100644 --- a/github/widget.go +++ b/github/widget.go @@ -30,6 +30,10 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { + if widget.Enabled == false { + return + } + client := NewClient() repo, _ := client.Repository(Config.UString("wtf.github.organization"), Config.UString("wtf.github.repo")) diff --git a/jira/widget.go b/jira/widget.go index 249ca710..352da32d 100644 --- a/jira/widget.go +++ b/jira/widget.go @@ -29,6 +29,10 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { + if widget.Enabled == false { + return + } + widget.View.SetTitle(fmt.Sprintf(" %s ", widget.Name)) widget.RefreshedAt = time.Now() diff --git a/newrelic/widget.go b/newrelic/widget.go index 6d3890c3..47a46dd5 100644 --- a/newrelic/widget.go +++ b/newrelic/widget.go @@ -30,6 +30,10 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { + if widget.Enabled == false { + return + } + app, _ := Application() deploys, _ := Deployments() diff --git a/opsgenie/widget.go b/opsgenie/widget.go index 4beccf3c..cbd4e690 100644 --- a/opsgenie/widget.go +++ b/opsgenie/widget.go @@ -30,6 +30,10 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { + if widget.Enabled == false { + return + } + data := Fetch() widget.View.SetTitle(" ⏰ On Call ") diff --git a/security/widget.go b/security/widget.go index c39adfd3..cd9d8187 100644 --- a/security/widget.go +++ b/security/widget.go @@ -30,6 +30,10 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { + if widget.Enabled == false { + return + } + data := Fetch() widget.View.SetTitle(" 🤺 Security ") diff --git a/status/widget.go b/status/widget.go index 9484ac14..bd9a1cc9 100644 --- a/status/widget.go +++ b/status/widget.go @@ -32,6 +32,10 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { + if widget.Enabled == false { + return + } + widget.View.SetTitle(" 🎉 Status ") widget.RefreshedAt = time.Now() diff --git a/weather/widget.go b/weather/widget.go index 65508290..335d9d7c 100644 --- a/weather/widget.go +++ b/weather/widget.go @@ -31,6 +31,10 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { + if widget.Enabled == false { + return + } + data := Fetch(Config.UInt("wtf.weather.cityId", 6176823)) widget.View.SetTitle(fmt.Sprintf(" %s Weather - %s ", icon(data), data.Name)) diff --git a/wtf/text_widget.go b/wtf/text_widget.go index 25a059d6..899173b6 100644 --- a/wtf/text_widget.go +++ b/wtf/text_widget.go @@ -28,7 +28,7 @@ type TextWidget struct { func NewTextWidget(name string, configKey string) TextWidget { widget := TextWidget{ - Enabled: Config.UBool(fmt.Sprintf("wtf.%s.refreshInterval", configKey), false), + Enabled: Config.UBool(fmt.Sprintf("wtf.%s.enabled", configKey), false), Name: name, RefreshInt: Config.UInt(fmt.Sprintf("wtf.%s.refreshInterval", configKey)), }