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!
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

85 líneas
2.3KB

  1. import { h, Component } from 'preact';
  2. import WBTable from 'wb-table';
  3. import WBBreadcrumbs from 'wb-breadcrumbs';
  4. import { WBManifestReader } from 'wb-collection-manifest';
  5. import makeArvadosRequest from 'make-arvados-request';
  6. class WBCollectionContent extends Component {
  7. constructor(...args) {
  8. super(...args);
  9. this.state.rows = [];
  10. this.state.manifestReader = null;
  11. }
  12. getUrl(params) {
  13. let res = '/collection-browse/' +
  14. (params.uuid || this.props.uuid) + '/' +
  15. encodeURIComponent(params.collectionPath || this.props.collectionPath) + '/' +
  16. (params.page || this.props.page);
  17. return res;
  18. }
  19. componentDidMount() {
  20. let { arvHost, arvToken } = this.props.app.state;
  21. let { uuid } = this.props;
  22. let select = [ 'manifest_text' ];
  23. let prom = makeArvadosRequest(arvHost, arvToken,
  24. '/arvados/v1/collections/' + uuid +
  25. '?select=' + encodeURIComponent(JSON.stringify(select)));
  26. prom = prom.then(xhr => {
  27. this.state.manifestReader = new WBManifestReader(xhr.response.manifest_text);
  28. this.prepareRows();
  29. });
  30. }
  31. componentWillReceiveProps(nextProps) {
  32. this.props = nextProps;
  33. this.prepareRows();
  34. }
  35. prepareRows() {
  36. let { manifestReader } = this.state;
  37. let { collectionPath } = this.props;
  38. //path = path.split('/');
  39. //path = [ '.' ].concat(path);
  40. let listing = manifestReader.listDirectory('.' + collectionPath);
  41. this.setState({
  42. 'rows': listing.map(item => (
  43. (item[0] === 'd') ? [
  44. (<a href={ this.getUrl({ 'collectionPath': collectionPath + '/' + item[1] }) }>{ item[1] }/</a>),
  45. 'Directory',
  46. null,
  47. (<div></div>)
  48. ] : [
  49. (<a href={ this.getUrl({ 'collectionPath': collectionPath + '/' + item[1] }) }>{ item[1] }</a>),
  50. 'File',
  51. filesize(item[2]),
  52. (<div></div>)
  53. ]
  54. ))
  55. });
  56. }
  57. render({ collectionPath }, { rows }) {
  58. return (
  59. <div>
  60. <WBBreadcrumbs items={ ('.' + collectionPath).split('/') } />
  61. <WBTable columns={ [ 'Name', 'Type', 'Size', 'Actions' ] }
  62. rows={ rows } />
  63. </div>
  64. );
  65. }
  66. }
  67. WBCollectionContent.defaultProps = {
  68. 'collectionPath': '',
  69. 'page': 0
  70. };
  71. export default WBCollectionContent;