From 4b46f260a6e79adf2fdbcbc5fd03fdf0e9d5cb3c Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 5 Jan 2018 17:08:02 +0100 Subject: [PATCH] Added react-table for the visitor table (fix #46) --- static/src/Visitors/Visitors.js | 44 +++++++++++++++++---------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/static/src/Visitors/Visitors.js b/static/src/Visitors/Visitors.js index 3232965..59186b1 100644 --- a/static/src/Visitors/Visitors.js +++ b/static/src/Visitors/Visitors.js @@ -1,6 +1,8 @@ import React, { Component } from 'react' -import { Container, Table } from 'semantic-ui-react' +import { Container } from 'semantic-ui-react' import Moment from 'react-moment'; +import ReactTable from 'react-table' +import 'react-table/react-table.css' import util from '../util/util' export default class VisitorComponent extends Component { @@ -36,31 +38,31 @@ export default class VisitorComponent extends Component { render() { const { visitors, id, entry } = this.state + + const columns = [{ + Header: 'Timestamp', + accessor: 'Timestamp', + Cell: props => {props.value} + }, { + Header: 'IP', + accessor: "IP" + }, { + Header: 'User Agent', + accessor: "UserAgent" + }, { + Header: 'Referer', + accessor: "Referer" + }, { + Header: 'UTM (source, medium, campaign, content, term)', + Cell: props => this.getUTMSource(props.original) + }] + return ( {entry &&

Entry with id '{id}' was created at {entry.CreatedOn} and redirects to '{entry.URL}'. Currently it has {visitors.length} visits.

} - - - - Timestamp - IP - User Agent - Referer - UTM (source, medium, campaign, content, term) - - - - {visitors && visitors.map((visit, idx) => - {visit.Timestamp} - {visit.IP} - {visit.UserAgent} - {visit.Referer} - {this.getUTMSource(visit)} - )} - -
+
) }