import React from "react"; import { withRouter } from 'react-router-dom' import Modal from './modal' import * as api from '../../api' import numberFormatter from '../../number-formatter' import Bar from '../bar' import {parseQuery} from '../../query' class OperatingSystemsModal extends React.Component { constructor(props) { super(props) this.state = {loading: true} } componentDidMount() { const query = parseQuery(this.props.location.search, this.props.site) api.get(`/api/stats/${encodeURIComponent(this.props.site.domain)}/operating-systems`, query, {limit: 100}) .then((res) => this.setState({loading: false, systems: res})) } renderSystem(system) { return (
{system.name} {system.percentage}%
) } renderBody() { if (this.state.loading) { return (
) } else if (this.state.systems) { return (

Operating Systems

by visitors
{ this.state.systems.map(this.renderSystem.bind(this)) }
) } } render() { return ( { this.renderBody() } ) } } export default withRouter(OperatingSystemsModal)