IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.0KB

  1. import { h, Component } from 'preact';
  2. import WBPagination from 'wb-pagination';
  3. import makeArvadosRequest from 'make-arvados-request';
  4. import urlForObject from 'url-for-object';
  5. class WBUserListing extends Component {
  6. componentDidMount() {
  7. this.preparePage();
  8. }
  9. componentWillReceiveProps(nextProps) {
  10. this.props = nextProps;
  11. this.preparePage();
  12. }
  13. preparePage() {
  14. const { arvHost, arvToken } = this.props.app.state;
  15. const { itemsPerPage, page, textSearch } = this.props;
  16. const order = ['last_name asc'];
  17. const filters = [];
  18. if (textSearch)
  19. filters.push([ 'any', 'ilike', '%' + textSearch + '%' ]);
  20. let prom = makeArvadosRequest(arvHost, arvToken,
  21. '/arvados/v1/users?order=' + encodeURIComponent(JSON.stringify(order)) +
  22. '&filters=' + encodeURIComponent(JSON.stringify(filters)) +
  23. '&limit=' + itemsPerPage + '&offset=' + (itemsPerPage * page));
  24. prom = prom.then(xhr => {
  25. this.setState({
  26. 'items': xhr.response['items'],
  27. 'numPages': Math.ceil(xhr.response['items_available'] / itemsPerPage)
  28. });
  29. });
  30. }
  31. render({ app, page, getPageUrl }, { items, numPages }) {
  32. return (
  33. <div class="container-fluid">
  34. <h1>Users</h1>
  35. <div class="d-flex flex-wrap">
  36. { items ? items.map(it => (
  37. <div class="card mx-2 my-2">
  38. <h5 class="card-header">
  39. <a href={ urlForObject(it) }>{ it.last_name + ', ' + it.first_name }</a>
  40. </h5>
  41. <div class="card-body">
  42. <div><a href={ 'mailto:' + it.email }>{ it.email }</a></div>
  43. <div>{ it.uuid }</div>
  44. </div>
  45. </div>
  46. )) : 'Loading...' }
  47. </div>
  48. <WBPagination activePage={ page } numPages={ numPages }
  49. getPageUrl={ getPageUrl } />
  50. </div>
  51. );
  52. }
  53. }
  54. WBUserListing.defaultProps = {
  55. 'itemsPerPage': 20,
  56. 'page': 0
  57. };
  58. export default WBUserListing;