project-settings-window.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <div class="project-settings-window">
  3. <h1>Project Settings</h1>
  4. <div class="content">
  5. <text-input placeholder="Name"
  6. :value="name"
  7. @input="nameF"
  8. :error="nameError"
  9. @clearError="nameError = false">
  10. Name
  11. </text-input>
  12. <textarea-input placeholder="Description"
  13. :value="description"
  14. @input="descriptionF"
  15. :error="descriptionError"
  16. @clearError="descriptionError = false">
  17. Description
  18. </textarea-input>
  19. <div class="features">
  20. The used model supports:
  21. <ul>
  22. <li v-for="(feature, key) in supports"
  23. v-bind:key="key">
  24. {{ feature }}
  25. </li>
  26. </ul>
  27. </div>
  28. <div class="text">Delete Project</div>
  29. <confirmed-button-input @click="deleteProject">
  30. <template v-slot:first>
  31. <button-input>
  32. Delete Project
  33. </button-input>
  34. </template>
  35. <template v-slot:second>
  36. <button-input type="error">
  37. Do you really want to delete this project? <br>
  38. This cannot be undone.
  39. </button-input>
  40. </template>
  41. </confirmed-button-input>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. import TextInput from "@/components/base/text-input";
  47. import TextareaInput from "@/components/base/textarea-input";
  48. import ConfirmedButtonInput from "@/components/base/confirmed-button-input";
  49. import ButtonInput from "@/components/base/button-input";
  50. export default {
  51. name: "project-settings-window",
  52. components: {ButtonInput, ConfirmedButtonInput, TextareaInput, TextInput},
  53. props: ['currentProject', 'socket'],
  54. data: function () {
  55. return {
  56. project: null,
  57. name: '',
  58. nameError: false,
  59. description: '',
  60. descriptionError: false
  61. }
  62. },
  63. computed: {
  64. path: function () {
  65. return '/projects/' + this.currentProject.id;
  66. },
  67. supports: function () {
  68. const supported = {
  69. 'bounding-boxes': 'bounding boxes',
  70. 'labeled-bounding-boxes': 'labeled bounding boxes',
  71. 'labeled-images': 'labeled images',
  72. 'fit': 'fit new data'
  73. };
  74. return this.currentProject.model.supports.map(k => k in supported ? supported[k] : 'unknown feature');
  75. }
  76. },
  77. methods: {
  78. nameF: function (value) {
  79. // TODO then / error
  80. this.socket.post(this.path, {
  81. name: value
  82. });
  83. },
  84. descriptionF: function (value) {
  85. // TODO then / error
  86. this.socket.post(this.path, {
  87. description: value
  88. });
  89. },
  90. deleteProject: function () {
  91. // TODO then / error
  92. this.socket.post(this.path, {
  93. delete: true
  94. });
  95. this.$emit('close', true);
  96. }
  97. },
  98. created: function () {
  99. this.name = this.currentProject.name;
  100. this.description = this.currentProject.description;
  101. }
  102. }
  103. </script>
  104. <style scoped>
  105. .project-settings-window {
  106. padding: 1rem;
  107. }
  108. h1 {
  109. margin: 0;
  110. font-family: "Roboto Condensed";
  111. text-overflow: ellipsis;
  112. width: 100%;
  113. white-space: nowrap;
  114. overflow: hidden;
  115. }
  116. .content {
  117. overflow: auto;
  118. flex-grow: 1;
  119. }
  120. .content > * {
  121. margin-bottom: 0.6rem;
  122. }
  123. .content > div.text {
  124. margin-bottom: 0.2rem;
  125. font-size: 80%;
  126. }
  127. .features {
  128. font-size: 80%;
  129. }
  130. .features ul {
  131. margin-top: 0.4rem;
  132. }
  133. /deep/ .content textarea {
  134. height: 4rem;
  135. }
  136. </style>