From 56c58b325db80c66fe4b9b7822f6889661863f5b Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Thu, 6 Feb 2020 14:27:43 +0100 Subject: [PATCH] Working on workflow launcher --- frontend/src/js/page/wb-app.js | 3 + .../src/js/page/wb-launch-workflow-page.js | 97 +++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 frontend/src/js/page/wb-launch-workflow-page.js diff --git a/frontend/src/js/page/wb-app.js b/frontend/src/js/page/wb-app.js index c2e214b..5ec264b 100644 --- a/frontend/src/js/page/wb-app.js +++ b/frontend/src/js/page/wb-app.js @@ -9,6 +9,7 @@ import WBCollectionView from 'wb-collection-view'; import WBCollectionBrowse from 'wb-collection-browse'; import WBUsersPage from 'wb-users-page'; import WBWorkflowView from 'wb-workflow-view'; +import WBLaunchWorkflowPage from 'wb-launch-workflow-page'; import arvadosTypeName from 'arvados-type-name'; class WBApp extends Component { @@ -64,6 +65,8 @@ class WBApp extends Component { + + ); } diff --git a/frontend/src/js/page/wb-launch-workflow-page.js b/frontend/src/js/page/wb-launch-workflow-page.js new file mode 100644 index 0000000..db2ca9e --- /dev/null +++ b/frontend/src/js/page/wb-launch-workflow-page.js @@ -0,0 +1,97 @@ +import { h, Component } from 'preact'; +import WBNavbarCommon from 'wb-navbar-common'; +import WBArvadosCrumbs from 'wb-arvados-crumbs'; +import makeArvadosRequest from 'make-arvados-request'; +import linkState from 'linkstate'; + +function createInputsTemplate(workflow) { + const g = JSON.parse(workflow.definition)['$graph']; + const main = g.find(it => (it.id === '#main')); + /* let res = ''; + main.inputs.map(it => { + let id = it.id.split('/'); + id = id[id.length - 1]; + if (it.label) res += ' // ' + it.label + '\n'; + if (it.doc) res += ' //' + it.doc + '\n'; + res += ' ' + it.type + res += '\'' + it.id + '\': null' + }); */ + let res = main.inputs.map(it => { it.value = null; return it; }); + res = JSON.stringify(res, null, 2); + res = res.split('\n'); + res = res.map((ln, i) => (i == 0 ? ln : ' ' + ln)); + res = res.join('\n'); + return res; +} + +class WBLaunchWorkflowPage extends Component { + componentDidMount() { + let { app, workflowUuid } = this.props; + let { arvHost, arvToken } = app.state; + + let prom = makeArvadosRequest(arvHost, arvToken, + '/arvados/v1/workflows/' + workflowUuid); + prom = prom.then(xhr => this.setState({ + 'workflow': xhr.response, + 'processName': xhr.response.name, + 'processDescription': xhr.response.description, + 'inputsFunctionText': '(() => {\n return ' + + createInputsTemplate(xhr.response) + + ';\n})()' + })); + } + + render({ app, projectUuid, workflowUuid }, + { workflow, processName, processDescription, + inputsFunctionText }) { + + return ( +
+ + + { workflow ? + (
+

Launch Workflow

+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
) :
Loading...
} +
+ ); + } +} + +export default WBLaunchWorkflowPage;