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.

157 lines
4.3 KiB

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