mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
WIP
This commit is contained in:
commit
35c2e088e0
@ -86,8 +86,8 @@
|
||||
branch = "master"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/darkSasori/todoist"
|
||||
branch = "master"
|
||||
|
||||
[prune]
|
||||
go-tests = true
|
||||
|
@ -208,6 +208,7 @@ wtf:
|
||||
cityids:
|
||||
- 3370352
|
||||
- 1283240
|
||||
WTF_OWM_API_KEY: [YOUR API KEY]
|
||||
colors:
|
||||
current: "lightblue"
|
||||
enabled: true
|
||||
|
@ -21,7 +21,20 @@ wtf/jira/
|
||||
|
||||
## Keyboard Commands
|
||||
|
||||
None.
|
||||
<span class="caption">Key:</span> `[return]` <br />
|
||||
<span class="caption">Action:</span> Open the selected issue in the browser.
|
||||
|
||||
<span class="caption">Key:</span> `j` <br />
|
||||
<span class="caption">Action:</span> Select the next item in the list.
|
||||
|
||||
<span class="caption">Key:</span> `k` <br />
|
||||
<span class="caption">Action:</span> Select the previous item in the list.
|
||||
|
||||
<span class="caption">Key:</span> `↓` <br />
|
||||
<span class="caption">Action:</span> Select the next item in the list.
|
||||
|
||||
<span class="caption">Key:</span> `↑` <br />
|
||||
<span class="caption">Action:</span> Select the previous item in the list.
|
||||
|
||||
## Configuration
|
||||
|
||||
|
@ -310,9 +310,11 @@ Key: j Action: Select the next item in the list.</description>
|
||||
<guid>https://wtfutil.com/posts/modules/jira/</guid>
|
||||
<description>Displays all Jira issues assigned to you for the specified project.
|
||||
Source Code wtf/jira/ Required ENV Variables Key: WTF_JIRA_API_KEY Value: Your Jira API key.
|
||||
Keyboard Commands None.
|
||||
Configuration Single Jira Project jira:colors:rows:even:&#34;lightblue&#34;odd:&#34;white&#34;domain:&#34;https://umbrellacorp.atlassian.net&#34;email:&#34;chriscummer@me.com&#34;enabled:truejql:&#34;issueType = Story&#34;position:top:4left:1height:1width:2project:&#34;ProjectA&#34;refreshInterval:900username:&#34;chris.cummer&#34;verifyServerCertificate:true Multiple Jira Projects If you want to monitor multiple Jira projects, use the following configuration (note the difference in project):
|
||||
jira:colors:rows:even:&#34;lightblue&#34;odd:&#34;white&#34;domain:&#34;https://umbrellacorp.atlassian.net&#34;email:&#34;chriscummer@me.com&#34;enabled:truejql:&#34;issueType = Story&#34;position:top:4left:1height:1width:2project:[&#34;ProjectA&#34;,&#34;ProjectB&#34;]refreshInterval:900username:&#34;chris.cummer&#34;verifyServerCertificate:true Attributes colors.rows.even Define the foreground color for even-numbered rows. Values: Any X11 color name.</description>
|
||||
Keyboard Commands Key: [return] Action: Open the selected issue in the browser.
|
||||
Key: j Action: Select the next item in the list.
|
||||
Key: k Action: Select the previous item in the list.
|
||||
Key: ↓ Action: Select the next item in the list.
|
||||
Key: ↑ Action: Select the previous item in the list.</description>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
|
@ -310,9 +310,11 @@ Key: j Action: Select the next item in the list.</description>
|
||||
<guid>https://wtfutil.com/posts/modules/jira/</guid>
|
||||
<description>Displays all Jira issues assigned to you for the specified project.
|
||||
Source Code wtf/jira/ Required ENV Variables Key: WTF_JIRA_API_KEY Value: Your Jira API key.
|
||||
Keyboard Commands None.
|
||||
Configuration Single Jira Project jira:colors:rows:even:&#34;lightblue&#34;odd:&#34;white&#34;domain:&#34;https://umbrellacorp.atlassian.net&#34;email:&#34;chriscummer@me.com&#34;enabled:truejql:&#34;issueType = Story&#34;position:top:4left:1height:1width:2project:&#34;ProjectA&#34;refreshInterval:900username:&#34;chris.cummer&#34;verifyServerCertificate:true Multiple Jira Projects If you want to monitor multiple Jira projects, use the following configuration (note the difference in project):
|
||||
jira:colors:rows:even:&#34;lightblue&#34;odd:&#34;white&#34;domain:&#34;https://umbrellacorp.atlassian.net&#34;email:&#34;chriscummer@me.com&#34;enabled:truejql:&#34;issueType = Story&#34;position:top:4left:1height:1width:2project:[&#34;ProjectA&#34;,&#34;ProjectB&#34;]refreshInterval:900username:&#34;chris.cummer&#34;verifyServerCertificate:true Attributes colors.rows.even Define the foreground color for even-numbered rows. Values: Any X11 color name.</description>
|
||||
Keyboard Commands Key: [return] Action: Open the selected issue in the browser.
|
||||
Key: j Action: Select the next item in the list.
|
||||
Key: k Action: Select the previous item in the list.
|
||||
Key: ↓ Action: Select the next item in the list.
|
||||
Key: ↑ Action: Select the previous item in the list.</description>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
|
@ -148,7 +148,20 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
||||
|
||||
<h2 id="keyboard-commands">Keyboard Commands</h2>
|
||||
|
||||
<p>None.</p>
|
||||
<p><span class="caption">Key:</span> <code>[return]</code> <br />
|
||||
<span class="caption">Action:</span> Open the selected issue in the browser.</p>
|
||||
|
||||
<p><span class="caption">Key:</span> <code>j</code> <br />
|
||||
<span class="caption">Action:</span> Select the next item in the list.</p>
|
||||
|
||||
<p><span class="caption">Key:</span> <code>k</code> <br />
|
||||
<span class="caption">Action:</span> Select the previous item in the list.</p>
|
||||
|
||||
<p><span class="caption">Key:</span> <code>↓</code> <br />
|
||||
<span class="caption">Action:</span> Select the next item in the list.</p>
|
||||
|
||||
<p><span class="caption">Key:</span> <code>↑</code> <br />
|
||||
<span class="caption">Action:</span> Select the previous item in the list.</p>
|
||||
|
||||
<h2 id="configuration">Configuration</h2>
|
||||
|
||||
|
@ -156,7 +156,11 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
||||
<span class="caption">Action:</span> Show the previous project.</p>
|
||||
|
||||
<p><span class="caption">Key:</span> <code>←</code> <br />
|
||||
<<<<<<< HEAD
|
||||
<span class="caption">Action:</span←> Show the previous project.</p>
|
||||
=======
|
||||
<span class="caption">Action:</span> Show the previous project.</p>
|
||||
>>>>>>> baustinanki-make-jira-interactable
|
||||
|
||||
<p><span class="caption">Key:</span> <code>l</code> <br />
|
||||
<span class="caption">Action:</span> Show the next project.</p>
|
||||
|
117
jira/widget.go
117
jira/widget.go
@ -3,18 +3,24 @@ package jira
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
result *SearchResult
|
||||
selected int
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" Jira ", "jira", false),
|
||||
TextWidget: wtf.NewTextWidget(" Jira ", "jira", true),
|
||||
}
|
||||
widget.unselect()
|
||||
|
||||
widget.View.SetInputCapture(widget.keyboardIntercept)
|
||||
return &widget
|
||||
}
|
||||
|
||||
@ -29,38 +35,71 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
widget.UpdateRefreshedAt()
|
||||
|
||||
var content string
|
||||
if err != nil {
|
||||
widget.result = nil
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.Name)
|
||||
content = err.Error()
|
||||
widget.View.SetText(err.Error())
|
||||
} else {
|
||||
widget.View.SetWrap(false)
|
||||
widget.View.SetTitle(
|
||||
fmt.Sprintf(
|
||||
"%s- [green]%s[white]",
|
||||
widget.Name,
|
||||
wtf.Config.UString("wtf.mods.jira.project"),
|
||||
),
|
||||
)
|
||||
content = widget.contentFrom(searchResult)
|
||||
widget.result = searchResult
|
||||
}
|
||||
|
||||
widget.View.SetText(content)
|
||||
widget.display()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) display() {
|
||||
if widget.result == nil {
|
||||
return
|
||||
}
|
||||
widget.View.SetWrap(false)
|
||||
widget.View.SetTitle(
|
||||
fmt.Sprintf(
|
||||
"%s- [green]%s[white]",
|
||||
widget.Name,
|
||||
wtf.Config.UString("wtf.mods.jira.project"),
|
||||
),
|
||||
)
|
||||
widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(widget.result)))
|
||||
}
|
||||
|
||||
func (widget *Widget) next() {
|
||||
widget.selected++
|
||||
if widget.result != nil && widget.selected >= len(widget.result.Issues) {
|
||||
widget.selected = 0
|
||||
}
|
||||
}
|
||||
|
||||
func (widget *Widget) prev() {
|
||||
widget.selected--
|
||||
if widget.selected < 0 && widget.result != nil {
|
||||
widget.selected = len(widget.result.Issues) - 1
|
||||
}
|
||||
}
|
||||
|
||||
func (widget *Widget) openItem() {
|
||||
sel := widget.selected
|
||||
if sel >= 0 && widget.result != nil && sel < len(widget.result.Issues) {
|
||||
issue := &widget.result.Issues[widget.selected]
|
||||
wtf.OpenFile(wtf.Config.UString("wtf.mods.jira.domain") + "/browse/" + issue.Key)
|
||||
}
|
||||
}
|
||||
|
||||
func (widget *Widget) unselect() {
|
||||
widget.selected = -1
|
||||
}
|
||||
|
||||
func (widget *Widget) contentFrom(searchResult *SearchResult) string {
|
||||
str := " [red]Assigned Issues[white]\n"
|
||||
|
||||
for idx, issue := range searchResult.Issues {
|
||||
str = str + fmt.Sprintf(
|
||||
" [%s]%-6s[white] [green]%-10s[%s] %s\n",
|
||||
" [%s]%-6s[white] [green]%-10s [%s]%s\n",
|
||||
widget.issueTypeColor(&issue),
|
||||
issue.IssueFields.IssueType.Name,
|
||||
issue.Key,
|
||||
wtf.RowColor("jira", idx),
|
||||
widget.rowColor(idx),
|
||||
issue.IssueFields.Summary,
|
||||
)
|
||||
}
|
||||
@ -68,6 +107,15 @@ func (widget *Widget) contentFrom(searchResult *SearchResult) string {
|
||||
return str
|
||||
}
|
||||
|
||||
func (widget *Widget) rowColor(idx int) string {
|
||||
if widget.View.HasFocus() && (idx == widget.selected) {
|
||||
foreColor := wtf.Config.UString("wtf.mods.jira.colors.highlight.fore", "black")
|
||||
backColor := wtf.Config.UString("wtf.mods.jira.colors.highlight.back", "white")
|
||||
return fmt.Sprintf("%s:%s", foreColor, backColor)
|
||||
}
|
||||
return wtf.RowColor("jira", idx)
|
||||
}
|
||||
|
||||
func (widget *Widget) issueTypeColor(issue *Issue) string {
|
||||
switch issue.IssueFields.IssueType.Name {
|
||||
case "Bug":
|
||||
@ -98,3 +146,42 @@ func getProjects() []string {
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
|
||||
switch string(event.Rune()) {
|
||||
case "j":
|
||||
// Select the next item down
|
||||
widget.next()
|
||||
widget.display()
|
||||
return nil
|
||||
case "k":
|
||||
// Select the next item up
|
||||
widget.prev()
|
||||
widget.display()
|
||||
return nil
|
||||
}
|
||||
|
||||
switch event.Key() {
|
||||
case tcell.KeyDown:
|
||||
// Select the next item down
|
||||
widget.next()
|
||||
widget.display()
|
||||
return nil
|
||||
case tcell.KeyEnter:
|
||||
widget.openItem()
|
||||
return nil
|
||||
case tcell.KeyEsc:
|
||||
// Unselect the current row
|
||||
widget.unselect()
|
||||
widget.display()
|
||||
return event
|
||||
case tcell.KeyUp:
|
||||
// Select the next item up
|
||||
widget.prev()
|
||||
widget.display()
|
||||
return nil
|
||||
default:
|
||||
// Pass it along
|
||||
return event
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
}
|
||||
|
||||
if widget.APIKey == "" {
|
||||
logger.Log("loading weather WTF_OWM_API_KEY key from config")
|
||||
logger.Log("loading weather API key from config")
|
||||
widget.APIKey = wtf.Config.UString(fmt.Sprintf("wtf.mods.%s.apiKey", configKey), "")
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user