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!
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

64 wiersze
1.8KB

  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 } = this.props;
  16. const order = ['last_name asc'];
  17. let prom = makeArvadosRequest(arvHost, arvToken,
  18. '/arvados/v1/users?order=' + encodeURIComponent(JSON.stringify(order)) +
  19. '&limit=' + itemsPerPage + '&offset=' + (itemsPerPage * page));
  20. prom = prom.then(xhr => {
  21. this.setState({
  22. 'items': xhr.response['items'],
  23. 'numPages': Math.ceil(xhr.response['items_available'] / itemsPerPage)
  24. });
  25. });
  26. }
  27. render({ app, page, getPageUrl }, { items, numPages }) {
  28. return (
  29. <div class="container-fluid">
  30. <h1>Users</h1>
  31. <div class="d-flex flex-wrap">
  32. { items ? items.map(it => (
  33. <div class="card mx-2 my-2">
  34. <h5 class="card-header">
  35. <a href={ urlForObject(it) }>{ it.last_name + ', ' + it.first_name }</a>
  36. </h5>
  37. <div class="card-body">
  38. <div><a href={ 'mailto:' + it.email }>{ it.email }</a></div>
  39. <div>{ it.uuid }</div>
  40. </div>
  41. </div>
  42. )) : 'Loading...' }
  43. </div>
  44. <WBPagination activePage={ page } numPages={ numPages }
  45. getPageUrl={ getPageUrl } />
  46. </div>
  47. );
  48. }
  49. }
  50. WBUserListing.defaultProps = {
  51. 'itemsPerPage': 20,
  52. 'page': 0
  53. };
  54. export default WBUserListing;