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!
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

123 Zeilen
3.9KB

  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. import wbFormatDate from 'wb-format-date';
  8. import wbFetchObjects from 'wb-fetch-objects';
  9. import WBNameAndUuid from 'wb-name-and-uuid';
  10. import WBProcessState from 'wb-process-state';
  11. function maskRows(rows) {
  12. return rows.map(r => r.map(c => '-'));
  13. }
  14. class WBProcessListing extends Component {
  15. constructor(...args) {
  16. super(...args);
  17. this.state.rows = [];
  18. this.state.numPages = 0;
  19. this.state.requestStates = [ 'Uncommitted', 'Committed', 'Final' ];
  20. this.state.reqStateMask = [ true, true, true ];
  21. }
  22. componentDidMount() {
  23. this.fetchItems();
  24. }
  25. prepareRows(requests, containerLookup, ownerLookup, outputLookup) {
  26. const { app, renderRenameLink, renderDeleteButton,
  27. renderSelectionCell, renderSharingButton } = this.props;
  28. return requests.map(item => {
  29. return ( [
  30. renderSelectionCell(item),
  31. (<div>
  32. <div>
  33. <a href={ '/process/' + item['uuid'] }>
  34. { item['name'] }
  35. </a> { renderRenameLink(item, () => this.fetchItems()) }
  36. </div>
  37. <div>{ item['uuid'] }</div>
  38. </div>),
  39. ( <WBProcessState app={ app } process={ item } /> ),
  40. ( <WBNameAndUuid app={ app } uuid={ item['owner_uuid'] } /> ),
  41. wbFormatDate(item['created_at']),
  42. ( <WBNameAndUuid app={ app } uuid={ item['output_uuid'] } /> ),
  43. (<div>
  44. { renderDeleteButton(item, () => this.fetchItems()) }
  45. { renderSharingButton(item) }
  46. </div>)
  47. ] );
  48. });
  49. }
  50. fetchItems() {
  51. const { arvHost, arvToken } = this.props.appState;
  52. const { requestStates, reqStateMask } = this.state;
  53. const { activePage, itemsPerPage, ownerUuid,
  54. requestingContainerUuid, waitForNextProps } = this.props;
  55. if (waitForNextProps)
  56. return;
  57. const filters = [
  58. [ 'requesting_container_uuid', '=', requestingContainerUuid ]
  59. ];
  60. if (!reqStateMask.reduce((a, b) => a & b))
  61. filters.push([ 'state', 'in', requestStates.filter((_, idx) => reqStateMask[idx]) ]);
  62. if (ownerUuid)
  63. filters.push([ 'owner_uuid', '=', ownerUuid ]);
  64. let prom = makeArvadosRequest(arvHost, arvToken,
  65. '/arvados/v1/container_requests?filters=' + encodeURIComponent(JSON.stringify(filters)) +
  66. '&limit=' + itemsPerPage +
  67. '&offset=' + (itemsPerPage * activePage));
  68. prom = prom.then(xhr =>
  69. this.setState({
  70. 'numPages': Math.ceil(xhr.response['items_available'] / xhr.response['limit']),
  71. 'rows': this.prepareRows(xhr.response.items)
  72. }));
  73. }
  74. componentWillReceiveProps(nextProps, nextState) {
  75. this.props = nextProps;
  76. this.setState({ 'rows': maskRows(this.state.rows) });
  77. this.fetchItems();
  78. }
  79. render({ appState, ownerUuid, activePage, onPageChanged, getPageUrl },
  80. { rows, numPages, requestStates, containerStates,
  81. reqStateMask, contStateMask }) {
  82. return (
  83. <div>
  84. <WBCheckboxes items={ requestStates } checked={ reqStateMask }
  85. cssClass="float-left mx-2 my-2" title="Request State: "
  86. onChange={ () => this.fetchItems() } />
  87. <WBTable columns={ [ '', 'Name', 'Status', 'Owner', 'Created At', 'Output', 'Actions' ] }
  88. headerClasses={ [ 'w-1' ] }
  89. rows={ rows } />
  90. <WBPagination numPages={ numPages }
  91. activePage={ activePage }
  92. getPageUrl={ getPageUrl }
  93. onPageChanged={ onPageChanged } />
  94. </div>
  95. );
  96. }
  97. }
  98. WBProcessListing.defaultProps = {
  99. 'itemsPerPage': 100,
  100. 'ownerUuid': null,
  101. 'requestingContainerUuid': null,
  102. 'renderRenameLink': () => {},
  103. 'renderDeleteButton': () => {}
  104. };
  105. export default WBProcessListing;