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 13, 2021
1 parent 92a9709 commit c97f895
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
10 changes: 9 additions & 1 deletion dkron/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,21 @@ func (h *HTTPTransport) jobsHandler(c *gin.Context) {
order := c.DefaultQuery("_order", "ASC")
q := c.Query("q")

disabled := c.Query("disabled")
if disabled == "disabled" {
disabled = "true"
} else if disabled == "enabled" {
disabled = "false"
}

jobs, err := h.agent.Store.GetJobs(
&JobOptions{
Metadata: metadata,
Sort: sort,
Order: order,
Query: q,
Status: c.Query("status"),
Disabled: disabled,
},
)
if err != nil {
Expand Down Expand Up @@ -340,7 +348,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: 5 additions & 1 deletion 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 @@ -24,6 +24,10 @@ const JobFilter = (props: any) => (
{ id: 'success', name: 'Success' },
{ id: 'failed', name: 'Failed' },
]} />
<SelectInput source="disabled" choices={[
{ id: 'disabled', name: 'Diabled' },
{ id: 'enabled', name: 'Enabled' },
]} />
</Filter>
);

Expand Down

0 comments on commit c97f895

Please sign in to comment.