@@ -7,14 +7,7 @@ import urlForObject from 'url-for-object'; | |||||
import wbFormatDate from 'wb-format-date'; | import wbFormatDate from 'wb-format-date'; | ||||
import WBNameAndUuid from 'wb-name-and-uuid'; | import WBNameAndUuid from 'wb-name-and-uuid'; | ||||
import WBAccordion from 'wb-accordion'; | 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 { | class WBCollectionFields extends Component { | ||||
componentDidMount() { | componentDidMount() { | ||||
@@ -43,7 +36,7 @@ class WBCollectionFields extends Component { | |||||
throw Error('Item not found'); | throw Error('Item not found'); | ||||
let rows = [ | let rows = [ | ||||
[ 'Name', item.name ], | [ 'Name', item.name ], | ||||
[ 'Description', formatSpecialValue(item.description) ], | |||||
[ 'Description', wbFormatSpecialValue(item.description) ], | |||||
[ 'Properties', ( | [ 'Properties', ( | ||||
<WBAccordion names={ ['Properties'] } cardHeaderClass="card-header-sm"> | <WBAccordion names={ ['Properties'] } cardHeaderClass="card-header-sm"> | ||||
<pre class="word-wrap">{ JSON.stringify(item.properties, null, 2) }</pre> | <pre class="word-wrap">{ JSON.stringify(item.properties, null, 2) }</pre> | ||||
@@ -1,6 +1,7 @@ | |||||
import { h, Component } from 'preact'; | import { h, Component } from 'preact'; | ||||
import WBTable from 'wb-table'; | import WBTable from 'wb-table'; | ||||
import makeArvadosRequest from 'make-arvados-request'; | import makeArvadosRequest from 'make-arvados-request'; | ||||
import wbProcessStateName from 'wb-process-state-name'; | |||||
function getAll(makeRequest) { | function getAll(makeRequest) { | ||||
let prom = makeRequest(0); | let prom = makeRequest(0); | ||||
@@ -20,23 +21,6 @@ function getAll(makeRequest) { | |||||
return prom; | 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 { | class WBProcessDashboard extends Component { | ||||
constructor(...args) { | constructor(...args) { | ||||
super(...args); | super(...args); | ||||
@@ -85,7 +69,7 @@ class WBProcessDashboard extends Component { | |||||
}); | }); | ||||
prom = prom.then(cl => { | prom = prom.then(cl => { | ||||
cl.map(a => (crlist.find(b => (b.container_uuid === a.uuid)).container = a)); | 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 = {}; | const stats = {}; | ||||
for (let state in { 'Pending': 1, 'Running': 1, 'Complete': 1, 'Failed': 1, 'Cancelled': 1 }) { | for (let state in { 'Pending': 1, 'Running': 1, 'Complete': 1, 'Failed': 1, 'Cancelled': 1 }) { | ||||
const f = crlist.filter(a => (a.wb_state === state)); | const f = crlist.filter(a => (a.wb_state === state)); | ||||
@@ -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; |