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

58 рядки
1.9KB

  1. import { h, Component } from 'preact';
  2. import makeArvadosRequest from 'make-arvados-request';
  3. class WBProcessState extends Component {
  4. componentDidMount() {
  5. if (!this.props.lazy)
  6. this.fetchData();
  7. }
  8. componentWillReceiveProps(nextProps) {
  9. if (this.props.lazy) {
  10. this.setState({ container: null, apiError: null });
  11. } else {
  12. this.props = nextProps;
  13. this.fetchData();
  14. }
  15. }
  16. fetchData() {
  17. const { app, process } = this.props;
  18. const { arvHost, arvToken } = app.state;
  19. if (!process.container_uuid)
  20. return;
  21. let prom = makeArvadosRequest(arvHost, arvToken,
  22. '/arvados/v1/containers/' + process.container_uuid);
  23. prom = prom.then(xhr => this.setState({ 'container': xhr.response }));
  24. prom = prom.catch(() => this.setState({ 'apiError': 'Failed to fetch container' }));
  25. }
  26. render({ process, lazy }, { container, apiError }) {
  27. const runtimeStatus = container ? container.runtime_status : null;
  28. const error = runtimeStatus ? runtimeStatus.error : null;
  29. const warning = runtimeStatus ? runtimeStatus.warning : null;
  30. return (
  31. <div>
  32. { process.state }
  33. { apiError ? <i>{ [ ' / ', apiError ] }</i> : null }
  34. { container ? [ " / ", container.state ] : null }
  35. { !(error || warning) && container && container.state === 'Complete' ? " / Success" : null }
  36. { error ? [" / ", <a href={ '/container/' + container.uuid }
  37. title={ error }>E</a> ] : null }
  38. { warning ? [ " / ", <a href={ '/container/' + container.uuid }
  39. title={ warning }>W</a> ] : null } { lazy && !container && !apiError ? (
  40. <a href="#" title="Look up" onclick={ e => { e.preventDefault(); this.fetchData(); } }>
  41. <i class="fas fa-search"></i>
  42. </a>
  43. ) : null }
  44. </div>
  45. );
  46. }
  47. }
  48. export default WBProcessState;