add countries table to interface

This commit is contained in:
Danny van Kooten 2016-11-24 14:21:02 +01:00
parent a2a54482ff
commit cbd1020bbf
2 changed files with 4 additions and 3 deletions

View File

@ -23,7 +23,7 @@ class Table extends Component {
}
fetchRecords(period) {
return fetch('/api/languages?period=' + period, {
return fetch('/api/'+this.props.endpoint+'?period=' + period, {
credentials: 'include'
}).then((r) => {
if( r.ok ) {
@ -40,7 +40,7 @@ class Table extends Component {
const tableRows = this.state.records.map( (p, i) => (
<tr>
<td>{i+1}</td>
<td>{p.Language}</td>
<td>{p.Label}</td>
<td>{p.Count}</td>
<td>{Math.round(p.Percentage)}%</td>
</tr>

View File

@ -35,7 +35,8 @@ class App extends Component {
<div class="clear"><DatePicker period={this.state.period} onChoose={(p) => { this.setState({ period: p })}} /></div>
<Graph period={this.state.period} />
<Pageviews period={this.state.period} />
<Table period={this.state.period} title="Languages" headers={["#", "Language", "Count", "%"]} />
<Table period={this.state.period} endpoint="screen-resolutions" title="Languages" headers={["#", "Language", "Count", "%"]} />
<Table period={this.state.period} endpoint="countries" title="Countries" headers={["#", "Country", "Count", "%"]} />
</div>
)
}