mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Move jenkins filter to the data retrieval portion (#533)
Per #532, we are keeping track of all items regardless of filter, meaning that selection does not work as expected
This commit is contained in:
parent
2efa6eed7c
commit
28f9b55e4f
@ -8,6 +8,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -43,6 +44,17 @@ func (widget *Widget) Create(jenkinsURL string, username string, apiKey string)
|
|||||||
view := &View{}
|
view := &View{}
|
||||||
parseJson(view, resp.Body)
|
parseJson(view, resp.Body)
|
||||||
|
|
||||||
|
jobs := []Job{}
|
||||||
|
|
||||||
|
var validID = regexp.MustCompile(widget.settings.jobNameRegex)
|
||||||
|
for _, job := range view.Jobs {
|
||||||
|
if validID.MatchString(job.Name) {
|
||||||
|
jobs = append(jobs, job)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
view.Jobs = jobs
|
||||||
|
|
||||||
return view, nil
|
return view, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package jenkins
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
"github.com/wtfutil/wtf/utils"
|
"github.com/wtfutil/wtf/utils"
|
||||||
@ -73,9 +72,7 @@ func (widget *Widget) Render() {
|
|||||||
func (widget *Widget) contentFrom(view *View) string {
|
func (widget *Widget) contentFrom(view *View) string {
|
||||||
var str string
|
var str string
|
||||||
for idx, job := range view.Jobs {
|
for idx, job := range view.Jobs {
|
||||||
var validID = regexp.MustCompile(widget.settings.jobNameRegex)
|
|
||||||
|
|
||||||
if validID.MatchString(job.Name) {
|
|
||||||
row := fmt.Sprintf(
|
row := fmt.Sprintf(
|
||||||
`[%s] [%s]%-6s[white]`,
|
`[%s] [%s]%-6s[white]`,
|
||||||
widget.RowColor(idx),
|
widget.RowColor(idx),
|
||||||
@ -85,7 +82,6 @@ func (widget *Widget) contentFrom(view *View) string {
|
|||||||
|
|
||||||
str += utils.HighlightableHelper(widget.View, row, idx, len(job.Name))
|
str += utils.HighlightableHelper(widget.View, row, idx, len(job.Name))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user