Skip to content

Commit

Permalink
Provide filter query by job displayName, add pristine jobs reports (#897
Browse files Browse the repository at this point in the history
)

* Provide filter query by job displayName, add disabled pristine jobs reports

* Added Pristine Jobs to React UI

* Provide filter query by job displayName, add disabled pristine jobs reports

Co-authored-by: Miguel Sousa <miguelsousa@MacBook-Pro-de-Miguel.local>
Co-authored-by: Victor Castell <victor@victorcastell.com>
  • Loading branch information
3 people committed Mar 22, 2021
1 parent f1ba46a commit 79eaa39
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 87 deletions.
142 changes: 71 additions & 71 deletions dkron/assets_ui/assets_vfsdata.go

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dkron/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,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.Status == "" || job.Status == options.Status) &&
(options.Disabled == "" || strconv.FormatBool(job.Disabled) == options.Disabled) {
(options.Query == "" || strings.Contains(job.Name, options.Query) || strings.Contains(job.DisplayName, options.Query)) &&
(options.Disabled == "" || strconv.FormatBool(job.Disabled) == options.Disabled) &&
((options.Status == "untriggered" && job.Status == "") || (options.Status == "" || job.Status == options.Status)) {

jobs = append(jobs, job)
}
Expand Down Expand Up @@ -716,4 +716,4 @@ func trimDirectoryKey(key []byte) []byte {

func isDirectoryKey(key []byte) bool {
return len(key) > 0 && key[len(key)-1] == ':'
}
}
22 changes: 13 additions & 9 deletions dkron/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@ func (h *HTTPTransport) UI(r *gin.RouterGroup) {
if err != nil {
log.Error(err)
}
totalJobs := len(jobs)
successfulJobs := 0
failedJobs := 0
var (
totalJobs = len(jobs)
successfulJobs, failedJobs, untriggeredJobs int
)
for _, j := range jobs {
if j.Status == "success" {
successfulJobs++
} else {
} else if j.Status == "failed" {
failedJobs++
} else if j.Status == "" {
untriggeredJobs++
}
}
l, err := h.agent.leaderMember()
Expand All @@ -68,11 +71,12 @@ func (h *HTTPTransport) UI(r *gin.RouterGroup) {
ln = l.Name
}
ctx.HTML(http.StatusOK, "index.html", gin.H{
"DKRON_API_URL": fmt.Sprintf("/%s", apiPathPrefix),
"DKRON_LEADER": ln,
"DKRON_TOTAL_JOBS": totalJobs,
"DKRON_FAILED_JOBS": failedJobs,
"DKRON_SUCCESSFUL_JOBS": successfulJobs,
"DKRON_API_URL": fmt.Sprintf("/%s", apiPathPrefix),
"DKRON_LEADER": ln,
"DKRON_TOTAL_JOBS": totalJobs,
"DKRON_FAILED_JOBS": failedJobs,
"DKRON_UNTRIGGERED_JOBS": untriggeredJobs,
"DKRON_SUCCESSFUL_JOBS": successfulJobs,
})
}
})
Expand Down
1 change: 1 addition & 0 deletions ui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
window.DKRON_TOTAL_JOBS={{.DKRON_TOTAL_JOBS}};
window.DKRON_SUCCESSFUL_JOBS={{.DKRON_SUCCESSFUL_JOBS}};
window.DKRON_FAILED_JOBS={{.DKRON_FAILED_JOBS}};
window.DKRON_UNTRIGGERED_JOBS={{.DKRON_UNTRIGGERED_JOBS}};
</script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion ui/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
}
2 changes: 1 addition & 1 deletion ui/public/robots.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
Disallow:
1 change: 1 addition & 0 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ declare global {
interface Window {
DKRON_API_URL: string;
DKRON_LEADER: string;
DKRON_UNTRIGGERED_JOBS: string;
DKRON_FAILED_JOBS: string;
DKRON_SUCCESSFUL_JOBS: string;
DKRON_TOTAL_JOBS: string;
Expand Down
3 changes: 3 additions & 0 deletions ui/src/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TagsField } from '../TagsField'
import Leader from './Leader';
import FailedJobs from './FailedJobs';
import SuccessfulJobs from './SuccessfulJobs';
import UntriggeredJobs from './UntriggeredJobs';
import TotalJobs from './TotalJobs';

let fakeProps = {
Expand Down Expand Up @@ -46,6 +47,8 @@ const Dashboard = () => (
<SuccessfulJobs value={window.DKRON_SUCCESSFUL_JOBS || "0"} />
<Spacer />
<FailedJobs value={window.DKRON_FAILED_JOBS || "0"} />
<Spacer />
<UntriggeredJobs value={window.DKRON_UNTRIGGERED_JOBS || "0"} />
</div>
</div>
</div>
Expand Down
22 changes: 22 additions & 0 deletions ui/src/dashboard/UntriggeredJobs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from 'react';
import { FC } from 'react';
import Icon from '@material-ui/icons/NewReleases';

import CardWithIcon from './CardWithIcon';

interface Props {
value?: string;
}

const UntriggeredJobs: FC<Props> = ({ value }) => {
return (
<CardWithIcon
to='/jobs?filter={"status":"untriggered"}'
icon={Icon}
title='Untriggered Jobs'
subtitle={value}
/>
);
};

export default UntriggeredJobs;
1 change: 1 addition & 0 deletions ui/src/jobs/JobList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const JobFilter = (props: any) => (
<SelectInput source="status" choices={[
{ id: 'success', name: 'Success' },
{ id: 'failed', name: 'Failed' },
{ id: 'untriggered', name: 'Waiting to Run' },
]} />
<BooleanInput source="disabled"/>
</Filter>
Expand Down
13 changes: 12 additions & 1 deletion ui/src/jobs/StatusField.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import * as React from "react";
import SuccessIcon from '@material-ui/icons/CheckCircle';
import FailedIcon from '@material-ui/icons/Cancel';
import UntriggeredIcon from '@material-ui/icons/Timer';
import { Tooltip } from '@material-ui/core';

const StatusField = (props: any) => {
return props.record === undefined ? null : (props.record[props.source] === 'success' ? <Tooltip title="Success"><SuccessIcon htmlColor="green" /></Tooltip> : <Tooltip title="Success"><FailedIcon htmlColor="red" /></Tooltip>);
if (props.record === undefined) {
return null
} else {
if (props.record[props.source] === 'success') {
return <Tooltip title="Success"><SuccessIcon htmlColor="green" /></Tooltip>
} else if (props.record[props.source] === 'failed') {
return <Tooltip title="Error"><FailedIcon htmlColor="red" /></Tooltip>
} else {
return <Tooltip title="Waiting to Run"><UntriggeredIcon htmlColor="blue" /></Tooltip>
}
}
};

export default StatusField;

0 comments on commit 79eaa39

Please sign in to comment.