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!
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

80 lignes
2.4KB

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