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!
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

76 lignes
2.2KB

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