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.

65 lines
2.0KB

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