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!
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

wb-project-fields.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // Copyright (C) Stanislaw Adaszewski, 2020
  3. // Contact: s.adaszewski@gmail.com
  4. // Website: https://adared.ch/wba
  5. // License: GNU Affero General Public License, Version 3
  6. //
  7. import { h, Component } from 'preact';
  8. import WBTable from 'wb-table';
  9. import makeArvadosRequest from 'make-arvados-request';
  10. import WBAccordion from 'wb-accordion';
  11. import WBJsonViewer from 'wb-json-viewer';
  12. import wbFormatSpecialValue from 'wb-format-special-value';
  13. import WBLazyInlineName from 'wb-lazy-inline-name';
  14. import wbFormatDate from 'wb-format-date';
  15. import wbUpdateField from 'wb-update-field';
  16. import WBJsonEditor from 'wb-json-editor';
  17. class WBProjectFields extends Component {
  18. componentDidMount() {
  19. this.fetchData();
  20. }
  21. componentWillReceiveProps(nextProps) {
  22. this.props = nextProps;
  23. this.fetchData();
  24. }
  25. prepareRows(item) {
  26. const { app } = this.props;
  27. const { arvHost, arvToken } = app.state;
  28. const rows = [
  29. [ 'Name', wbFormatSpecialValue(item.name) ],
  30. [ 'Description', wbFormatSpecialValue(item.description) ],
  31. [ 'Properties', (
  32. <WBJsonEditor name="Properties" app={ app } value={ item.properties }
  33. onChange={ value => wbUpdateField(arvHost, arvToken, item.uuid, 'properties', value)
  34. .then(() => { item.properties = value; this.prepareRows(item); }) } />
  35. ) ],
  36. [ 'Writable by', item.writable_by
  37. .map(a => (<WBLazyInlineName app={ app } identifier={ a } />))
  38. .reduce((a, b) => [].concat(a).concat(', ').concat(b))
  39. ],
  40. [ 'Trash At', wbFormatDate(item.trash_at) ],
  41. [ 'Delete At', wbFormatDate(item.delete_at) ],
  42. [ 'Is Trashed', wbFormatSpecialValue(item.is_trashed) ]
  43. ];
  44. this.setState({ rows });
  45. }
  46. fetchData() {
  47. let { uuid, app } = this.props;
  48. let { arvHost, arvToken } = app.state;
  49. let prom = makeArvadosRequest(arvHost, arvToken,
  50. '/arvados/v1/groups/' + uuid);
  51. prom = prom.then(xhr => this.prepareRows(xhr.response));
  52. }
  53. render({}, { rows }) {
  54. return (
  55. rows ? (
  56. <WBTable columns={ [ "Name", "Value" ] }
  57. headerClasses={ [ "col-sm-2", "col-sm-4" ] }
  58. rows={ rows }
  59. verticalHeader={ true } />
  60. ) : (
  61. <div>Loading...</div>
  62. )
  63. );
  64. }
  65. }
  66. export default WBProjectFields;