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!
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

64 řádky
1.8KB

  1. import { h, Component } from 'preact';
  2. import makeArvadosRequest from 'make-arvados-request';
  3. import WBTable from 'wb-table';
  4. import WBPagination from 'wb-pagination';
  5. class WBProjectListing extends Component {
  6. constructor(...args) {
  7. super(...args);
  8. this.state.rows = [];
  9. this.state.numPages = 0;
  10. this.state.activePage = 0;
  11. }
  12. componentDidMount() {
  13. this.setActivePage(0);
  14. }
  15. prepareRows(items) {
  16. return items.map(item => [
  17. item['name'],
  18. item['description'],
  19. item['owner_uuid']
  20. ]);
  21. }
  22. setActivePage(i) {
  23. this.state.activePage = i;
  24. let filters = [
  25. [ 'group_class', '=', 'project' ]
  26. ];
  27. if (this.props.ownerUuid)
  28. filters.push([ 'owner_uuid', '=', this.props.ownerUuid ]);
  29. let prom = makeArvadosRequest(this.props.arvHost, this.props.arvToken,
  30. '/arvados/v1/groups?filters=' + encodeURIComponent(JSON.stringify(filters)) +
  31. '&limit=' + encodeURIComponent(this.props.itemsPerPage) +
  32. '&offset=' + encodeURIComponent(this.props.itemsPerPage * i));
  33. prom = prom.then(xhr =>
  34. this.setState({
  35. 'numPages': Math.ceil(xhr.response['items_available'] / xhr.response['limit']),
  36. 'rows': this.prepareRows(xhr.response['items'])
  37. }));
  38. }
  39. render({ arvHost, arvToken, ownerUuid }, { rows, numPages, activePage }) {
  40. return (
  41. <div>
  42. <WBTable columns={ [ 'Name', 'Description', 'Owner' ] }
  43. rows={ rows } />
  44. <WBPagination numPages={ numPages }
  45. activePage={ activePage }
  46. onPageChanged={ i => this.setActivePage(i) } />
  47. </div>
  48. );
  49. }
  50. }
  51. WBProjectListing.defaultProps = {
  52. 'itemsPerPage': 100,
  53. 'ownerUuid': null
  54. };
  55. export default WBProjectListing;