{"size": 1451, "ext": "js", "max_stars_repo_path": "admin/src/pages/dashboard/index.js", "max_stars_repo_name": "zenghongtu/TuBlog", "max_stars_repo_stars_event_min_datetime": "2019-05-14T09:35:42.000Z", "max_stars_repo_stars_event_max_datetime": "2019-06-07T00:25:55.000Z", "max_issues_repo_path": "admin/src/pages/dashboard/index.js", "max_issues_repo_name": "zenghongtu/tu-blog", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "admin/src/pages/dashboard/index.js", "max_forks_repo_name": "zenghongtu/tu-blog", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.0317460317, "max_line_length": 90, "alphanum_fraction": 0.5416953825}
/**
 * Created by zenghongtu on 08/09/2018
 * Desc: index
 */

import React, {Component} from "react";
import PropTypes from 'prop-types';
import {withStyles} from '@material-ui/core/styles';
import Paper from '@material-ui/core/Paper';
import Typography from "@material-ui/core/Typography/Typography";
import {getSiteInfo} from "../../http/index";
import SiteInfoLineChart from "./chart";

const styles = theme => ({
    root: {
        width: '100%',
        marginTop: theme.spacing.unit * 3,
    }
});

class Dashboard extends Component {
    state = {
        siteInfo: [],
    };

    async fetchSiteInfo() {
        try {
            const siteInfo = await getSiteInfo();
            this.setState((state) => ({
                    siteInfo: siteInfo
                }
            ))
        } catch (e) {

        }
    }

    componentDidMount() {
        this.fetchSiteInfo()
    }

    render() {
        const {classes} = this.props;
        const {siteInfo} = this.state;
        return (
            <div>
                <Typography variant="title" gutterBottom={true} className={classes.title}>
                    网站分析
                </Typography>
                <Paper className={classes.root}>
                    <SiteInfoLineChart data={siteInfo}/>
                </Paper>
            </div>
        )
    }
}

Dashboard.propTypes = {
    classes: PropTypes.object.isRequired,
};

export default withStyles(styles)(Dashboard);
