mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
* WTF-730 Fix missing color key config error Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Add Subheading color formatting to modules Users can now set a `subheading` color in their config to change the color of subheadings in widget display. Defaults to `red`. Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix oustanding color issues Clean up missing color config changes not addressed in earlier commits. Signed-off-by: Chris Cummer <chriscummer@me.com> * Remove unused dependency Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Base cleanup Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix a few bugs related to color config changes Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix issues with PagerDuty subheading display Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix bug with Todo list colour rendering Signed-off-by: Chris Cummer <chriscummer@me.com>
76 lines
1.4 KiB
Go
76 lines
1.4 KiB
Go
package trello
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/adlio/trello"
|
|
"github.com/rivo/tview"
|
|
"github.com/wtfutil/wtf/view"
|
|
)
|
|
|
|
type Widget struct {
|
|
view.TextWidget
|
|
|
|
settings *Settings
|
|
}
|
|
|
|
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
|
widget := Widget{
|
|
TextWidget: view.NewTextWidget(app, settings.common),
|
|
|
|
settings: settings,
|
|
}
|
|
|
|
return &widget
|
|
}
|
|
|
|
/* -------------------- Exported Functions -------------------- */
|
|
|
|
func (widget *Widget) Refresh() {
|
|
widget.Redraw(widget.content)
|
|
}
|
|
|
|
/* -------------------- Unexported Functions -------------------- */
|
|
|
|
func (widget *Widget) content() (string, string, bool) {
|
|
|
|
client := trello.NewClient(
|
|
widget.settings.apiKey,
|
|
widget.settings.accessToken,
|
|
)
|
|
|
|
// Get the cards
|
|
searchResult, err := GetCards(
|
|
client,
|
|
widget.settings.username,
|
|
widget.settings.board,
|
|
widget.settings.list,
|
|
)
|
|
|
|
var title string
|
|
content := ""
|
|
|
|
wrap := false
|
|
if err != nil {
|
|
wrap = true
|
|
title = widget.CommonSettings().Title
|
|
content = err.Error()
|
|
} else {
|
|
title = fmt.Sprintf(
|
|
"[white]%s: [green]%s ",
|
|
widget.CommonSettings().Title,
|
|
widget.settings.board,
|
|
)
|
|
for list, cardArray := range searchResult.TrelloCards {
|
|
content += fmt.Sprintf(" [%s]%s[white]\n", widget.settings.common.Colors.Subheading, list)
|
|
|
|
for _, card := range cardArray {
|
|
content += fmt.Sprintf(" %s[white]\n", card.Name)
|
|
}
|
|
content = fmt.Sprintf("%s\n", content)
|
|
}
|
|
}
|
|
|
|
return title, content, wrap
|
|
}
|