From cf3b341c4f1fb408bb182ed68ea0a843a6fcfd5b Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Fri, 14 Feb 2020 16:54:14 +0100 Subject: [PATCH] Added WBContainerView. --- .../src/js/component/wb-container-fields.js | 106 ++++++++++++++++++ frontend/src/js/misc/url-for-object.js | 2 +- frontend/src/js/page/wb-app.js | 3 + frontend/src/js/page/wb-container-view.js | 29 +++++ 4 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 frontend/src/js/component/wb-container-fields.js create mode 100644 frontend/src/js/page/wb-container-view.js diff --git a/frontend/src/js/component/wb-container-fields.js b/frontend/src/js/component/wb-container-fields.js new file mode 100644 index 0000000..e674e4f --- /dev/null +++ b/frontend/src/js/component/wb-container-fields.js @@ -0,0 +1,106 @@ +import { h, Component } from 'preact'; +import WBTable from 'wb-table'; +import makeArvadosRequest from 'make-arvados-request'; +import arvadosTypeName from 'arvados-type-name'; +import arvadosObjectName from 'arvados-object-name'; +import urlForObject from 'url-for-object'; +import wbFormatDate from 'wb-format-date'; +import WBNameAndUuid from 'wb-name-and-uuid'; +import WBAccordion from 'wb-accordion'; + +class WBContainerFields extends Component { + componentDidMount() { + this.prepareRows(); + } + + componentWillReceiveProps(nextProps) { + this.props = nextProps; + this.prepareRows(); + } + + prepareRows() { + let { uuid, app } = this.props; + let { arvHost, arvToken } = app.state; + + let item; + let prom = makeArvadosRequest(arvHost, arvToken, + '/arvados/v1/containers/' + uuid); + prom = prom.then(xhr => (item = xhr.response)); + + prom = prom.then(() => { + let rows = [ + [ 'State', item.state ], + [ 'Started At', wbFormatDate(item.started_at) ], + [ 'Finished At', wbFormatDate(item.started_at) ], + [ 'Log', item.uuid ? ( + + ) : ( { String(item.uuid) } ) ], + [ 'Environment', ( + +
{ JSON.stringify(item.environment, null, 2) }
+
+ ) ], + [ 'Working Directory', item.cwd ], + [ 'Command', ( +
{ JSON.stringify(item.command) }
+ ) ], + [ 'Output Path', item.output_path ], + [ 'Mounts', ( + + { Object.keys(item.mounts).map(k => ( +
{ JSON.stringify(item.mounts[k], null, 2) }
+ )) } +
+ ) ], + [ 'Runtime Constraints', ( + +
{ JSON.stringify(item.runtime_constraints, null, 2) }
+
+ ) ], + [ 'Runtime Status', ( + +
{ JSON.stringify(item.runtime_status, null, 2) }
+
+ ) ], + [ 'Scheduling Parameters', ( + +
{ JSON.stringify(item.scheduling_parameters, null, 2) }
+
+ ) ], + [ 'Output', item.output ? ( + + ) : ( { String(item.output) } )], + [ 'Container Image', ( + + ) ], + [ 'Progress', item.progress ], + [ 'Priority', item.priority ], + [ 'Exit Code', item.exit_code === null ? ( null ) : item.exit_code ], + [ 'Auth UUID', item.auth_uuid === null ? ( null ) : item.auth_uuid ], + [ 'Locked by UUID', item.locked_by_uuid === null ? ( null ) : item.locked_by_uuid ] + ]; + rows = rows.map(r => [r[0], r[1] ? r[1] : ({ String(r[1]) })]); + this.setState({ 'rows': rows }); + }); + } + + render({}, { rows }) { + return ( + rows ? ( + + ) : ( +
Loading...
+ ) + ); + } +} + +export default WBContainerFields; diff --git a/frontend/src/js/misc/url-for-object.js b/frontend/src/js/misc/url-for-object.js index b18e941..8a3e4a9 100644 --- a/frontend/src/js/misc/url-for-object.js +++ b/frontend/src/js/misc/url-for-object.js @@ -19,7 +19,7 @@ function urlForObject(item, mode='primary') { else return ('/collection/' + item.uuid); } else if (objectType === 'container') - return ('https://wb.arkau.roche.com/containers/' + item.uuid); + return ('/container/' + item.uuid); } export default urlForObject; diff --git a/frontend/src/js/page/wb-app.js b/frontend/src/js/page/wb-app.js index 1862de3..cf119f8 100644 --- a/frontend/src/js/page/wb-app.js +++ b/frontend/src/js/page/wb-app.js @@ -5,6 +5,7 @@ import WBSignIn from 'wb-sign-in'; import WBSignOut from 'wb-sign-out'; import WBLandingPage from 'wb-landing-page'; import WBProcessView from 'wb-process-view'; +import WBContainerView from 'wb-container-view'; import WBCollectionView from 'wb-collection-view'; import WBCollectionBrowse from 'wb-collection-browse'; import WBUsersPage from 'wb-users-page'; @@ -79,6 +80,8 @@ class WBApp extends Component { + + diff --git a/frontend/src/js/page/wb-container-view.js b/frontend/src/js/page/wb-container-view.js new file mode 100644 index 0000000..ea2a804 --- /dev/null +++ b/frontend/src/js/page/wb-container-view.js @@ -0,0 +1,29 @@ +import { h, Component } from 'preact'; +import WBNavbarCommon from 'wb-navbar-common'; +import WBArvadosCrumbs from 'wb-arvados-crumbs'; +import WBCommonFields from 'wb-common-fields'; +import WBContainerFields from 'wb-container-fields'; + +class WBContainerView extends Component { + render({ app, uuid }) { + return ( +
+ + + + +
+ This is the container view for { uuid } +
+ +

Common Fields

+ + +

Container Fields

+ +
+ ); + } +} + +export default WBContainerView;