-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt fields to admin v4
- Loading branch information
Showing
15 changed files
with
171 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 44 additions & 44 deletions
88
dkron/ui-dist/assets/index-d296cf7c.js → dkron/ui-dist/assets/index-2356520b.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import * as React from 'react'; | ||
import { Card, CardHeader, CardContent } from '@mui/material'; | ||
import { | ||
ResponsiveContainer, | ||
AreaChart, | ||
Area, | ||
XAxis, | ||
YAxis, | ||
CartesianGrid, | ||
Tooltip, | ||
} from 'recharts'; | ||
import { useTranslate } from 'react-admin'; | ||
import { format, subDays, addDays } from 'date-fns'; | ||
|
||
const lastDay = new Date(); | ||
const lastMonthDays = Array.from({ length: 30 }, (_, i) => subDays(lastDay, i)); | ||
const aMonthAgo = subDays(new Date(), 30); | ||
|
||
const dateFormatter = (date: number): string => | ||
new Date(date).toLocaleDateString(); | ||
|
||
const aggregateJobsByHour = (jobs: any): { [key: string]: number } => | ||
jobs | ||
.reduce((acc, curr) => { | ||
const day = format(new Date(curr.date), 'yyyy-MM-dd'); | ||
if (!acc[day]) { | ||
acc[day] = 0; | ||
} | ||
acc[day] += curr.total; | ||
return acc; | ||
}, {} as { [key: string]: number }); | ||
|
||
const JobChart = (props: { jobs?: any }) => { | ||
const { jobs } = props; | ||
if (!jobs) return null; | ||
|
||
return ( | ||
<Card> | ||
<CardHeader title="Job Executions" /> | ||
<CardContent> | ||
<div style={{ width: '100%', height: 300 }}> | ||
<ResponsiveContainer> | ||
<AreaChart data={aggregateJobsByHour(props)}> | ||
<defs> | ||
<linearGradient | ||
id="colorUv" | ||
x1="0" | ||
y1="0" | ||
x2="0" | ||
y2="1" | ||
> | ||
<stop | ||
offset="5%" | ||
stopColor="#8884d8" | ||
stopOpacity={0.8} | ||
/> | ||
<stop | ||
offset="95%" | ||
stopColor="#8884d8" | ||
stopOpacity={0} | ||
/> | ||
</linearGradient> | ||
</defs> | ||
<XAxis | ||
dataKey="date" | ||
name="Date" | ||
type="number" | ||
scale="time" | ||
domain={[ | ||
addDays(aMonthAgo, 1).getTime(), | ||
new Date().getTime(), | ||
]} | ||
tickFormatter={dateFormatter} | ||
/> | ||
<YAxis dataKey="total" name="Revenue" unit="€" /> | ||
<CartesianGrid strokeDasharray="3 3" /> | ||
<Tooltip | ||
cursor={{ strokeDasharray: '3 3' }} | ||
formatter={(value: any) => | ||
new Intl.NumberFormat(undefined, { | ||
style: 'currency', | ||
currency: 'USD', | ||
}).format(value) | ||
} | ||
labelFormatter={(label: any) => | ||
dateFormatter(label) | ||
} | ||
/> | ||
<Area | ||
type="monotone" | ||
dataKey="total" | ||
stroke="#8884d8" | ||
strokeWidth={2} | ||
fill="url(#colorUv)" | ||
/> | ||
</AreaChart> | ||
</ResponsiveContainer> | ||
</div> | ||
</CardContent> | ||
</Card> | ||
); | ||
}; | ||
|
||
interface TotalByDay { | ||
date: number; | ||
total: number; | ||
} | ||
|
||
export default JobChart; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import * as React from 'react'; | ||
import { useState } from 'react'; | ||
import { | ||
useNotify, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import * as React from "react"; | ||
import { | ||
Edit, | ||
SelectInput, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import * as React from "react"; | ||
import { | ||
Datagrid, | ||
TextField, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import * as React from "react"; | ||
import { | ||
Datagrid, | ||
TextField, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters