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.

154 lines
4.2 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <v-stepper
  3. v-model="step.count"
  4. >
  5. <v-overlay :value="isLoading">
  6. <v-progress-circular indeterminate size="64" />
  7. </v-overlay>
  8. <config-header :step="step.count" />
  9. <config-template-name
  10. v-model="fields"
  11. @next="step.next()"
  12. />
  13. <config-parameters
  14. v-if="fields.modelAttrs !== undefined"
  15. v-model="fields.modelAttrs"
  16. :is-passed="passTesting.parameter"
  17. :error-messages="errors"
  18. :response="response.parameter"
  19. @prev="step.prev()"
  20. @next="step.next()"
  21. @onTest="testParameters"
  22. />
  23. <config-template
  24. v-model="fields.template"
  25. :is-passed="passTesting.template"
  26. :error-messages="errors"
  27. :response="response.parameter"
  28. :result="response.template"
  29. @prev="step.prev()"
  30. @next="step.next()"
  31. @onTest="testTemplate"
  32. />
  33. <config-label-mapping
  34. v-model="fields.labelMapping"
  35. :is-passed="passTesting.mapping"
  36. :error-messages="errors"
  37. :response="response.template"
  38. :result="response.mapping"
  39. @prev="step.prev()"
  40. @next="saveConfig"
  41. @onTest="testMapping"
  42. />
  43. </v-stepper>
  44. </template>
  45. <script lang="ts">
  46. import Vue from 'vue'
  47. import { StepCounter } from '@/domain/models/utils/stepper'
  48. import ConfigHeader from './form/ConfigHeader.vue'
  49. import ConfigTemplateName from './form/ConfigTemplateName.vue'
  50. import ConfigTemplate from './form/ConfigTemplate.vue'
  51. import ConfigParameters from './form/ConfigParameters.vue'
  52. import ConfigLabelMapping from './form/ConfigLabelMapping.vue'
  53. import { ConfigItem, Fields } from '~/domain/models/autoLabeling/config'
  54. export default Vue.extend({
  55. components: {
  56. ConfigHeader,
  57. ConfigLabelMapping,
  58. ConfigParameters,
  59. ConfigTemplate,
  60. ConfigTemplateName
  61. },
  62. data() {
  63. return {
  64. config: {} as ConfigItem,
  65. errors: [] as string[],
  66. fields: {} as Fields,
  67. isLoading: false,
  68. step: new StepCounter(),
  69. passTesting: {
  70. parameter: false,
  71. template: false,
  72. mapping: false
  73. },
  74. response: {
  75. parameter: [],
  76. template: [],
  77. mapping: []
  78. }
  79. }
  80. },
  81. watch: {
  82. 'fields.modelName'() {
  83. this.passTesting = {parameter: false, template: false, mapping: false}
  84. },
  85. 'fields.modelAttrs': {
  86. handler() {
  87. this.passTesting = {parameter: false, template: false, mapping: false}
  88. },
  89. deep: true
  90. },
  91. 'fields.template'() {
  92. this.passTesting = {parameter: true, template: false, mapping: false}
  93. },
  94. 'fields.labelMapping': {
  95. handler() {
  96. this.passTesting = {parameter: true, template: true, mapping: false}
  97. },
  98. deep: true
  99. },
  100. },
  101. methods: {
  102. testConfig(promise: Promise<any>, key: 'parameter'|'template'|'mapping') {
  103. this.isLoading = true
  104. promise.then((value) => {
  105. this.response[key] = value
  106. this.passTesting[key] = true
  107. this.errors = []
  108. }).catch((error) => {
  109. this.errors = [error.message]
  110. }).finally(() => {
  111. this.isLoading = false
  112. })
  113. },
  114. testParameters(text: string) {
  115. const projectId = this.$route.params.id
  116. const item = ConfigItem.parseFromUI(this.fields)
  117. const promise = this.$services.config.testParameters(projectId, item, text)
  118. this.testConfig(promise, 'parameter')
  119. },
  120. testTemplate() {
  121. const projectId = this.$route.params.id
  122. const item = ConfigItem.parseFromUI(this.fields)
  123. const promise = this.$services.config.testTemplate(projectId, this.response.parameter, item)
  124. this.testConfig(promise, 'template')
  125. },
  126. testMapping() {
  127. const projectId = this.$route.params.id
  128. const item = ConfigItem.parseFromUI(this.fields)
  129. const promise = this.$services.config.testMapping(projectId, item, this.response.template)
  130. this.testConfig(promise, 'mapping')
  131. },
  132. saveConfig() {
  133. const projectId = this.$route.params.id
  134. const item = ConfigItem.parseFromUI(this.fields)
  135. this.isLoading = true
  136. this.$services.config.save(projectId, item)
  137. .then(() => {
  138. this.step.first()
  139. this.$emit('onCreate')
  140. })
  141. .finally(() => {
  142. this.isLoading = false
  143. })
  144. }
  145. }
  146. })
  147. </script>