|
|
@@ -0,0 +1,56 @@ |
|
|
|
import { h, Component } from 'preact';
|
|
|
|
import makeArvadosRequest from 'make-arvados-request';
|
|
|
|
|
|
|
|
function getAll(makeRequest) {
|
|
|
|
let prom = makeRequest(0);
|
|
|
|
prom = prom.then(xhr => {
|
|
|
|
const { items, limit, items_available } = xhr.response;
|
|
|
|
let res = [].concat(items);
|
|
|
|
let prom_1 = new Promise(accept => accept());
|
|
|
|
for (let ofs = limit; ofs < items_available; ofs += limit) {
|
|
|
|
prom_1 = prom_1.then(() => makeRequest(ofs));
|
|
|
|
prom_1 = prom_1.then(xhr_1 => {
|
|
|
|
res = res.concat(xhr_1.response.items);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
prom_1 = prom_1.then(() => res);
|
|
|
|
return prom_1;
|
|
|
|
});
|
|
|
|
return prom;
|
|
|
|
}
|
|
|
|
|
|
|
|
class WBProcessDashboard extends Component {
|
|
|
|
fetchData() {
|
|
|
|
const { app, uuid } = this.props;
|
|
|
|
const { arvHost, arvToken } = app.state;
|
|
|
|
let prom = new Promise(accept => accept());
|
|
|
|
if (uuid) {
|
|
|
|
prom = prom.then(() => {
|
|
|
|
return makeArvadosRequest(arvHost, arvToken,
|
|
|
|
'/arvados/v1/container_requests/' + encodeURIComponent(uuid));
|
|
|
|
});
|
|
|
|
prom = prom.then(xhr => {
|
|
|
|
const cr = xhr.response;
|
|
|
|
return makeArvadosRequest(arvHost, arvToken,
|
|
|
|
'/arvados/v1/containers/' + encodeURIComponent(cr.container_uuid));
|
|
|
|
});
|
|
|
|
prom = prom.then(xhr => {
|
|
|
|
const c = xhr.response;
|
|
|
|
const filters = [ [ 'requesting_container_uuid', '=', c.uuid ] ];
|
|
|
|
return makeArvadosRequest(arvHost, arvToken,
|
|
|
|
'/arvados/v1/container_requests?filters=' +
|
|
|
|
encodeURIComponent(JSON.stringify(filters)));
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
prom = prom.then(() => {
|
|
|
|
return makeArvadosRequest(arvHost, arvToken,
|
|
|
|
'/arvados/v1/container_requests');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|