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.

98 lignes
3.3KB

  1. import { h, Component } from 'preact';
  2. import { route } from 'preact-router';
  3. import makeArvadosRequest from 'make-arvados-request';
  4. import WBTable from 'wb-table';
  5. import WBPagination from 'wb-pagination';
  6. import WBCheckboxes from 'wb-checkboxes';
  7. class WBProcessListing extends Component {
  8. constructor(...args) {
  9. super(...args);
  10. this.state.rows = [];
  11. this.state.numPages = 0;
  12. this.state.requestStates = [ 'Uncommitted', 'Committed', 'Final' ];
  13. this.state.containerStates = [ 'Queued', 'Locked', 'Running', 'Cancelled', 'Complete' ];
  14. this.state.reqStateMask = [ true, true, true ];
  15. this.state.contStateMask = [ true, true, true, true, true ];
  16. }
  17. componentDidMount() {
  18. this.fetchItems();
  19. }
  20. prepareRows(items) {
  21. return items.map(item => [
  22. (<div>
  23. <div>
  24. <a href="#"
  25. onclick={ e => { e.preventDefault(); route('/process/' + item['uuid']) }}>{ item['name'] }</a>
  26. </div>
  27. <div>{ item['uuid'] }</div>
  28. </div>),
  29. item['state'],
  30. item['owner_uuid'],
  31. item['created_at'].replace('T', ' ').substr(0, item['created_at'].length - 11) + '',
  32. item['output_uuid'],
  33. (<div>
  34. <button class="btn btn-outline-danger"><i class="fas fa-trash"></i></button>
  35. </div>)
  36. ]);
  37. }
  38. fetchItems() {
  39. let { arvHost, arvToken } = this.props.appState;
  40. let i = this.props.activePage;
  41. let filters = [
  42. [ 'state', 'in', this.state.requestStates.filter((_, idx) => this.state.reqStateMask[idx]) ]
  43. ];
  44. if (this.props.ownerUuid)
  45. filters.push([ 'owner_uuid', '=', this.props.ownerUuid ]);
  46. let prom = makeArvadosRequest(arvHost, arvToken,
  47. '/arvados/v1/container_requests?filters=' + encodeURIComponent(JSON.stringify(filters)) +
  48. '&limit=' + encodeURIComponent(this.props.itemsPerPage) +
  49. '&offset=' + encodeURIComponent(this.props.itemsPerPage * i));
  50. prom = prom.then(xhr =>
  51. this.setState({
  52. 'numPages': Math.ceil(xhr.response['items_available'] / xhr.response['limit']),
  53. 'rows': this.prepareRows(xhr.response['items'])
  54. }));
  55. }
  56. componentWillReceiveProps(nextProps, nextState) {
  57. // this.setState({ 'rows': [] }); // .rows = [];
  58. this.props = nextProps;
  59. this.fetchItems();
  60. }
  61. render({ appState, ownerUuid, activePage, onPageChanged },
  62. { rows, numPages, requestStates, containerStates,
  63. reqStateMask, contStateMask }) {
  64. return (
  65. <div>
  66. <WBCheckboxes items={ requestStates } checked={ reqStateMask }
  67. cssClass="float-left mx-2 my-2" title="Request State: "
  68. onChange={ () => this.fetchItems() } />
  69. <WBCheckboxes items={ containerStates } checked={ contStateMask }
  70. cssClass="float-left mx-2 my-2" title="Container State: "
  71. onChange={ () => this.fetchItems() } />
  72. <WBTable columns={ [ 'Name', 'Status', 'Owner', 'Created At (UTC)', 'Output', 'Actions' ] }
  73. rows={ rows } />
  74. <WBPagination numPages={ numPages }
  75. activePage={ activePage }
  76. onPageChanged={ i => onPageChanged(i) } />
  77. </div>
  78. );
  79. }
  80. }
  81. WBProcessListing.defaultProps = {
  82. 'itemsPerPage': 100,
  83. 'ownerUuid': null
  84. };
  85. export default WBProcessListing;