mirror of https://github.com/doccano/doccano.git
Browse Source
- avanzamento creazione grafica relazioni
- avanzamento creazione grafica relazioni
- tentativo di creazione pagine di gestione tipi di relazionipull/1384/head
15 changed files with 984 additions and 243 deletions
Split View
Diff Options
-
1frontend/components/layout/TheSideBar.vue
-
32frontend/components/links/ActionMenu.vue
-
106frontend/components/links/FormCreate.vue
-
28frontend/components/links/FormDelete.vue
-
89frontend/components/links/LinksList.vue
-
111frontend/components/tasks/sequenceLabeling/EntityItem.vue
-
209frontend/components/tasks/sequenceLabeling/EntityItemBox.vue
-
81frontend/domain/models/links/link.ts
-
11frontend/domain/models/links/linksRepository.ts
-
169frontend/pages/projects/_id/links/index.vue
-
94frontend/pages/projects/_id/sequence-labeling/index.vue
-
202frontend/plugins/services.ts
-
45frontend/repositories/links/apiLinksRepository.ts
-
19frontend/services/application/links/linkData.ts
-
30frontend/services/application/links/linksApplicationService.ts
@ -0,0 +1,32 @@ |
|||
<template> |
|||
<action-menu |
|||
:items="items" |
|||
:text="$t('dataset.actions')" |
|||
@create="$emit('create')" |
|||
@upload="$emit('upload')" |
|||
@download="$emit('download')" |
|||
/> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import Vue from 'vue' |
|||
import ActionMenu from '~/components/utils/ActionMenu.vue' |
|||
|
|||
export default Vue.extend({ |
|||
components: { |
|||
ActionMenu |
|||
}, |
|||
|
|||
computed: { |
|||
items() { |
|||
return [ |
|||
{ |
|||
title: this.$t('links.createLink'), |
|||
icon: 'mdi-pencil', |
|||
event: 'create' |
|||
} |
|||
] |
|||
} |
|||
} |
|||
}) |
|||
</script> |
@ -0,0 +1,106 @@ |
|||
<template> |
|||
<base-card |
|||
:disabled="!valid" |
|||
:title="$t('labels.createLabel')" |
|||
:agree-text="$t('generic.save')" |
|||
:cancel-text="$t('generic.cancel')" |
|||
@agree="$emit('save')" |
|||
@cancel="$emit('cancel')" |
|||
> |
|||
<template #content> |
|||
<v-form v-model="valid"> |
|||
<v-text-field |
|||
:value="text" |
|||
:label="$t('labels.labelName')" |
|||
:rules="[rules.required, rules.counter, rules.nameDuplicated]" |
|||
prepend-icon="label" |
|||
single-line |
|||
counter |
|||
autofocus |
|||
@input="updateValue('text', $event)" |
|||
/> |
|||
<v-select |
|||
:value="suffixKey" |
|||
:items="shortkeys" |
|||
:label="$t('labels.key')" |
|||
:rules="[rules.keyDuplicated]" |
|||
prepend-icon="mdi-keyboard" |
|||
@input="updateValue('suffixKey', $event)" |
|||
/> |
|||
<v-color-picker |
|||
:value="backgroundColor" |
|||
:rules="[rules.required]" |
|||
show-swatches |
|||
hide-mode-switch |
|||
width="800" |
|||
@input="updateValue('backgroundColor', $event)" |
|||
/> |
|||
</v-form> |
|||
</template> |
|||
</base-card> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import Vue from 'vue' |
|||
import BaseCard from '@/components/utils/BaseCard.vue' |
|||
|
|||
export default Vue.extend({ |
|||
components: { |
|||
BaseCard |
|||
}, |
|||
|
|||
props: { |
|||
text: { |
|||
type: String, |
|||
default: '', |
|||
required: true |
|||
}, |
|||
suffixKey: { |
|||
type: String, |
|||
default: null, |
|||
}, |
|||
backgroundColor: { |
|||
type: String, |
|||
default: '#ffffff', |
|||
required: true |
|||
}, |
|||
usedNames: { |
|||
type: Array, |
|||
default: () => [], |
|||
required: true |
|||
}, |
|||
usedKeys: { |
|||
type: Array, |
|||
default: () => [], |
|||
required: true |
|||
} |
|||
}, |
|||
|
|||
data() { |
|||
return { |
|||
valid: false, |
|||
rules: { |
|||
required: (v: string) => !!v || 'Required', |
|||
// @ts-ignore |
|||
counter: (v: string) => (v && v.length <= 100) || this.$t('rules.labelNameRules').labelLessThan100Chars, |
|||
// @ts-ignore |
|||
nameDuplicated: (v: string) => (!this.usedNames.includes(v)) || this.$t('rules.labelNameRules').duplicated, |
|||
// @ts-ignore |
|||
keyDuplicated: (v: string) => !this.usedKeys.includes(v) || this.$t('rules.keyNameRules').duplicated, |
|||
} |
|||
} |
|||
}, |
|||
|
|||
computed: { |
|||
shortkeys() { |
|||
return '0123456789abcdefghijklmnopqrstuvwxyz'.split('') |
|||
} |
|||
}, |
|||
|
|||
methods: { |
|||
updateValue(key: string, value: string) { |
|||
this.$emit(`update:${key}`, value); |
|||
} |
|||
} |
|||
}) |
|||
</script> |
@ -0,0 +1,28 @@ |
|||
<template> |
|||
<confirm-form |
|||
:items="selected" |
|||
title="Delete Label" |
|||
:message="$t('labels.deleteMessage')" |
|||
item-key="text" |
|||
@ok="$emit('remove')" |
|||
@cancel="$emit('cancel')" |
|||
/> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import Vue from 'vue' |
|||
import ConfirmForm from '@/components/utils/ConfirmForm.vue' |
|||
|
|||
export default Vue.extend({ |
|||
components: { |
|||
ConfirmForm |
|||
}, |
|||
|
|||
props: { |
|||
selected: { |
|||
type: Array, |
|||
default: () => [] |
|||
} |
|||
} |
|||
}) |
|||
</script> |
@ -0,0 +1,89 @@ |
|||
<template> |
|||
<v-data-table |
|||
:value="value" |
|||
:headers="headers" |
|||
:items="items" |
|||
:search="search" |
|||
:loading="isLoading" |
|||
:loading-text="$t('generic.loading')" |
|||
:no-data-text="$t('vuetify.noDataAvailable')" |
|||
:footer-props="{ |
|||
'showFirstLastPage': true, |
|||
'items-per-page-options': [5, 10, 15, $t('generic.all')], |
|||
'items-per-page-text': $t('vuetify.itemsPerPageText'), |
|||
'page-text': $t('dataset.pageText') |
|||
}" |
|||
item-key="id" |
|||
show-select |
|||
@input="$emit('input', $event)" |
|||
> |
|||
<template v-slot:top> |
|||
<v-text-field |
|||
v-model="search" |
|||
prepend-inner-icon="search" |
|||
:label="$t('generic.search')" |
|||
single-line |
|||
hide-details |
|||
filled |
|||
/> |
|||
</template> |
|||
<template v-slot:[`item.backgroundColor`]="props"> |
|||
<v-chip |
|||
:color="props.item.backgroundColor" |
|||
:text-color="$contrastColor(props.item.backgroundColor)" |
|||
> |
|||
{{ props.item.backgroundColor }} |
|||
</v-chip> |
|||
</template> |
|||
<template v-slot:[`item.actions`]="{ item }"> |
|||
<v-icon |
|||
small |
|||
@click="$emit('edit', item)" |
|||
> |
|||
mdi-pencil |
|||
</v-icon> |
|||
</template> |
|||
</v-data-table> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import Vue, { PropType } from 'vue' |
|||
import { LinkDTO } from '~/services/application/links/linkData' |
|||
|
|||
export default Vue.extend({ |
|||
props: { |
|||
isLoading: { |
|||
type: Boolean, |
|||
default: false, |
|||
required: true |
|||
}, |
|||
items: { |
|||
type: Array as PropType<LinkDTO[]>, |
|||
default: () => [], |
|||
required: true |
|||
}, |
|||
value: { |
|||
type: Array as PropType<LinkDTO[]>, |
|||
default: () => [], |
|||
required: true |
|||
} |
|||
}, |
|||
|
|||
data() { |
|||
return { |
|||
search: '' |
|||
} |
|||
}, |
|||
|
|||
computed: { |
|||
headers() { |
|||
return [ |
|||
{ text: this.$t('generic.name'), value: 'text' }, |
|||
{ text: this.$t('links.shortkey'), value: 'suffixKey' }, |
|||
{ text: this.$t('links.color'), value: 'backgroundColor' }, |
|||
{ text: 'Actions', value: 'actions', sortable: false }, |
|||
] |
|||
} |
|||
} |
|||
}) |
|||
</script> |
@ -0,0 +1,81 @@ |
|||
export class LinkItemList { |
|||
constructor(public LinkItems: LinkItem[]) {} |
|||
|
|||
static valueOf(items: LinkItem[]): LinkItemList { |
|||
return new LinkItemList(items) |
|||
} |
|||
|
|||
add(item: LinkItem) { |
|||
this.LinkItems.push(item) |
|||
} |
|||
|
|||
update(item: LinkItem) { |
|||
const index = this.LinkItems.findIndex(label => label.id === item.id) |
|||
this.LinkItems.splice(index, 1, item) |
|||
} |
|||
|
|||
delete(item: LinkItem) { |
|||
this.LinkItems = this.LinkItems.filter(label => label.id !== item.id) |
|||
} |
|||
|
|||
bulkDelete(items: LinkItemList) { |
|||
const ids = items.ids() |
|||
this.LinkItems = this.LinkItems.filter(label => !ids.includes(label.id)) |
|||
} |
|||
|
|||
count(): Number { |
|||
return this.LinkItems.length |
|||
} |
|||
|
|||
ids(): Number[]{ |
|||
return this.LinkItems.map(item => item.id) |
|||
} |
|||
|
|||
get nameList(): string[] { |
|||
return this.LinkItems.map(item => item.name) |
|||
} |
|||
|
|||
get usedKeys(): string[] { |
|||
const items = this.LinkItems |
|||
.filter(item => item.suffixKey !== null) |
|||
.map(item => item.suffixKey) as string[] |
|||
return items |
|||
} |
|||
|
|||
toArray(): Object[] { |
|||
return this.LinkItems.map(item => item.toObject()) |
|||
} |
|||
} |
|||
|
|||
export class LinkItem { |
|||
constructor( |
|||
public id: number, |
|||
public text: string, |
|||
public prefixKey: string | null, |
|||
public suffixKey: string | null, |
|||
public backgroundColor: string, |
|||
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 } |
|||
): LinkItem { |
|||
return new LinkItem(id, text, prefix_key, suffix_key, background_color, text_color) |
|||
} |
|||
|
|||
get name(): string { |
|||
return this.text |
|||
} |
|||
|
|||
toObject(): Object { |
|||
return { |
|||
id: this.id, |
|||
text: this.text, |
|||
prefix_key: this.prefixKey, |
|||
suffix_key: this.suffixKey, |
|||
background_color: this.backgroundColor, |
|||
text_color: this.textColor |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
import { LinkItem } from '~/domain/models/links/link' |
|||
|
|||
export interface LinksRepository { |
|||
list(projectId: string): Promise<LinkItem[]> |
|||
|
|||
create(projectId: string, item: LinkItem): Promise<LinkItem> |
|||
|
|||
update(projectId: string, item: LinkItem): Promise<LinkItem> |
|||
|
|||
bulkDelete(projectId: string, linkIds: number[]): Promise<void> |
|||
} |
@ -0,0 +1,169 @@ |
|||
<template> |
|||
<v-card> |
|||
<v-card-title> |
|||
<action-menu |
|||
@create="dialogCreate=true" |
|||
@upload="dialogUpload=true" |
|||
/> |
|||
<v-btn |
|||
class="text-capitalize ms-2" |
|||
:disabled="!canDelete" |
|||
outlined |
|||
@click.stop="dialogDelete=true" |
|||
> |
|||
{{ $t('generic.delete') }} |
|||
</v-btn> |
|||
<v-dialog v-model="dialogCreate"> |
|||
<form-create |
|||
v-bind.sync="editedItem" |
|||
:used-keys="usedKeys" |
|||
:used-names="usedNames" |
|||
@cancel="close" |
|||
@save="save" |
|||
/> |
|||
</v-dialog> |
|||
<v-dialog v-model="dialogDelete"> |
|||
<form-delete |
|||
:selected="selected" |
|||
@cancel="dialogDelete=false" |
|||
@remove="remove" |
|||
/> |
|||
</v-dialog> |
|||
</v-card-title> |
|||
|
|||
<p>WORK IN PROGRESS... THIS WILL BECOME THE RELATIONS TYPE CRUD PAGE</p> |
|||
|
|||
<links-list |
|||
v-model="selected" |
|||
:items="items" |
|||
:is-loading="isLoading" |
|||
@edit="editItem" |
|||
/> |
|||
</v-card> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import Vue from 'vue' |
|||
import ActionMenu from '@/components/links/ActionMenu.vue' |
|||
import FormCreate from '@/components/links/FormCreate.vue' |
|||
import FormDelete from '@/components/links/FormDelete.vue' |
|||
import LinksList from '~/components/links/LinksList.vue' |
|||
import { LinkDTO } from '~/services/application/links/linkData' |
|||
|
|||
export default Vue.extend({ |
|||
layout: 'project', |
|||
|
|||
components: { |
|||
ActionMenu, |
|||
FormCreate, |
|||
FormDelete, |
|||
LinksList |
|||
}, |
|||
|
|||
async fetch() { |
|||
this.isLoading = true |
|||
this.items = await this.$services.links.list(this.projectId) |
|||
this.isLoading = false |
|||
}, |
|||
|
|||
data() { |
|||
return { |
|||
dialogCreate: false, |
|||
dialogDelete: false, |
|||
dialogUpload: false, |
|||
editedIndex: -1, |
|||
editedItem: { |
|||
text: '', |
|||
prefixKey: null, |
|||
suffixKey: null, |
|||
backgroundColor: '#2196F3', |
|||
textColor: '#ffffff' |
|||
} as LinkDTO, |
|||
defaultItem: { |
|||
text: '', |
|||
prefixKey: null, |
|||
suffixKey: null, |
|||
backgroundColor: '#2196F3', |
|||
textColor: '#ffffff' |
|||
} as LinkDTO, |
|||
items: [] as LinkDTO[], |
|||
selected: [] as LinkDTO[], |
|||
isLoading: false, |
|||
errorMessage: '' |
|||
} |
|||
}, |
|||
|
|||
computed: { |
|||
canDelete(): boolean { |
|||
return this.selected.length > 0 |
|||
}, |
|||
projectId(): string { |
|||
return this.$route.params.id |
|||
}, |
|||
usedNames(): string[] { |
|||
const item = this.items[this.editedIndex] // to remove myself |
|||
return this.items.filter(_ => _ !== item).map(item => item.text) |
|||
}, |
|||
usedKeys(): string[] { |
|||
const item = this.items[this.editedIndex] // to remove myself |
|||
return this.items.filter(_ => _ !== item).map(item => item.suffixKey) |
|||
.filter(item => item !==null) as string[] |
|||
} |
|||
}, |
|||
|
|||
methods: { |
|||
async create() { |
|||
await this.$services.links.create(this.projectId, this.editedItem) |
|||
}, |
|||
|
|||
async update() { |
|||
await this.$services.links.update(this.projectId, this.editedItem) |
|||
}, |
|||
|
|||
save() { |
|||
if (this.editedIndex > -1) { |
|||
this.update() |
|||
} else { |
|||
this.create() |
|||
} |
|||
this.$fetch() |
|||
this.close() |
|||
}, |
|||
|
|||
close() { |
|||
this.dialogCreate = false |
|||
this.$nextTick(() => { |
|||
this.editedItem = Object.assign({}, this.defaultItem) |
|||
this.editedIndex = -1 |
|||
}) |
|||
}, |
|||
|
|||
async remove() { |
|||
await this.$services.links.bulkDelete(this.projectId, this.selected) |
|||
this.$fetch() |
|||
this.dialogDelete = false |
|||
this.selected = [] |
|||
}, |
|||
|
|||
clearErrorMessage() { |
|||
this.errorMessage = '' |
|||
}, |
|||
|
|||
editItem(item: LinkDTO) { |
|||
this.editedIndex = this.items.indexOf(item) |
|||
this.editedItem = Object.assign({}, item) |
|||
this.dialogCreate = true |
|||
} |
|||
}, |
|||
|
|||
validate({ params }) { |
|||
return /^\d+$/.test(params.id) |
|||
} |
|||
}) |
|||
</script> |
|||
|
|||
<style scoped> |
|||
::v-deep .v-dialog { |
|||
width: 800px; |
|||
} |
|||
</style> |
@ -1,110 +1,116 @@ |
|||
import { Plugin } from '@nuxt/types' |
|||
import { APISequenceLabelingRepository } from '~/repositories/tasks/sequenceLabeling/apiSequenceLabeling' |
|||
import { APISeq2seqRepository } from '~/repositories/tasks/seq2seq/apiSeq2seq' |
|||
import { APIConfigRepository } from '~/repositories/autoLabeling/config/apiConfigRepository' |
|||
import { APITemplateRepository } from '~/repositories/autoLabeling/template/apiTemplateRepository' |
|||
import { APIUserRepository } from '~/repositories/user/apiUserRepository' |
|||
import { APIStatisticsRepository } from '~/repositories/statistics/apiStatisticsRepository' |
|||
import { APIRoleRepository } from '~/repositories/role/apiRoleRepository' |
|||
import { APIProjectRepository } from '~/repositories/project/apiProjectRepository' |
|||
import { LocalStorageOptionRepository} from '~/repositories/option/apiOptionRepository' |
|||
import { APIMemberRepository } from '~/repositories/member/apiMemberRepository' |
|||
import { APILabelRepository } from '~/repositories/label/apiLabelRepository' |
|||
import { APIDocumentRepository } from '~/repositories/document/apiDocumentRepository' |
|||
import { APICommentRepository } from '~/repositories/comment/apiCommentRepository' |
|||
import { APIAuthRepository } from '~/repositories/auth/apiAuthRepository' |
|||
import { LabelApplicationService } from '~/services/application/label/labelApplicationService' |
|||
import { MemberApplicationService } from '~/services/application/member/memberApplicationService' |
|||
import { UserApplicationService } from '~/services/application/user/userApplicationService' |
|||
import { RoleApplicationService } from '~/services/application/role/roleApplicationService' |
|||
import { ProjectApplicationService } from '~/services/application/project/projectApplicationService' |
|||
import { CommentApplicationService } from '~/services/application/comment/commentApplicationService' |
|||
import { StatisticsApplicationService } from '~/services/application/statistics/statisticsApplicationService' |
|||
import { DocumentApplicationService } from '~/services/application/document/documentApplicationService' |
|||
import { OptionApplicationService } from '~/services/application/option/optionApplicationService' |
|||
import { SequenceLabelingApplicationService } from '~/services/application/tasks/sequenceLabeling/sequenceLabelingApplicationService' |
|||
import { Seq2seqApplicationService } from '~/services/application/tasks/seq2seq/seq2seqApplicationService' |
|||
import { ConfigApplicationService } from '~/services/application/autoLabeling/configApplicationService' |
|||
import { TemplateApplicationService } from '~/services/application/autoLabeling/templateApplicationService' |
|||
import { APITextClassificationRepository } from '~/repositories/tasks/textClassification/apiTextClassification' |
|||
import { TextClassificationApplicationService } from '~/services/application/tasks/textClassification/textClassificationApplicationService' |
|||
import { AuthApplicationService } from '~/services/application/auth/authApplicationService' |
|||
import {Plugin} from '@nuxt/types' |
|||
import {APISequenceLabelingRepository} from '~/repositories/tasks/sequenceLabeling/apiSequenceLabeling' |
|||
import {APISeq2seqRepository} from '~/repositories/tasks/seq2seq/apiSeq2seq' |
|||
import {APIConfigRepository} from '~/repositories/autoLabeling/config/apiConfigRepository' |
|||
import {APITemplateRepository} from '~/repositories/autoLabeling/template/apiTemplateRepository' |
|||
import {APIUserRepository} from '~/repositories/user/apiUserRepository' |
|||
import {APIStatisticsRepository} from '~/repositories/statistics/apiStatisticsRepository' |
|||
import {APIRoleRepository} from '~/repositories/role/apiRoleRepository' |
|||
import {APIProjectRepository} from '~/repositories/project/apiProjectRepository' |
|||
import {LocalStorageOptionRepository} from '~/repositories/option/apiOptionRepository' |
|||
import {APIMemberRepository} from '~/repositories/member/apiMemberRepository' |
|||
import {APILabelRepository} from '~/repositories/label/apiLabelRepository' |
|||
import {ApiLinksRepository} from "~/repositories/links/apiLinksRepository"; |
|||
import {APIDocumentRepository} from '~/repositories/document/apiDocumentRepository' |
|||
import {APICommentRepository} from '~/repositories/comment/apiCommentRepository' |
|||
import {APIAuthRepository} from '~/repositories/auth/apiAuthRepository' |
|||
import {LabelApplicationService} from '~/services/application/label/labelApplicationService' |
|||
import {LinksApplicationService} from "~/services/application/links/linksApplicationService"; |
|||
import {MemberApplicationService} from '~/services/application/member/memberApplicationService' |
|||
import {UserApplicationService} from '~/services/application/user/userApplicationService' |
|||
import {RoleApplicationService} from '~/services/application/role/roleApplicationService' |
|||
import {ProjectApplicationService} from '~/services/application/project/projectApplicationService' |
|||
import {CommentApplicationService} from '~/services/application/comment/commentApplicationService' |
|||
import {StatisticsApplicationService} from '~/services/application/statistics/statisticsApplicationService' |
|||
import {DocumentApplicationService} from '~/services/application/document/documentApplicationService' |
|||
import {OptionApplicationService} from '~/services/application/option/optionApplicationService' |
|||
import {SequenceLabelingApplicationService} from '~/services/application/tasks/sequenceLabeling/sequenceLabelingApplicationService' |
|||
import {Seq2seqApplicationService} from '~/services/application/tasks/seq2seq/seq2seqApplicationService' |
|||
import {ConfigApplicationService} from '~/services/application/autoLabeling/configApplicationService' |
|||
import {TemplateApplicationService} from '~/services/application/autoLabeling/templateApplicationService' |
|||
import {APITextClassificationRepository} from '~/repositories/tasks/textClassification/apiTextClassification' |
|||
import {TextClassificationApplicationService} from '~/services/application/tasks/textClassification/textClassificationApplicationService' |
|||
import {AuthApplicationService} from '~/services/application/auth/authApplicationService' |
|||
|
|||
export interface Services { |
|||
label: LabelApplicationService, |
|||
member: MemberApplicationService, |
|||
user: UserApplicationService, |
|||
role: RoleApplicationService, |
|||
project: ProjectApplicationService, |
|||
comment: CommentApplicationService, |
|||
statistics: StatisticsApplicationService, |
|||
document: DocumentApplicationService, |
|||
textClassification: TextClassificationApplicationService, |
|||
sequenceLabeling: SequenceLabelingApplicationService, |
|||
seq2seq: Seq2seqApplicationService, |
|||
option: OptionApplicationService, |
|||
config: ConfigApplicationService, |
|||
template: TemplateApplicationService, |
|||
auth: AuthApplicationService |
|||
label: LabelApplicationService, |
|||
links: LinksApplicationService, |
|||
member: MemberApplicationService, |
|||
user: UserApplicationService, |
|||
role: RoleApplicationService, |
|||
project: ProjectApplicationService, |
|||
comment: CommentApplicationService, |
|||
statistics: StatisticsApplicationService, |
|||
document: DocumentApplicationService, |
|||
textClassification: TextClassificationApplicationService, |
|||
sequenceLabeling: SequenceLabelingApplicationService, |
|||
seq2seq: Seq2seqApplicationService, |
|||
option: OptionApplicationService, |
|||
config: ConfigApplicationService, |
|||
template: TemplateApplicationService, |
|||
auth: AuthApplicationService |
|||
} |
|||
|
|||
declare module 'vue/types/vue' { |
|||
interface Vue { |
|||
readonly $services: Services |
|||
} |
|||
interface Vue { |
|||
readonly $services: Services |
|||
} |
|||
} |
|||
|
|||
const plugin: Plugin = (context, inject) => { |
|||
const labelRepository = new APILabelRepository() |
|||
const memberRepository = new APIMemberRepository() |
|||
const userRepository = new APIUserRepository() |
|||
const roleRepository = new APIRoleRepository() |
|||
const projectRepository = new APIProjectRepository() |
|||
const commentRepository = new APICommentRepository() |
|||
const statisticsRepository = new APIStatisticsRepository() |
|||
const documentRepository = new APIDocumentRepository() |
|||
const textClassificationRepository = new APITextClassificationRepository() |
|||
const sequenceLabelingRepository = new APISequenceLabelingRepository() |
|||
const seq2seqRepository = new APISeq2seqRepository() |
|||
const optionRepository = new LocalStorageOptionRepository() |
|||
const configRepository = new APIConfigRepository() |
|||
const templateRepository = new APITemplateRepository() |
|||
const authRepository = new APIAuthRepository() |
|||
const labelRepository = new APILabelRepository() |
|||
const linksRepository = new ApiLinksRepository() |
|||
const memberRepository = new APIMemberRepository() |
|||
const userRepository = new APIUserRepository() |
|||
const roleRepository = new APIRoleRepository() |
|||
const projectRepository = new APIProjectRepository() |
|||
const commentRepository = new APICommentRepository() |
|||
const statisticsRepository = new APIStatisticsRepository() |
|||
const documentRepository = new APIDocumentRepository() |
|||
const textClassificationRepository = new APITextClassificationRepository() |
|||
const sequenceLabelingRepository = new APISequenceLabelingRepository() |
|||
const seq2seqRepository = new APISeq2seqRepository() |
|||
const optionRepository = new LocalStorageOptionRepository() |
|||
const configRepository = new APIConfigRepository() |
|||
const templateRepository = new APITemplateRepository() |
|||
const authRepository = new APIAuthRepository() |
|||
|
|||
const label = new LabelApplicationService(labelRepository) |
|||
const member = new MemberApplicationService(memberRepository) |
|||
const user = new UserApplicationService(userRepository) |
|||
const role = new RoleApplicationService(roleRepository) |
|||
const project = new ProjectApplicationService(projectRepository) |
|||
const comment = new CommentApplicationService(commentRepository) |
|||
const statistics = new StatisticsApplicationService(statisticsRepository) |
|||
const document = new DocumentApplicationService(documentRepository) |
|||
const textClassification = new TextClassificationApplicationService(textClassificationRepository) |
|||
const sequenceLabeling = new SequenceLabelingApplicationService(sequenceLabelingRepository) |
|||
const seq2seq = new Seq2seqApplicationService(seq2seqRepository) |
|||
const option = new OptionApplicationService(optionRepository) |
|||
const config = new ConfigApplicationService(configRepository) |
|||
const template = new TemplateApplicationService(templateRepository) |
|||
const auth = new AuthApplicationService(authRepository) |
|||
|
|||
const services: Services = { |
|||
label, |
|||
member, |
|||
user, |
|||
role, |
|||
project, |
|||
comment, |
|||
statistics, |
|||
document, |
|||
textClassification, |
|||
sequenceLabeling, |
|||
seq2seq, |
|||
option, |
|||
config, |
|||
template, |
|||
auth |
|||
} |
|||
inject('services', services) |
|||
const label = new LabelApplicationService(labelRepository) |
|||
const links = new LinksApplicationService(linksRepository) |
|||
const member = new MemberApplicationService(memberRepository) |
|||
const user = new UserApplicationService(userRepository) |
|||
const role = new RoleApplicationService(roleRepository) |
|||
const project = new ProjectApplicationService(projectRepository) |
|||
const comment = new CommentApplicationService(commentRepository) |
|||
const statistics = new StatisticsApplicationService(statisticsRepository) |
|||
const document = new DocumentApplicationService(documentRepository) |
|||
const textClassification = new TextClassificationApplicationService(textClassificationRepository) |
|||
const sequenceLabeling = new SequenceLabelingApplicationService(sequenceLabelingRepository) |
|||
const seq2seq = new Seq2seqApplicationService(seq2seqRepository) |
|||
const option = new OptionApplicationService(optionRepository) |
|||
const config = new ConfigApplicationService(configRepository) |
|||
const template = new TemplateApplicationService(templateRepository) |
|||
const auth = new AuthApplicationService(authRepository) |
|||
|
|||
const services: Services = { |
|||
label, |
|||
links, |
|||
member, |
|||
user, |
|||
role, |
|||
project, |
|||
comment, |
|||
statistics, |
|||
document, |
|||
textClassification, |
|||
sequenceLabeling, |
|||
seq2seq, |
|||
option, |
|||
config, |
|||
template, |
|||
auth |
|||
} |
|||
inject('services', services) |
|||
} |
|||
|
|||
export default plugin |
@ -0,0 +1,45 @@ |
|||
import ApiService from '@/services/api.service' |
|||
import { LinksRepository } from "~/domain/models/links/linksRepository"; |
|||
import { LinkItem } from "~/domain/models/links/link"; |
|||
|
|||
export interface LinkItemResponse { |
|||
id: number, |
|||
text: string, |
|||
prefix_key: string, |
|||
suffix_key: string, |
|||
background_color: string, |
|||
text_color: string |
|||
} |
|||
|
|||
export class ApiLinksRepository implements LinksRepository { |
|||
constructor( |
|||
private readonly request = ApiService |
|||
) {} |
|||
|
|||
async list(projectId: string): Promise<LinkItem[]> { |
|||
const url = `/projects/${projectId}/relation_types` |
|||
const response = await this.request.get(url) |
|||
console.log(response); |
|||
const responseItems: LinkItemResponse[] = response.data |
|||
return responseItems.map(item => LinkItem.valueOf(item)) |
|||
} |
|||
|
|||
async create(projectId: string, item: LinkItem): Promise<LinkItem> { |
|||
const url = `/projects/${projectId}/relation_types` |
|||
const response = await this.request.post(url, item.toObject()) |
|||
const responseItem: LinkItemResponse = response.data |
|||
return LinkItem.valueOf(responseItem) |
|||
} |
|||
|
|||
async update(projectId: string, item: LinkItem): Promise<LinkItem> { |
|||
const url = `/projects/${projectId}/relation_types/${item.id}` |
|||
const response = await this.request.patch(url, item.toObject()) |
|||
const responseItem: LinkItemResponse = response.data |
|||
return LinkItem.valueOf(responseItem) |
|||
} |
|||
|
|||
async bulkDelete(projectId: string, linkIds: number[]): Promise<void> { |
|||
const url = `/projects/${projectId}/relation_types` |
|||
await this.request.delete(url, { ids: linkIds }) |
|||
} |
|||
} |
@ -0,0 +1,19 @@ |
|||
import { LinkItem } from '~/domain/models/links/link' |
|||
|
|||
export class LinkDTO { |
|||
id: number |
|||
text: string |
|||
prefixKey: string | null |
|||
suffixKey: string | null |
|||
backgroundColor: string |
|||
textColor: string |
|||
|
|||
constructor(item: LinkItem) { |
|||
this.id = item.id |
|||
this.text = item.text |
|||
this.prefixKey = item.prefixKey |
|||
this.suffixKey = item.suffixKey |
|||
this.backgroundColor = item.backgroundColor |
|||
this.textColor = '#ffffff' |
|||
} |
|||
} |
@ -0,0 +1,30 @@ |
|||
import { LinkDTO } from './linkData'; |
|||
import { LinksRepository } from '~/domain/models/links/linksRepository'; |
|||
import { LinkItem } from '~/domain/models/links/link'; |
|||
|
|||
|
|||
export class LinksApplicationService { |
|||
constructor( |
|||
private readonly repository: LinksRepository |
|||
) {} |
|||
|
|||
public async list(id: string): Promise<LinkDTO[]> { |
|||
const items = await this.repository.list(id) |
|||
return items.map(item => new LinkDTO(item)) |
|||
} |
|||
|
|||
public create(projectId: string, item: LinkDTO): void { |
|||
const label = new LinkItem(0, item.text, item.prefixKey, item.suffixKey, item.backgroundColor, item.textColor) |
|||
this.repository.create(projectId, label) |
|||
} |
|||
|
|||
public update(projectId: string, item: LinkDTO): void { |
|||
const label = new LinkItem(item.id, item.text, item.prefixKey, item.suffixKey, item.backgroundColor, item.textColor) |
|||
this.repository.update(projectId, label) |
|||
} |
|||
|
|||
public bulkDelete(projectId: string, items: LinkDTO[]): Promise<void> { |
|||
const ids = items.map(item => item.id) |
|||
return this.repository.bulkDelete(projectId, ids) |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save