Browse Source

Remove config application service

pull/2148/head
Hironsan 1 year ago
parent
commit
cac9dbedb4
6 changed files with 26 additions and 97 deletions
  1. 24
      frontend/components/configAutoLabeling/ConfigCreationForm.vue
  2. 10
      frontend/components/configAutoLabeling/ConfigList.vue
  3. 22
      frontend/domain/models/autoLabeling/configRepository.ts
  4. 3
      frontend/plugins/services.ts
  5. 10
      frontend/repositories/autoLabeling/config/apiConfigRepository.ts
  6. 54
      frontend/services/application/autoLabeling/configApplicationService.ts

24
frontend/components/configAutoLabeling/ConfigCreationForm.vue

@ -43,12 +43,12 @@
<script lang="ts">
import Vue from 'vue'
import ConfigHeader from './form/ConfigHeader.vue'
import ConfigTemplateName from './form/ConfigTemplateName.vue'
import ConfigTemplate from './form/ConfigTemplate.vue'
import ConfigParameters from './form/ConfigParameters.vue'
import ConfigLabelMapping from './form/ConfigLabelMapping.vue'
import ConfigParameters from './form/ConfigParameters.vue'
import ConfigTemplate from './form/ConfigTemplate.vue'
import ConfigTemplateName from './form/ConfigTemplateName.vue'
import { StepCounter } from '@/domain/models/utils/stepper'
import { ConfigItem, Fields } from '~/domain/models/autoLabeling/config'
import { ConfigItem, Fields } from '@/domain/models/autoLabeling/config'
export default Vue.extend({
components: {
@ -114,7 +114,7 @@ export default Vue.extend({
this.errors = []
})
.catch((error) => {
this.errors = [error.message]
this.errors = [error.response.data]
})
.finally(() => {
this.isLoading = false
@ -123,27 +123,31 @@ export default Vue.extend({
testParameters(text: string) {
const projectId = this.$route.params.id
const item = ConfigItem.parseFromUI(this.fields)
const promise = this.$services.config.testParameters(projectId, item, text)
const promise = this.$repositories.config.testParameters(projectId, item, text)
this.testConfig(promise, 'parameter')
},
testTemplate() {
const projectId = this.$route.params.id
const item = ConfigItem.parseFromUI(this.fields)
const promise = this.$services.config.testTemplate(projectId, this.response.parameter, item)
const promise = this.$repositories.config.testTemplate(
projectId,
this.response.parameter,
item
)
this.testConfig(promise, 'template')
},
testMapping() {
const projectId = this.$route.params.id
const item = ConfigItem.parseFromUI(this.fields)
const promise = this.$services.config.testMapping(projectId, item, this.response.template)
const promise = this.$repositories.config.testMapping(projectId, item, this.response.template)
this.testConfig(promise, 'mapping')
},
saveConfig() {
const projectId = this.$route.params.id
const item = ConfigItem.parseFromUI(this.fields)
this.isLoading = true
this.$services.config
.save(projectId, item)
this.$repositories.config
.create(projectId, item)
.then(() => {
this.step.first()
this.$emit('onCreate')

10
frontend/components/configAutoLabeling/ConfigList.vue

@ -51,8 +51,8 @@
<script lang="ts">
import Vue from 'vue'
import ConfigCreationForm from './ConfigCreationForm.vue'
import { ConfigItemResponse } from '@/repositories/autoLabeling/config/apiConfigRepository'
import ConfirmForm from '@/components/utils/ConfirmForm.vue'
import { ConfigItemResponse } from '@/repositories/autoLabeling/config/apiConfigRepository'
import { ConfigItemList } from '~/domain/models/autoLabeling/config'
export default Vue.extend({
@ -81,7 +81,7 @@ export default Vue.extend({
async created(): Promise<void> {
this.isLoading = true
this.items = await this.$services.config.list(this.$route.params.id)
this.items = await this.$repositories.config.list(this.$route.params.id)
this.isLoading = false
},
@ -90,9 +90,9 @@ export default Vue.extend({
this.isLoading = true
const projectId = this.$route.params.id
for (const item of this.selected) {
await this.$services.config.delete(projectId, item.id)
await this.$repositories.config.delete(projectId, item.id)
}
this.items = await this.$services.config.list(projectId)
this.items = await this.$repositories.config.list(projectId)
this.selected = []
this.isLoading = false
},
@ -101,7 +101,7 @@ export default Vue.extend({
},
async onCreate() {
this.isLoading = true
this.items = await this.$services.config.list(this.$route.params.id)
this.items = await this.$repositories.config.list(this.$route.params.id)
this.isLoading = false
}
}

22
frontend/domain/models/autoLabeling/configRepository.ts

@ -1,22 +0,0 @@
import { ConfigItem, ConfigItemList } from '~/domain/models/autoLabeling/config'
export interface ConfigTestResponse {
valid: boolean
labels: object[]
}
export interface ConfigRepository {
list(projectId: string): Promise<ConfigItemList>
create(projectId: string, item: ConfigItem): Promise<ConfigItem>
delete(projectId: string, itemId: number): Promise<void>
update(projectId: string, item: ConfigItem): Promise<ConfigItem>
testParameters(projectId: string, item: ConfigItem, text: string): Promise<ConfigTestResponse>
testTemplate(projectId: string, response: any, item: ConfigItem): Promise<ConfigTestResponse>
testMapping(projectId: string, item: ConfigItem, response: any): Promise<ConfigTestResponse>
}

3
frontend/plugins/services.ts

@ -1,6 +1,5 @@
import { Plugin } from '@nuxt/types'
import { repositories } from './repositories'
import { ConfigApplicationService } from '@/services/application/autoLabeling/configApplicationService'
import { ExampleApplicationService } from '@/services/application/example/exampleApplicationService'
import { LabelApplicationService } from '@/services/application/label/labelApplicationService'
import { OptionApplicationService } from '@/services/application/option/optionApplicationService'
@ -22,7 +21,6 @@ export interface Services {
sequenceLabeling: SequenceLabelingApplicationService
seq2seq: Seq2seqApplicationService
option: OptionApplicationService
config: ConfigApplicationService
tag: TagApplicationService
bbox: BoundingBoxApplicationService
segmentation: SegmentationApplicationService
@ -48,7 +46,6 @@ const plugin: Plugin = (_, inject) => {
),
seq2seq: new Seq2seqApplicationService(repositories.textLabel),
option: new OptionApplicationService(repositories.option),
config: new ConfigApplicationService(repositories.config),
tag: new TagApplicationService(repositories.tag),
bbox: new BoundingBoxApplicationService(repositories.boundingBox),
segmentation: new SegmentationApplicationService(repositories.segmentation)

10
frontend/repositories/autoLabeling/config/apiConfigRepository.ts

@ -1,6 +1,5 @@
import ApiService from '@/services/api.service'
import { ConfigRepository, ConfigTestResponse } from '~/domain/models/autoLabeling/configRepository'
import { ConfigItemList, ConfigItem } from '~/domain/models/autoLabeling/config'
import { ConfigItem, ConfigItemList } from '~/domain/models/autoLabeling/config'
export interface ConfigItemResponse {
id: number
@ -11,7 +10,12 @@ export interface ConfigItemResponse {
task_type: string
}
export class APIConfigRepository implements ConfigRepository {
export interface ConfigTestResponse {
valid: boolean
labels: object[]
}
export class APIConfigRepository {
constructor(private readonly request = ApiService) {}
async list(projectId: string): Promise<ConfigItemList> {

54
frontend/services/application/autoLabeling/configApplicationService.ts

@ -1,54 +0,0 @@
import { ConfigRepository } from '~/domain/models/autoLabeling/configRepository'
import { ConfigItemList, ConfigItem } from '~/domain/models/autoLabeling/config'
export class ConfigApplicationService {
constructor(private readonly configRepository: ConfigRepository) {}
public list(id: string): Promise<ConfigItemList> {
return this.configRepository.list(id)
}
public save(projectId: string, item: ConfigItem): Promise<ConfigItem> {
return this.configRepository.create(projectId, item)
}
public delete(projectId: string, itemId: number) {
return this.configRepository.delete(projectId, itemId)
}
public testParameters(projectId: string, item: ConfigItem, text: string) {
return this.configRepository
.testParameters(projectId, item, text)
.then((value) => {
return value
})
.catch((error) => {
const data = error.response.data
throw new Error(data)
})
}
public testTemplate(projectId: string, response: any, item: ConfigItem) {
return this.configRepository
.testTemplate(projectId, response, item)
.then((value) => {
return value
})
.catch((error) => {
const data = error.response.data
throw new Error(data)
})
}
public testMapping(projectId: string, item: ConfigItem, response: any) {
return this.configRepository
.testMapping(projectId, item, response)
.then((value) => {
return value
})
.catch((error) => {
const data = error.response.data
throw new Error(data)
})
}
}
Loading…
Cancel
Save