diff --git a/frontend/src/js/misc/detect-hashes.js b/frontend/src/js/misc/detect-hashes.js new file mode 100644 index 0000000..cffce2e --- /dev/null +++ b/frontend/src/js/misc/detect-hashes.js @@ -0,0 +1,27 @@ +function detectHashes(obj) { + let Q = [ obj ]; + let matches = {}; + + while (Q.length > 0) { + let item = Q.pop(); + + if (!item) + continue; + + if (typeof(item) === 'string') { + // use regexes + let rx = /[a-f0-9]{32}\+[0-9]+/g; + for (let m = rx.exec(item); m; m = rx.exec(item)) + matches[m[0]] = true; + + } else if (typeof(item) === 'object') { + Object.keys(item).map(k => Q.push(item[k])); + } + } + + matches = Object.keys(matches); + + return matches; +} + +export default detectHashes; diff --git a/frontend/src/js/page/wb-process-view.js b/frontend/src/js/page/wb-process-view.js index 8e05b3c..456f722 100644 --- a/frontend/src/js/page/wb-process-view.js +++ b/frontend/src/js/page/wb-process-view.js @@ -5,6 +5,7 @@ import makeArvadosRequest from 'make-arvados-request'; import detectUuids from 'detect-uuids'; import arvadosTypeName from 'arvados-type-name'; import urlForObject from 'url-for-object'; +import detectHashes from 'detect-hashes'; class WBProcessView extends Component { constructor(...args) { @@ -29,7 +30,24 @@ class WBProcessView extends Component { }); //prom = prom.then(xhr => (cont = xhr.response)); prom = prom.then(() => { + let hashes = detectHashes([ req, cont ]); + let filters = [ + [ 'portable_data_hash', 'in', hashes ] + ]; + return makeArvadosRequest(arvHost, arvToken, + '/arvados/v1/collections?filters=' + + encodeURIComponent(JSON.stringify(filters))); + }); + prom = prom.then(xhr => { + let colUuids = xhr.response['items'].map(item => item.uuid); let uuids = detectUuids([ req, cont ]); + let dict = {}; + colUuids.map(u => (dict[u] = true)); + uuids.map(u => (dict[u] = true)); + return Object.keys(dict); + }); + prom = prom.then(uuids => { + // let uuids = detectUuids([ req, cont ]); let objectTypes = uuids.map(u => arvadosTypeName(u.split('-')[1]) + 's'); let objQueries = {}; objectTypes.map(t => (objQueries[t] = []));