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"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -43,6 +44,17 @@ func (widget *Widget) Create(jenkinsURL string, username string, apiKey string)
|
||||
view := &View{}
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package jenkins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/wtfutil/wtf/utils"
|
||||
@ -73,18 +72,15 @@ func (widget *Widget) Render() {
|
||||
func (widget *Widget) contentFrom(view *View) string {
|
||||
var str string
|
||||
for idx, job := range view.Jobs {
|
||||
var validID = regexp.MustCompile(widget.settings.jobNameRegex)
|
||||
|
||||
if validID.MatchString(job.Name) {
|
||||
row := fmt.Sprintf(
|
||||
`[%s] [%s]%-6s[white]`,
|
||||
widget.RowColor(idx),
|
||||
widget.jobColor(&job),
|
||||
job.Name,
|
||||
)
|
||||
row := fmt.Sprintf(
|
||||
`[%s] [%s]%-6s[white]`,
|
||||
widget.RowColor(idx),
|
||||
widget.jobColor(&job),
|
||||
job.Name,
|
||||
)
|
||||
|
||||
str += utils.HighlightableHelper(widget.View, row, idx, len(job.Name))
|
||||
}
|
||||
str += utils.HighlightableHelper(widget.View, row, idx, len(job.Name))
|
||||
}
|
||||
|
||||
return str
|
||||
|
Loading…
x
Reference in New Issue
Block a user