diff --git a/backend/api/urls.py b/backend/api/urls.py index a2289817..2142170b 100644 --- a/backend/api/urls.py +++ b/backend/api/urls.py @@ -47,12 +47,12 @@ urlpatterns_project = [ # name='label_detail' # ), path( - route='doc-types', + route='category-types', view=label.DocTypeList.as_view(), name='doc_types' ), path( - route='doc-types/', + route='category-types/', view=label.DocTypeDetail.as_view(), name='doc_type' ), @@ -67,7 +67,7 @@ urlpatterns_project = [ name='span_type' ), path( - route='doc-type-upload', + route='category-type-upload', view=label.DocTypeUploadAPI.as_view(), name='doc_type_upload' ), diff --git a/frontend/components/configAutoLabeling/form/LabelMapping.vue b/frontend/components/configAutoLabeling/form/LabelMapping.vue index 3cbb8301..c3b08509 100644 --- a/frontend/components/configAutoLabeling/form/LabelMapping.vue +++ b/frontend/components/configAutoLabeling/form/LabelMapping.vue @@ -155,8 +155,14 @@ export default Vue.extend({ }, async created() { - const labels = await this.$services.label.list(this.$route.params.id) - this.items = labels.map(item => item.text) + const project = await this.$services.project.findById(this.$route.params.id) + if (project.projectType.endsWith('Classification')) { + const labels = await this.$services.categoryType.list(this.$route.params.id) + this.items = labels.map(item => item.text) + } else { + const labels = await this.$services.spanType.list(this.$route.params.id) + this.items = labels.map(item => item.text) + } }, methods: { diff --git a/frontend/domain/models/label/label.ts b/frontend/domain/models/label/label.ts index 3e9fb79b..804f9cd9 100644 --- a/frontend/domain/models/label/label.ts +++ b/frontend/domain/models/label/label.ts @@ -47,6 +47,15 @@ export class LabelItemList { } } +interface LabelResponse { + id: number + text: string + prefix_key: string | null + suffix_key: string | null + background_color: string + text_color: string +} + export class LabelItem { constructor( public id: number, @@ -57,18 +66,22 @@ export class LabelItem { public textColor: string = '#ffffff' ) {} - static valueOf( - { id, text, prefix_key, suffix_key, background_color, text_color }: - { id: number, text: string, prefix_key: string, suffix_key: string, background_color: string, text_color: string } - ): LabelItem { - return new LabelItem(id, text, prefix_key, suffix_key, background_color, text_color) + static valueOf(label: LabelResponse): LabelItem { + return new LabelItem( + label.id, + label.text, + label.prefix_key, + label.suffix_key, + label.background_color, + label.text_color + ) } get name(): string { return this.text } - toObject(): Object { + toObject(): LabelResponse { return { id: this.id, text: this.text, @@ -79,3 +92,6 @@ export class LabelItem { } } } + +export class DocTypeItem extends LabelItem {} +export class SpanTypeItem extends LabelItem {} diff --git a/frontend/pages/projects/_id/labels/index.vue b/frontend/pages/projects/_id/labels/index.vue index 6dced232..981744e6 100644 --- a/frontend/pages/projects/_id/labels/index.vue +++ b/frontend/pages/projects/_id/labels/index.vue @@ -1,5 +1,9 @@