From 1afd3a1f1597cd092a42c748a065ec095e6b468b Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Thu, 16 Apr 2020 16:18:14 +0200 Subject: [PATCH] Added properties editor to WBContainerRequestFields. --- .../component/wb-container-request-fields.js | 175 +++++++++--------- 1 file changed, 90 insertions(+), 85 deletions(-) diff --git a/frontend/src/js/component/wb-container-request-fields.js b/frontend/src/js/component/wb-container-request-fields.js index 3130db6..8d3b23d 100644 --- a/frontend/src/js/component/wb-container-request-fields.js +++ b/frontend/src/js/component/wb-container-request-fields.js @@ -8,106 +8,111 @@ import wbFormatDate from 'wb-format-date'; import WBNameAndUuid from 'wb-name-and-uuid'; import WBAccordion from 'wb-accordion'; import WBJsonViewer from 'wb-json-viewer'; +import wbUpdateField from 'wb-update-field'; +import WBJsonEditor from 'wb-json-editor'; class WBContainerRequestFields extends Component { componentDidMount() { - this.prepareRows(); + this.fetchData(); } componentWillReceiveProps(nextProps) { this.props = nextProps; - this.prepareRows(); + this.fetchData(); } - prepareRows() { + prepareRows(item) { + const { app } = this.props; + const { arvHost, arvToken } = app.state; + + let rows = [ + [ 'Name', item.name ], + [ 'Description', item.description || ({ String(item.description) }) ], + [ 'Properties', ( + wbUpdateField(arvHost, arvToken, item.uuid, 'properties', value) + .then(() => { item.properties = value; this.prepareRows(item); }) } /> + ) ], + [ 'State', item.state ], + [ 'Requesting Container', ( + + ) ], + [ 'Container', ( + + ) ], + [ 'Container Count Max', item.container_count_max ], + [ 'Mounts', ( + + { Object.keys(item.mounts).map(k => ( + + )) } + + ) ], + [ 'Runtime Constraints', ( + + + + ) ], + [ 'Scheduling Parameters', ( + + + + ) ], + [ 'Container Image', ( + + ) ], + [ 'Environment', ( + + + + ) ], + [ 'Working Directory', item.cwd ], + [ 'Command', ( + + ) ], + [ 'Output Path', item.output_path ], + [ 'Output Name', item.output_name ], + [ 'Output TTL', item.output_ttl ], + [ 'Priority', item.priority ], + [ 'Expires At', wbFormatDate(item.expires_at) ], + [ 'Use Existing', String(item.use_existing) ], + [ 'Log', ( + + ) ], + [ 'Output', ( + + ) ], + [ 'Filters', ( + item.filters ? () : ({ String(item.filters) }) + ) ], + [ 'Runtime Token', item.runtime_token || ({ String(item.runtime_token) }) ], + [ 'Runtime User', ( + + ) ], + [ 'Runtime Auth Scopes', ( + item.runtime_auth_scopes ? ( + + ) : ( + { String(item.runtime_auth_scopes) } + ) + ) ] + ]; + rows = rows.map(r => [r[0], r[1] ? r[1] : ({ String(r[1]) })]); + this.setState({ rows }); + } + + fetchData() { let { uuid, app } = this.props; let { arvHost, arvToken } = app.state; let item; let prom = makeArvadosRequest(arvHost, arvToken, '/arvados/v1/container_requests/' + uuid); - prom = prom.then(xhr => (item = xhr.response)); - - prom = prom.then(() => { - let rows = [ - [ 'Name', item.name ], - [ 'Description', item.description || ({ String(item.description) }) ], - [ 'Properties', ( - - - - ) ], - [ 'State', item.state ], - [ 'Requesting Container', ( - - ) ], - [ 'Container', ( - - ) ], - [ 'Container Count Max', item.container_count_max ], - [ 'Mounts', ( - - { Object.keys(item.mounts).map(k => ( - - )) } - - ) ], - [ 'Runtime Constraints', ( - - - - ) ], - [ 'Scheduling Parameters', ( - - - - ) ], - [ 'Container Image', ( - - ) ], - [ 'Environment', ( - - - - ) ], - [ 'Working Directory', item.cwd ], - [ 'Command', ( - - ) ], - [ 'Output Path', item.output_path ], - [ 'Output Name', item.output_name ], - [ 'Output TTL', item.output_ttl ], - [ 'Priority', item.priority ], - [ 'Expires At', wbFormatDate(item.expires_at) ], - [ 'Use Existing', String(item.use_existing) ], - [ 'Log', ( - - ) ], - [ 'Output', ( - - ) ], - [ 'Filters', ( - item.filters ? () : ({ String(item.filters) }) - ) ], - [ 'Runtime Token', item.runtime_token || ({ String(item.runtime_token) }) ], - [ 'Runtime User', ( - - ) ], - [ 'Runtime Auth Scopes', ( - item.runtime_auth_scopes ? ( - - ) : ( - { String(item.runtime_auth_scopes) } - ) - ) ] - ]; - rows = rows.map(r => [r[0], r[1] ? r[1] : ({ String(r[1]) })]); - this.setState({ 'rows': rows }); - }); + prom = prom.then(xhr => this.prepareRows(xhr.response)); } render({}, { rows }) {