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.

77 lines
2.2KB

  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. class WBCommonFields extends Component {
  10. componentDidMount() {
  11. this.prepareRows();
  12. }
  13. componentWillReceiveProps(nextProps) {
  14. this.props = nextProps;
  15. // this.setState({ 'rows': null });
  16. this.prepareRows();
  17. }
  18. prepareRows() {
  19. let { uuid, app } = this.props;
  20. let { arvHost, arvToken } = app.state;
  21. const filters = [
  22. ['uuid', '=', uuid]
  23. ];
  24. let prom = makeArvadosRequest(arvHost, arvToken,
  25. '/arvados/v1/' + arvadosTypeName(uuid) +
  26. 's?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. [ 'UUID', item.uuid ],
  33. [ 'Kind', item.kind ],
  34. [ 'Owner', (
  35. <WBNameAndUuid app={ app } uuid={ item.owner_uuid } />
  36. ) ],
  37. [ 'Created at', wbFormatDate(item.created_at) ],
  38. [ 'Modified at', wbFormatDate(item.modified_at) ],
  39. [ 'Modified by User', (
  40. <WBNameAndUuid app={ app } uuid={ item.modified_by_user_uuid } />
  41. ) ],
  42. [ 'Modified by Client', (
  43. <WBNameAndUuid app={ app } uuid={ item.modified_by_client_uuid } />
  44. ) ],
  45. [ 'API Url', (
  46. <a href={ 'https://' + app.state.arvHost + '/arvados/v1' + item.href }>
  47. { 'https://' + app.state.arvHost + '/arvados/v1' + item.href }
  48. </a>
  49. ) ],
  50. [ 'ETag', item.etag ]
  51. ];
  52. this.setState({ 'rows': rows });
  53. });
  54. }
  55. render({}, { rows }) {
  56. return (
  57. rows ? (
  58. <WBTable columns={ [ "Name", "Value" ] }
  59. headerClasses={ [ "col-sm-2", "col-sm-4" ] }
  60. verticalHeader={ true }
  61. rows={ rows } />
  62. ) : (
  63. <div>Loading...</div>
  64. )
  65. );
  66. }
  67. }
  68. export default WBCommonFields;