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 Typography from "@material-ui/core/Typography"; import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import Alert from "@material-ui/lab/Alert"; import AlertTitle from "@material-ui/lab/AlertTitle"; import SyntaxHighlighter from "react-syntax-highlighter"; import syntaxHighlightStyle from "react-syntax-highlighter/dist/esm/styles/hljs/github"; import { getRedisInfoAsync } from "../actions/redisInfoActions"; import { usePolling } from "../hooks"; import { AppState } from "../store"; import { timeAgoUnix } from "../utils"; const useStyles = makeStyles((theme) => ({ container: { paddingTop: theme.spacing(4), paddingBottom: theme.spacing(4), }, })); function mapStateToProps(state: AppState) { return { loading: state.redis.loading, error: state.redis.error, redisInfo: state.redis.data, redisAddress: state.redis.address, redisInfoRaw: state.redis.rawData, pollInterval: state.settings.pollInterval, }; } const connector = connect(mapStateToProps, { getRedisInfoAsync }); type Props = ConnectedProps; function RedisInfoView(props: Props) { const classes = useStyles(); const { pollInterval, getRedisInfoAsync, redisInfo, redisInfoRaw } = props; usePolling(getRedisInfoAsync, pollInterval); // Metrics to show // - Used Memory // - Memory Fragmentation Ratio // - Connected Clients // - Connected Replicas (slaves) // - Persistence (rdb_last_save_time, rdb_changes_since_last_save) // - Errors (rejected_connections) return ( {props.error === "" ? ( <> Redis Info Connected to: {props.redisAddress} {redisInfo !== null && ( <> Server Memory Connections Persistence )} {redisInfoRaw !== null && ( <> INFO Command Output {redisInfoRaw} )} ) : ( Error Could not retreive redis live data —{" "} See the logs for details )} ); } interface MetricCardProps { title: string; content: string; } function MetricCard(props: MetricCardProps) { return ( {props.content} {props.title} ); } export default connector(RedisInfoView);