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.

112 lines
2.8 KiB

3 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
  15. class="primary text-capitalize"
  16. @click="dialogCreate=true"
  17. >
  18. {{ $t('generic.create') }}
  19. </v-btn>
  20. <v-btn
  21. class="text-capitalize ms-2"
  22. :disabled="!isDeletable()"
  23. outlined
  24. @click="dialogDelete=true"
  25. >
  26. {{ $t('generic.delete') }}
  27. </v-btn>
  28. <v-dialog v-model="dialogCreate">
  29. <config-creation-form
  30. @onCreate="onCreate();dialogCreate=false"
  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="remove();dialogDelete=false"
  40. @cancel="dialogDelete=false"
  41. />
  42. </v-dialog>
  43. </div>
  44. </template>
  45. </v-data-table>
  46. </template>
  47. <script lang="ts">
  48. import Vue from 'vue'
  49. import { ConfigItemResponse } from '@/repositories/autoLabeling/config/apiConfigRepository'
  50. import ConfirmForm from '@/components/utils/ConfirmForm.vue'
  51. import ConfigCreationForm from './ConfigCreationForm.vue'
  52. import { ConfigItemList } from '~/domain/models/autoLabeling/config'
  53. export default Vue.extend({
  54. components: {
  55. ConfirmForm,
  56. ConfigCreationForm
  57. },
  58. data() {
  59. return {
  60. dialogCreate: false,
  61. dialogDelete: false,
  62. isLoading: false as Boolean,
  63. items: ConfigItemList.valueOf([]) as ConfigItemList,
  64. selected: [] as ConfigItemResponse[],
  65. headers: [
  66. {
  67. text: 'Model name',
  68. align: 'left',
  69. value: 'modelName',
  70. sortable: false
  71. }
  72. ]
  73. }
  74. },
  75. async created(): Promise<void> {
  76. this.isLoading = true
  77. this.items = await this.$services.config.list(this.$route.params.id)
  78. this.isLoading = false
  79. },
  80. methods: {
  81. async remove(): Promise<void> {
  82. this.isLoading = true
  83. const projectId = this.$route.params.id
  84. for (const item of this.selected) {
  85. await this.$services.config.delete(projectId, item.id)
  86. }
  87. this.items = await this.$services.config.list(projectId)
  88. this.selected = []
  89. this.isLoading = false
  90. },
  91. isDeletable(): boolean {
  92. return this.selected.length > 0
  93. },
  94. async onCreate() {
  95. this.isLoading = true
  96. this.items = await this.$services.config.list(this.$route.params.id)
  97. this.isLoading = false
  98. }
  99. }
  100. })
  101. </script>
  102. <style scoped>
  103. ::v-deep .v-dialog {
  104. width: 800px;
  105. }
  106. </style>