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

feat(ui): add a filter on disabled state #923

Merged
merged 1 commit into from
Mar 14, 2021
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
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