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 символів.

90 рядки
3.0KB

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