From 17a712bccedbb5f65e944f2817e58f58f1bc6853 Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Wed, 1 Apr 2020 21:51:10 +0200 Subject: [PATCH] Cleaning up WBProcessView. --- .../src/js/component/wb-process-dashboard.js | 8 ++- frontend/src/js/page/wb-process-view.js | 63 +------------------ 2 files changed, 6 insertions(+), 65 deletions(-) diff --git a/frontend/src/js/component/wb-process-dashboard.js b/frontend/src/js/component/wb-process-dashboard.js index bc02f24..abdf85b 100644 --- a/frontend/src/js/component/wb-process-dashboard.js +++ b/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 ( - ); } diff --git a/frontend/src/js/page/wb-process-view.js b/frontend/src/js/page/wb-process-view.js index 0ff4b3f..f89f712 100644 --- a/frontend/src/js/page/wb-process-view.js +++ b/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 (
@@ -132,15 +80,6 @@ class WBProcessView extends Component { itemsPerPage="20" activePage={ Number(page || 0) } getPageUrl={ page => this.getUrl({ page }) } /> - -
- Click here -
-
    - { objectUrls.map(url => ( -
  • { url }
  • - )) } -
); }