Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit a127a76
Merge: ffaf975 347cf72
Author: Miguel Sousa <miguelsousa@MacBook-Pro-de-Miguel.local>
Date:   Mon Mar 15 15:39:45 2021 +0000

    Merge branch 'master' of https://github.com/MGSousa/dkron

commit ffaf975
Author: Miguel Sousa <miguelsousa@MacBook-Pro-de-Miguel.local>
Date:   Mon Mar 15 13:07:06 2021 +0000

    Remove custom status for untriggered/pristine jobs && Minor changes

commit 8c9440b
Author: Miguel Sousa <miguelsousa@MacBook-Pro-de-Miguel.local>
Date:   Mon Mar 15 11:44:07 2021 +0000

    Added public directory

commit aa96dcf
Author: Miguel Sousa <miguelsousa@MacBook-Pro-de-Miguel.local>
Date:   Wed Mar 10 12:52:52 2021 +0000

    Added Pristine Jobs to React UI

commit eb18129
Author: Miguel Sousa <miguelsousa@MacBook-Pro-de-Miguel.local>
Date:   Mon Jan 25 11:53:02 2021 +0000

    FIX change header name DKRON_PRISTINE_JOBS

commit d1c3184
Author: Miguel Sousa <miguelsousa@MacBook-Pro-de-Miguel.local>
Date:   Mon Jan 25 10:22:15 2021 +0000

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

commit 347cf72
Author: Miguel Sousa <miguelsousa@MacBook-Pro-de-Miguel.local>
Date:   Mon Mar 15 13:07:06 2021 +0000

    Remove custom status for untriggered/pristine jobs && Minor changes

commit 92fd8f5
Author: Miguel Sousa <miguelsousa@MacBook-Pro-de-Miguel.local>
Date:   Mon Mar 15 11:44:07 2021 +0000

    Added public directory

commit b6b593a
Author: Yuri van Oers <yvanoers@gmail.com>
Date:   Sun Mar 14 23:40:46 2021 +0100

    Fix XSS vulnerability (distribworks#922)

    * Tidy modules

    * Fix "can't import package" error

    * Fix XSS vulnerability

commit 2b2a2b2
Author: Etienne Duclos <duclosetienne@gmail.com>
Date:   Sun Mar 14 13:41:24 2021 -0400

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

commit 31c6324
Author: Miguel Sousa <miguelsousa@MacBook-Pro-de-Miguel.local>
Date:   Wed Mar 10 12:52:52 2021 +0000

    Added Pristine Jobs to React UI

commit 92a9709
Author: Victor Castell <victor@victorcastell.com>
Date:   Tue Mar 9 09:37:53 2021 +0100

    Update go.sum

commit 296a9fa
Author: Victor Castell <victor@victorcastell.com>
Date:   Mon Mar 8 22:44:39 2021 +0100

    Update changelog

commit 1a982e0
Author: Victor Castell <victor@victorcastell.com>
Date:   Mon Mar 8 22:30:55 2021 +0100

    Add the ui/public dir (distribworks#919)

    It was missing because of wrong gitignore

commit 20ab436
Author: Miguel Sousa <miguelsousa@MacBook-Pro-de-Miguel.local>
Date:   Mon Jan 25 11:53:02 2021 +0000

    FIX change header name DKRON_PRISTINE_JOBS

commit 5be4196
Author: Miguel Sousa <miguelsousa@MacBook-Pro-de-Miguel.local>
Date:   Mon Jan 25 10:22:15 2021 +0000

    Provide filter query by job displayName, add disabled pristine jobs reports
  • Loading branch information
Miguel Sousa authored and Miguel Sousa committed Mar 15, 2021
1 parent bd897fc commit 52c44af
Show file tree
Hide file tree
Showing 21 changed files with 235 additions and 271 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
site/
public
/public
/website/public
docs/scss/Gemfile.lock
docs/scss/.sass-cache
downloads/
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [3.1.5] - 2021-03-08

### Features

- Configurable job timeout [#906](https://github.com/distribworks/dkron/pull/906)
- Add kafka and nats executor [#854](https://github.com/distribworks/dkron/pull/854)
- Add reporting usage stats [#910](https://github.com/distribworks/dkron/pull/910)

### Changes

- Bump some deps

### Fixes

- Add the ui/public dir [#919](https://github.com/distribworks/dkron/pull/919)

## [3.1.4] - 2021-01-25

### Changes
Expand Down
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
138 changes: 69 additions & 69 deletions dkron/assets_ui/assets_vfsdata.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dkron/assets_ui/generate.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package assets_ui

//go:generate vfsgendev -source="github.com/distribworks/dkron/dkron/assets_ui".Assets
//go:generate vfsgendev -source="github.com/distribworks/dkron/v3/dkron/assets_ui".Assets
9 changes: 6 additions & 3 deletions 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 @@ -327,8 +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.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 @@ -713,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 @@ -40,14 +40,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 {
untriggeredJobs++
}
}
l, err := h.agent.leaderMember()
Expand All @@ -58,11 +61,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_PRISTINE_JOBS": untriggeredJobs,
"DKRON_SUCCESSFUL_JOBS": successfulJobs,
})
}
})
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ require (
github.com/gin-contrib/expvar v0.0.1
github.com/gin-contrib/multitemplate v0.0.0-20200226145339-3e397ee01bc6
github.com/gin-gonic/gin v1.6.3
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/protobuf v1.4.3
github.com/hashicorp/go-discover v0.0.0-20201029210230-738cb3105cd0
github.com/hashicorp/go-hclog v0.15.0
Expand Down
188 changes: 7 additions & 181 deletions go.sum

Large diffs are not rendered by default.

Binary file added ui/public/dkron-logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ui/public/favicon.ico
Binary file not shown.
51 changes: 51 additions & 0 deletions ui/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/dkron-logo.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Dkron</title>
<script>
window.DKRON_API_URL={{.DKRON_API_URL}};
window.DKRON_LEADER={{.DKRON_LEADER}};
window.DKRON_TOTAL_JOBS={{.DKRON_TOTAL_JOBS}};
window.DKRON_SUCCESSFUL_JOBS={{.DKRON_SUCCESSFUL_JOBS}};
window.DKRON_FAILED_JOBS={{.DKRON_FAILED_JOBS}};
window.DKRON_PRISTINE_JOBS={{.DKRON_PRISTINE_JOBS}};
</script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added ui/public/logo512.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions ui/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions ui/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
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":"untriggered"}'
icon={Icon}
title='Untriggered Jobs'
subtitle={value}
/>
);
};

export default PristineJobs;
3 changes: 1 addition & 2 deletions ui/src/executions/BusyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import * as React from "react";
import { List, Datagrid, TextField, DateField } from 'react-admin';

export const OutputPanel = ({ id, record, resource }: any) => {
let o = record.output || "Empty output";
return (<div className="execution-output" dangerouslySetInnerHTML={{ __html: o }} />);
return (<div className="execution-output">{record.output || "Empty output"}</div>);
};

export const BusyList = (props: any) => (
Expand Down
7 changes: 5 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 @@ -23,7 +24,9 @@ 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
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 52c44af

Please sign in to comment.