|
|
@@ -2,17 +2,57 @@ import React, { Fragment } from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
|
import { withTranslation } from 'react-i18next';
|
|
|
|
|
|
+import PaginationWrapper from '../../PaginationWrapper';
|
|
|
import InviteUserControl from './InviteUserControl';
|
|
|
import UserTable from './UserTable';
|
|
|
|
|
|
-import AppContainer from '../../../services/AppContainer';
|
|
|
import { createSubscribedElement } from '../../UnstatedUtils';
|
|
|
+import AppContainer from '../../../services/AppContainer';
|
|
|
+import { toastSuccess, toastError } from '../../../util/apiNotification';
|
|
|
|
|
|
class UserPage extends React.Component {
|
|
|
|
|
|
constructor(props) {
|
|
|
super();
|
|
|
|
|
|
+ this.state = {
|
|
|
+ users: [],
|
|
|
+ activePage: 1,
|
|
|
+ totalUsers: 0,
|
|
|
+ pagingLimit: Infinity,
|
|
|
+ };
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ async syncUsersAndRelations() {
|
|
|
+ let users = [];
|
|
|
+ let userRelations = {};
|
|
|
+ let totalUsers = 0;
|
|
|
+ let pagingLimit = Infinity;
|
|
|
+
|
|
|
+ try {
|
|
|
+ const params = { page: this.state.activePage };
|
|
|
+ const responses = await Promise.all([
|
|
|
+ this.props.appContainer.apiv3.get('/user-groups', params),
|
|
|
+ this.props.appContainer.apiv3.get('/user-group-relations', params),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ const [usersRes, userRelationsRes] = responses;
|
|
|
+ users = usersRes.data.users;
|
|
|
+ totalUsers = usersRes.data.totalUsers;
|
|
|
+ pagingLimit = usersRes.data.pagingLimit;
|
|
|
+ userRelations = userRelationsRes.data.userRelations;
|
|
|
+
|
|
|
+ this.setState({
|
|
|
+ users,
|
|
|
+ userRelations,
|
|
|
+ totalUsers,
|
|
|
+ pagingLimit,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ toastError(err);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
@@ -27,7 +67,18 @@ class UserPage extends React.Component {
|
|
|
{ t('user_management.external_account') }
|
|
|
</a>
|
|
|
</p>
|
|
|
- <UserTable />
|
|
|
+ <UserTable
|
|
|
+ users={this.state.users}
|
|
|
+ onDelete={this.showDeleteModal}
|
|
|
+ userRelations={this.state.userRelations}
|
|
|
+ />
|
|
|
+ <PaginationWrapper
|
|
|
+ activePage={this.state.activePage}
|
|
|
+ changePage={this.handlePage}
|
|
|
+ totalItemsCount={this.state.totalUsers}
|
|
|
+ pagingLimit={this.state.pagingLimit}
|
|
|
+ >
|
|
|
+ </PaginationWrapper>
|
|
|
</Fragment>
|
|
|
);
|
|
|
}
|