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!
Explorar el Código

Add wbProcessStateName for reuse.

pull/1/head
Stanislaw Adaszewski hace 4 años
padre
commit
49574a208a
Se han modificado 3 ficheros con 22 adiciones y 27 borrados
  1. +2
    -9
      frontend/src/js/component/wb-collection-fields.js
  2. +2
    -18
      frontend/src/js/component/wb-process-dashboard.js
  3. +18
    -0
      frontend/src/js/misc/wb-process-state-name.js

+ 2
- 9
frontend/src/js/component/wb-collection-fields.js Ver fichero

@@ -7,14 +7,7 @@ import urlForObject from 'url-for-object';
import wbFormatDate from 'wb-format-date';
import WBNameAndUuid from 'wb-name-and-uuid';
import WBAccordion from 'wb-accordion';
function formatSpecialValue(value) {
if (value === null) return (<i>null</i>);
if (value === undefined) return (<i>undefined</i>);
if (typeof(value) === 'boolean') return (<i>{ String(value) }</i>);
if (value === '') return '-';
return String(value);
}
import wbFormatSpecialValue from 'wb-format-special-value';
class WBCollectionFields extends Component {
componentDidMount() {
@@ -43,7 +36,7 @@ class WBCollectionFields extends Component {
throw Error('Item not found');
let rows = [
[ 'Name', item.name ],
[ 'Description', formatSpecialValue(item.description) ],
[ 'Description', wbFormatSpecialValue(item.description) ],
[ 'Properties', (
<WBAccordion names={ ['Properties'] } cardHeaderClass="card-header-sm">
<pre class="word-wrap">{ JSON.stringify(item.properties, null, 2) }</pre>


+ 2
- 18
frontend/src/js/component/wb-process-dashboard.js Ver fichero

@@ -1,6 +1,7 @@
import { h, Component } from 'preact';
import WBTable from 'wb-table';
import makeArvadosRequest from 'make-arvados-request';
import wbProcessStateName from 'wb-process-state-name';
function getAll(makeRequest) {
let prom = makeRequest(0);
@@ -20,23 +21,6 @@ function getAll(makeRequest) {
return prom;
}
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')
return 'Running';
if (c.state === 'Complete' && c.exit_code === 0)
return 'Complete';
if (c.state === 'Complete' && c.exit_code !== 0)
return 'Failed';
if (c.state === 'Cancelled')
return 'Cancelled';
}
class WBProcessDashboard extends Component {
constructor(...args) {
super(...args);
@@ -85,7 +69,7 @@ class WBProcessDashboard extends Component {
});
prom = prom.then(cl => {
cl.map(a => (crlist.find(b => (b.container_uuid === a.uuid)).container = a));
crlist.map(a => (a.wb_state = determineState(a)));
crlist.map(a => (a.wb_state = wbProcessStateName(a, a.container)));
const stats = {};
for (let state in { 'Pending': 1, 'Running': 1, 'Complete': 1, 'Failed': 1, 'Cancelled': 1 }) {
const f = crlist.filter(a => (a.wb_state === state));


+ 18
- 0
frontend/src/js/misc/wb-process-state-name.js Ver fichero

@@ -0,0 +1,18 @@
function wbProcessStateName(containerRequest, container) {
const cr = containerRequest;
const c = 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')
return 'Running';
if (c.state === 'Complete' && c.exit_code === 0)
return 'Complete';
if (c.state === 'Complete' && c.exit_code !== 0)
return 'Failed';
if (c.state === 'Cancelled')
return 'Cancelled';
}
export default wbProcessStateName;

Cargando…
Cancelar
Guardar