You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
2.9 KiB

3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
  1. <template>
  2. <v-data-table
  3. v-model="selected"
  4. :headers="headers"
  5. :items="items.toArray()"
  6. :loading="isLoading"
  7. :no-data-text="$t('vuetify.noDataAvailable')"
  8. item-key="id"
  9. :loading-text="$t('generic.loading')"
  10. show-select
  11. >
  12. <template #top>
  13. <div class="ma-4">
  14. <v-btn class="primary text-capitalize" @click="dialogCreate = true">
  15. {{ $t('generic.create') }}
  16. </v-btn>
  17. <v-btn
  18. class="text-capitalize ms-2"
  19. :disabled="!isDeletable()"
  20. outlined
  21. @click="dialogDelete = true"
  22. >
  23. {{ $t('generic.delete') }}
  24. </v-btn>
  25. <v-dialog v-model="dialogCreate">
  26. <config-creation-form
  27. @onCreate="
  28. onCreate()
  29. dialogCreate = false
  30. "
  31. />
  32. </v-dialog>
  33. <v-dialog v-model="dialogDelete">
  34. <confirm-form
  35. :items="selected"
  36. title="Delete Config"
  37. message="Are you sure you want to delete these configs?"
  38. item-key="modelName"
  39. @ok="
  40. remove()
  41. dialogDelete = false
  42. "
  43. @cancel="dialogDelete = false"
  44. />
  45. </v-dialog>
  46. </div>
  47. </template>
  48. </v-data-table>
  49. </template>
  50. <script lang="ts">
  51. import Vue from 'vue'
  52. import { ConfigItemResponse } from '@/repositories/autoLabeling/config/apiConfigRepository'
  53. import ConfirmForm from '@/components/utils/ConfirmForm.vue'
  54. import ConfigCreationForm from './ConfigCreationForm.vue'
  55. import { ConfigItemList } from '~/domain/models/autoLabeling/config'
  56. export default Vue.extend({
  57. components: {
  58. ConfirmForm,
  59. ConfigCreationForm
  60. },
  61. data() {
  62. return {
  63. dialogCreate: false,
  64. dialogDelete: false,
  65. isLoading: false as Boolean,
  66. items: ConfigItemList.valueOf([]) as ConfigItemList,
  67. selected: [] as ConfigItemResponse[],
  68. headers: [
  69. {
  70. text: 'Model name',
  71. align: 'left',
  72. value: 'modelName',
  73. sortable: false
  74. }
  75. ]
  76. }
  77. },
  78. async created(): Promise<void> {
  79. this.isLoading = true
  80. this.items = await this.$services.config.list(this.$route.params.id)
  81. this.isLoading = false
  82. },
  83. methods: {
  84. async remove(): Promise<void> {
  85. this.isLoading = true
  86. const projectId = this.$route.params.id
  87. for (const item of this.selected) {
  88. await this.$services.config.delete(projectId, item.id)
  89. }
  90. this.items = await this.$services.config.list(projectId)
  91. this.selected = []
  92. this.isLoading = false
  93. },
  94. isDeletable(): boolean {
  95. return this.selected.length > 0
  96. },
  97. async onCreate() {
  98. this.isLoading = true
  99. this.items = await this.$services.config.list(this.$route.params.id)
  100. this.isLoading = false
  101. }
  102. }
  103. })
  104. </script>
  105. <style scoped>
  106. ::v-deep .v-dialog {
  107. width: 800px;
  108. }
  109. </style>