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!
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

83 строки
2.8KB

  1. import { h, Component } from 'preact';
  2. import WBTable from 'wb-table';
  3. import makeArvadosRequest from 'make-arvados-request';
  4. import arvadosTypeName from 'arvados-type-name';
  5. import arvadosObjectName from 'arvados-object-name';
  6. import urlForObject from 'url-for-object';
  7. import wbFormatDate from 'wb-format-date';
  8. import WBNameAndUuid from 'wb-name-and-uuid';
  9. import WBAccordion from 'wb-accordion';
  10. import wbFormatSpecialValue from 'wb-format-special-value';
  11. class WBCollectionFields extends Component {
  12. componentDidMount() {
  13. this.prepareRows();
  14. }
  15. componentWillReceiveProps(nextProps) {
  16. this.props = nextProps;
  17. this.prepareRows();
  18. }
  19. prepareRows() {
  20. let { uuid, app } = this.props;
  21. let { arvHost, arvToken } = app.state;
  22. const filters = [
  23. ['uuid', '=', uuid]
  24. ];
  25. let prom = makeArvadosRequest(arvHost, arvToken,
  26. '/arvados/v1/collections?filters=' + encodeURIComponent(JSON.stringify(filters)));
  27. prom = prom.then(xhr => {
  28. const item = xhr.response.items[0];
  29. if (!item)
  30. throw Error('Item not found');
  31. let rows = [
  32. [ 'Name', item.name ],
  33. [ 'Description', wbFormatSpecialValue(item.description) ],
  34. [ 'Properties', (
  35. <WBAccordion names={ ['Properties'] } cardHeaderClass="card-header-sm">
  36. <pre class="word-wrap">{ JSON.stringify(item.properties, null, 2) }</pre>
  37. </WBAccordion>
  38. ) ],
  39. [ 'Portable Data Hash', item.portable_data_hash ],
  40. [ 'Replication Desired', item.replication_desired ? item.replication_desired : (
  41. <i>{ String(item.replication_desired) }</i>
  42. ) ],
  43. [ 'Replication Confirmed', item.replication_confirmed ? item.replication_confirmed : (
  44. <i>{ String(item.replication_confirmed) }</i>
  45. ) ],
  46. [ 'Replication Confirmed At', wbFormatDate(item.replication_confirmed_at) ],
  47. [ 'Trash At', wbFormatDate(item.trash_at) ],
  48. [ 'Delete At', wbFormatDate(item.delete_at) ],
  49. [ 'Is Trashed', String(item.is_trashed) ],
  50. [ 'Current Version UUID', (
  51. <WBNameAndUuid app={ app } uuid={ item.current_version_uuid } />
  52. ) ],
  53. [ 'Version', item.version ],
  54. [ 'Preserve Version', String(item.preserve_version) ],
  55. [ 'File Count', item.file_count ],
  56. [ 'Total Size', filesize(item.file_size_total) ]
  57. ];
  58. this.setState({ 'rows': rows });
  59. });
  60. }
  61. render({}, { rows }) {
  62. return (
  63. rows ? (
  64. <WBTable columns={ [ "Name", "Value" ] }
  65. headerClasses={ [ "col-sm-2", "col-sm-4" ] }
  66. rows={ rows }
  67. verticalHeader={ true } />
  68. ) : (
  69. <div>Loading...</div>
  70. )
  71. );
  72. }
  73. }
  74. export default WBCollectionFields;