Fetch scheduler entries data periodically

This commit is contained in:
Ken Hibino
2020-12-03 07:09:02 -08:00
parent 3e5b145883
commit c6471e8c04
5 changed files with 78 additions and 99 deletions

View File

@@ -1,10 +1,14 @@
import React from "react";
import { connect, ConnectedProps } from "react-redux";
import Container from "@material-ui/core/Container";
import { makeStyles } from "@material-ui/core/styles";
import Grid from "@material-ui/core/Grid";
import Paper from "@material-ui/core/Paper";
import CronEntriesTable from "../components/CronEntriesTable";
import SchedulerEntriesTable from "../components/SchedulerEntriesTable";
import Typography from "@material-ui/core/Typography";
import { AppState } from "../store";
import { listSchedulerEntriesAsync } from "../actions/schedulerEntriesActions";
import { usePolling } from "../hooks";
const useStyles = makeStyles((theme) => ({
container: {
@@ -19,20 +23,37 @@ const useStyles = makeStyles((theme) => ({
},
heading: {
paddingLeft: theme.spacing(2),
marginBottom: theme.spacing(1),
},
}));
function CronView() {
function mapStateToProps(state: AppState) {
return {
loading: state.schedulerEntries.loading,
entries: state.schedulerEntries.data,
pollInterval: state.settings.pollInterval,
};
}
const connector = connect(mapStateToProps, { listSchedulerEntriesAsync });
type Props = ConnectedProps<typeof connector>;
function SchedulersView(props: Props) {
const { pollInterval, listSchedulerEntriesAsync } = props;
const classes = useStyles();
usePolling(listSchedulerEntriesAsync, pollInterval);
return (
<Container maxWidth="lg" className={classes.container}>
<Grid container spacing={3}>
<Grid item xs={12}>
<Paper className={classes.paper} variant="outlined">
<Typography variant="h6" className={classes.heading}>
Cron Entries
Scheduler Entries
</Typography>
<CronEntriesTable />
<SchedulerEntriesTable entries={props.entries} />
</Paper>
</Grid>
</Grid>
@@ -40,4 +61,4 @@ function CronView() {
);
}
export default CronView;
export default connector(SchedulersView);