mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
adding inforamtion about when the processor ran the last time
This commit is contained in:
1
index.js
1
index.js
@@ -24,6 +24,7 @@ console.log(`Started Fredy successfully. Ui can be accessed via http://localhost
|
|||||||
/* eslint-enable no-console */
|
/* eslint-enable no-console */
|
||||||
setInterval(
|
setInterval(
|
||||||
(function exec() {
|
(function exec() {
|
||||||
|
config.lastRun = Date.now();
|
||||||
jobStorage
|
jobStorage
|
||||||
.getJobs()
|
.getJobs()
|
||||||
.filter((job) => job.enabled)
|
.filter((job) => job.enabled)
|
||||||
|
|||||||
@@ -29,6 +29,15 @@ jobRouter.get('/', async (req, res) => {
|
|||||||
res.send();
|
res.send();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jobRouter.get('/processingTimes', async (req, res) => {
|
||||||
|
res.body = {
|
||||||
|
interval: config.interval,
|
||||||
|
lastRun: config.lastRun || null,
|
||||||
|
};
|
||||||
|
|
||||||
|
res.send();
|
||||||
|
});
|
||||||
|
|
||||||
jobRouter.post('/', async (req, res) => {
|
jobRouter.post('/', async (req, res) => {
|
||||||
const { provider, notificationAdapter, name, blacklist = [], jobId, enabled } = req.body;
|
const { provider, notificationAdapter, name, blacklist = [], jobId, enabled } = req.body;
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export default function FredyApp() {
|
|||||||
useEffect(async () => {
|
useEffect(async () => {
|
||||||
await dispatch.provider.getProvider();
|
await dispatch.provider.getProvider();
|
||||||
await dispatch.jobs.getJobs();
|
await dispatch.jobs.getJobs();
|
||||||
|
await dispatch.jobs.getProcessingTimes();
|
||||||
await dispatch.notificationAdapter.getAdapter();
|
await dispatch.notificationAdapter.getAdapter();
|
||||||
await dispatch.user.getCurrentUser();
|
await dispatch.user.getCurrentUser();
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export const jobs = {
|
|||||||
state: {
|
state: {
|
||||||
jobs: [],
|
jobs: [],
|
||||||
insights: {},
|
insights: {},
|
||||||
|
processingTimes: {},
|
||||||
},
|
},
|
||||||
reducers: {
|
reducers: {
|
||||||
setJobs: (state, payload) => {
|
setJobs: (state, payload) => {
|
||||||
@@ -12,6 +13,12 @@ export const jobs = {
|
|||||||
jobs: Object.freeze(payload),
|
jobs: Object.freeze(payload),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
setProcessingTimes: (state, payload) => {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
processingTimes: Object.freeze(payload),
|
||||||
|
};
|
||||||
|
},
|
||||||
setJobInsights: (state, payload, jobId) => {
|
setJobInsights: (state, payload, jobId) => {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
@@ -31,6 +38,14 @@ export const jobs = {
|
|||||||
console.error(`Error while trying to get resource for api/jobs. Error:`, Exception);
|
console.error(`Error while trying to get resource for api/jobs. Error:`, Exception);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async getProcessingTimes() {
|
||||||
|
try {
|
||||||
|
const response = await xhrGet('/api/jobs/processingTimes');
|
||||||
|
this.setProcessingTimes(response.json);
|
||||||
|
} catch (Exception) {
|
||||||
|
console.error(`Error while trying to get resource for api/processingTimes. Error:`, Exception);
|
||||||
|
}
|
||||||
|
},
|
||||||
async getInsightDataForJob(jobId) {
|
async getInsightDataForJob(jobId) {
|
||||||
try {
|
try {
|
||||||
const response = await xhrGet(`/api/jobs/insights/${jobId}`);
|
const response = await xhrGet(`/api/jobs/insights/${jobId}`);
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ import { useSelector, useDispatch } from 'react-redux';
|
|||||||
import { xhrDelete, xhrPut } from '../../services/xhr';
|
import { xhrDelete, xhrPut } from '../../services/xhr';
|
||||||
import { Button, Icon } from 'semantic-ui-react';
|
import { Button, Icon } from 'semantic-ui-react';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
import ProcessingTimes from './ProcessingTimes';
|
||||||
|
|
||||||
import './Jobs.less';
|
import './Jobs.less';
|
||||||
|
|
||||||
export default function Jobs() {
|
export default function Jobs() {
|
||||||
const jobs = useSelector((state) => state.jobs.jobs);
|
const jobs = useSelector((state) => state.jobs.jobs);
|
||||||
|
const processingTimes = useSelector((state) => state.jobs.processingTimes);
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const ctx = React.useContext(ToastContext);
|
const ctx = React.useContext(ToastContext);
|
||||||
@@ -61,10 +63,13 @@ export default function Jobs() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Button primary className="jobs__newButton" onClick={() => history.push('/jobs/new')}>
|
<div>
|
||||||
<Icon name="plus" />
|
{processingTimes != null && <ProcessingTimes processingTimes={processingTimes} />}
|
||||||
New Job
|
<Button primary className="jobs__newButton" onClick={() => history.push('/jobs/new')}>
|
||||||
</Button>
|
<Icon name="plus" />
|
||||||
|
New Job
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<JobTable
|
<JobTable
|
||||||
jobs={jobs || []}
|
jobs={jobs || []}
|
||||||
|
|||||||
26
ui/src/views/jobs/ProcessingTimes.js
Normal file
26
ui/src/views/jobs/ProcessingTimes.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { format } from '../../services/time/timeService';
|
||||||
|
import { Label } from 'semantic-ui-react';
|
||||||
|
|
||||||
|
export default function ProcessingTimes({ processingTimes }) {
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<Label as="span" color="black">
|
||||||
|
Processing Interval:
|
||||||
|
<Label.Detail>{processingTimes.interval} min</Label.Detail>
|
||||||
|
</Label>
|
||||||
|
{processingTimes.lastRun && (
|
||||||
|
<React.Fragment>
|
||||||
|
<Label as="span" color="black">
|
||||||
|
Last run:
|
||||||
|
<Label.Detail>{format(processingTimes.lastRun)}</Label.Detail>
|
||||||
|
</Label>
|
||||||
|
<Label as="span" color="black">
|
||||||
|
Next run:
|
||||||
|
<Label.Detail>{format(processingTimes.lastRun + processingTimes.interval * 60000)}</Label.Detail>
|
||||||
|
</Label>
|
||||||
|
</React.Fragment>
|
||||||
|
)}
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user