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.

133 lines
4.6KB

  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. import WBJsonViewer from 'wb-json-viewer';
  11. import wbUpdateField from 'wb-update-field';
  12. import WBJsonEditor from 'wb-json-editor';
  13. class WBContainerRequestFields extends Component {
  14. componentDidMount() {
  15. this.fetchData();
  16. }
  17. componentWillReceiveProps(nextProps) {
  18. this.props = nextProps;
  19. this.fetchData();
  20. }
  21. prepareRows(item) {
  22. const { app } = this.props;
  23. const { arvHost, arvToken } = app.state;
  24. let rows = [
  25. [ 'Name', item.name ],
  26. [ 'Description', item.description || (<i>{ String(item.description) }</i>) ],
  27. [ 'Properties', (
  28. <WBJsonEditor name="Properties" app={ app } value={ item.properties }
  29. onChange={ value => wbUpdateField(arvHost, arvToken, item.uuid, 'properties', value)
  30. .then(() => { item.properties = value; this.prepareRows(item); }) } />
  31. ) ],
  32. [ 'State', item.state ],
  33. [ 'Requesting Container', (
  34. <WBNameAndUuid app={ app } uuid={ item.requesting_container_uuid } />
  35. ) ],
  36. [ 'Container', (
  37. <WBNameAndUuid app={ app } uuid={ item.container_uuid } />
  38. ) ],
  39. [ 'Container Count Max', item.container_count_max ],
  40. [ 'Mounts', (
  41. <WBAccordion names={ Object.keys(item.mounts) }
  42. cardHeaderClass="card-header-sm">
  43. { Object.keys(item.mounts).map(k => (
  44. <WBJsonViewer app={ app } value={ item.mounts[k] } />
  45. )) }
  46. </WBAccordion>
  47. ) ],
  48. [ 'Runtime Constraints', (
  49. <WBAccordion names={ ['Runtime Constraints'] }
  50. cardHeaderClass="card-header-sm">
  51. <WBJsonViewer app={ app } value={ item.runtime_constraints } />
  52. </WBAccordion>
  53. ) ],
  54. [ 'Scheduling Parameters', (
  55. <WBAccordion names={ ['Scheduling Parameters'] }
  56. cardHeaderClass="card-header-sm">
  57. <WBJsonViewer app={ app } value={ item.scheduling_parameters } />
  58. </WBAccordion>
  59. ) ],
  60. [ 'Container Image', (
  61. <WBNameAndUuid app={ app } uuid={ item.container_image } />
  62. ) ],
  63. [ 'Environment', (
  64. <WBAccordion names={ ['Environment'] }
  65. cardHeaderClass="card-header-sm">
  66. <WBJsonViewer app={ app } value={ item.environment } />
  67. </WBAccordion>
  68. ) ],
  69. [ 'Working Directory', item.cwd ],
  70. [ 'Command', (
  71. <WBJsonViewer app={ app } value={ item.command } pretty={ false } />
  72. ) ],
  73. [ 'Output Path', item.output_path ],
  74. [ 'Output Name', item.output_name ],
  75. [ 'Output TTL', item.output_ttl ],
  76. [ 'Priority', item.priority ],
  77. [ 'Expires At', wbFormatDate(item.expires_at) ],
  78. [ 'Use Existing', String(item.use_existing) ],
  79. [ 'Log', (
  80. <WBNameAndUuid app={ app } uuid={ item.log_uuid } />
  81. ) ],
  82. [ 'Output', (
  83. <WBNameAndUuid app={ app } uuid={ item.output_uuid } />
  84. ) ],
  85. [ 'Filters', (
  86. item.filters ? (<WBJsonViewer app={ app } value={ item.filters } />) : (<i>{ String(item.filters) }</i>)
  87. ) ],
  88. [ 'Runtime Token', item.runtime_token || (<i>{ String(item.runtime_token) }</i>) ],
  89. [ 'Runtime User', (
  90. <WBNameAndUuid app={ app } uuid={ item.runtime_user } />
  91. ) ],
  92. [ 'Runtime Auth Scopes', (
  93. item.runtime_auth_scopes ? (
  94. <WBJsonViewer app={ app } value={ item.runtime_auth_scopes } />
  95. ) : (
  96. <i>{ String(item.runtime_auth_scopes) }</i>
  97. )
  98. ) ]
  99. ];
  100. rows = rows.map(r => [r[0], r[1] ? r[1] : (<i>{ String(r[1]) }</i>)]);
  101. this.setState({ rows });
  102. }
  103. fetchData() {
  104. let { uuid, app } = this.props;
  105. let { arvHost, arvToken } = app.state;
  106. let item;
  107. let prom = makeArvadosRequest(arvHost, arvToken,
  108. '/arvados/v1/container_requests/' + uuid);
  109. prom = prom.then(xhr => this.prepareRows(xhr.response));
  110. }
  111. render({}, { rows }) {
  112. return (
  113. rows ? (
  114. <WBTable columns={ [ "Name", "Value" ] }
  115. headerClasses={ [ "col-sm-2", "col-sm-4" ] }
  116. rows={ rows }
  117. verticalHeader={ true } />
  118. ) : (
  119. <div>Loading...</div>
  120. )
  121. );
  122. }
  123. }
  124. export default WBContainerRequestFields;