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!
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

wb-process-state.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { h, Component } from 'preact';
  2. import makeArvadosRequest from 'make-arvados-request';
  3. import wbProcessStateName from 'wb-process-state-name';
  4. class WBProcessState extends Component {
  5. componentDidMount() {
  6. if (!this.props.lazy)
  7. this.fetchData();
  8. }
  9. componentWillReceiveProps(nextProps) {
  10. if (this.props.lazy) {
  11. this.setState({ container: null, apiError: null });
  12. } else {
  13. this.props = nextProps;
  14. this.fetchData();
  15. }
  16. }
  17. fetchData() {
  18. const { app, process } = this.props;
  19. const { arvHost, arvToken } = app.state;
  20. if (!process.container_uuid)
  21. return;
  22. let prom = makeArvadosRequest(arvHost, arvToken,
  23. '/arvados/v1/containers/' + process.container_uuid);
  24. prom = prom.then(xhr => this.setState({ 'container': xhr.response }));
  25. prom = prom.catch(() => this.setState({ 'apiError': 'Failed to fetch container' }));
  26. }
  27. render({ process, lazy }, { container, apiError }) {
  28. const runtimeStatus = container ? container.runtime_status : null;
  29. const error = runtimeStatus ? runtimeStatus.error : null;
  30. const warning = runtimeStatus ? runtimeStatus.warning : null;
  31. return (
  32. <div>
  33. { wbProcessStateName(process, container) }
  34. { apiError ? <i>{ [ ' / ', apiError ] }</i> : null }
  35. { error ? [" / ", <a href={ '/container/' + container.uuid }
  36. title={ error }>E</a> ] : null }
  37. { warning ? [ " / ", <a href={ '/container/' + container.uuid }
  38. title={ warning }>W</a> ] : null } {}
  39. { 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;