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.

wb-launch-workflow-page.js 6.1KB

пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. import { h, Component, createRef } from 'preact';
  2. import { route } from 'preact-router';
  3. import WBNavbarCommon from 'wb-navbar-common';
  4. import WBArvadosCrumbs from 'wb-arvados-crumbs';
  5. import WBBrowseDialog from 'wb-browse-dialog';
  6. import WBTable from 'wb-table';
  7. import makeArvadosRequest from 'make-arvados-request';
  8. import { wbDisableControls, wbEnableControls } from 'wb-disable-controls';
  9. import linkState from 'linkstate';
  10. import wbParseWorkflowDef from 'wb-parse-workflow-def';
  11. import { wbParseWorkflowInputs, wbSubmitContainerRequest } from 'wb-submit-container-request';
  12. import WBWorkflowInput from 'wb-workflow-input';
  13. class WBLaunchWorkflowPage extends Component {
  14. constructor(...args) {
  15. super(...args);
  16. this.browseDialogRef = createRef();
  17. this.state.inputs = {};
  18. this.state.errors = [];
  19. }
  20. componentDidMount() {
  21. let { app, workflowUuid } = this.props;
  22. let { arvHost, arvToken } = app.state;
  23. let prom = makeArvadosRequest(arvHost, arvToken,
  24. '/arvados/v1/workflows/' + workflowUuid);
  25. prom = prom.then(xhr => {
  26. const def = wbParseWorkflowDef(xhr.response.definition);
  27. const inputs = {};
  28. const main = def['$graph'].find(a => (a.id === '#main'));
  29. main.inputs.map(a => (inputs[a.id] = JSON.stringify(a.default)));
  30. this.setState({
  31. 'workflow': xhr.response,
  32. 'workflowDefinition': def,
  33. 'defaultProcessName': xhr.response.name + ' ' + (new Date().toISOString()),
  34. 'defaultProcessDescription': xhr.response.description,
  35. inputs
  36. });
  37. });
  38. }
  39. submit() {
  40. // first see if all inputs are parseable
  41. const { app, workflowUuid } = this.props;
  42. const { arvHost, arvToken, currentUser } = app.state;
  43. const { workflowDefinition, projectUuid,
  44. processName, processDescription,
  45. defaultProcessName, defaultProcessDescription } = this.state;
  46. const errors = [];
  47. const inputs = wbParseWorkflowInputs(workflowDefinition,
  48. this.state.inputs, errors);
  49. if (errors.length > 0) {
  50. this.setState({ errors });
  51. return;
  52. }
  53. const params = {
  54. arvHost, arvToken, inputs,
  55. processName: processName || defaultProcessName,
  56. processDescription: processDescription || defaultProcessDescription,
  57. projectUuid: projectUuid || currentUser.uuid,
  58. workflowUuid, workflowDefinition
  59. }
  60. wbDisableControls();
  61. let prom = wbSubmitContainerRequest(params);
  62. prom = prom.then(xhr => {
  63. wbEnableControls();
  64. route('/process/' + xhr.response.uuid);
  65. });
  66. prom = prom.catch(exc => {
  67. wbEnableControls();
  68. this.setState({ errors: [ exc.message ] });
  69. });
  70. }
  71. render({ app, workflowUuid },
  72. { workflow, workflowDefinition, projectUuid, processName, processDescription,
  73. defaultProcessName, defaultProcessDescription, errors }) {
  74. return (
  75. <div>
  76. <WBNavbarCommon app={ app } />
  77. <WBBrowseDialog app={ app } ref={ this.browseDialogRef } />
  78. { workflow ?
  79. (<form class="container-fluid">
  80. <h1>Launch Workflow</h1>
  81. <div class="form-group">
  82. <label>Workflow</label>
  83. <WBArvadosCrumbs app={ app } uuid={ workflowUuid } />
  84. </div>
  85. <div class="form-group">
  86. <label for="projectUuid">Project UUID</label>
  87. <div class="input-group mb-3">
  88. <input type="text" class="form-control" id="projectUuid"
  89. placeholder="Enter Project UUID" aria-label="Project UUID"
  90. aria-describedby="button-addon2" value={ projectUuid }
  91. onChange={ linkState(this, 'projectUuid') } />
  92. <div class="input-group-append">
  93. <button class="btn btn-primary" type="button"
  94. id="button-addon2" onclick={ e => { e.preventDefault();
  95. this.browseDialogRef.current.show('owner', false,
  96. projectUuid => this.setState({ projectUuid })); } }>Browse</button>
  97. </div>
  98. </div>
  99. { projectUuid ? (
  100. <WBArvadosCrumbs app={ app } uuid={ projectUuid } />
  101. ) : null }
  102. </div>
  103. <div class="form-group">
  104. <label for="processName">Process Name</label>
  105. <input type="text" class="form-control" id="processName"
  106. placeholder={ defaultProcessName } value={ processName }
  107. onChange={ linkState(this, 'processName') }/>
  108. </div>
  109. <div class="form-group">
  110. <label for="processDescription">Process Description</label>
  111. <input type="text" class="form-control" id="processDescription"
  112. placeholder={ defaultProcessDescription } value={ processDescription }
  113. onChange={ linkState(this, 'processDescription') } />
  114. </div>
  115. <div class="form-group">
  116. <label for="inputs">Inputs</label>
  117. <WBTable columns={ [ 'Name', 'Value'] }
  118. rows={ workflowDefinition.$graph.find(a => (a.id === '#main')).inputs.map(it => [
  119. it.label || it.id,
  120. ( <WBWorkflowInput app={ app } inputSpec={ it }
  121. inputsDict={ this.state.inputs }
  122. browseDialogRef={ this.browseDialogRef } /> )
  123. ]) } />
  124. </div>
  125. { errors.length > 0 ? (
  126. <div class="form-group">
  127. { errors.map(err => (
  128. <div class="alert alert-danger" role="alert">
  129. { err }
  130. </div>
  131. ))}
  132. </div>
  133. ) : null }
  134. <div class="form-group">
  135. <button class="btn btn-success" onclick={ e => { e.preventDefault(); this.submit(); } }>
  136. Submit
  137. </button>
  138. </div>
  139. </form>) : <div>Loading...</div> }
  140. </div>
  141. );
  142. }
  143. }
  144. export default WBLaunchWorkflowPage;