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.

72 lignes
2.1KB

  1. import { h, Component } from 'preact';
  2. import WBTable from 'wb-table';
  3. import WBPagination from 'wb-pagination';
  4. import makeArvadosRequest from 'make-arvados-request';
  5. class WBBrowseDialogCollectionList extends Component {
  6. constructor(...args) {
  7. super(...args);
  8. this.state.rows = [];
  9. }
  10. componentDidMount() {
  11. this.fetchRows();
  12. }
  13. componentWillReceiveProps(nextProps) {
  14. this.props = nextProps;
  15. this.fetchRows();
  16. }
  17. prepareRows(items) {
  18. const { navigate, selectWhat, makeSelectionCell } = this.props;
  19. return items.map(it => [
  20. ([].concat(selectWhat).indexOf('directory') !== -1 ? makeSelectionCell(it.uuid + '/') : null),
  21. (
  22. <a href="#" onclick={ e => { e.preventDefault();
  23. navigate('/browse-dialog/content/' + it.uuid + '////'); } }>{ it.name }</a>
  24. ),
  25. it.uuid
  26. ]);
  27. }
  28. fetchRows() {
  29. const { arvHost, arvToken } = this.props.app.state;
  30. const { ownerUuid, textSearch, page, itemsPerPage } = this.props;
  31. const filters = [];
  32. if (ownerUuid)
  33. filters.push(['owner_uuid', '=', ownerUuid]);
  34. if (textSearch)
  35. filters.push(['name', 'ilike', '%' + textSearch + '%']);
  36. let prom = makeArvadosRequest(arvHost, arvToken,
  37. '/arvados/v1/collections?filters=' +
  38. encodeURIComponent(JSON.stringify(filters)) +
  39. '&limit=' + itemsPerPage +
  40. '&offset=' + (itemsPerPage * page));
  41. prom = prom.then(xhr => this.setState({
  42. 'rows': this.prepareRows(xhr.response.items),
  43. 'numPages': Math.ceil(xhr.response.items_available / itemsPerPage)
  44. }));
  45. return prom;
  46. }
  47. render({ selectWhat, page, navigate }, { rows, numPages }) {
  48. return (
  49. <div>
  50. <WBTable columns={ ['', 'Name', 'UUID'] }
  51. headerClasses={ ['w-1'] }
  52. rows={ rows } />
  53. <WBPagination activePage={ page } numPages={ numPages }
  54. onPageChanged={ i => navigate({ 'bottomPage': i }) } />
  55. </div>
  56. );
  57. }
  58. }
  59. WBBrowseDialogCollectionList.defaultProps = {
  60. 'itemsPerPage': 20
  61. };
  62. export default WBBrowseDialogCollectionList;