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!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
3.1KB

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