|
|
@ -1,5 +1,9 @@ |
|
|
|
<template> |
|
|
|
<v-card> |
|
|
|
<v-tabs v-if="hasMultiType" v-model="tab"> |
|
|
|
<v-tab class="text-capitalize">Category</v-tab> |
|
|
|
<v-tab class="text-capitalize">Span</v-tab> |
|
|
|
</v-tabs> |
|
|
|
<v-card-title> |
|
|
|
<action-menu |
|
|
|
@create="dialogCreate=true" |
|
|
@ -102,15 +106,20 @@ export default Vue.extend({ |
|
|
|
items: [] as LabelDTO[], |
|
|
|
selected: [] as LabelDTO[], |
|
|
|
isLoading: false, |
|
|
|
errorMessage: '' |
|
|
|
errorMessage: '', |
|
|
|
tab: null, |
|
|
|
project: {} as ProjectDTO, |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
async fetch() { |
|
|
|
this.isLoading = true |
|
|
|
this.items = await this.$services.label.list(this.projectId) |
|
|
|
this.isLoading = false |
|
|
|
}, |
|
|
|
// async fetch() { |
|
|
|
// this.items = [] |
|
|
|
// this.isLoading = true |
|
|
|
// console.log('start fetch') |
|
|
|
// this.items = await this.service.list(this.projectId) |
|
|
|
// console.log('end fetch') |
|
|
|
// this.isLoading = false |
|
|
|
// }, |
|
|
|
|
|
|
|
computed: { |
|
|
|
canDelete(): boolean { |
|
|
@ -127,16 +136,58 @@ export default Vue.extend({ |
|
|
|
const item = this.items[this.editedIndex] // to remove myself |
|
|
|
return this.items.filter(_ => _ !== item).map(item => item.suffixKey) |
|
|
|
.filter(item => item !==null) as string[] |
|
|
|
}, |
|
|
|
hasMultiType(): boolean { |
|
|
|
if ('projectType' in this.project) { |
|
|
|
return this.project.projectType === 'IntentDetectionAndSlotFilling' |
|
|
|
} else { |
|
|
|
return false |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
service(): any { |
|
|
|
if (!('projectType' in this.project)) { |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.hasMultiType) { |
|
|
|
if (this.tab === 0) { |
|
|
|
return this.$services.categoryType |
|
|
|
} else { |
|
|
|
return this.$services.spanType |
|
|
|
} |
|
|
|
} else if (this.project.projectType.endsWith('Classification')) { |
|
|
|
return this.$services.categoryType |
|
|
|
} else { |
|
|
|
return this.$services.spanType |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
watch: { |
|
|
|
tab() { |
|
|
|
this.list() |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
async created() { |
|
|
|
this.project = await this.$services.project.findById(this.projectId) |
|
|
|
this.list() |
|
|
|
}, |
|
|
|
|
|
|
|
methods: { |
|
|
|
async list() { |
|
|
|
this.items = [] |
|
|
|
this.isLoading = true |
|
|
|
this.items = await this.service.list(this.projectId) |
|
|
|
this.isLoading = false |
|
|
|
}, |
|
|
|
|
|
|
|
async create() { |
|
|
|
await this.$services.label.create(this.projectId, this.editedItem) |
|
|
|
await this.service.create(this.projectId, this.editedItem) |
|
|
|
}, |
|
|
|
|
|
|
|
async update() { |
|
|
|
await this.$services.label.update(this.projectId, this.editedItem) |
|
|
|
await this.service.update(this.projectId, this.editedItem) |
|
|
|
}, |
|
|
|
|
|
|
|
save() { |
|
|
@ -145,7 +196,7 @@ export default Vue.extend({ |
|
|
|
} else { |
|
|
|
this.create() |
|
|
|
} |
|
|
|
this.$fetch() |
|
|
|
this.list() |
|
|
|
this.close() |
|
|
|
}, |
|
|
|
|
|
|
@ -158,20 +209,20 @@ export default Vue.extend({ |
|
|
|
}, |
|
|
|
|
|
|
|
async remove() { |
|
|
|
await this.$services.label.bulkDelete(this.projectId, this.selected) |
|
|
|
this.$fetch() |
|
|
|
await this.service.bulkDelete(this.projectId, this.selected) |
|
|
|
this.list() |
|
|
|
this.dialogDelete = false |
|
|
|
this.selected = [] |
|
|
|
}, |
|
|
|
|
|
|
|
async download() { |
|
|
|
await this.$services.label.export(this.projectId) |
|
|
|
await this.service.export(this.projectId) |
|
|
|
}, |
|
|
|
|
|
|
|
async upload(file: File) { |
|
|
|
try { |
|
|
|
await this.$services.label.upload(this.projectId, file) |
|
|
|
this.$fetch() |
|
|
|
await this.service.upload(this.projectId, file) |
|
|
|
this.list() |
|
|
|
this.closeUpload() |
|
|
|
} catch(e) { |
|
|
|
this.errorMessage = e.message |
|
|
|