mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-08-24 14:48:42 +08:00
Fetch servers info and show in ServersTable
This commit is contained in:
@@ -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 Typography from "@material-ui/core/Typography";
|
||||
import ServersTable from "../components/ServersTable";
|
||||
import { listServersAsync } from "../actions/serversActions";
|
||||
import { AppState } from "../store";
|
||||
import { usePolling } from "../hooks";
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
container: {
|
||||
@@ -23,8 +27,24 @@ const useStyles = makeStyles((theme) => ({
|
||||
},
|
||||
}));
|
||||
|
||||
export default function ServersView() {
|
||||
function mapStateToProps(state: AppState) {
|
||||
return {
|
||||
loading: state.servers.loading,
|
||||
servers: state.servers.data,
|
||||
pollInterval: state.settings.pollInterval,
|
||||
};
|
||||
}
|
||||
|
||||
const connector = connect(mapStateToProps, { listServersAsync });
|
||||
|
||||
type Props = ConnectedProps<typeof connector>;
|
||||
|
||||
function ServersView(props: Props) {
|
||||
const { pollInterval, listServersAsync } = props;
|
||||
const classes = useStyles();
|
||||
|
||||
usePolling(listServersAsync, pollInterval);
|
||||
|
||||
return (
|
||||
<Container maxWidth="lg" className={classes.container}>
|
||||
<Grid container spacing={3}>
|
||||
@@ -33,10 +53,12 @@ export default function ServersView() {
|
||||
<Typography variant="h6" className={classes.heading}>
|
||||
Servers
|
||||
</Typography>
|
||||
<ServersTable servers={[]} />
|
||||
<ServersTable servers={props.servers} />
|
||||
</Paper>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
export default connector(ServersView);
|
||||
|
Reference in New Issue
Block a user