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!
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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