feat: exportar logs a csv desde la interfaz del usuario

This commit is contained in:
fede committed 2026-07-20 18:21:21 -03:00
1 parent 6d123ea01d
commit 605d2e763f
4 files changed
+43 -2

No files matched your search

+4
View File
@@ -20,3 +20,7 @@ AGENTS.md
.idea .idea
*.log *.log
.opencode
bun.lock
+7
View File
@@ -2,6 +2,13 @@ export class ExportarLogs {
#data; #data;
constructor(logs) { constructor(logs) {
logs.forEach((x) => {
x.detalles.forEach((y) => {
if (typeof y.valorAnterior == 'undefined') {
y.valorAnterior = '.';
}
});
});
this.#data = this.#extraerInfo(logs); this.#data = this.#extraerInfo(logs);
} }
+27 -2
View File
@@ -12,9 +12,10 @@
TableHeader, TableHeader,
TableRow TableRow
} from 'carbon-components-svelte'; } from 'carbon-components-svelte';
import { Add, Edit, Information, TrashCan } from 'carbon-icons-svelte'; import { ArrowUp, Add, Edit, Information, TrashCan } from 'carbon-icons-svelte';
import CrearRepuestoForm from './CrearRepuestoForm.svelte'; import CrearRepuestoForm from './CrearRepuestoForm.svelte';
import EliminarRepuestoForm from './EliminarRepuestoForm.svelte'; import EliminarRepuestoForm from './EliminarRepuestoForm.svelte';
import AltaRepuestoForm from './AltaRepuestoForm.svelte';
import ModalStructured from '$lib/components/ModalStructured.svelte'; import ModalStructured from '$lib/components/ModalStructured.svelte';
import EditarRepuestoForm from './EditarRepuestoForm.svelte'; import EditarRepuestoForm from './EditarRepuestoForm.svelte';
@@ -26,10 +27,12 @@
let openCrear = $state(false); let openCrear = $state(false);
let openEliminar = $state(false); let openEliminar = $state(false);
let openInfo = $state(false); let openInfo = $state(false);
let openAlta = $state(false);
let openEditar = $state(false); let openEditar = $state(false);
let repuestoEliminar = $state({ id: 0 }); let repuestoEliminar = $state({ id: 0 });
let repuestoEditar = $state({ id: 0 }); let repuestoEditar = $state({ id: 0 });
let repuestoAlta = $state({ id: 0 });
let repuestoInfo = $state(); let repuestoInfo = $state();
$effect(() => { $effect(() => {
@@ -43,7 +46,8 @@
{ key: 'nombre', value: 'Nombre' }, { key: 'nombre', value: 'Nombre' },
{ key: 'descripcion', value: 'Descripción' }, { key: 'descripcion', value: 'Descripción' },
{ key: 'precio', value: 'Precio' }, { key: 'precio', value: 'Precio' },
{ key: 'marcaId', value: 'Marca' } { key: 'marcaId', value: 'Marca' },
{ key: 'deleted_at', value: 'Estado' }
]; ];
</script> </script>
@@ -101,6 +105,7 @@
size="small" size="small"
icon={Information}>Ver registro</Button icon={Information}>Ver registro</Button
> >
{#if p.deleted_at == '✔'}
<Button <Button
onclick={() => { onclick={() => {
repuestoEliminar = p; repuestoEliminar = p;
@@ -110,6 +115,17 @@
size="small" size="small"
icon={TrashCan}>Eliminar</Button icon={TrashCan}>Eliminar</Button
> >
{:else}
<Button
onclick={() => {
repuestoAlta = p;
openAlta = true;
}}
kind="ghost"
size="small"
icon={ArrowUp}>Alta</Button
>
{/if}
</TableCell> </TableCell>
</TableRow> </TableRow>
{/each} {/each}
@@ -136,6 +152,15 @@
repuesto={repuestoEliminar} repuesto={repuestoEliminar}
></EliminarRepuestoForm> ></EliminarRepuestoForm>
<AltaRepuestoForm
bind:show={openAlta}
onclose={() => {
openAlta = false;
repuestoAlta = { id: 0 };
}}
repuesto={repuestoAlta}
></AltaRepuestoForm>
<EditarRepuestoForm <EditarRepuestoForm
bind:open={openEditar} bind:open={openEditar}
onClose={() => { onClose={() => {
+5
View File
@@ -8,6 +8,11 @@ export async function load({ fetch, depends }) {
let error = ''; let error = '';
if (typeof repuestos === 'string') { if (typeof repuestos === 'string') {
error = repuestos; error = repuestos;
} else {
if (typeof repuestos[0].deleted_at !== 'undefined')
repuestos.forEach((x) => {
x.deleted_at = x.deleted_at ? '✗' : '✔';
});
} }
return { return {
repuestos: repuestos, repuestos: repuestos,