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"
|
branch = "master"
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
branch = "master"
|
|
||||||
name = "github.com/darkSasori/todoist"
|
name = "github.com/darkSasori/todoist"
|
||||||
|
branch = "master"
|
||||||
|
|
||||||
[prune]
|
[prune]
|
||||||
go-tests = true
|
go-tests = true
|
||||||
|
@ -208,6 +208,7 @@ wtf:
|
|||||||
cityids:
|
cityids:
|
||||||
- 3370352
|
- 3370352
|
||||||
- 1283240
|
- 1283240
|
||||||
|
WTF_OWM_API_KEY: [YOUR API KEY]
|
||||||
colors:
|
colors:
|
||||||
current: "lightblue"
|
current: "lightblue"
|
||||||
enabled: true
|
enabled: true
|
||||||
|
@ -21,7 +21,20 @@ wtf/jira/
|
|||||||
|
|
||||||
## Keyboard Commands
|
## 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
|
## Configuration
|
||||||
|
|
||||||
|
@ -310,9 +310,11 @@ Key: j Action: Select the next item in the list.</description>
|
|||||||
<guid>https://wtfutil.com/posts/modules/jira/</guid>
|
<guid>https://wtfutil.com/posts/modules/jira/</guid>
|
||||||
<description>Displays all Jira issues assigned to you for the specified project.
|
<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.
|
Source Code wtf/jira/ Required ENV Variables Key: WTF_JIRA_API_KEY Value: Your Jira API key.
|
||||||
Keyboard Commands None.
|
Keyboard Commands Key: [return] Action: Open the selected issue in the browser.
|
||||||
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):
|
Key: j Action: Select the next item in the list.
|
||||||
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>
|
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>
|
||||||
|
|
||||||
<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>
|
<guid>https://wtfutil.com/posts/modules/jira/</guid>
|
||||||
<description>Displays all Jira issues assigned to you for the specified project.
|
<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.
|
Source Code wtf/jira/ Required ENV Variables Key: WTF_JIRA_API_KEY Value: Your Jira API key.
|
||||||
Keyboard Commands None.
|
Keyboard Commands Key: [return] Action: Open the selected issue in the browser.
|
||||||
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):
|
Key: j Action: Select the next item in the list.
|
||||||
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>
|
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>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
|
@ -148,7 +148,20 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
|||||||
|
|
||||||
<h2 id="keyboard-commands">Keyboard Commands</h2>
|
<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>
|
<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>
|
<span class="caption">Action:</span> Show the previous project.</p>
|
||||||
|
|
||||||
<p><span class="caption">Key:</span> <code>←</code> <br />
|
<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>
|
||||||
|
=======
|
||||||
|
<span class="caption">Action:</span> Show the previous project.</p>
|
||||||
|
>>>>>>> baustinanki-make-jira-interactable
|
||||||
|
|
||||||
<p><span class="caption">Key:</span> <code>l</code> <br />
|
<p><span class="caption">Key:</span> <code>l</code> <br />
|
||||||
<span class="caption">Action:</span> Show the next project.</p>
|
<span class="caption">Action:</span> Show the next project.</p>
|
||||||
|
107
jira/widget.go
107
jira/widget.go
@ -3,18 +3,24 @@ package jira
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/gdamore/tcell"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Widget struct {
|
type Widget struct {
|
||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
|
|
||||||
|
result *SearchResult
|
||||||
|
selected int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget() *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget(" Jira ", "jira", false),
|
TextWidget: wtf.NewTextWidget(" Jira ", "jira", true),
|
||||||
}
|
}
|
||||||
|
widget.unselect()
|
||||||
|
|
||||||
|
widget.View.SetInputCapture(widget.keyboardIntercept)
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,12 +35,24 @@ func (widget *Widget) Refresh() {
|
|||||||
|
|
||||||
widget.UpdateRefreshedAt()
|
widget.UpdateRefreshedAt()
|
||||||
|
|
||||||
var content string
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
widget.result = nil
|
||||||
widget.View.SetWrap(true)
|
widget.View.SetWrap(true)
|
||||||
widget.View.SetTitle(widget.Name)
|
widget.View.SetTitle(widget.Name)
|
||||||
content = err.Error()
|
widget.View.SetText(err.Error())
|
||||||
} else {
|
} else {
|
||||||
|
widget.result = searchResult
|
||||||
|
}
|
||||||
|
|
||||||
|
widget.display()
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
|
func (widget *Widget) display() {
|
||||||
|
if widget.result == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
widget.View.SetWrap(false)
|
widget.View.SetWrap(false)
|
||||||
widget.View.SetTitle(
|
widget.View.SetTitle(
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
@ -43,24 +61,45 @@ func (widget *Widget) Refresh() {
|
|||||||
wtf.Config.UString("wtf.mods.jira.project"),
|
wtf.Config.UString("wtf.mods.jira.project"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
content = widget.contentFrom(searchResult)
|
widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(widget.result)))
|
||||||
}
|
|
||||||
|
|
||||||
widget.View.SetText(content)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
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 {
|
func (widget *Widget) contentFrom(searchResult *SearchResult) string {
|
||||||
str := " [red]Assigned Issues[white]\n"
|
str := " [red]Assigned Issues[white]\n"
|
||||||
|
|
||||||
for idx, issue := range searchResult.Issues {
|
for idx, issue := range searchResult.Issues {
|
||||||
str = str + fmt.Sprintf(
|
str = str + fmt.Sprintf(
|
||||||
" [%s]%-6s[white] [green]%-10s[%s] %s\n",
|
" [%s]%-6s[white] [green]%-10s [%s]%s\n",
|
||||||
widget.issueTypeColor(&issue),
|
widget.issueTypeColor(&issue),
|
||||||
issue.IssueFields.IssueType.Name,
|
issue.IssueFields.IssueType.Name,
|
||||||
issue.Key,
|
issue.Key,
|
||||||
wtf.RowColor("jira", idx),
|
widget.rowColor(idx),
|
||||||
issue.IssueFields.Summary,
|
issue.IssueFields.Summary,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -68,6 +107,15 @@ func (widget *Widget) contentFrom(searchResult *SearchResult) string {
|
|||||||
return str
|
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 {
|
func (widget *Widget) issueTypeColor(issue *Issue) string {
|
||||||
switch issue.IssueFields.IssueType.Name {
|
switch issue.IssueFields.IssueType.Name {
|
||||||
case "Bug":
|
case "Bug":
|
||||||
@ -98,3 +146,42 @@ func getProjects() []string {
|
|||||||
}
|
}
|
||||||
return ret
|
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 == "" {
|
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), "")
|
widget.APIKey = wtf.Config.UString(fmt.Sprintf("wtf.mods.%s.apiKey", configKey), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user