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

73 строки
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 typeName = arvadosTypeName(uuid);
  22. let prom = makeArvadosRequest(arvHost, arvToken,
  23. '/arvados/v1/' + typeName + 's/' +
  24. encodeURIComponent(uuid));
  25. prom = prom.then(xhr => {
  26. const item = xhr.response;
  27. let rows = [
  28. [ 'UUID', item.uuid ],
  29. [ 'Kind', item.kind ],
  30. [ 'Owner', (
  31. <WBNameAndUuid app={ app } uuid={ item.owner_uuid } />
  32. ) ],
  33. [ 'Created at', wbFormatDate(item.created_at) ],
  34. [ 'Modified at', wbFormatDate(item.modified_at) ],
  35. [ 'Modified by User', (
  36. item.modified_by_user_uuid ? (<WBNameAndUuid app={ app } uuid={ item.modified_by_user_uuid } />) : '-'
  37. ) ],
  38. [ 'Modified by Client', (
  39. item.modified_by_client_uuid ? (<WBNameAndUuid app={ app } uuid={ item.modified_by_client_uuid } />) : '-'
  40. ) ],
  41. [ 'API Url', (
  42. <a href={ 'https://' + app.state.arvHost + '/arvados/v1/' + typeName + 's/' + uuid }>
  43. { 'https://' + app.state.arvHost + '/arvados/v1/' + typeName + 's/' + uuid }
  44. </a>
  45. ) ],
  46. [ 'ETag', item.etag ]
  47. ];
  48. this.setState({ 'rows': rows });
  49. });
  50. }
  51. render({}, { rows }) {
  52. return (
  53. rows ? (
  54. <WBTable columns={ [ "Name", "Value" ] }
  55. headerClasses={ [ "col-sm-2", "col-sm-4" ] }
  56. verticalHeader={ true }
  57. rows={ rows } />
  58. ) : (
  59. <div>Loading...</div>
  60. )
  61. );
  62. }
  63. }
  64. export default WBCommonFields;