Skip to content

Commit

Permalink
Update labels in DocumentChunks modal (#19)
Browse files Browse the repository at this point in the history
* chore: document chunks model labels update

* chore: prettier
  • Loading branch information
stefanorosanelli authored Oct 1, 2024
1 parent 32f0827 commit 1d812ae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
11 changes: 9 additions & 2 deletions components/Dialog/DocumentChunks.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<template>
<div class="w-full">
<div class="flex justify-between items-center pb-4 mb-4 rounded-t border-b sm:mb-5">
<h3 class="text-xl font-semibold text-gray-900">{{ $t('CHUNKS_FOUND', { chunks: documentChunks.length }) }}</h3>
<h3 class="text-xl font-semibold text-gray-900">{{ fileName }} {{ $t('CHUNKS_FOUND', { chunks: documentChunks.length }) }}</h3>
<Icon class="text-2xl hover:cursor-pointer hover:bg-sky-100" name="ph:x-bold" @click="$closeModal()" />
</div>
<div class="mb-4 p-2 w-full whitespace-break-spaces overflow-y-auto max-h-[60vh]" v-if="!loadingChunks">

Check warning on line 7 in components/Dialog/DocumentChunks.vue

View workflow job for this annotation

GitHub Actions / Check code using Prettier and ESLint (ubuntu-latest, 20)

Attribute "v-if" should go before "class"
<div v-if="documentChunks && documentChunks.length > 0" class="flex flex-col space-y-3">
<div v-for="(doc, n) in documentChunks" :key="n" class="bg-sky-100 shadow-md p-3 rounded-lg">
<p class="text-lg font-bold">{{ $t('CHUNK') }} {{ n + 1 }}.</p>
<p class="text-lg font-bold">{{ $t('CHUNK') }} {{ n + 1 }}. - {{ $t('NUM_CHARS', { num: doc.document.length }) }}</p>
<p class="pt-2 pb-2">{{ doc.document }}</p>
</div>
</div>
Expand Down Expand Up @@ -35,13 +35,20 @@ const { $closeModal } = useNuxtApp();
const collectionUuid: string = statesStore.collection?.uuid || '';
const documentChunks = ref<any>([]);
const loadingChunks = ref(true);
const fileName = ref('');
onBeforeMount(async () => {
try {
const response = await fetch(`/api/brevia/index/${collectionUuid}/${props.documentId}`);
const data = await response.json();
if (data) {
documentChunks.value = data.sort((a: any, b: any) => a.cmetadata.part - b.cmetadata.part);
const type = data?.[0]?.cmetadata?.type || '';
if (type === 'files') {
fileName.value = data?.[0]?.cmetadata?.file || '';
} else if (type === 'links') {
fileName.value = data?.[0]?.cmetadata?.url || '';
}
}
setTimeout(() => (loadingChunks.value = false), 250);
} catch (err) {
Expand Down
3 changes: 2 additions & 1 deletion locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"CHECK_YOUR_INBOX": "Check your inbox and follow the instructions to active the account",
"CHECK_YOUR_INBOX_RESET": "Check your inbox and follow the instructions to reset your password",
"CHOOSE_NEW_PASSWORD": "Choose a new Password",
"CHUNKS_FOUND": "Parts found for this document ({chunks} parts)",
"CHUNKS_FOUND": "({chunks} parts)",
"CHUNK": "Part",
"CLIC_TO_ADD_QUESTION": "Click here to add a new question",
"CLIC_TO_ADD_LINK": "Click here to add a link to a webpage",
Expand Down Expand Up @@ -116,6 +116,7 @@
"NO_RESULTS_WITH_FILTER": "There are no results available with this filter",
"NOT_A_MEMBER": "Not a member?",
"NOT_VALID_EMAIL": "The provided email address is not valid",
"NUM_CHARS": "{num} characters",
"OVERVIEW": "Overview",
"PASSWORD": "Password",
"PASSWORD_ADVICE": "A strong password helps protect your account effectively.",
Expand Down
3 changes: 2 additions & 1 deletion locales/it/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"CHECK_YOUR_INBOX": "Controlla la tua casella di posta e segui le istruzioni per completare la registrazione",
"CHECK_YOUR_INBOX_RESET": "Controlla la tua casella di posta e segui le istruzioni per resettare la tua password",
"CHOOSE_NEW_PASSWORD": "Scegli una nuova password",
"CHUNKS_FOUND": "Parti trovate per questo documento ({chunks} parti)",
"CHUNKS_FOUND": "({chunks} parti)",
"CHUNK": "Parte",
"CLIC_TO_ADD_QUESTION": "Clicca qui per aggiungere una nuova domanda",
"CLIC_TO_ADD_LINK": "Clicca qui per aggiungere un link a una pagina web",
Expand Down Expand Up @@ -116,6 +116,7 @@
"NO_RESULTS_WITH_FILTER": "Non ci sono risultati per questo filtro",
"NOT_A_MEMBER": "Non sei ancora registrato?",
"NOT_VALID_EMAIL": "L'indirizzo di e-mail inserito non è valido",
"NUM_CHARS": "{num} caratteri",
"OVERVIEW": "Generale",
"PASSWORD": "Password",
"PASSWORD_ADVICE": "Una password sicura aiuta a proteggere il tuo account in modo efficace",
Expand Down

0 comments on commit 1d812ae

Please sign in to comment.