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 "../components/SyntaxHighlighter"; import { getRedisInfoAsync } from "../actions/redisInfoActions"; import { usePolling } from "../hooks"; import { AppState } from "../store"; import { timeAgoUnix } from "../utils"; import { RedisInfo } from "../api"; import QueueLocationTable from "../components/QueueLocationTable"; import Link from "@material-ui/core/Link"; 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, redisClusterEnabled: state.redis.cluster, redisClusterNodesRaw: state.redis.rawClusterNodes, queueLocations: state.redis.queueLocations, pollInterval: state.settings.pollInterval, themePreference: state.settings.themePreference, }; } const connector = connect(mapStateToProps, { getRedisInfoAsync }); type Props = ConnectedProps; function RedisInfoView(props: Props) { const classes = useStyles(); const { pollInterval, getRedisInfoAsync, redisInfo, redisInfoRaw, redisClusterEnabled, redisClusterNodesRaw, queueLocations, } = 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 === "" ? ( <> {redisClusterEnabled ? "Redis Cluster Info" : "Redis Info"} {!redisClusterEnabled && ( Connected to: {props.redisAddress} )} {queueLocations && queueLocations.length > 0 && ( Queue Location in Cluster )} {redisClusterNodesRaw && ( <> CLUSTER NODES {" "} Command Output {redisClusterNodesRaw} )} {redisInfo && !redisClusterEnabled && ( )} {redisInfoRaw && ( <> {redisClusterEnabled ? ( CLUSTER INFO ) : ( INFO )}{" "} Command Output {redisInfoRaw} )} ) : ( Error Could not retrieve redis live data —{" "} See the logs for details )} ); } function RedisMetricCards(props: { redisInfo: RedisInfo }) { const { redisInfo } = props; return ( <> Server Memory Connections Persistence ); } interface MetricCardProps { title: string; content: string; } function MetricCard(props: MetricCardProps) { return ( {props.content} {props.title} ); } export default connector(RedisInfoView);