Browse Source

Add try/catch to update/delete method

pull/1583/head
Hironsan 3 years ago
parent
commit
1c9c6825aa
3 changed files with 20 additions and 2 deletions
  1. 10
      frontend/pages/projects/_id/sequence-labeling/index.vue
  2. 6
      frontend/services/application/tasks/annotationApplicationService.ts
  3. 6
      frontend/services/application/tasks/sequenceLabeling/sequenceLabelingApplicationService.ts

10
frontend/pages/projects/_id/sequence-labeling/index.vue

@ -129,9 +129,19 @@ export default {
},
methods: {
async maybeFetchLabels(annotations) {
const labelIds = new Set(this.labels.map((label) => label.id));
if (annotations.some((item) => !labelIds.has(item.label))) {
this.labels = await this.$services.label.list(this.projectId);
}
},
async list(docId) {
const annotations = await this.$services.sequenceLabeling.list(this.projectId, docId);
const links = await this.$services.sequenceLabeling.listLinks(this.projectId);
// In colab mode, if someone add a new label and annotate data with the label during your work,
// it occurs exception because there is no corresponding label.
await this.maybeFetchLabels(annotations);
this.annotations = annotations;
this.links = links;
},

6
frontend/services/application/tasks/annotationApplicationService.ts

@ -8,7 +8,11 @@ export class AnnotationApplicationService<T extends AnnotationModel> {
) {}
public async delete(projectId: string, docId: number, annotationId: number): Promise<void> {
await this.repository.delete(projectId, docId, annotationId)
try {
await this.repository.delete(projectId, docId, annotationId)
} catch(e) {
console.log(e.response.data.detail)
}
}
public async clear(projectId: string, docId: number): Promise<void> {

6
frontend/services/application/tasks/sequenceLabeling/sequenceLabelingApplicationService.ts

@ -28,7 +28,11 @@ export class SequenceLabelingApplicationService extends AnnotationApplicationSer
}
public async changeLabel(projectId: string, docId: number, annotationId: number, labelId: number): Promise<void> {
await this.repository.update(projectId, docId, annotationId, labelId)
try {
await this.repository.update(projectId, docId, annotationId, labelId)
} catch(e) {
console.log(e.response.data.detail)
}
}
public async listLinks(projectId: string): Promise<LinkItem[]> {

Loading…
Cancel
Save