diff --git a/frontend/src/js/component/wb-collection-fields.js b/frontend/src/js/component/wb-collection-fields.js index 0bedadc..d693123 100644 --- a/frontend/src/js/component/wb-collection-fields.js +++ b/frontend/src/js/component/wb-collection-fields.js @@ -40,7 +40,7 @@ class WBCollectionFields extends Component { [ 'Description', wbFormatSpecialValue(item.description) ], [ 'Properties', ( - + ) ], [ 'Portable Data Hash', item.portable_data_hash ], diff --git a/frontend/src/js/component/wb-container-fields.js b/frontend/src/js/component/wb-container-fields.js index 9597301..bab11e4 100644 --- a/frontend/src/js/component/wb-container-fields.js +++ b/frontend/src/js/component/wb-container-fields.js @@ -39,38 +39,38 @@ class WBContainerFields extends Component { [ 'Environment', ( - + ) ], [ 'Working Directory', item.cwd ], [ 'Command', ( - + ) ], [ 'Output Path', item.output_path ], [ 'Mounts', ( { Object.keys(item.mounts).map(k => ( - + )) } ) ], [ 'Runtime Constraints', ( - + ) ], [ 'Runtime Status', ( - + ) ], [ 'Scheduling Parameters', ( - + ) ], [ 'Output', item.output ? ( diff --git a/frontend/src/js/component/wb-container-request-fields.js b/frontend/src/js/component/wb-container-request-fields.js index cfedefe..38df3fd 100644 --- a/frontend/src/js/component/wb-container-request-fields.js +++ b/frontend/src/js/component/wb-container-request-fields.js @@ -34,7 +34,7 @@ class WBContainerRequestFields extends Component { [ 'Description', item.description || ({ String(item.description) }) ], [ 'Properties', ( - + ) ], [ 'State', item.state ], @@ -49,20 +49,20 @@ class WBContainerRequestFields extends Component { { Object.keys(item.mounts).map(k => ( - + )) } ) ], [ 'Runtime Constraints', ( - + ) ], [ 'Scheduling Parameters', ( - + ) ], [ 'Container Image', ( @@ -71,12 +71,12 @@ class WBContainerRequestFields extends Component { [ 'Environment', ( - + ) ], [ 'Working Directory', item.cwd ], [ 'Command', ( - + ) ], [ 'Output Path', item.output_path ], [ 'Output Name', item.output_name ], @@ -91,7 +91,7 @@ class WBContainerRequestFields extends Component { ) ], [ 'Filters', ( - item.filters ? () : ({ String(item.filters) }) + item.filters ? () : ({ String(item.filters) }) ) ], [ 'Runtime Token', item.runtime_token || ({ String(item.runtime_token) }) ], [ 'Runtime User', ( @@ -99,7 +99,7 @@ class WBContainerRequestFields extends Component { ) ], [ 'Runtime Auth Scopes', ( item.runtime_auth_scopes ? ( - + ) : ( { String(item.runtime_auth_scopes) } ) diff --git a/frontend/src/js/component/wb-json-viewer.js b/frontend/src/js/component/wb-json-viewer.js index a9fdd20..b12f32e 100644 --- a/frontend/src/js/component/wb-json-viewer.js +++ b/frontend/src/js/component/wb-json-viewer.js @@ -1,8 +1,56 @@ import { h, Component } from 'preact'; import WBIdTools from 'wb-id-tools'; import urlForObject from 'url-for-object'; +import makeArvadosRequest from 'make-arvados-request'; +import arvadosObjectName from 'arvados-object-name'; -function detectIds(value) { +class WBLazyInlineName extends Component { + fetchData() { + const { app, identifier } = this.props; + const { arvHost, arvToken } = app.state; + const typeName = WBIdTools.typeName(identifier); + if (WBIdTools.isPDH(identifier)) { + const filters = [ + [ 'portable_data_hash', '=', identifier ] + ]; + let prom = makeArvadosRequest(arvHost, arvToken, + '/arvados/v1/collections?filters=' + encodeURIComponent(JSON.stringify(filters))); + prom = prom.then(xhr => this.setState({ item: { + uuid: xhr.response.items.length > 0 ? xhr.response.items[0].uuid : '', + name: xhr.response.items.length > 0 ? xhr.response.items[0].name : 'Not Found' + + ( xhr.response.items_available > 1 ? ' (+' + (xhr.response.items_available - 1) + ' others)' : '' ) + }})); + return; + } + let prom = makeArvadosRequest(arvHost, arvToken, + '/arvados/v1/' + typeName + 's/' + identifier); + prom = prom.then(xhr => this.setState({ item: xhr.response })); + prom = prom.catch(() => this.setState({ item: { name: 'Not Found' }})); + } + + render({ identifier }, { item }) { + if (item) { + return ( + { arvadosObjectName(item) } + ); + } + + const typeName = WBIdTools.typeName(identifier); + const url = (typeName === 'group' ? '/browse/' + identifier : + typeName === 'collection' ? '/collection-browse/' + identifier : + urlForObject({ uuid: identifier })); + return ( + + { identifier } { e.preventDefault(); this.fetchData(); } }> + + + + ); + } +} + +function detectIds(value, app) { const matches = WBIdTools.detectIdentifiers(value); matches.sort((a, b) => (a.index - b.index)); const res = []; @@ -15,7 +63,7 @@ function detectIds(value) { typeName === 'collection' ? '/collection-browse/' + id : urlForObject({ uuid: id })); res.push(value.substring(ofs, index)); - res.push(h('a', { href: url }, id)); + res.push(h(WBLazyInlineName, { identifier: id, app }, id)); ofs = index + id.length; } res.push(value.substring(ofs)); @@ -23,11 +71,11 @@ function detectIds(value) { } class WBJsonViewer extends Component { - render({ value, stringify }) { + render({ value, stringify, app }) { if (stringify) value = JSON.stringify(value, null, 2); return ( -
{ detectIds(value) }
+
{ detectIds(value, app) }
); } } diff --git a/frontend/src/js/component/wb-workflow-fields.js b/frontend/src/js/component/wb-workflow-fields.js index 069e1fc..4e74eba 100644 --- a/frontend/src/js/component/wb-workflow-fields.js +++ b/frontend/src/js/component/wb-workflow-fields.js @@ -52,9 +52,9 @@ class WBWorkflowFields extends Component { - + - + { (() => { delete it['inputs']; @@ -64,7 +64,7 @@ class WBWorkflowFields extends Component { delete it['doc']; delete it['id']; return ( - + ); })() } @@ -78,7 +78,7 @@ class WBWorkflowFields extends Component { cardHeaderClass="card-header-sm"> { graph.map(it => ( - + )) }