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.

108 lines
3.8KB

  1. import { h, Component } from 'preact';
  2. import WBNavbarCommon from 'wb-navbar-common';
  3. import WBArvadosCrumbs from 'wb-arvados-crumbs';
  4. import WBToolboxDialog from 'wb-toolbox-dialog';
  5. import makeArvadosRequest from 'make-arvados-request';
  6. import linkState from 'linkstate';
  7. function createInputsTemplate(workflow) {
  8. const g = JSON.parse(workflow.definition)['$graph'];
  9. const main = g.find(it => (it.id === '#main'));
  10. /* let res = '';
  11. main.inputs.map(it => {
  12. let id = it.id.split('/');
  13. id = id[id.length - 1];
  14. if (it.label) res += ' // ' + it.label + '\n';
  15. if (it.doc) res += ' //' + it.doc + '\n';
  16. res += ' ' + it.type
  17. res += '\'' + it.id + '\': null'
  18. }); */
  19. let res = main.inputs.map(it => { it.value = null; return it; });
  20. res = JSON.stringify(res, null, 2);
  21. res = res.split('\n');
  22. res = res.map((ln, i) => (i == 0 ? ln : ' ' + ln));
  23. res = res.join('\n');
  24. return res;
  25. }
  26. class WBLaunchWorkflowPage extends Component {
  27. constructor(...args) {
  28. super(...args);
  29. this.state.toolboxDialogId = uuid.v4();
  30. }
  31. componentDidMount() {
  32. let { app, workflowUuid } = this.props;
  33. let { arvHost, arvToken } = app.state;
  34. let prom = makeArvadosRequest(arvHost, arvToken,
  35. '/arvados/v1/workflows/' + workflowUuid);
  36. prom = prom.then(xhr => this.setState({
  37. 'workflow': xhr.response,
  38. 'processName': xhr.response.name,
  39. 'processDescription': xhr.response.description,
  40. 'inputsFunctionText': '(() => {\n return ' +
  41. createInputsTemplate(xhr.response) +
  42. ';\n})()'
  43. }));
  44. }
  45. render({ app, projectUuid, workflowUuid },
  46. { workflow, processName, processDescription,
  47. inputsFunctionText, toolboxDialogId }) {
  48. return (
  49. <div>
  50. <WBNavbarCommon app={ app } />
  51. <WBToolboxDialog app={ app } id={ toolboxDialogId }
  52. items={ app.state.toolboxItems } />
  53. { workflow ?
  54. (<form class="container-fluid">
  55. <h1>Launch Workflow</h1>
  56. <div class="form-group">
  57. <label>Workflow</label>
  58. <WBArvadosCrumbs app={ app } uuid={ workflowUuid } />
  59. </div>
  60. <div class="form-group">
  61. <label for="projectUuid">Project UUID</label>
  62. <input type="email" class="form-control" id="projectUuid" placeholder="Enter project uuid" />
  63. <button class="btn btn-primary" onclick={ e => { e.preventDefault(); $('#' + toolboxDialogId).modal(); } }>Browse</button>
  64. </div>
  65. <div class="form-check">
  66. <input type="checkbox" class="form-check-input" id="createSubproject" />
  67. <label class="form-check-label" for="createSubproject">Create subproject</label>
  68. </div>
  69. <div class="form-group">
  70. <label for="processName">Process Name</label>
  71. <input type="text" class="form-control" id="processName"
  72. placeholder="Enter process name" value={ processName }
  73. onChange={ linkState(this, 'processName') }/>
  74. </div>
  75. <div class="form-group">
  76. <label for="processDescription">Process Description</label>
  77. <input type="text" class="form-control" id="processDescription"
  78. placeholder="Enter process name" value={ processDescription }
  79. onChange={ linkState(this, 'processDescription') } />
  80. </div>
  81. <div class="form-group">
  82. <label for="inputs">Inputs</label>
  83. <textarea class="form-control" id="inputs"
  84. style="font-family: monospace;" rows="20"
  85. value={ inputsFunctionText }></textarea>
  86. </div>
  87. </form>) : <div>Loading...</div> }
  88. </div>
  89. );
  90. }
  91. }
  92. export default WBLaunchWorkflowPage;