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'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

150 satır
4.9KB

  1. import { h, Component } from 'preact';
  2. import WBNavbarCommon from 'wb-navbar-common';
  3. import WBArvadosCrumbs from 'wb-arvados-crumbs';
  4. import makeArvadosRequest from 'make-arvados-request';
  5. import detectUuids from 'detect-uuids';
  6. import arvadosTypeName from 'arvados-type-name';
  7. import urlForObject from 'url-for-object';
  8. import detectHashes from 'detect-hashes';
  9. import WBCommonFields from 'wb-common-fields';
  10. import WBContainerRequestFields from 'wb-container-request-fields';
  11. import WBProcessListing from 'wb-process-listing';
  12. import WBProcessDashboard from 'wb-process-dashboard';
  13. import wbFetchObjects from 'wb-fetch-objects';
  14. class WBProcessView extends Component {
  15. constructor(...args) {
  16. super(...args);
  17. this.state.objectUrls = [];
  18. }
  19. getUrl(props) {
  20. const page = ('page' in props ? props.page : this.props.page);
  21. return ('/process/' + this.props.uuid +
  22. (page ? '/' + page : ''));
  23. }
  24. fetchData() {
  25. let { arvHost, arvToken } = this.props.app.state;
  26. let prom = makeArvadosRequest(arvHost, arvToken,
  27. '/arvados/v1/container_requests/' + this.props.uuid);
  28. let req;
  29. let cont;
  30. prom = prom.then(xhr => {
  31. req = xhr.response;
  32. if (req.container_uuid) {
  33. let prom_1 = makeArvadosRequest(arvHost, arvToken,
  34. '/arvados/v1/containers/' + req.container_uuid);
  35. prom_1 = prom_1.then(xhr => (cont = xhr.response));
  36. return prom_1;
  37. }
  38. });
  39. //prom = prom.then(xhr => (cont = xhr.response));
  40. prom = prom.then(() => {
  41. let hashes = detectHashes([ req, cont ]);
  42. let filters = [
  43. [ 'portable_data_hash', 'in', hashes ]
  44. ];
  45. return makeArvadosRequest(arvHost, arvToken,
  46. '/arvados/v1/collections?filters=' +
  47. encodeURIComponent(JSON.stringify(filters)));
  48. });
  49. prom = prom.then(xhr => {
  50. let colUuids = xhr.response['items'].map(item => item.uuid);
  51. let uuids = detectUuids([ req, cont ]);
  52. let dict = {};
  53. colUuids.map(u => (dict[u] = true));
  54. uuids.map(u => (dict[u] = true));
  55. return Object.keys(dict);
  56. });
  57. prom = prom.then(uuids => wbFetchObjects(arvHost, arvToken, uuids));
  58. /* prom = prom.then(() => {
  59. // let uuids = detectUuids([ req, cont ]);
  60. let objectTypes = uuids.map(u => arvadosTypeName(u) + 's');
  61. //objectTypes = objectTypes.filter(ot => ot);
  62. //objectTypes = objectTypes.map(ot => ot + 's');
  63. let objQueries = {};
  64. objectTypes.map(t => (objQueries[t] = []));
  65. uuids.map((u, idx) => (objQueries[objectTypes[idx]].push(u)));
  66. let prom_1 = new Promise(accept => accept());
  67. let objects = [];
  68. // delete objQueries['users'];
  69. delete objQueries['api_clients'];
  70. for (let k in objQueries) {
  71. let filters = [
  72. ['uuid', 'in', objQueries[k]]
  73. ];
  74. prom_1 = prom_1.then(() => makeArvadosRequest(arvHost, arvToken,
  75. '/arvados/v1/' + k + '?filters=' +
  76. encodeURIComponent(JSON.stringify(filters))));
  77. prom_1 = prom_1.then(xhr => (objects = objects.concat(xhr.response['items'])));
  78. }
  79. prom_1 = prom_1.then(() => objects);
  80. return prom_1;
  81. }); */
  82. prom = prom.then(objects => {
  83. // let objDict = {};
  84. // objects.map(o => (objDict[o['uuid']] = o));
  85. let urls = Object.values(objects).map(o => urlForObject(o));
  86. this.setState({
  87. 'objectUrls': urls,
  88. 'request': req,
  89. 'container': cont
  90. });
  91. });
  92. }
  93. componentDidMount() {
  94. this.fetchData();
  95. }
  96. componentWillReceiveProps(nextProps) {
  97. this.props = nextProps;
  98. this.setState({ 'objectUrls': [], 'request': null, 'container': null });
  99. this.fetchData();
  100. }
  101. render({ app, uuid, page }, { objectUrls, container }) {
  102. return (
  103. <div>
  104. <WBNavbarCommon app={ app } />
  105. <WBArvadosCrumbs app={ app } uuid={ uuid } />
  106. <div class="my-2">
  107. This is the process view for { uuid }
  108. </div>
  109. <h2>Children Dashboard</h2>
  110. <WBProcessDashboard app={ app } parentProcessUuid={ uuid } />
  111. <h2>Common Fields</h2>
  112. <WBCommonFields app={ app } uuid={ uuid } />
  113. <h2>Container Request Fields</h2>
  114. <WBContainerRequestFields app={ app } uuid={ uuid } />
  115. <h2>Children</h2>
  116. <WBProcessListing app={ app }
  117. appState={ app.state }
  118. requestingContainerUuid={ container ? container.uuid : null }
  119. waitForNextProps={ !container }
  120. itemsPerPage="20"
  121. activePage={ Number(page || 0) }
  122. getPageUrl={ page => this.getUrl({ page }) } />
  123. <div>
  124. <a href="/browse">Click here</a>
  125. </div>
  126. <ul>
  127. { objectUrls.map(url => (
  128. <li><a href={ url }>{ url }</a></li>
  129. )) }
  130. </ul>
  131. </div>
  132. );
  133. }
  134. }
  135. export default WBProcessView;