// // Copyright (C) Stanislaw Adaszewski, 2020 // Contact: s.adaszewski@gmail.com // Website: https://adared.ch/wba // License: GNU Affero General Public License, Version 3 // 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'; import WBJsonViewer from 'wb-json-viewer'; import wbUpdateField from 'wb-update-field'; import WBJsonEditor from 'wb-json-editor'; class WBContainerRequestFields extends Component { componentDidMount() { this.fetchData(); } componentWillReceiveProps(nextProps) { this.props = nextProps; this.fetchData(); } 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 => this.prepareRows(xhr.response)); } render({}, { rows }) { return ( rows ? ( ) : (
Loading...
) ); } } export default WBContainerRequestFields;