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!
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

100 linhas
3.2KB

  1. //
  2. // Copyright (C) Stanislaw Adaszewski, 2020
  3. // Contact: s.adaszewski@gmail.com
  4. // Website: https://adared.ch/wba
  5. // License: GNU Affero General Public License, Version 3
  6. //
  7. import { h, Component } from 'preact';
  8. import WBTable from 'wb-table';
  9. import makeArvadosRequest from 'make-arvados-request';
  10. import arvadosTypeName from 'arvados-type-name';
  11. import arvadosObjectName from 'arvados-object-name';
  12. import urlForObject from 'url-for-object';
  13. import wbFormatDate from 'wb-format-date';
  14. import WBNameAndUuid from 'wb-name-and-uuid';
  15. import WBAccordion from 'wb-accordion';
  16. import wbFormatSpecialValue from 'wb-format-special-value';
  17. import WBJsonViewer from 'wb-json-viewer';
  18. import WBJsonEditor from 'wb-json-editor';
  19. import wbUpdateField from 'wb-update-field';
  20. class WBCollectionFields extends Component {
  21. componentDidMount() {
  22. this.fetchData();
  23. }
  24. componentWillReceiveProps(nextProps) {
  25. this.props = nextProps;
  26. this.fetchData();
  27. }
  28. prepareRows(item) {
  29. const { app } = this.props;
  30. const { arvHost, arvToken } = app.state;
  31. let rows = [
  32. [ 'Name', item.name ],
  33. [ 'Description', wbFormatSpecialValue(item.description) ],
  34. [ 'Properties', (
  35. <WBJsonEditor name="Properties" app={ app } value={ item.properties }
  36. onChange={ value => wbUpdateField(arvHost, arvToken, item.uuid, 'properties', value)
  37. .then(() => { item.properties = value; this.prepareRows(item); }) } />
  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. fetchData() {
  61. let { uuid, app } = this.props;
  62. let { arvHost, arvToken } = app.state;
  63. const filters = [
  64. ['uuid', '=', uuid]
  65. ];
  66. let prom = makeArvadosRequest(arvHost, arvToken,
  67. '/arvados/v1/collections?filters=' + encodeURIComponent(JSON.stringify(filters)));
  68. prom = prom.then(xhr => {
  69. const item = xhr.response.items[0];
  70. if (!item)
  71. throw Error('Item not found');
  72. this.prepareRows(item);
  73. });
  74. }
  75. render({}, { rows }) {
  76. return (
  77. rows ? (
  78. <WBTable columns={ [ "Name", "Value" ] }
  79. headerClasses={ [ "col-sm-2", "col-sm-4" ] }
  80. rows={ rows }
  81. verticalHeader={ true } />
  82. ) : (
  83. <div>Loading...</div>
  84. )
  85. );
  86. }
  87. }
  88. export default WBCollectionFields;