mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
A modest number of disjointed improvements
This commit is contained in:
parent
3a3efbd59f
commit
06d4d2c2f7
@ -10,39 +10,6 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
type SearchResult struct {
|
||||
StartAt int `json:"startAt"`
|
||||
MaxResults int `json:"maxResults"`
|
||||
Total int `json:"total"`
|
||||
Issues []Issue `json:"issues"`
|
||||
}
|
||||
|
||||
type Issue struct {
|
||||
Expand string `json:"expand"`
|
||||
ID string `json:"id"`
|
||||
Self string `json:"self"`
|
||||
Key string `json:"key"`
|
||||
|
||||
IssueFields *IssueFields `json:"fields"`
|
||||
}
|
||||
|
||||
type IssueFields struct {
|
||||
Summary string `json:"summary"`
|
||||
|
||||
IssueType *IssueType `json:"issuetype"`
|
||||
}
|
||||
|
||||
type IssueType struct {
|
||||
Self string `json:"self"`
|
||||
ID string `json:"id"`
|
||||
Description string `json:"description"`
|
||||
IconURL string `json:"iconUrl"`
|
||||
Name string `json:"name"`
|
||||
Subtask bool `json:"subtask"`
|
||||
}
|
||||
|
||||
/* -------------------- -------------------- */
|
||||
|
||||
func IssuesFor(username string) (*SearchResult, error) {
|
||||
url := fmt.Sprintf("/rest/api/2/search?jql=assignee=%s", username)
|
||||
|
||||
|
28
jira/issues.go
Normal file
28
jira/issues.go
Normal file
@ -0,0 +1,28 @@
|
||||
package jira
|
||||
|
||||
import (
|
||||
)
|
||||
|
||||
type Issue struct {
|
||||
Expand string `json:"expand"`
|
||||
ID string `json:"id"`
|
||||
Self string `json:"self"`
|
||||
Key string `json:"key"`
|
||||
|
||||
IssueFields *IssueFields `json:"fields"`
|
||||
}
|
||||
|
||||
type IssueFields struct {
|
||||
Summary string `json:"summary"`
|
||||
|
||||
IssueType *IssueType `json:"issuetype"`
|
||||
}
|
||||
|
||||
type IssueType struct {
|
||||
Self string `json:"self"`
|
||||
ID string `json:"id"`
|
||||
Description string `json:"description"`
|
||||
IconURL string `json:"iconUrl"`
|
||||
Name string `json:"name"`
|
||||
Subtask bool `json:"subtask"`
|
||||
}
|
10
jira/search_result.go
Normal file
10
jira/search_result.go
Normal file
@ -0,0 +1,10 @@
|
||||
package jira
|
||||
|
||||
import ()
|
||||
|
||||
type SearchResult struct {
|
||||
StartAt int `json:"startAt"`
|
||||
MaxResults int `json:"maxResults"`
|
||||
Total int `json:"total"`
|
||||
Issues []Issue `json:"issues"`
|
||||
}
|
61
wtf.go
61
wtf.go
@ -37,15 +37,22 @@ func addToGrid(grid *tview.Grid, widget wtf.TextViewer) {
|
||||
}
|
||||
|
||||
// Grid stores all the widgets onscreen (like an HTML table)
|
||||
func buildGrid() *tview.Grid {
|
||||
func buildGrid(modules []wtf.TextViewer) *tview.Grid {
|
||||
grid := tview.NewGrid()
|
||||
grid.SetColumns(wtf.ToInts(Config.UList("wtf.grid.columns"))...)
|
||||
grid.SetRows(wtf.ToInts(Config.UList("wtf.grid.rows"))...)
|
||||
grid.SetBorder(false)
|
||||
|
||||
for _, module := range modules {
|
||||
addToGrid(grid, module)
|
||||
go wtf.Schedule(module)
|
||||
}
|
||||
|
||||
return grid
|
||||
}
|
||||
|
||||
// FIXME: Not a fan of how this function has to reach outside itself, grab
|
||||
// Modules, and then operate on them. Should be able to pass that in instead
|
||||
func keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
|
||||
// Ctrl-R: force-refreshes every widget
|
||||
if event.Key() == tcell.KeyCtrlR {
|
||||
@ -57,7 +64,7 @@ func keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
|
||||
return event
|
||||
}
|
||||
|
||||
func refresher(stat *status.Widget, app *tview.Application) {
|
||||
func refresher(app *tview.Application) {
|
||||
tick := time.NewTicker(time.Duration(Config.UInt("wtf.refreshInterval", 1)) * time.Second)
|
||||
quit := make(chan struct{})
|
||||
|
||||
@ -82,63 +89,37 @@ var Modules []wtf.TextViewer
|
||||
func main() {
|
||||
wtf.Config = Config
|
||||
|
||||
// TODO: Really need to generalize all of these. This don't scale
|
||||
bamboohr.Config = Config
|
||||
bamboo := bamboohr.NewWidget()
|
||||
|
||||
gcal.Config = Config
|
||||
cal := gcal.NewWidget()
|
||||
|
||||
git.Config = Config
|
||||
git := git.NewWidget()
|
||||
|
||||
github.Config = Config
|
||||
github := github.NewWidget()
|
||||
|
||||
jira.Config = Config
|
||||
jira := jira.NewWidget()
|
||||
|
||||
newrelic.Config = Config
|
||||
newrelic := newrelic.NewWidget()
|
||||
|
||||
opsgenie.Config = Config
|
||||
opsgenie := opsgenie.NewWidget()
|
||||
|
||||
security.Config = Config
|
||||
sec := security.NewWidget()
|
||||
|
||||
status.Config = Config
|
||||
stat := status.NewWidget()
|
||||
|
||||
weather.Config = Config
|
||||
weather := weather.NewWidget()
|
||||
|
||||
Modules = []wtf.TextViewer{
|
||||
bamboo,
|
||||
cal,
|
||||
git,
|
||||
github,
|
||||
jira,
|
||||
newrelic,
|
||||
opsgenie,
|
||||
sec,
|
||||
stat,
|
||||
weather,
|
||||
}
|
||||
|
||||
grid := buildGrid()
|
||||
|
||||
for _, module := range Modules {
|
||||
addToGrid(grid, module)
|
||||
go wtf.Schedule(module)
|
||||
bamboohr.NewWidget(),
|
||||
gcal.NewWidget(),
|
||||
git.NewWidget(),
|
||||
github.NewWidget(),
|
||||
jira.NewWidget(),
|
||||
newrelic.NewWidget(),
|
||||
opsgenie.NewWidget(),
|
||||
security.NewWidget(),
|
||||
status.NewWidget(),
|
||||
weather.NewWidget(),
|
||||
}
|
||||
|
||||
app := tview.NewApplication()
|
||||
app.SetInputCapture(keyboardIntercept)
|
||||
|
||||
// Loop in a routine to redraw the screen
|
||||
go refresher(stat, app)
|
||||
go refresher(app)
|
||||
|
||||
grid := buildGrid(Modules)
|
||||
if err := app.SetRoot(grid, true).Run(); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user