diff --git a/client/src/app/admin/panel/dashboard/activity-list.js b/client/src/app/admin/panel/dashboard/activity-list.js new file mode 100644 index 00000000..a1f65461 --- /dev/null +++ b/client/src/app/admin/panel/dashboard/activity-list.js @@ -0,0 +1,94 @@ +import React from 'react'; + +import API from 'lib-app/api-call'; +import i18n from 'lib-app/i18n'; + +import ActivityRow from 'app-components/activity-row'; +import SubmitButton from 'core-components/submit-button'; + +class ActivityList extends React.Component { + + static propTypes = { + mode: React.PropTypes.oneOf(['staff', 'system']) + }; + + static childContextTypes = { + loading: React.PropTypes.bool + }; + + getChildContext() { + return { + loading: this.state.loading + }; + } + + state = { + activities: [], + page: 1, + limit: false, + loading: false + }; + + componentDidMount() { + this.retrieveNextPage(); + } + + render() { + if (this.props.mode === 'staff') { + return ( +
+ {this.state.activities.map(this.renderRow.bind(this))} + {(!this.state.limit) ? this.renderButton() : null} +
+ ); + } + else { + return ( +
+ {this.state.activities.map(this.renderRow.bind(this))} + {(!this.state.limit) ? this.renderButton() : null} +
+ ); + } + } + + renderButton() { + return ( + + {i18n('LOAD_MORE')} + + ); + } + + renderRow(row) { + return ( + + ); + } + + retrieveNextPage() { + this.setState({loading: true}); + + API.call({ + path: '/staff/last-events', + data: { + page: this.state.page + } + }).then(this.onRetrieveSuccess.bind(this)).catch(this.onRetrieveFail.bind(this)) + } + + onRetrieveSuccess(result) { + this.setState({ + activities: this.state.activities.concat(result.data), + page: this.state.page + 1, + limit: (result.data.length !== 10), + loading: false + }); + } + + onRetrieveFail() { + + } +} + +export default ActivityList; \ No newline at end of file diff --git a/client/src/app/admin/panel/dashboard/activity-list.scss b/client/src/app/admin/panel/dashboard/activity-list.scss new file mode 100644 index 00000000..e69de29b diff --git a/client/src/app/admin/panel/dashboard/admin-panel-activity.js b/client/src/app/admin/panel/dashboard/admin-panel-activity.js index 1c6fae4d..0bac4788 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-activity.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-activity.js @@ -1,60 +1,23 @@ import React from 'react'; -import API from 'lib-app/api-call'; import i18n from 'lib-app/i18n'; -import ActivityRow from 'app-components/activity-row'; import Header from 'core-components/header'; -import SubmitButton from 'core-components/submit-button'; import Menu from 'core-components/menu'; +import ActivityList from 'app/admin/panel/dashboard/activity-list'; + class AdminPanelActivity extends React.Component { - static childContextTypes = { - loading: React.PropTypes.bool - }; - - getChildContext() { - return { - loading: this.state.loading - }; - } - - state = { - activities: [], - page: 1, - limit: false, - loading: false - }; - - componentDidMount() { - this.retrieveNextPage(); - } - render() { return (
- {this.state.activities.map(this.renderRow.bind(this))} - {(!this.state.limit) ? this.renderButton() : null} +
); } - - renderButton() { - return ( - - {i18n('LOAD_MORE')} - - ); - } - - renderRow(row) { - return ( - - ); - } getMenuProps() { return { @@ -72,30 +35,6 @@ class AdminPanelActivity extends React.Component { ] } } - - retrieveNextPage() { - this.setState({loading: true}); - - API.call({ - path: '/staff/last-events', - data: { - page: this.state.page - } - }).then(this.onRetrieveSuccess.bind(this)).catch(this.onRetrieveFail.bind(this)) - } - - onRetrieveSuccess(result) { - this.setState({ - activities: this.state.activities.concat(result.data), - page: this.state.page + 1, - limit: (result.data.length !== 10), - loading: false - }); - } - - onRetrieveFail() { - - } } export default AdminPanelActivity; \ No newline at end of file diff --git a/client/src/data/fixtures/staff-fixtures.js b/client/src/data/fixtures/staff-fixtures.js index 7aa87f0b..79e3c503 100644 --- a/client/src/data/fixtures/staff-fixtures.js +++ b/client/src/data/fixtures/staff-fixtures.js @@ -1060,7 +1060,7 @@ module.exports = [ }, { path: '/staff/last-events', - time: 430, + time: 30, response: function(data) { if(data.page > 5) {