import React from 'react';
import superagent from 'superagent';
import msgpack from 'msgpack-lite';
import {Button, Header, Label, Table, Image, Form} from 'semantic-ui-react';

import NetworkWrapper from './NetworkWrapper.jsx';

class RedisInfo extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            info: null,
            loading: false
        };
    }

    async componentDidMount() {
        this.setState({ loading: true });
        try {
            const res = await superagent.get(`/cloud/admin/network/redis-info`).accept('json');
            console.log(res.body);
            this.setState({ loading: false, info: res.body.info});
        } catch (e) {
            console.error(e);
        }
    }

    render() {
        return (
            <NetworkWrapper title="Redis Cluster Info" loading={this.state.loading}>
                <pre>
                    {this.state.info || ""}
                </pre>
            </NetworkWrapper>
        );
    }
}

export default RedisInfo;
