Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow filter by status #872

Merged
merged 1 commit into from
Dec 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions dkron/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,23 +165,20 @@ func (h *HTTPTransport) indexHandler(c *gin.Context) {

func (h *HTTPTransport) jobsHandler(c *gin.Context) {
metadata := c.QueryMap("metadata")
sort, ok := c.GetQuery("_sort")
if !ok || sort == "id" {
sort := c.DefaultQuery("_sort", "id")
if sort == "id" {
sort = "name"
}
order, ok := c.GetQuery("_order")
if !ok {
order = "ASC"
}

q, _ := c.GetQuery("q")
order := c.DefaultQuery("_order", "ASC")
q := c.Query("q")

jobs, err := h.agent.Store.GetJobs(
&JobOptions{
Metadata: metadata,
Sort: sort,
Order: order,
Query: q,
Status: c.Query("status"),
},
)
if err != nil {
Expand Down
130 changes: 65 additions & 65 deletions dkron/assets_ui/assets_vfsdata.go

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion dkron/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type JobOptions struct {
Sort string
Order string
Query string
Status string
}

type kv struct {
Expand Down Expand Up @@ -316,7 +317,9 @@ func (s *Store) GetJobs(options *JobOptions) ([]*Job, error) {

if options == nil ||
(options.Metadata == nil || len(options.Metadata) == 0 || s.jobHasMetadata(job, options.Metadata)) &&
(options.Query == "" || strings.Contains(job.Name, options.Query)) {
(options.Query == "" || strings.Contains(job.Name, options.Query)) &&
(options.Status == "" || job.Status == options.Status) {

jobs = append(jobs, job)
}
return true
Expand Down
5 changes: 5 additions & 0 deletions ui/src/jobs/JobList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ import {
Filter,
TextInput,
List,
SelectInput
} from 'react-admin';
import ToggleButton from "./ToggleButton"
import RunButton from "./RunButton"

const PostFilter = (props: any) => (
<Filter {...props}>
<TextInput label="Search" source="q" alwaysOn />
<SelectInput source="status" choices={[
{ id: 'success', name: 'Success' },
{ id: 'failed', name: 'Failed' },
]} />
</Filter>
);

Expand Down