IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Parcourir la source

Added UUID detection.

pull/1/head
Stanislaw Adaszewski il y a 4 ans
Parent
révision
429223bb67
4 fichiers modifiés avec 116 ajouts et 3 suppressions
  1. +3
    -1
      frontend/src/js/misc/arvados-type-name.js
  2. +27
    -0
      frontend/src/js/misc/detect-uuids.js
  3. +19
    -0
      frontend/src/js/misc/url-for-object.js
  4. +67
    -2
      frontend/src/js/page/wb-process-view.js

+ 3
- 1
frontend/src/js/misc/arvados-type-name.js Voir le fichier

@@ -3,7 +3,9 @@ const typeIdToName = {
'j7d0g': 'group',
'xvhdp': 'container_request',
'dz642': 'container',
'7fd4e': 'workflow'
'7fd4e': 'workflow',
'ozdt8': 'api_client',
'4zz18': 'collection'
};
function arvadosTypeName(id) {


+ 27
- 0
frontend/src/js/misc/detect-uuids.js Voir le fichier

@@ -0,0 +1,27 @@
function detectUuids(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-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}/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 detectUuids;

+ 19
- 0
frontend/src/js/misc/url-for-object.js Voir le fichier

@@ -0,0 +1,19 @@
import arvadosTypeName from 'arvados-type-name';
function urlForObject(item) {
let objectType = arvadosTypeName(item.uuid.split('-')[1]);
if (objectType === 'user')
return ('/browse/' + item.uuid);
else if (objectType === 'group' && item.group_class === 'project')
return ('/browse/' + item.uuid);
else if (objectType === 'container_request')
return ('/process/' + item.uuid);
else if (objectType === 'workflow')
return ('https://wb.arkau.roche.com/workflows/' + item.uuid);
else if (objectType === 'collection')
return ('https://wb.arkau.roche.com/collections/' + item.uuid);
else if (objectType === 'container')
return ('https://wb.arkau.roche.com/containers/' + item.uuid);
}
export default urlForObject;

+ 67
- 2
frontend/src/js/page/wb-process-view.js Voir le fichier

@@ -1,16 +1,81 @@
import { h, Component } from 'preact';
import WBNavbarCommon from 'wb-navbar-common';
import WBArvadosCrumbs from 'wb-arvados-crumbs';
import makeArvadosRequest from 'make-arvados-request';
import detectUuids from 'detect-uuids';
import arvadosTypeName from 'arvados-type-name';
import urlForObject from 'url-for-object';
class WBProcessView extends Component {
render({ app, uuid }) {
constructor(...args) {
super(...args);
this.state.objectUrls = [];
}
componentDidMount() {
let { arvHost, arvToken } = this.props.app.state;
let prom = makeArvadosRequest(arvHost, arvToken,
'/arvados/v1/container_requests/' + this.props.uuid);
let req;
let cont;
prom = prom.then(xhr => {
req = xhr.response;
if (req.container_uuid) {
let prom_1 = makeArvadosRequest(arvHost, arvToken,
'/arvados/v1/containers/' + req.container_uuid);
prom_1 = prom_1.then(xhr => (cont = xhr.response));
return prom_1;
}
});
//prom = prom.then(xhr => (cont = xhr.response));
prom = prom.then(() => {
let uuids = detectUuids([ req, cont ]);
let objectTypes = uuids.map(u => arvadosTypeName(u.split('-')[1]) + 's');
let objQueries = {};
objectTypes.map(t => (objQueries[t] = []));
uuids.map((u, idx) => (objQueries[objectTypes[idx]].push(u)));
let prom_1 = new Promise(accept => accept());
let objects = [];
// delete objQueries['users'];
delete objQueries['api_clients'];
for (let k in objQueries) {
let filters = [
['uuid', 'in', objQueries[k]]
];
prom_1 = prom_1.then(() => makeArvadosRequest(arvHost, arvToken,
'/arvados/v1/' + k + '?filters=' +
encodeURIComponent(JSON.stringify(filters))));
prom_1 = prom_1.then(xhr => (objects = objects.concat(xhr.response['items'])));
}
prom_1 = prom_1.then(() => objects);
return prom_1;
});
prom = prom.then(objects => {
let objDict = {};
objects.map(o => (objDict[o['uuid']] = o));
let urls = objects.map(o => urlForObject(o));
this.setState({ 'objectUrls': urls });
});
}
render({ app, uuid }, { objectUrls }) {
return (
<div>
<WBNavbarCommon app={ app } />
<WBArvadosCrumbs app={ app } uuid={ uuid } />
<div class="my-2">This is the process view for { uuid }</div>
<div class="my-2">
This is the process view for { uuid }
</div>
<div>
<a href="/browse">Click here</a>
</div>
<ul>
{ objectUrls.map(url => (
<li><a href={ url }>{ url }</a></li>
)) }
</ul>
</div>
);
}


Chargement…
Annuler
Enregistrer