Skip to content

Commit

Permalink
Added Pristine Jobs to React UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Sousa authored and Miguel Sousa committed Mar 15, 2021
1 parent eb18129 commit aa96dcf
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 9 deletions.
152 changes: 144 additions & 8 deletions dkron/assets_ui/assets_vfsdata.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dkron/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ func (s *Store) SetJob(job *Job, copyDependentJobs bool) error {
}

err := s.db.Update(func(tx *buntdb.Tx) error {
// set pristine as default for newly created jobs
job.Status = "pristine"

// Get if the requested job already exist
err := s.getJobTxFunc(job.Name, &pbej)(tx)
if err != nil && err != buntdb.ErrNotFound {
Expand Down
1 change: 1 addition & 0 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ declare global {
interface Window {
DKRON_API_URL: string;
DKRON_LEADER: string;
DKRON_PRISTINE_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 PristineJobs from './PristineJobs';
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 />
<PristineJobs value={window.DKRON_PRISTINE_JOBS || "0"} />
</div>
</div>
</div>
Expand Down
22 changes: 22 additions & 0 deletions ui/src/dashboard/PristineJobs.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 PristineJobs: FC<Props> = ({ value }) => {
return (
<CardWithIcon
to='/jobs?filter={"status":"pristine"}'
icon={Icon}
title='Pristine Jobs'
subtitle={value}
/>
);
};

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

const StatusField = (props: any) => {
return (props.record[props.source] === 'success' ? <Tooltip title="Success"><SuccessIcon htmlColor="green" /></Tooltip> : <Tooltip title="Success"><FailedIcon htmlColor="red" /></Tooltip>);
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"><PristineIcon htmlColor="blue" /></Tooltip>
}
};

export default StatusField;

0 comments on commit aa96dcf

Please sign in to comment.