6
0

general-settings.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div class="general-settings">
  3. <text-input placeholder="Project ID"
  4. :value="projectId"
  5. readonly="readonly">
  6. Project ID
  7. </text-input>
  8. <text-input placeholder="Project Root"
  9. :value="$root.project.root_folder"
  10. readonly="readonly">
  11. Project Root
  12. </text-input>
  13. <text-input placeholder="Data Root"
  14. :value="$root.project.data_folder"
  15. readonly="readonly">
  16. Data Root
  17. </text-input>
  18. <text-input placeholder="Name"
  19. :value="name"
  20. @change="sendName"
  21. :error="nameError"
  22. @clearError="nameError = false">
  23. Name
  24. </text-input>
  25. <textarea-input placeholder="Description"
  26. :value="description"
  27. @change="sendDescription"
  28. :error="descriptionError"
  29. @clearError="descriptionError = false">
  30. Description
  31. </textarea-input>
  32. <div class="text">Delete Project</div>
  33. <confirmed-button-input @click="deleteProject">
  34. <template v-slot:first>
  35. <button-input>
  36. Delete Project
  37. </button-input>
  38. </template>
  39. <template v-slot:second>
  40. <button-input type="error">
  41. Do you really want to delete this project? <br>
  42. This cannot be undone.
  43. </button-input>
  44. </template>
  45. </confirmed-button-input>
  46. </div>
  47. </template>
  48. <script>
  49. import TextInput from "@/components/base/text-input";
  50. import TextareaInput from "@/components/base/textarea-input";
  51. import ConfirmedButtonInput from "@/components/base/confirmed-button-input";
  52. import ButtonInput from "@/components/base/button-input";
  53. export default {
  54. name: "general-settings",
  55. components: {ButtonInput, ConfirmedButtonInput, TextareaInput, TextInput},
  56. created: function () {
  57. this.name = this.$root.project.name;
  58. this.description = this.$root.project.description;
  59. console.log(this.$root.project);
  60. },
  61. data: function () {
  62. return {
  63. name: '',
  64. nameError: false,
  65. description: '',
  66. descriptionError: false,
  67. }
  68. },
  69. methods: {
  70. sendName: function (value) {
  71. this.name = value;
  72. // check input
  73. if (!value) {
  74. this.nameError = true;
  75. return;
  76. }
  77. // TODO then / error
  78. this.$root.socket.post(`/projects/${this.projectId}/name`, {name: value});
  79. },
  80. sendDescription: function (value) {
  81. this.description = value;
  82. // check input
  83. console.log(value, !value);
  84. if (!value) {
  85. this.descriptionError = true;
  86. return;
  87. }
  88. // TODO then / error
  89. this.$root.socket.post(`/projects/${this.projectId}/description`, {description: value});
  90. },
  91. deleteProject: function () {
  92. // TODO then / error
  93. this.$root.socket.post(`/projects/${this.projectId}/remove`, {remove: true})
  94. }
  95. },
  96. computed: {
  97. projectId: function () {
  98. return this.$root.project.identifier;
  99. }
  100. }
  101. }
  102. </script>
  103. <style scoped>
  104. .general-settings > * {
  105. margin-bottom: 0.4rem;
  106. }
  107. .general-settings > :last-child {
  108. margin-bottom: 0;
  109. }
  110. .general-settings .text {
  111. font-size: 80%;
  112. margin-bottom: 0.1rem;
  113. }
  114. </style>