Skip to content

Commit

Permalink
feat(ui): add a filter on disabled state
Browse files Browse the repository at this point in the history
  • Loading branch information
educlos committed Mar 14, 2021
1 parent 92a9709 commit f807574
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion dkron/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func (h *HTTPTransport) jobsHandler(c *gin.Context) {
Order: order,
Query: q,
Status: c.Query("status"),
Disabled: c.Query("disabled"),
},
)
if err != nil {
Expand Down Expand Up @@ -340,7 +341,7 @@ func (h *HTTPTransport) executionsHandler(c *gin.Context) {
return
}

executions, err := h.agent.Store.GetExecutions(job.Name,
executions, err := h.agent.Store.GetExecutions(job.Name,
&ExecutionOptions{
Sort: sort,
Order: order,
Expand Down
5 changes: 4 additions & 1 deletion dkron/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"io"
"sort"
"strconv"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -45,6 +46,7 @@ type JobOptions struct {
Order string
Query string
Status string
Disabled string
}

// ExecutionOptions additional options like "Sort" will be ready for JSON marshall
Expand Down Expand Up @@ -328,7 +330,8 @@ 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.Status == "" || job.Status == options.Status) {
(options.Status == "" || job.Status == options.Status) &&
(options.Disabled == "" || strconv.FormatBool(job.Disabled) == options.Disabled) {

jobs = append(jobs, job)
}
Expand Down
6 changes: 4 additions & 2 deletions ui/src/jobs/JobList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import {
import {
Datagrid,
TextField,
NumberField,
Expand All @@ -10,7 +10,8 @@ import {
TextInput,
List,
SelectInput,
BulkDeleteButton
BulkDeleteButton,
BooleanInput
} from 'react-admin';
import { Fragment } from 'react';
import BulkRunButton from "./BulkRunButton"
Expand All @@ -24,6 +25,7 @@ const JobFilter = (props: any) => (
{ id: 'success', name: 'Success' },
{ id: 'failed', name: 'Failed' },
]} />
<BooleanInput source="disabled"/>
</Filter>
);

Expand Down

0 comments on commit f807574

Please sign in to comment.