Browse Source

Update frontend to use isConfirmed

pull/1402/head
Hironsan 3 years ago
parent
commit
483db70c55
11 changed files with 50 additions and 32 deletions
  1. 7
      frontend/composables/useExampleItem.ts
  2. 15
      frontend/domain/models/example/example.ts
  3. 2
      frontend/domain/models/example/exampleRepository.ts
  4. 9
      frontend/pages/projects/_id/image-classification/index.vue
  5. 9
      frontend/pages/projects/_id/sequence-labeling/index.vue
  6. 9
      frontend/pages/projects/_id/sequence-to-sequence/index.vue
  7. 9
      frontend/pages/projects/_id/speech-to-text/index.vue
  8. 8
      frontend/pages/projects/_id/text-classification/index.vue
  9. 5
      frontend/repositories/example/apiDocumentRepository.ts
  10. 7
      frontend/services/application/example/exampleApplicationService.ts
  11. 2
      frontend/services/application/example/exampleData.ts

7
frontend/composables/useExampleItem.ts

@ -29,17 +29,16 @@ export const useExampleItem = () => {
state.example = await exampleService.findById(projectId, state.example.id)
}
const approve = async(
const confirm = async(
projectId: string,
) => {
const approved = !state.example.isApproved
await exampleService.approve(projectId, state.example.id, approved)
await exampleService.confirm(projectId, state.example.id)
await getExampleById(projectId)
}
return {
state,
approve,
confirm,
getExample,
}
}

15
frontend/domain/models/example/example.ts

@ -49,13 +49,22 @@ export class ExampleItem {
public annotationApprover: boolean | null,
public commentCount: number,
public fileUrl: string,
public isConfirmed: boolean
) {}
static valueOf(
{ id, text, meta, annotation_approver, comment_count, filename }:
{ id: number, text: string, meta: object, annotation_approver: boolean | null, comment_count: number, filename: string }
{ id, text, meta, annotation_approver, comment_count, filename, is_confirmed }:
{
id: number,
text: string,
meta: object,
annotation_approver: boolean | null,
comment_count: number,
filename: string,
is_confirmed: boolean
}
): ExampleItem {
return new ExampleItem(id, text, meta, annotation_approver, comment_count, filename)
return new ExampleItem(id, text, meta, annotation_approver, comment_count, filename, is_confirmed)
}
get url() {

2
frontend/domain/models/example/exampleRepository.ts

@ -16,4 +16,6 @@ export interface ExampleRepository {
findById(projectId: string, exampleId: number): Promise<ExampleItem>
approve(projectId: string, docId: number, approved: boolean): Promise<void>
confirm(projectId: string, exampleId: number): Promise<void>
}

9
frontend/pages/projects/_id/image-classification/index.vue

@ -5,12 +5,12 @@
:doc-id="image.id"
:enable-auto-labeling.sync="enableAutoLabeling"
:guideline-text="project.guideline"
:is-reviewd="image.isApproved"
:is-reviewd="image.isConfirmed"
:show-approve-button="project.permitApprove"
:total="images.count"
class="d-none d-sm-block"
@click:clear-label="clear"
@click:review="approve"
@click:review="confirm"
>
<v-btn-toggle
v-model="labelOption"
@ -196,9 +196,8 @@ export default {
}
},
async approve() {
const approved = !this.image.isApproved
await this.$services.example.approve(this.projectId, this.image.id, approved)
async confirm() {
await this.$services.example.confirm(this.projectId, this.image.id)
await this.$fetch()
},

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

@ -5,12 +5,12 @@
:doc-id="doc.id"
:enable-auto-labeling.sync="enableAutoLabeling"
:guideline-text="project.guideline"
:is-reviewd="doc.isApproved"
:is-reviewd="doc.isConfirmed"
:show-approve-button="project.permitApprove"
:total="docs.count"
class="d-none d-sm-block"
@click:clear-label="clear"
@click:review="approve"
@click:review="confirm"
/>
<toolbar-mobile
:total="docs.count"
@ -188,9 +188,8 @@ export default {
}
},
async approve() {
const approved = !this.doc.isApproved
await this.$services.example.approve(this.projectId, this.doc.id, approved)
async confirm() {
await this.$services.example.confirm(this.projectId, this.doc.id)
await this.$fetch()
},

9
frontend/pages/projects/_id/sequence-to-sequence/index.vue

@ -5,12 +5,12 @@
:doc-id="doc.id"
:enable-auto-labeling.sync="enableAutoLabeling"
:guideline-text="project.guideline"
:is-reviewd="doc.isApproved"
:is-reviewd="doc.isConfirmed"
:show-approve-button="project.permitApprove"
:total="docs.count"
class="d-none d-sm-block"
@click:clear-label="clear"
@click:review="approve"
@click:review="confirm"
/>
<toolbar-mobile
:total="docs.count"
@ -137,9 +137,8 @@ export default {
}
},
async approve() {
const approved = !this.doc.isApproved
await this.$services.example.approve(this.projectId, this.doc.id, approved)
async confirm() {
await this.$services.example.confirm(this.projectId, this.doc.id)
await this.$fetch()
}
},

9
frontend/pages/projects/_id/speech-to-text/index.vue

@ -5,12 +5,12 @@
:doc-id="item.id"
:enable-auto-labeling.sync="enableAutoLabeling"
:guideline-text="project.guideline"
:is-reviewd="item.isApproved"
:is-reviewd="item.isConfirmed"
:show-approve-button="project.permitApprove"
:total="items.count"
class="d-none d-sm-block"
@click:clear-label="clear"
@click:review="approve"
@click:review="confirm"
/>
<toolbar-mobile
:total="items.count"
@ -140,9 +140,8 @@ export default {
}
},
async approve() {
const approved = !this.item.isApproved
await this.$services.example.approve(this.projectId, this.item.id, approved)
async confirm() {
await this.$services.example.confirm(this.projectId, this.item.id)
await this.$fetch()
}
},

8
frontend/pages/projects/_id/text-classification/index.vue

@ -5,12 +5,12 @@
:doc-id="example.id"
:enable-auto-labeling.sync="enableAutoLabeling"
:guideline-text="project.guideline"
:is-reviewd="example.isApproved"
:is-reviewd="example.isConfirmed"
:show-approve-button="project.permitApprove"
:total="totalExample"
class="d-none d-sm-block"
@click:clear-label="clearTeacherList(project.id, example.id)"
@click:review="approve(project.id)"
@click:review="confirm(project.id)"
>
<button-label-switch
class="ms-2"
@ -82,7 +82,7 @@ export default {
const { app, params, query } = useContext()
const projectId = params.value.id
const { state: projectState, getProjectById } = useProjectItem()
const { state: exampleState, approve, getExample } = useExampleItem()
const { state: exampleState, confirm, getExample } = useExampleItem()
const {
state: teacherState,
annotateLabel,
@ -123,7 +123,7 @@ export default {
...toRefs(projectState),
...toRefs(teacherState),
...toRefs(exampleState),
approve,
confirm,
annotateLabel,
annotateOrRemoveLabel,
clearTeacherList,

5
frontend/repositories/example/apiDocumentRepository.ts

@ -46,4 +46,9 @@ export class APIExampleRepository implements ExampleRepository {
const url = `/projects/${projectId}/approval/${exampleId}`
await this.request.post(url, { approved })
}
async confirm(projectId: string, exampleId: number): Promise<void> {
const url = `/projects/${projectId}/examples/${exampleId}/states`
await this.request.post(url)
}
}

7
frontend/services/application/example/exampleApplicationService.ts

@ -62,6 +62,10 @@ export class ExampleApplicationService {
await this.repository.approve(projectId, docId, approved)
}
public async confirm(projectId: string, exampleId: number): Promise<void> {
await this.repository.confirm(projectId, exampleId)
}
private toModel(item: ExampleDTO): ExampleItem {
return new ExampleItem(
item.id,
@ -69,7 +73,8 @@ export class ExampleApplicationService {
item.meta,
item.annotationApprover,
item.commentCount,
item.fileUrl
item.fileUrl,
item.isConfirmed
)
}
}

2
frontend/services/application/example/exampleData.ts

@ -11,6 +11,7 @@ export class ExampleDTO {
fileUrl: string;
filename: string;
url: string;
isConfirmed: boolean;
constructor(item: ExampleItem) {
this.id = item.id
@ -22,6 +23,7 @@ export class ExampleDTO {
this.fileUrl = item.fileUrl
this.filename = item.filename
this.url = item.url
this.isConfirmed = item.isConfirmed
}
}

Loading…
Cancel
Save