import React from 'react'; import { Col, Row, Badge } from 'react-bootstrap'; import { Card, ReactTable, WaitIcon, Profile } from '../../../components/index'; import { server } from '../../../commons/server'; import moment from 'moment'; /** * The page controller of the public module */ export default class OnlineUsers extends React.Component { constructor(props) { super(props); this.state = { }; } componentWillMount() { this.refreshTable(); } /** * Called when the report wants to update its content * @return {[type]} [description] */ refreshTable() { const self = this; return server.post('/api/admin/rep/onlineusers') .then(res => { // generate new result const result = { count: res.length, list: res }; // set state self.setState({ values: result }); // return to the promise return result; }); } headerRender(count) { const countHTML = {count}; // create the header of the card return (

{__('admin.websessions')} {countHTML}

); } collapseRender(item) { return (
{__('User.login') + ':'}
{item.userLogin}
{__('admin.websessions.lastrequest') + ':'}
{moment(item.lastAccess).format('L LT')}
{__('admin.websessions.sessiontime') + ':'}
{moment(item.loginDate).fromNow(true)}
); } render() { if (!this.state || !this.state.values) { return ; } const colschema = [ { title: __('User'), content: item => , size: { sm: 4 } }, { title: __('UserLogin.loginDate'), content: item => moment(item.loginDate).format('L LT'), size: { sm: 4 } }, { title: __('admin.websessions.idletime'), content: item => moment(item.lastAccess).fromNow(true), size: { sm: 4 } } ]; return (
); } } OnlineUsers.propTypes = { route: React.PropTypes.object };