diff --git a/src/api/entity.ts b/src/api/entity.ts index 05adc810aa313189f4de17997aab6f29e1b6b30d..8752e479a533a1a4f464671ca377c479f96c9850 100644 --- a/src/api/entity.ts +++ b/src/api/entity.ts @@ -1,6 +1,6 @@ import axios from 'axios' import { PageNumberPaginationParameters, unique } from '.' -import { ElementSlim, PageNumberPagination, UUID } from '@/types' +import { ElementTiny, PageNumberPagination, UUID } from '@/types' import { Entity, EntityLight, EntityLink, EntityType, TranscriptionEntity } from '@/types/entity' // Retrieve an entity @@ -18,7 +18,7 @@ export const listCorpusEntities = unique(async (id: UUID, params: CorpusEntities export const listElementLinks = unique(async (id: UUID): Promise<PageNumberPagination<EntityLink>> => (await axios.get(`/element/${id}/links/`)).data) // List all elements linked to an entity -export const listEntityElements = unique(async (id: UUID, params: PageNumberPaginationParameters = {}): Promise<PageNumberPagination<ElementSlim>> => (await axios.get(`/entity/${id}/elements/`, { params })).data) +export const listEntityElements = unique(async (id: UUID, params: PageNumberPaginationParameters = {}): Promise<PageNumberPagination<ElementTiny>> => (await axios.get(`/entity/${id}/elements/`, { params })).data) interface TranscriptionEntityListParameters extends PageNumberPaginationParameters { entity_worker_run?: UUID | false diff --git a/src/api/image.ts b/src/api/image.ts index 9c58df7b5f24f0ff2ee1fbddc12ac97edafe18af..9c7cc0615e31551923971c8bcba065d2c8f89529 100644 --- a/src/api/image.ts +++ b/src/api/image.ts @@ -1,5 +1,5 @@ import axios from 'axios' -import { PageNumberPagination, ElementSlim, Image, UUID } from '@/types' +import { PageNumberPagination, ElementTiny, Image, UUID } from '@/types' import { PageNumberPaginationParameters, unique } from '.' /** @@ -29,6 +29,6 @@ export interface ImageElementsParameters extends PageNumberPaginationParameters * List all elements on an image. */ export const listImageElements = unique( - async ({ id, ...params }: ImageElementsParameters): Promise<PageNumberPagination<ElementSlim>> => + async ({ id, ...params }: ImageElementsParameters): Promise<PageNumberPagination<ElementTiny>> => (await axios.get(`/image/${id}/elements/`, { params })).data ) diff --git a/src/stores/entity.ts b/src/stores/entity.ts index 917b0de9f0d2f5b77d0ad87c63b5cd0499bf64a3..dfe5d68979ff78168435a337a03380c601c3fe67 100644 --- a/src/stores/entity.ts +++ b/src/stores/entity.ts @@ -1,4 +1,4 @@ -import { ElementSlim, PageNumberPagination, UUID } from '@/types' +import { ElementTiny, PageNumberPagination, UUID } from '@/types' import { defineStore } from 'pinia' import { useNotificationStore } from './notification' import { CorpusEntitiesListParameters, PageNumberPaginationParameters, listCorpusEntities, listElementLinks, listEntityElements, listTranscriptionEntities, retrieveEntity } from '@/api' @@ -25,7 +25,7 @@ interface State { /** * A page of elements related to an entity */ - elements: PageNumberPagination<ElementSlim> | null, + elements: PageNumberPagination<ElementTiny> | null, /** * Entities per transcription, with pagination status * { [transcription ID]: { count, results, loaded } } diff --git a/src/stores/image.ts b/src/stores/image.ts index a5ee2bab96ea0b59c7d7726b3018d34dbde8cb64..f250dbbea82edf46278d9a4bb94d17809eb1a235 100644 --- a/src/stores/image.ts +++ b/src/stores/image.ts @@ -1,10 +1,10 @@ import { defineStore } from 'pinia' import { listImageElements, ImageElementsParameters } from '@/api' import { errorParser } from '@/helpers' -import { ElementSlim, PageNumberPagination, UUID } from '@/types' +import { ElementTiny, PageNumberPagination, UUID } from '@/types' import { useNotificationStore } from '.' -export interface ImageElements extends PageNumberPagination<ElementSlim> { +export interface ImageElements extends PageNumberPagination<ElementTiny> { imageId: UUID } @@ -27,7 +27,7 @@ export const useImageStore = defineStore('image', { notificationStore.notify({ type: 'error', text: errorParser(err) }) } }, - setElements (imageId: UUID, data: PageNumberPagination<ElementSlim>) { + setElements (imageId: UUID, data: PageNumberPagination<ElementTiny>) { this.elements = { ...data, imageId diff --git a/src/types/index.ts b/src/types/index.ts index 36926bd765a2882e04ecc8095ff4a87f437e9747..a744af9c3d156ec9462266a5213fd090b6525152 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -147,23 +147,21 @@ export interface ElementTiny extends Required<Pick<ElementBase, 'id' | 'type' | corpus: CorpusLight } -export interface ElementSlim extends ElementTiny { +export interface Element extends ElementTiny { + created: string + creator: string | null + rights: Right[] + metadata_count: number + classifications: Classification[] + worker_version: UUID | null + worker_run: WorkerRunSummary | null + confidence: number | null /** * URL of the element's thumbnail, on which a PUT request can be made to upload a new thumbnail. - * The URL will only be available if the element's type is a folder type and the user is admin or internal. + * The URL will only be available if the element's type is a folder type + * and the user is a corpus admin, or a corpus contributor and the element's creator. */ - thumbnail_put_url?: string | null -} - -export interface Element extends ElementSlim { - created: string, - creator: string | null, - rights: Right[], - metadata_count: number, - classifications: Classification[], - worker_version: UUID | null, - worker_run: WorkerRunSummary | null, - confidence: number | null + thumbnail_put_url: string | null } export interface ElementList extends Required<Pick<ElementBase, 'id' | 'type' | 'name' | 'corpus' | 'thumbnail_url' | 'zone' | 'rotation_angle' | 'mirrored' | 'created' | 'classes' | 'metadata' | 'has_children'>> {}