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!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wb-container-fields.js 3.8KB

4 年之前
4 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import { h, Component } from 'preact';
  2. import WBTable from 'wb-table';
  3. import makeArvadosRequest from 'make-arvados-request';
  4. import arvadosTypeName from 'arvados-type-name';
  5. import arvadosObjectName from 'arvados-object-name';
  6. import urlForObject from 'url-for-object';
  7. import wbFormatDate from 'wb-format-date';
  8. import WBNameAndUuid from 'wb-name-and-uuid';
  9. import WBAccordion from 'wb-accordion';
  10. class WBContainerFields extends Component {
  11. componentDidMount() {
  12. this.prepareRows();
  13. }
  14. componentWillReceiveProps(nextProps) {
  15. this.props = nextProps;
  16. this.prepareRows();
  17. }
  18. prepareRows() {
  19. let { uuid, app } = this.props;
  20. let { arvHost, arvToken } = app.state;
  21. let item;
  22. let prom = makeArvadosRequest(arvHost, arvToken,
  23. '/arvados/v1/containers/' + uuid);
  24. prom = prom.then(xhr => (item = xhr.response));
  25. prom = prom.then(() => {
  26. let rows = [
  27. [ 'State', item.state ],
  28. [ 'Started At', wbFormatDate(item.started_at) ],
  29. [ 'Finished At', wbFormatDate(item.started_at) ],
  30. [ 'Log', item.log ? (
  31. <WBNameAndUuid app={ app } uuid={ item.log } />
  32. ) : ( <i>{ String(item.log) }</i> ) ],
  33. [ 'Environment', (
  34. <WBAccordion names={ ['Environment'] }
  35. cardHeaderClass="card-header-sm">
  36. <pre class="word-wrap">{ JSON.stringify(item.environment, null, 2) }</pre>
  37. </WBAccordion>
  38. ) ],
  39. [ 'Working Directory', item.cwd ],
  40. [ 'Command', (
  41. <pre class="word-wrap">{ JSON.stringify(item.command) }</pre>
  42. ) ],
  43. [ 'Output Path', item.output_path ],
  44. [ 'Mounts', (
  45. <WBAccordion names={ Object.keys(item.mounts) }
  46. cardHeaderClass="card-header-sm">
  47. { Object.keys(item.mounts).map(k => (
  48. <pre class="word-wrap">{ JSON.stringify(item.mounts[k], null, 2) }</pre>
  49. )) }
  50. </WBAccordion>
  51. ) ],
  52. [ 'Runtime Constraints', (
  53. <WBAccordion names={ ['Runtime Constraints'] }
  54. cardHeaderClass="card-header-sm">
  55. <pre class="word-wrap">{ JSON.stringify(item.runtime_constraints, null, 2) }</pre>
  56. </WBAccordion>
  57. ) ],
  58. [ 'Runtime Status', (
  59. <WBAccordion names={ ['Runtime Status'] }
  60. cardHeaderClass="card-header-sm">
  61. <pre class="word-wrap">{ JSON.stringify(item.runtime_status, null, 2) }</pre>
  62. </WBAccordion>
  63. ) ],
  64. [ 'Scheduling Parameters', (
  65. <WBAccordion names={ ['Scheduling Parameters'] }
  66. cardHeaderClass="card-header-sm">
  67. <pre class="word-wrap">{ JSON.stringify(item.scheduling_parameters, null, 2) }</pre>
  68. </WBAccordion>
  69. ) ],
  70. [ 'Output', item.output ? (
  71. <WBNameAndUuid app={ app } uuid={ item.output } />
  72. ) : ( <i>{ String(item.output) }</i> )],
  73. [ 'Container Image', (
  74. <WBNameAndUuid app={ app } uuid={ item.container_image } />
  75. ) ],
  76. [ 'Progress', item.progress ],
  77. [ 'Priority', item.priority ],
  78. [ 'Exit Code', item.exit_code === null ? ( <i>null</i> ) : item.exit_code ],
  79. [ 'Auth UUID', item.auth_uuid === null ? ( <i>null</i> ) : item.auth_uuid ],
  80. [ 'Locked by UUID', item.locked_by_uuid === null ? ( <i>null</i> ) : item.locked_by_uuid ]
  81. ];
  82. rows = rows.map(r => [r[0], r[1] ? r[1] : (<i>{ String(r[1]) }</i>)]);
  83. this.setState({ 'rows': rows });
  84. });
  85. }
  86. render({}, { rows }) {
  87. return (
  88. rows ? (
  89. <WBTable columns={ [ "Name", "Value" ] }
  90. headerClasses={ [ "col-sm-2", "col-sm-4" ] }
  91. rows={ rows }
  92. verticalHeader={ true } />
  93. ) : (
  94. <div>Loading...</div>
  95. )
  96. );
  97. }
  98. }
  99. export default WBContainerFields;