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!
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

63 lignes
1.6KB

  1. import { h, Component } from 'preact';
  2. import makeArvadosRequest from 'make-arvados-request';
  3. import WBPagination from 'wb-pagination';
  4. class WBLiveLogs extends Component {
  5. constructor(...args) {
  6. super(...args);
  7. this.state.page = 0;
  8. }
  9. componentDidMount() {
  10. this.fetchData();
  11. }
  12. componentWillReceiveProps(nextProps) {
  13. if (nextProps.uuid === this.props.uuid);
  14. return;
  15. this.props = nextProps;
  16. this.state.page = 0;
  17. this.fetchData();
  18. }
  19. fetchData() {
  20. const { uuid, app, itemsPerPage } = this.props;
  21. const { page } = this.state;
  22. const { arvHost, arvToken } = app.state;
  23. const filters = [
  24. [ 'object_uuid', '=', uuid ]
  25. ];
  26. let prom = makeArvadosRequest(arvHost, arvToken,
  27. '/arvados/v1/logs?filters=' + encodeURIComponent(JSON.stringify(filters)) +
  28. '&offset=' + (itemsPerPage * page) +
  29. '&limit=' + itemsPerPage);
  30. prom = prom.then(xhr => {
  31. const { items } = xhr.response;
  32. this.setState({
  33. content: items
  34. .filter(a => ('text' in a.properties))
  35. .map(a => a.properties.text.trim()).join('\n'),
  36. numPages: Math.ceil(xhr.response.items_available / itemsPerPage)
  37. });
  38. });
  39. }
  40. render({}, { content, page, numPages }) {
  41. return (
  42. <div>
  43. <WBPagination activePage={ page } numPages={ numPages }
  44. onPageChanged={ page => { this.state.page = page; this.fetchData(); } } />
  45. <pre class="word-warp terminal">
  46. { content }
  47. </pre>
  48. </div>
  49. );
  50. }
  51. }
  52. WBLiveLogs.defaultProps = {
  53. itemsPerPage: 1000
  54. };
  55. export default WBLiveLogs;