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.

74 lignes
2.3KB

  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, createRef } from 'preact';
  8. import WBDialog from 'wb-dialog';
  9. import linkState from 'linkstate';
  10. import makeArvadosRequest from 'make-arvados-request';
  11. class WBNewProjectDialog extends Component {
  12. constructor(...args) {
  13. super(...args);
  14. this.dialogRef = createRef();
  15. this.state.inputId = uuid.v4();
  16. }
  17. show(ownerUuid, callback) {
  18. const { inputId } = this.state;
  19. this.setState({
  20. 'ownerUuid': ownerUuid,
  21. 'newName': null,
  22. 'placeholderName': 'New Project (' + (new Date()).toISOString() + ')',
  23. 'callback': callback || (() => {})
  24. });
  25. this.dialogRef.current.show();
  26. $('#' + inputId).focus();
  27. }
  28. hide() {
  29. this.dialogRef.current.hide();
  30. }
  31. render({ app }, { ownerUuid, newName, placeholderName, callback, inputId,
  32. projectDescription }) {
  33. const { arvHost, arvToken } = app.state;
  34. return (
  35. <WBDialog title="New Project" ref={ this.dialogRef } accept={ () => {
  36. const group = {
  37. 'group_class': 'project',
  38. 'name': newName || placeholderName,
  39. 'description': projectDescription || null,
  40. 'owner_uuid': ownerUuid
  41. };
  42. makeArvadosRequest(arvHost, arvToken,
  43. '/arvados/v1/groups', { 'method': 'POST',
  44. 'data': JSON.stringify(group),
  45. 'expectedStatus': [200, 202] }
  46. ).then(callback);
  47. } }>
  48. <div>
  49. <div class="form-group">
  50. <label for={ inputId }>Project Name</label>
  51. <input type="text" class="form-control" id={ inputId }
  52. placeholder={ placeholderName }
  53. value={ newName } onChange={ linkState(this, 'newName') } />
  54. </div>
  55. <div class="form-group">
  56. <label for="projectDescription">Project Description (optional)</label>
  57. <input type="text" class="form-control" id="projectDescription"
  58. placeholder="Project Description (optional)"
  59. value={ projectDescription } onChange={ linkState(this, 'projectDescription') } />
  60. </div>
  61. </div>
  62. </WBDialog>
  63. );
  64. }
  65. }
  66. export default WBNewProjectDialog;