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!
Преглед изворни кода

Cleaning up WBProcessView.

master
Stanislaw Adaszewski пре 4 година
родитељ
комит
17a712bcce
2 измењених фајлова са 6 додато и 65 уклоњено
  1. +5
    -3
      frontend/src/js/component/wb-process-dashboard.js
  2. +1
    -62
      frontend/src/js/page/wb-process-view.js

+ 5
- 3
frontend/src/js/component/wb-process-dashboard.js Прегледај датотеку

@@ -23,6 +23,8 @@ function getAll(makeRequest) {
function determineState(containerRequest) {
const cr = containerRequest;
const c = cr.container;
if (cr.state !== 'Uncommitted' && cr.priority === 0)
return 'Cancelled';
if (cr.state === 'Uncommitted' || !c || c.state === 'Queued' || c.state === 'Locked')
return 'Pending';
if (c.state === 'Running')
@@ -90,7 +92,7 @@ class WBProcessDashboard extends Component {
if (state === 'Pending')
f.map(a => (a.wb_wait_time = (new Date() - new Date(a.created_at)) / 3.6e6));
else
f.map(a => (a.wb_wait_time = (new Date(a.container.started_at) - new Date(a.created_at)) / 3.6e6));
f.map(a => (a.wb_wait_time = Math.max(0, (a.container ? new Date(a.container.started_at) : new Date(0)) - new Date(a.created_at)) / 3.6e6));
f.sort((a, b) => (a.wb_wait_time - b.wb_wait_time));
stats[state]['Shortest Wait Time'] = f.length ? (f[0].wb_wait_time.toFixed(2) + ' hours') : '-';
stats[state]['Longest Wait Time'] = f.length ? (f[f.length - 1].wb_wait_time.toFixed(2) + ' hours') : '-';
@@ -99,7 +101,7 @@ class WBProcessDashboard extends Component {
else if (state === 'Running')
f.map(a => (a.wb_run_time = (new Date() - new Date(a.container.started_at)) / 3.6e6));
else
f.map(a => (a.wb_run_time = Math.max(0, new Date(a.container.finished_at) - new Date(a.container.started_at)) / 3.6e6));
f.map(a => (a.wb_run_time = Math.max(0, a.container ? new Date(a.container.finished_at) - new Date(a.container.started_at) : 0) / 3.6e6));
f.sort((a, b) => (a.wb_run_time - b.wb_run_time));
stats[state]['Shortest Run Time'] = f.length ? (f[0].wb_run_time.toFixed(2) + ' hours') : '-';
stats[state]['Longest Run Time'] = f.length ? (f[f.length - 1].wb_run_time.toFixed(2) + ' hours') : '-';
@@ -124,7 +126,7 @@ class WBProcessDashboard extends Component {
render({}, { rows }) {
return (
<WBTable columns={ [ '', 'Pending', 'Running', 'Complete', 'Failed', 'Cancelled' ] }
<WBTable columns={ [ 'State', 'Pending', 'Running', 'Complete', 'Failed', 'Cancelled' ] }
rows={ rows } verticalHeader={ true } />
);
}


+ 1
- 62
frontend/src/js/page/wb-process-view.js Прегледај датотеку

@@ -2,15 +2,10 @@ 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';
import detectHashes from 'detect-hashes';
import WBCommonFields from 'wb-common-fields';
import WBContainerRequestFields from 'wb-container-request-fields';
import WBProcessListing from 'wb-process-listing';
import WBProcessDashboard from 'wb-process-dashboard';
import wbFetchObjects from 'wb-fetch-objects';
class WBProcessView extends Component {
constructor(...args) {
@@ -39,55 +34,8 @@ class WBProcessView extends Component {
return prom_1;
}
});
//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 => wbFetchObjects(arvHost, arvToken, uuids));
/* prom = prom.then(() => {
// let uuids = detectUuids([ req, cont ]);
let objectTypes = uuids.map(u => arvadosTypeName(u) + 's');
//objectTypes = objectTypes.filter(ot => ot);
//objectTypes = objectTypes.map(ot => ot + '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 = Object.values(objects).map(o => urlForObject(o));
this.setState({
'objectUrls': urls,
'request': req,
'container': cont
});
@@ -104,7 +52,7 @@ class WBProcessView extends Component {
this.fetchData();
}
render({ app, uuid, page }, { objectUrls, container }) {
render({ app, uuid, page }, { container }) {
return (
<div>
<WBNavbarCommon app={ app } />
@@ -132,15 +80,6 @@ class WBProcessView extends Component {
itemsPerPage="20"
activePage={ Number(page || 0) }
getPageUrl={ page => this.getUrl({ page }) } />
<div>
<a href="/browse">Click here</a>
</div>
<ul>
{ objectUrls.map(url => (
<li><a href={ url }>{ url }</a></li>
)) }
</ul>
</div>
);
}


Loading…
Откажи
Сачувај