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.

107 lines
2.6 KiB

3 years ago
3 years ago
  1. <template>
  2. <v-stepper-content step="1">
  3. <v-card>
  4. <v-card-text class="pa-0">
  5. <v-form ref="form" v-model="valid">
  6. <h4 class="text-h6">Select a config template</h4>
  7. <p class="font-weight-regular body-1">
  8. You can select the template to create the auto-labeling configuration.{{ valid }}
  9. </p>
  10. <v-select
  11. v-model="selectedTask"
  12. :items="taskNames"
  13. label="Select a task name"
  14. outlined
  15. />
  16. <v-select
  17. v-model="templateName"
  18. :items="templateNames"
  19. :rules="templateNameRules()"
  20. label="Select a config template"
  21. outlined
  22. />
  23. </v-form>
  24. </v-card-text>
  25. <v-card-actions class="pa-0">
  26. <v-spacer />
  27. <v-btn
  28. :disabled="!valid"
  29. color="primary"
  30. class="text-capitalize"
  31. @click="$emit('next')"
  32. >
  33. Next
  34. </v-btn>
  35. </v-card-actions>
  36. </v-card>
  37. </v-stepper-content>
  38. </template>
  39. <script lang="ts">
  40. import Vue from 'vue'
  41. import { templateNameRules } from '@/rules/index'
  42. import { ProjectDTO } from '~/services/application/project/projectData'
  43. export default Vue.extend({
  44. data() {
  45. return {
  46. project: {} as ProjectDTO,
  47. selectedTask: '',
  48. templateName: null,
  49. templateNames: [] as string[],
  50. templateNameRules,
  51. valid: false
  52. }
  53. },
  54. computed: {
  55. projectId() {
  56. return this.$route.params.id
  57. },
  58. taskNames(): string[] {
  59. return this.project.taskNames
  60. },
  61. taskType(): string {
  62. return {
  63. DocumentClassification: 'Category',
  64. SequenceLabeling : 'Span',
  65. Seq2seq : 'Text',
  66. ImageClassification : 'Category',
  67. Speech2text : 'Text',
  68. }[this.selectedTask]!
  69. }
  70. },
  71. watch: {
  72. async templateName(val) {
  73. if (val) {
  74. const response = await this.$services.template.find(this.projectId, val)
  75. const field = response.toObject()
  76. field.taskType = this.taskType
  77. this.$emit('input', field)
  78. }
  79. },
  80. async selectedTask() {
  81. this.templateName = null
  82. await this.fetchTemplateNames()
  83. // @ts-ignore
  84. this.$refs.form.resetValidation()
  85. }
  86. },
  87. async created() {
  88. this.project = await this.$services.project.findById(this.projectId)
  89. this.selectedTask = this.taskNames[0]
  90. await this.fetchTemplateNames()
  91. },
  92. methods: {
  93. async fetchTemplateNames() {
  94. this.templateNames = await this.$services.template.list(this.projectId, this.selectedTask)
  95. }
  96. }
  97. })
  98. </script>