asynqmon/ui/src/views/RedisInfoView.tsx

53 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-01-03 23:32:14 +08:00
import React from "react";
2021-01-04 00:07:19 +08:00
import { connect, ConnectedProps } from "react-redux";
2021-01-03 23:32:14 +08:00
import Container from "@material-ui/core/Container";
import { makeStyles } from "@material-ui/core/styles";
import Grid from "@material-ui/core/Grid";
import Typography from "@material-ui/core/Typography";
2021-01-04 00:07:19 +08:00
import { getRedisInfoAsync } from "../actions/redisInfoActions";
import { usePolling } from "../hooks";
import { AppState } from "../store";
2021-01-03 23:32:14 +08:00
const useStyles = makeStyles((theme) => ({
container: {
paddingTop: theme.spacing(4),
paddingBottom: theme.spacing(4),
},
paper: {
padding: theme.spacing(2),
display: "flex",
overflow: "auto",
flexDirection: "column",
},
}));
2021-01-04 00:07:19 +08:00
function mapStateToProps(state: AppState) {
return {
loading: state.redis.loading,
redisInfo: state.redis.data,
pollInterval: state.settings.pollInterval,
};
}
const connector = connect(mapStateToProps, { getRedisInfoAsync });
type Props = ConnectedProps<typeof connector>;
function RedisInfoView(props: Props) {
2021-01-03 23:32:14 +08:00
const classes = useStyles();
2021-01-04 00:07:19 +08:00
const { pollInterval, getRedisInfoAsync } = props;
usePolling(getRedisInfoAsync, pollInterval);
2021-01-03 23:32:14 +08:00
return (
<Container maxWidth="lg" className={classes.container}>
<Grid container spacing={3}>
<Grid item xs={12}>
<Typography variant="h5">Redis Info</Typography>
</Grid>
</Grid>
</Container>
);
}
2021-01-04 00:07:19 +08:00
export default connector(RedisInfoView);