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

WTF-730 Fix missing color key config error (#738)

* 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>
This commit is contained in:
Chris Cummer
2019-11-09 11:21:45 -08:00
committed by GitHub
parent 1bfca29d17
commit 200dbcc03c
33 changed files with 366 additions and 137 deletions

View File

@@ -85,7 +85,10 @@ func (widget *Widget) content() (string, string, bool) {
if len(triggeredMonitors) > 0 {
str += fmt.Sprintf(
" %s\n",
"[red]Triggered Monitors[white]",
fmt.Sprintf(
"[%s]Triggered Monitors[white]",
widget.settings.common.Colors.Subheading,
),
)
for idx, triggeredMonitor := range triggeredMonitors {
row := fmt.Sprintf(`[%s][red] %s[%s]`,

View File

@@ -41,13 +41,13 @@ func (widget *Widget) getSystemInfo() string {
}{
{
name: "name:",
value: fmt.Sprintf("[%s]%s", widget.settings.common.Foreground, info.Name),
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, info.Name),
}, {
name: "version:",
value: fmt.Sprintf("[%s]%s", widget.settings.common.Foreground, info.ServerVersion),
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, info.ServerVersion),
}, {
name: "root:",
value: fmt.Sprintf("[%s]%s", widget.settings.common.Foreground, info.DockerRootDir),
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, info.DockerRootDir),
},
{
name: "containers:",
@@ -57,15 +57,15 @@ func (widget *Widget) getSystemInfo() string {
},
{
name: "images:",
value: fmt.Sprintf("[%s]%d", widget.settings.common.Foreground, info.Images),
value: fmt.Sprintf("[%s]%d", widget.settings.common.Colors.RowTheme.EvenForeground, info.Images),
},
{
name: "volumes:",
value: fmt.Sprintf("[%s]%v", widget.settings.common.Foreground, len(diskUsage.Volumes)),
value: fmt.Sprintf("[%s]%v", widget.settings.common.Colors.RowTheme.EvenForeground, len(diskUsage.Volumes)),
},
{
name: "memory limit:",
value: fmt.Sprintf("[%s]%s", widget.settings.common.Foreground, humanize.Bytes(uint64(info.MemTotal))),
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, humanize.Bytes(uint64(info.MemTotal))),
},
{
name: "disk usage:",
@@ -76,19 +76,19 @@ func (widget *Widget) getSystemInfo() string {
[%s]* [::b]total: [%s]%s[::-]
`,
widget.settings.labelColor,
widget.settings.common.Foreground,
widget.settings.common.Colors.RowTheme.EvenForeground,
humanize.Bytes(uint64(duContainer)),
widget.settings.labelColor,
widget.settings.common.Foreground,
widget.settings.common.Colors.RowTheme.EvenForeground,
humanize.Bytes(uint64(duImg)),
widget.settings.labelColor,
widget.settings.common.Foreground,
widget.settings.common.Colors.RowTheme.EvenForeground,
humanize.Bytes(uint64(duVol)),
widget.settings.labelColor,
widget.settings.common.Foreground,
widget.settings.common.Colors.RowTheme.EvenForeground,
humanize.Bytes(uint64(duContainer+duImg+duVol))),
},
}

View File

@@ -140,7 +140,7 @@ func (widget *Widget) content() (string, string, bool) {
// Grays out viewed items in the list, while preserving background highlighting when selected
rowColor = "gray"
if idx == widget.Selected {
rowColor = fmt.Sprintf("gray:%s", widget.settings.common.Colors.HighlightBack)
rowColor = fmt.Sprintf("gray:%s", widget.settings.common.Colors.RowTheme.HighlightedBackground)
}
}

View File

@@ -23,13 +23,13 @@ func (widget *Widget) content() (string, string, bool) {
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.SigilStr(len(widget.GerritProjects), widget.Idx, width) + "\n"
str += " [red]Stats[white]\n"
str += fmt.Sprintf(" [%s]Stats[white]\n", widget.settings.common.Colors.Subheading)
str += widget.displayStats(project)
str += "\n"
str += " [red]Open Incoming Reviews[white]\n"
str += fmt.Sprintf(" [%s]Open Incoming Reviews[white]\n", widget.settings.common.Colors.Subheading)
str += widget.displayMyIncomingReviews(project, widget.settings.username)
str += "\n"
str += " [red]My Outgoing Reviews[white]\n"
str += fmt.Sprintf(" [%s]My Outgoing Reviews[white]\n", widget.settings.common.Colors.Subheading)
str += widget.displayMyOutgoingReviews(project, widget.settings.username)
return title, str, false

View File

@@ -16,11 +16,15 @@ func (widget *Widget) content() (string, string, bool) {
return widget.CommonSettings().Title, " Git repo data is unavailable ", false
}
title := fmt.Sprintf("%s - [green]%s[white]", widget.CommonSettings().Title, repoData.Repository)
title := fmt.Sprintf(
"%s - %s[white]",
widget.CommonSettings().Title,
repoData.Repository,
)
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.SigilStr(len(widget.GitRepos), widget.Idx, width) + "\n"
str += " [red]Branch[white]\n"
str += fmt.Sprintf(" [%s]Branch[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" %s", repoData.Branch)
str += "\n"
str += widget.formatChanges(repoData.ChangedFiles)
@@ -31,7 +35,7 @@ func (widget *Widget) content() (string, string, bool) {
}
func (widget *Widget) formatChanges(data []string) string {
str := " [red]Changed Files[white]\n"
str := fmt.Sprintf(" [%s]Changed Files[white]\n", widget.settings.common.Colors.Subheading)
if len(data) == 1 {
str += " [grey]none[white]\n"
@@ -68,7 +72,7 @@ func (widget *Widget) formatChange(line string) string {
}
func (widget *Widget) formatCommits(data []string) string {
str := " [red]Recent Commits[white]\n"
str := fmt.Sprintf(" [%s]Recent Commits[white]\n", widget.settings.common.Colors.Subheading)
for _, line := range data {
str += widget.formatCommit(line)

View File

@@ -34,14 +34,14 @@ func (widget *Widget) content() (string, string, bool) {
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.SigilStr(len(widget.GithubRepos), widget.Idx, width) + "\n"
str += " [red]Stats[white]\n"
str += fmt.Sprintf(" [%s]Stats[white]\n", widget.settings.common.Colors.Subheading)
str += widget.displayStats(repo)
str += "\n [red]Open Review Requests[white]\n"
str += fmt.Sprintf("\n [%s]Open Review Requests[white]\n", widget.settings.common.Colors.Subheading)
str += widget.displayMyReviewRequests(repo, username)
str += "\n [red]My Pull Requests[white]\n"
str += fmt.Sprintf("\n [%s]My Pull Requests[white]\n", widget.settings.common.Colors.Subheading)
str += widget.displayMyPullRequests(repo, username)
for _, customQuery := range widget.settings.customQueries {
str += fmt.Sprintf("\n [red]%s[white]\n", customQuery.title)
str += fmt.Sprintf("\n [%s]%s[white]\n", widget.settings.common.Colors.Subheading, customQuery.title)
str += widget.displayCustomQuery(repo, customQuery.filter, customQuery.perPage)
}
@@ -127,7 +127,12 @@ func (widget *Widget) displayStats(repo *GithubRepo) string {
}
func (widget *Widget) title(repo *GithubRepo) string {
return fmt.Sprintf("[green]%s - %s[white]", repo.Owner, repo.Name)
return fmt.Sprintf(
"[%s]%s - %s[white]",
widget.settings.common.Colors.TextTheme.Title,
repo.Owner,
repo.Name,
)
}
var mergeIcons = map[string]string{

View File

@@ -19,19 +19,19 @@ func (widget *Widget) content() (string, string, bool) {
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.SigilStr(len(widget.GitlabProjects), widget.Idx, width) + "\n"
str += " [red]Stats[white]\n"
str += fmt.Sprintf(" [%s]Stats[white]\n", widget.settings.common.Colors.Subheading)
str += widget.displayStats(project)
str += "\n"
str += " [red]Open Assigned Merge Requests[white]\n"
str += fmt.Sprintf(" [%s]Open Assigned Merge Requests[white]\n", widget.settings.common.Colors.Subheading)
str += widget.displayMyAssignedMergeRequests(project, widget.settings.username)
str += "\n"
str += " [red]My Merge Requests[white]\n"
str += fmt.Sprintf(" [%s]My Merge Requests[white]\n", widget.settings.common.Colors.Subheading)
str += widget.displayMyMergeRequests(project, widget.settings.username)
str += "\n"
str += " [red]Open Assigned Issues[white]\n"
str += fmt.Sprintf(" [%s]Open Assigned Issues[white]\n", widget.settings.common.Colors.Subheading)
str += widget.displayMyAssignedIssues(project, widget.settings.username)
str += "\n"
str += " [red]My Issues[white]\n"
str += fmt.Sprintf(" [%s]My Issues[white]\n", widget.settings.common.Colors.Subheading)
str += widget.displayMyIssues(project, widget.settings.username)
return title, str, false

View File

@@ -2,6 +2,7 @@ package jira
import (
"fmt"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/utils"
"github.com/wtfutil/wtf/view"
@@ -78,7 +79,7 @@ func (widget *Widget) content() (string, string, bool) {
title := fmt.Sprintf("%s- [green]%s[white]", widget.CommonSettings().Title, widget.settings.projects)
str := " [red]Assigned Issues[white]\n"
str := fmt.Sprintf(" [%s]Assigned Issues[white]\n", widget.settings.common.Colors.Subheading)
if widget.result == nil || len(widget.result.Issues) == 0 {
return title, "No results to display", false

View File

@@ -56,7 +56,7 @@ func (widget *Widget) Refresh() {
widget.Redraw(func() (string, string, bool) { return title, "[red] Error getting node data [white]\n", true })
return
}
content += "[red]Nodes[white]\n"
content += fmt.Sprintf("[%s]Nodes[white]\n", widget.settings.common.Colors.Subheading)
for _, node := range nodeList {
content += fmt.Sprintf("%s\n", node)
}
@@ -69,7 +69,7 @@ func (widget *Widget) Refresh() {
widget.Redraw(func() (string, string, bool) { return title, "[red] Error getting deployment data [white]\n", true })
return
}
content += "[red]Deployments[white]\n"
content += fmt.Sprintf("[%s]Deployments[white]\n", widget.settings.common.Colors.Subheading)
for _, deployment := range deploymentList {
content += fmt.Sprintf("%s\n", deployment)
}
@@ -82,7 +82,7 @@ func (widget *Widget) Refresh() {
widget.Redraw(func() (string, string, bool) { return title, "[red] Error getting pod data [white]\n", false })
return
}
content += "[red]Pods[white]\n"
content += fmt.Sprintf("[%s]Pods[white]\n", widget.settings.common.Colors.Subheading)
for _, pod := range podList {
content += fmt.Sprintf("%s\n", pod)
}

View File

@@ -16,11 +16,15 @@ func (widget *Widget) content() (string, string, bool) {
return widget.CommonSettings().Title, " Mercurial repo data is unavailable ", false
}
title := fmt.Sprintf("%s - [green]%s[white]", widget.CommonSettings().Title, repoData.Repository)
title := fmt.Sprintf(
"%s - %s[white]",
widget.settings.common.Colors.TextTheme.Title,
repoData.Repository,
)
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.SigilStr(len(widget.Data), widget.Idx, width) + "\n"
str += " [red]Branch:Bookmark[white]\n"
str += fmt.Sprintf(" [%s]Branch:Bookmark[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" %s:%s\n", repoData.Branch, repoData.Bookmark)
str += "\n"
str += widget.formatChanges(repoData.ChangedFiles)
@@ -31,7 +35,7 @@ func (widget *Widget) content() (string, string, bool) {
}
func (widget *Widget) formatChanges(data []string) string {
str := " [red]Changed Files[white]\n"
str := fmt.Sprintf(" [%s]Changed Files[white]\n", widget.settings.common.Colors.Subheading)
if len(data) == 1 {
str += " [grey]none[white]\n"
@@ -68,7 +72,7 @@ func (widget *Widget) formatChange(line string) string {
}
func (widget *Widget) formatCommits(data []string) string {
str := " [red]Recent Commits[white]\n"
str := fmt.Sprintf(" [%s]Recent Commits[white]\n", widget.settings.common.Colors.Subheading)
for _, line := range data {
str += widget.formatCommit(line)

View File

@@ -79,8 +79,9 @@ func (widget *Widget) nbascore() (string, string, bool) {
}
result := map[string]interface{}{}
json.Unmarshal(contents, &result)
allGame := "" // store result in allgame
allGame += (" " + "[red]" + (cur.Format(utils.FriendlyDateFormat) + "\n\n") + "[white]")
allGame := fmt.Sprintf(" [%s]", widget.settings.common.Colors.Subheading) + (cur.Format(utils.FriendlyDateFormat) + "\n\n") + "[white]"
for _, game := range result["games"].([]interface{}) {
vTeam, hTeam, vScore, hScore := "", "", "", ""
quarter := 0.

View File

@@ -37,7 +37,10 @@ func (widget *Widget) content() (string, string, bool) {
func (widget *Widget) contentFrom(deploys []nr.ApplicationDeployment) string {
str := fmt.Sprintf(
" %s\n",
"[red]Latest Deploys[white]",
fmt.Sprintf(
"[%s]Latest Deploys[white]",
widget.settings.common.Colors.Subheading,
),
)
revisions := []string{}

View File

@@ -70,7 +70,7 @@ func (widget *Widget) contentFrom(onCalls []pagerduty.OnCall, incidents []pagerd
if len(incidents) > 0 {
str += "[yellow]Incidents[white]\n"
for _, incident := range incidents {
str += fmt.Sprintf("[red]%s[white]\n", incident.Summary)
str += fmt.Sprintf("[%s]%s[white]\n", widget.settings.common.Colors.Subheading, incident.Summary)
str += fmt.Sprintf("Status: %s\n", incident.Status)
str += fmt.Sprintf("Service: %s\n", incident.Service.Summary)
str += fmt.Sprintf("Escalation: %s\n", incident.EscalationPolicy.Summary)
@@ -100,14 +100,26 @@ func (widget *Widget) contentFrom(onCalls []pagerduty.OnCall, incidents []pagerd
sort.Strings(keys)
if len(keys) > 0 {
str += "[red] Schedules[white]\n"
str += fmt.Sprintf("[%s] Schedules[white]\n", widget.settings.common.Colors.Subheading)
// Print out policies, and escalation order of users
for _, key := range keys {
str += fmt.Sprintf("\n [green::b]%s\n", key)
str += fmt.Sprintf(
"\n [%s]%s\n",
widget.settings.common.Colors.Subheading,
key,
)
values := tree[key]
sort.Sort(ByEscalationLevel(values))
for _, item := range values {
str += fmt.Sprintf(" [white]%d - %s\n", item.EscalationLevel, item.User.Summary)
str += fmt.Sprintf(
" [%s]%d - %s\n",
widget.settings.common.Colors.Text,
item.EscalationLevel,
item.User.Summary,
)
}
}
}

View File

@@ -58,12 +58,12 @@ func MakeGraph(widget *Widget) {
stat = math.Max(0, stat)
var label string
if (widget.settings.cpuCombined) {
if widget.settings.cpuCombined {
label = "CPU"
} else {
label = fmt.Sprint(i)
}
bar := view.Bar{
Label: label,
Percent: int(stat),
@@ -122,13 +122,12 @@ func MakeGraph(widget *Widget) {
// Refresh & update after interval time
func (widget *Widget) Refresh() {
if widget.Disabled() {
return
}
widget.app.QueueUpdateDraw(func() {
widget.View.Clear()
widget.View.Clear()
display(widget)
})
}

View File

@@ -40,21 +40,21 @@ func (widget *Widget) Refresh() {
func (widget *Widget) content() (string, string, bool) {
data := NewSecurityData()
data.Fetch()
str := " [red]WiFi[white]\n"
str := fmt.Sprintf(" [%s]WiFi[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" %8s: %s\n", "Network", data.WifiName)
str += fmt.Sprintf(" %8s: %s\n", "Crypto", data.WifiEncryption)
str += "\n"
str += " [red]Firewall[white]\n"
str += fmt.Sprintf(" [%s]Firewall[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" %8s: %4s\n", "Status", data.FirewallEnabled)
str += fmt.Sprintf(" %8s: %4s\n", "Stealth", data.FirewallStealth)
str += "\n"
str += " [red]Users[white]\n"
str += fmt.Sprintf(" [%s]Users[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" %s", strings.Join(data.LoggedInUsers, "\n "))
str += "\n\n"
str += " [red]DNS[white]\n"
str += fmt.Sprintf(" [%s]DNS[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf(" %12s\n", data.DnsAt(0))
str += fmt.Sprintf(" %12s\n", data.DnsAt(1))
str += "\n"

View File

@@ -71,7 +71,11 @@ func (widget *Widget) HelpText() string {
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) content() (string, string, bool) {
title := fmt.Sprintf("[green]%s[white]", widget.CurrentSource())
title := fmt.Sprintf(
"[%s]%s[white]",
widget.settings.common.Colors.TextTheme.Title,
widget.CurrentSource(),
)
_, _, width, _ := widget.View.GetRect()
text := widget.settings.common.SigilStr(len(widget.Sources), widget.Idx, width) + "\n"

View File

@@ -41,25 +41,23 @@ func (widget *Widget) content() (string, string, bool) {
return widget.CommonSettings().Title, str, false
}
func (widget *Widget) formattedItemLine(idx int, item *checklist.ChecklistItem, selectedItem *checklist.ChecklistItem, maxLen int) string {
foreColor, backColor := widget.settings.common.Colors.Text, widget.settings.common.Colors.Background
func (widget *Widget) formattedItemLine(idx int, currItem *checklist.ChecklistItem, selectedItem *checklist.ChecklistItem, maxLen int) string {
rowColor := widget.RowColor(idx)
if item.Checked {
foreColor = widget.settings.common.Colors.Checked
if currItem.Checked {
rowColor = widget.settings.common.Colors.CheckboxTheme.Checked
}
if widget.View.HasFocus() && (item == selectedItem) {
foreColor = widget.settings.common.Colors.HighlightFore
backColor = widget.settings.common.Colors.HighlightBack
if widget.View.HasFocus() && (currItem == selectedItem) {
rowColor = widget.RowColor(idx)
}
row := fmt.Sprintf(
` [%s:%s]|%s| %s[white]`,
foreColor,
backColor,
item.CheckMark(),
tview.Escape(item.Text),
` [%s]|%s| %s[white]`,
rowColor,
currItem.CheckMark(),
tview.Escape(currItem.Text),
)
return utils.HighlightableHelper(widget.View, row, idx, len(item.Text))
return utils.HighlightableHelper(widget.View, row, idx, len(currItem.Text))
}

View File

@@ -18,7 +18,11 @@ func (widget *Widget) content() (string, string, bool) {
return widget.CommonSettings().Title, proj.err.Error(), true
}
title := fmt.Sprintf("[green]%s[white]", proj.Project.Name)
title := fmt.Sprintf(
"[%s]%s[white]",
widget.settings.common.Colors.TextTheme.Title,
proj.Project.Name,
)
str := ""

View File

@@ -62,7 +62,7 @@ func (widget *Widget) content() (string, string, bool) {
widget.settings.board,
)
for list, cardArray := range searchResult.TrelloCards {
content += fmt.Sprintf(" [red]%s[white]\n", list)
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)

View File

@@ -10,13 +10,16 @@ import (
type Widget struct {
view.TextWidget
client *Client
client *Client
settings *Settings
}
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
client: NewClient(settings),
client: NewClient(settings),
settings: settings,
}
widget.View.SetBorderPadding(1, 1, 1, 1)
@@ -31,18 +34,25 @@ func (widget *Widget) Refresh() {
}
func (widget *Widget) content() (string, string, bool) {
usernames := widget.client.screenNames
// Add header row
str := fmt.Sprintf(
"[%s]%-12s %10s %8s[white]\n",
widget.settings.common.Colors.Subheading,
"Username",
"Followers",
"Tweets",
)
stats := widget.client.GetStats()
// Add header row
str := fmt.Sprintf("%-16s %8s %8s\n", "Username", "Followers", "Tweets")
// Add rows for each of the followed usernames
for i, username := range usernames {
followerCount := stats[i].FollowerCount
tweetCount := stats[i].TweetCount
str += fmt.Sprintf("%-16s %8d %8d\n", username, followerCount, tweetCount)
for i, username := range widget.client.screenNames {
str += fmt.Sprintf(
"%-12s %10d %8d\n",
username,
stats[i].FollowerCount,
stats[i].TweetCount,
)
}
return "Twitter Stats", str, true

View File

@@ -74,7 +74,7 @@ func (widget *Widget) content() (string, string, bool) {
func (widget *Widget) format(ticket Ticket, idx int) string {
textColor := widget.settings.common.Colors.Background
if idx == widget.GetSelected() {
textColor = widget.settings.common.Colors.BorderFocused
textColor = widget.settings.common.Colors.BorderTheme.Focused
}
requesterName := widget.parseRequester(ticket)