Skip to content

Commit

Permalink
Merge pull request #338 from weni-ai/nexus-1263-fail-status-on-conten…
Browse files Browse the repository at this point in the history
…t-items

[Nexus-1263] Content Base: Failure Status on Items
  • Loading branch information
cristiantela authored May 23, 2024
2 parents 5f563ee + 8f19ff5 commit 9b11575
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 62 deletions.
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@
"sites": "Websites",
"text": "Text"
},
"file_with_error": "File with error. Delete and add it again.",
"site_with_error": "Site with error. Delete and add it again.",
"files": {
"upload_content": "Upload content from files",
"drag_and_drop_your_file_here": "Drag and drop your file here to add the content to the AI knowledge base.",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@
"sites": "Sitios",
"text": "Texto"
},
"file_with_error": "Archivo con error. Bórrelo y añádalo de nuevo.",
"site_with_error": "Sitio con error. Borrar y añadir de nuevo.",
"files": {
"upload_content": "Cargar contenido a partir de archivos",
"drag_and_drop_your_file_here": "Arrastre y suelte su archivo aquí para añadir el contenido a la base de conocimientos de IA.",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/pt_br.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@
"sites": "Sites",
"text": "Texto"
},
"file_with_error": "Arquivo com erro. Exclua e adicione-o novamente.",
"site_with_error": "Site com erro. Exclua e adicione-o novamente.",
"files": {
"upload_content": "Carregar conteúdo de arquivos",
"drag_and_drop_your_file_here": "Arraste e solte seu arquivo aqui para adicionar o conteúdo à base de conhecimento da IA.",
Expand Down
12 changes: 10 additions & 2 deletions src/views/repository/content/BasesForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,11 @@ export default {
data.results
.map((file) => ({
...file,
status: file.status === 'success' ? 'uploaded' : 'processing',
status:
{
Processing: 'processing',
success: 'uploaded',
}[file.status] || file.status,
}))
.filter(
({ uuid }) =>
Expand Down Expand Up @@ -610,7 +614,11 @@ export default {
...site,
extension_file: 'site',
created_file_name: site.link,
status: site.status === 'success' ? 'uploaded' : 'processing',
status:
{
Processing: 'processing',
success: 'uploaded',
}[site.status] || site.status,
}))
.filter(
({ uuid }) =>
Expand Down
157 changes: 97 additions & 60 deletions src/views/repository/content/BasesFormFilesItem.vue
Original file line number Diff line number Diff line change
@@ -1,66 +1,75 @@
<template>
<div
:class="[
'files-list__content__file',
{ 'files-list__content__file--compressed': compressed },
]"
<UnnnicToolTip
side="top"
:text="failureMessage"
:enabled="file.status === 'fail'"
>
<div class="files-list__content__file__icon">
<UnnnicIcon
:icon="icon"
class="files-list__content__file__icon__itself"
:size="compressed ? 'sm' : 'avatar-nano'"
/>
</div>

<div class="files-list__content__file__content">
<div class="files-list__content__file__content__title">
{{ name }}
</div>

<div class="files-list__content__file__content__status">
<template v-if="file.status === 'uploading'">
{{ $t('content_bases.files.status.uploading') }}
</template>
</div>
</div>

<div class="files-list__content__file__actions">
<UnnnicIcon
v-if="downloading"
icon="cached"
size="sm"
scheme="neutral-cloudy"
class="files-list__content__file__actions__loading"
/>

<UnnnicIcon
v-else-if="file.status === 'uploaded' && file.extension_file !== 'site'"
icon="download"
size="sm"
class="files-list__content__file__actions__icon"
@click.native.stop="download"
/>

<UnnnicIcon
v-if="!file.uuid.startsWith('temp-')"
icon="delete"
size="sm"
class="files-list__content__file__actions__icon"
@click.native.stop="$emit('remove')"
/>
</div>

<div
v-if="file.status === 'uploading'"
:class="['files-list__content__file__status-bar', file.extension_file]"
<section
:class="[
'files-list__content__file',
`files-list__content__file--status-${file.status}`,
{ 'files-list__content__file--compressed': compressed },
]"
>
<div
class="files-list__content__file__status-bar__filled"
:style="{ width: `${file.progress * 100}%` }"
></div>
</div>
</div>
<section class="files-list__content__file__icon">
<UnnnicIcon
:icon="file.status === 'fail' ? 'warning' : icon"
class="files-list__content__file__icon__itself"
:size="compressed ? 'sm' : 'avatar-nano'"
/>
</section>

<header class="files-list__content__file__content">
<p class="files-list__content__file__content__title">
{{ name }}
</p>

<p class="files-list__content__file__content__status">
<template v-if="file.status === 'uploading'">
{{ $t('content_bases.files.status.uploading') }}
</template>
</p>
</header>

<section class="files-list__content__file__actions">
<UnnnicIcon
v-if="downloading"
icon="cached"
size="sm"
scheme="neutral-cloudy"
class="files-list__content__file__actions__loading"
/>

<UnnnicIcon
v-else-if="
file.status === 'uploaded' && file.extension_file !== 'site'
"
icon="download"
size="sm"
class="files-list__content__file__actions__icon"
@click.native.stop="download"
/>

<UnnnicIcon
v-if="!file.uuid.startsWith('temp-')"
icon="delete"
size="sm"
class="files-list__content__file__actions__icon"
@click.native.stop="$emit('remove')"
/>
</section>

<section
v-if="file.status === 'uploading'"
:class="['files-list__content__file__status-bar', file.extension_file]"
>
<div
class="files-list__content__file__status-bar__filled"
:style="{ width: `${file.progress * 100}%` }"
></div>
</section>
</section>
</UnnnicToolTip>
</template>

<script>
Expand Down Expand Up @@ -103,6 +112,13 @@ export default {
: this.fileName.slice(this.fileName.lastIndexOf('.') + 1);
},
failureMessage() {
const message =
{ site: 'site_with_error' }[this.extension] || 'file_with_error';
return this.$t(`content_bases.${message}`);
},
icon() {
return (
{
Expand Down Expand Up @@ -182,6 +198,10 @@ export default {
align-items: center;
position: relative;
p {
margin: 0;
}
&--compressed {
column-gap: $unnnic-spacing-xs;
Expand All @@ -190,6 +210,23 @@ export default {
}
}
&--status-fail {
outline-color: $unnnic-color-aux-red-500;
background-color: $unnnic-color-aux-red-100;
color: $unnnic-color-aux-red-500;
.files-list__content__file__icon {
background-color: inherit;
}
.files-list__content__file__icon__itself,
.files-list__content__file__content__title,
.files-list__content__file__actions__icon,
.files-list__content__file__actions__loading {
color: inherit;
}
}
&__icon {
display: flex;
background-color: $unnnic-color-neutral-light;
Expand Down

0 comments on commit 9b11575

Please sign in to comment.