localize UI to english
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
|||||||
PromptInputTools,
|
PromptInputTools,
|
||||||
} from "@/components/ai-elements/prompt-input";
|
} from "@/components/ai-elements/prompt-input";
|
||||||
import { Action, Actions } from "@/components/ai-elements/actions";
|
import { Action, Actions } from "@/components/ai-elements/actions";
|
||||||
import { Fragment, useState, useEffect } from "react";
|
import { Fragment, useState, useEffect, useMemo } from "react";
|
||||||
import { useChat } from "@ai-sdk/react";
|
import { useChat } from "@ai-sdk/react";
|
||||||
import { Response } from "@/components/ai-elements/response";
|
import { Response } from "@/components/ai-elements/response";
|
||||||
import {
|
import {
|
||||||
@@ -56,7 +56,7 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
setError(`Error en el chat: ${error.message}`);
|
setError(`Chat error: ${error.message}`);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -84,20 +84,32 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
|
|||||||
{
|
{
|
||||||
body: {
|
body: {
|
||||||
dataroom: selectedTema,
|
dataroom: selectedTema,
|
||||||
context: `Usuario está consultando sobre el dataroom: ${selectedTema}`,
|
context: `User is asking about the dataroom: ${selectedTema}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
setInput("");
|
setInput("");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const hasActiveToolRequest = useMemo(() => {
|
||||||
|
return messages.some((message) =>
|
||||||
|
message.parts.some(
|
||||||
|
(part: any) =>
|
||||||
|
typeof part?.type === "string" &&
|
||||||
|
part.type.startsWith("tool-") &&
|
||||||
|
part.state === "input-available",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}, [messages]);
|
||||||
|
|
||||||
|
const shouldShowGlobalLoader =
|
||||||
|
(status === "streaming" || status === "loading") && !hasActiveToolRequest;
|
||||||
|
|
||||||
if (!selectedTema) {
|
if (!selectedTema) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center h-64">
|
<div className="flex flex-col items-center justify-center h-64">
|
||||||
<MessageCircle className="w-12 h-12 text-gray-400 mb-4" />
|
<MessageCircle className="w-12 h-12 text-gray-400 mb-4" />
|
||||||
<p className="text-gray-500">
|
<p className="text-gray-500">Select a dataroom to start chatting</p>
|
||||||
Selecciona un dataroom para iniciar el chat
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -115,9 +127,9 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex-1 bg-gray-50 rounded-lg p-4">
|
<div className="flex-1 bg-gray-50 rounded-lg p-4">
|
||||||
<p className="text-sm text-gray-800">
|
<p className="text-sm text-gray-800">
|
||||||
¡Hola! Soy tu asistente de IA para el dataroom{" "}
|
Hi! I’m your AI assistant for dataroom{" "}
|
||||||
<strong>{selectedTema}</strong>. Puedes hacerme preguntas
|
<strong>{selectedTema}</strong>. Ask me anything about the
|
||||||
sobre los documentos almacenados aquí.
|
stored documents.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -206,11 +218,11 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={`${message.id}-${i}`}
|
key={`${message.id}-${i}`}
|
||||||
className="flex items-center gap-2 p-4 bg-blue-50 rounded-lg border border-blue-200"
|
className="mb-4 flex items-center gap-2 p-4 bg-blue-50 rounded-lg border border-blue-200"
|
||||||
>
|
>
|
||||||
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"></div>
|
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"></div>
|
||||||
<span className="text-sm text-blue-700">
|
<span className="text-sm text-blue-700">
|
||||||
Generando reporte de auditoría...
|
Generating audit report…
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -218,7 +230,7 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={`${message.id}-${i}`}
|
key={`${message.id}-${i}`}
|
||||||
className="mt-4 w-full"
|
className="mt-4 mb-4 w-full"
|
||||||
>
|
>
|
||||||
<div className="max-w-full overflow-hidden">
|
<div className="max-w-full overflow-hidden">
|
||||||
<AuditReport data={part.output} />
|
<AuditReport data={part.output} />
|
||||||
@@ -229,12 +241,12 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={`${message.id}-${i}`}
|
key={`${message.id}-${i}`}
|
||||||
className="p-4 bg-red-50 border border-red-200 rounded-lg"
|
className="mb-4 p-4 bg-red-50 border border-red-200 rounded-lg"
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<AlertCircle className="w-4 h-4 text-red-600" />
|
<AlertCircle className="w-4 h-4 text-red-600" />
|
||||||
<span className="text-sm font-medium text-red-800">
|
<span className="text-sm font-medium text-red-800">
|
||||||
Error generando reporte de auditoría
|
Failed to generate audit report
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm text-red-600 mt-1">
|
<p className="text-sm text-red-600 mt-1">
|
||||||
@@ -251,11 +263,11 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={`${message.id}-${i}`}
|
key={`${message.id}-${i}`}
|
||||||
className="flex items-center gap-2 p-4 bg-purple-50 rounded-lg border border-purple-200"
|
className="mb-4 flex items-center gap-2 p-4 bg-purple-50 rounded-lg border border-purple-200"
|
||||||
>
|
>
|
||||||
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-purple-600"></div>
|
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-purple-600"></div>
|
||||||
<span className="text-sm text-purple-700">
|
<span className="text-sm text-purple-700">
|
||||||
Generando análisis histórico...
|
Generating performance analysis…
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -263,7 +275,7 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={`${message.id}-${i}`}
|
key={`${message.id}-${i}`}
|
||||||
className="mt-4 w-full"
|
className="mt-4 mb-4 w-full"
|
||||||
>
|
>
|
||||||
<div className="max-w-full overflow-hidden">
|
<div className="max-w-full overflow-hidden">
|
||||||
<AnalystReport data={part.output} />
|
<AnalystReport data={part.output} />
|
||||||
@@ -274,12 +286,12 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={`${message.id}-${i}`}
|
key={`${message.id}-${i}`}
|
||||||
className="p-4 bg-red-50 border border-red-200 rounded-lg"
|
className="mb-4 p-4 bg-red-50 border border-red-200 rounded-lg"
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<AlertCircle className="w-4 h-4 text-red-600" />
|
<AlertCircle className="w-4 h-4 text-red-600" />
|
||||||
<span className="text-sm font-medium text-red-800">
|
<span className="text-sm font-medium text-red-800">
|
||||||
Error generando análisis histórico
|
Failed to generate performance analysis
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm text-red-600 mt-1">
|
<p className="text-sm text-red-600 mt-1">
|
||||||
@@ -296,11 +308,11 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={`${message.id}-${i}`}
|
key={`${message.id}-${i}`}
|
||||||
className="flex items-center gap-2 p-4 bg-green-50 rounded-lg border border-green-200"
|
className="mb-4 flex items-center gap-2 p-4 bg-green-50 rounded-lg border border-green-200"
|
||||||
>
|
>
|
||||||
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-green-600"></div>
|
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-green-600"></div>
|
||||||
<span className="text-sm text-green-700">
|
<span className="text-sm text-green-700">
|
||||||
Searching the web...
|
Searching the web…
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -308,7 +320,7 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={`${message.id}-${i}`}
|
key={`${message.id}-${i}`}
|
||||||
className="mt-4 w-full"
|
className="mt-4 mb-4 w-full"
|
||||||
>
|
>
|
||||||
<div className="max-w-full overflow-hidden">
|
<div className="max-w-full overflow-hidden">
|
||||||
<WebSearchResults data={part.output} />
|
<WebSearchResults data={part.output} />
|
||||||
@@ -319,12 +331,12 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={`${message.id}-${i}`}
|
key={`${message.id}-${i}`}
|
||||||
className="p-4 bg-red-50 border border-red-200 rounded-lg"
|
className="mb-4 p-4 bg-red-50 border border-red-200 rounded-lg"
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<AlertCircle className="w-4 h-4 text-red-600" />
|
<AlertCircle className="w-4 h-4 text-red-600" />
|
||||||
<span className="text-sm font-medium text-red-800">
|
<span className="text-sm font-medium text-red-800">
|
||||||
Error searching the web
|
Failed to search the web
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm text-red-600 mt-1">
|
<p className="text-sm text-red-600 mt-1">
|
||||||
@@ -341,8 +353,7 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{status === "streaming" && <Loader />}
|
{shouldShowGlobalLoader && <Loader />}
|
||||||
{status === "loading" && <Loader />}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -363,7 +374,7 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
|
|||||||
<PromptInputTextarea
|
<PromptInputTextarea
|
||||||
onChange={(e) => setInput(e.target.value)}
|
onChange={(e) => setInput(e.target.value)}
|
||||||
value={input}
|
value={input}
|
||||||
placeholder={`Pregunta algo sobre ${selectedTema}...`}
|
placeholder={`Ask something about ${selectedTema}...`}
|
||||||
disabled={status === "streaming" || status === "loading"}
|
disabled={status === "streaming" || status === "loading"}
|
||||||
className="min-h-[60px] resize-none border-0 focus:ring-0 transition-all duration-200 text-base px-4 py-3 bg-white rounded-xl"
|
className="min-h-[60px] resize-none border-0 focus:ring-0 transition-all duration-200 text-base px-4 py-3 bg-white rounded-xl"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -59,9 +59,8 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
|
|||||||
const info = await api.getDataroomInfo(selectedTema);
|
const info = await api.getDataroomInfo(selectedTema);
|
||||||
setDataroomInfo(info);
|
setDataroomInfo(info);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const errorMessage =
|
const errorMessage = err instanceof Error ? err.message : "Unknown error";
|
||||||
err instanceof Error ? err.message : "Error desconocido";
|
setError(`Unable to load dataroom info: ${errorMessage}`);
|
||||||
setError(`Error cargando información: ${errorMessage}`);
|
|
||||||
console.error("Error fetching dataroom info:", err);
|
console.error("Error fetching dataroom info:", err);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -70,7 +69,7 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
|
|||||||
|
|
||||||
const formatFileTypes = (fileTypes: Record<string, number>) => {
|
const formatFileTypes = (fileTypes: Record<string, number>) => {
|
||||||
const entries = Object.entries(fileTypes);
|
const entries = Object.entries(fileTypes);
|
||||||
if (entries.length === 0) return "Sin archivos";
|
if (entries.length === 0) return "No files";
|
||||||
|
|
||||||
return entries
|
return entries
|
||||||
.sort(([, a], [, b]) => b - a) // Sort by count descending
|
.sort(([, a], [, b]) => b - a) // Sort by count descending
|
||||||
@@ -90,9 +89,7 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center h-64">
|
<div className="flex flex-col items-center justify-center h-64">
|
||||||
<Activity className="w-12 h-12 text-gray-400 mb-4" />
|
<Activity className="w-12 h-12 text-gray-400 mb-4" />
|
||||||
<p className="text-gray-500">
|
<p className="text-gray-500">Select a dataroom to view its metrics</p>
|
||||||
Selecciona un dataroom para ver las métricas
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -101,7 +98,7 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center h-64">
|
<div className="flex flex-col items-center justify-center h-64">
|
||||||
<Loader2 className="w-8 h-8 text-blue-600 animate-spin mb-4" />
|
<Loader2 className="w-8 h-8 text-blue-600 animate-spin mb-4" />
|
||||||
<p className="text-gray-600">Cargando métricas...</p>
|
<p className="text-gray-600">Loading metrics…</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -124,24 +121,14 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center h-64">
|
<div className="flex flex-col items-center justify-center h-64">
|
||||||
<AlertCircle className="w-12 h-12 text-gray-400 mb-4" />
|
<AlertCircle className="w-12 h-12 text-gray-400 mb-4" />
|
||||||
<p className="text-gray-500">
|
<p className="text-gray-500">Unable to load dataroom information</p>
|
||||||
No se pudo cargar la información del dataroom
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-6">
|
<div className="p-6">
|
||||||
<div className="mb-6">
|
<h4 className="text-md font-semibold text-gray-900 mb-4">Metrics</h4>
|
||||||
<h3 className="text-lg font-semibold text-gray-900 mb-2">
|
|
||||||
Métricas del Dataroom: {selectedTema}
|
|
||||||
</h3>
|
|
||||||
<p className="text-sm text-gray-600">
|
|
||||||
Vista general del estado y actividad del dataroom
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
||||||
{/* Files Count Card */}
|
{/* Files Count Card */}
|
||||||
<div className="bg-white border border-gray-200 rounded-lg p-4">
|
<div className="bg-white border border-gray-200 rounded-lg p-4">
|
||||||
@@ -150,7 +137,7 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
|
|||||||
<FileText className="w-5 h-5 text-blue-600" />
|
<FileText className="w-5 h-5 text-blue-600" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-sm font-medium text-gray-600">Archivos</p>
|
<p className="text-sm font-medium text-gray-600">Files</p>
|
||||||
<p className="text-2xl font-bold text-gray-900">
|
<p className="text-2xl font-bold text-gray-900">
|
||||||
{dataroomInfo.file_count}
|
{dataroomInfo.file_count}
|
||||||
</p>
|
</p>
|
||||||
@@ -168,9 +155,7 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
|
|||||||
<Database className="w-5 h-5 text-green-600" />
|
<Database className="w-5 h-5 text-green-600" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-sm font-medium text-gray-600">
|
<p className="text-sm font-medium text-gray-600">Storage</p>
|
||||||
Almacenamiento
|
|
||||||
</p>
|
|
||||||
<p className="text-2xl font-bold text-gray-900">
|
<p className="text-2xl font-bold text-gray-900">
|
||||||
{dataroomInfo.total_size_mb.toFixed(1)} MB
|
{dataroomInfo.total_size_mb.toFixed(1)} MB
|
||||||
</p>
|
</p>
|
||||||
@@ -188,14 +173,14 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
|
|||||||
<Activity className="w-5 h-5 text-purple-600" />
|
<Activity className="w-5 h-5 text-purple-600" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-sm font-medium text-gray-600">Vectores</p>
|
<p className="text-sm font-medium text-gray-600">Vectors</p>
|
||||||
<p className="text-2xl font-bold text-gray-900">
|
<p className="text-2xl font-bold text-gray-900">
|
||||||
{dataroomInfo.vector_count ?? 0}
|
{dataroomInfo.vector_count ?? 0}
|
||||||
</p>
|
</p>
|
||||||
<p className="text-xs text-gray-500 mt-1">
|
<p className="text-xs text-gray-500 mt-1">
|
||||||
{dataroomInfo.collection_exists
|
{dataroomInfo.collection_exists
|
||||||
? "Vectores indexados"
|
? "Indexed vectors"
|
||||||
: "Sin vectores"}
|
: "No vectors"}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -208,10 +193,10 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
|
|||||||
<TrendingUp className="w-5 h-5 text-orange-600" />
|
<TrendingUp className="w-5 h-5 text-orange-600" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-sm font-medium text-gray-600">Estado</p>
|
<p className="text-sm font-medium text-gray-600">Status</p>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<p className="text-2xl font-bold text-gray-900">
|
<p className="text-2xl font-bold text-gray-900">
|
||||||
{dataroomInfo.collection_exists ? "Activo" : "Inactivo"}
|
{dataroomInfo.collection_exists ? "Active" : "Inactive"}
|
||||||
</p>
|
</p>
|
||||||
{dataroomInfo.collection_exists ? (
|
{dataroomInfo.collection_exists ? (
|
||||||
<CheckCircle className="w-6 h-6 text-green-600" />
|
<CheckCircle className="w-6 h-6 text-green-600" />
|
||||||
@@ -222,14 +207,13 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
|
|||||||
{dataroomInfo.collection_info ? (
|
{dataroomInfo.collection_info ? (
|
||||||
<p className="text-xs text-gray-500 mt-1">
|
<p className="text-xs text-gray-500 mt-1">
|
||||||
{dataroomInfo.collection_info.indexed_vectors_count}/
|
{dataroomInfo.collection_info.indexed_vectors_count}/
|
||||||
{dataroomInfo.collection_info.vectors_count} vectores
|
{dataroomInfo.collection_info.vectors_count} indexed vectors
|
||||||
indexados
|
|
||||||
</p>
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<p className="text-xs text-gray-500 mt-1">
|
<p className="text-xs text-gray-500 mt-1">
|
||||||
{dataroomInfo.collection_exists
|
{dataroomInfo.collection_exists
|
||||||
? "Colección sin datos"
|
? "Collection has no data"
|
||||||
: "Sin colección"}
|
: "No collection"}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -241,7 +225,7 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
|
|||||||
{dataroomInfo.recent_files.length > 0 && (
|
{dataroomInfo.recent_files.length > 0 && (
|
||||||
<div className="mt-8">
|
<div className="mt-8">
|
||||||
<h4 className="text-md font-semibold text-gray-900 mb-4">
|
<h4 className="text-md font-semibold text-gray-900 mb-4">
|
||||||
Archivos Recientes
|
Recent Files
|
||||||
</h4>
|
</h4>
|
||||||
<div className="bg-white border border-gray-200 rounded-lg overflow-hidden">
|
<div className="bg-white border border-gray-200 rounded-lg overflow-hidden">
|
||||||
<div className="divide-y divide-gray-200">
|
<div className="divide-y divide-gray-200">
|
||||||
@@ -258,7 +242,7 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
|
|||||||
</p>
|
</p>
|
||||||
<p className="text-xs text-gray-500">
|
<p className="text-xs text-gray-500">
|
||||||
{new Date(file.last_modified).toLocaleDateString(
|
{new Date(file.last_modified).toLocaleDateString(
|
||||||
"es-ES",
|
"en-US",
|
||||||
{
|
{
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
month: "short",
|
month: "short",
|
||||||
|
|||||||
@@ -87,14 +87,12 @@ export function DataroomView({ onProcessingChange }: DataroomViewProps = {}) {
|
|||||||
<div className="flex flex-wrap items-center justify-between gap-4">
|
<div className="flex flex-wrap items-center justify-between gap-4">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-2xl font-semibold text-gray-900 mb-2">
|
<h2 className="text-2xl font-semibold text-gray-900 mb-2">
|
||||||
{selectedTema
|
{selectedTema ? `Dataroom: ${selectedTema}` : "Select a dataroom"}
|
||||||
? `Dataroom: ${selectedTema}`
|
|
||||||
: "Selecciona un dataroom"}
|
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-sm text-gray-600">
|
<p className="text-sm text-gray-600">
|
||||||
{selectedTema
|
{selectedTema
|
||||||
? "Gestiona archivos, consulta métricas y chatea con IA sobre el contenido"
|
? "Manage files, review metrics, and chat with AI about the content."
|
||||||
: "Selecciona un dataroom de la barra lateral para comenzar"}
|
: "Pick a dataroom from the sidebar to get started."}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Button } from '@/components/ui/button'
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
@@ -6,17 +6,17 @@ import {
|
|||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from '@/components/ui/dialog'
|
} from "@/components/ui/dialog";
|
||||||
import { Trash2, AlertTriangle } from 'lucide-react'
|
import { Trash2, AlertTriangle } from "lucide-react";
|
||||||
|
|
||||||
interface DeleteConfirmDialogProps {
|
interface DeleteConfirmDialogProps {
|
||||||
open: boolean
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void
|
onOpenChange: (open: boolean) => void;
|
||||||
onConfirm: () => void
|
onConfirm: () => void;
|
||||||
title: string
|
title: string;
|
||||||
description: string
|
description: string;
|
||||||
fileList?: string[]
|
fileList?: string[];
|
||||||
loading?: boolean
|
loading?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DeleteConfirmDialog({
|
export function DeleteConfirmDialog({
|
||||||
@@ -26,7 +26,7 @@ export function DeleteConfirmDialog({
|
|||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
fileList,
|
fileList,
|
||||||
loading = false
|
loading = false,
|
||||||
}: DeleteConfirmDialogProps) {
|
}: DeleteConfirmDialogProps) {
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
@@ -41,7 +41,7 @@ export function DeleteConfirmDialog({
|
|||||||
|
|
||||||
{fileList && fileList.length > 0 && (
|
{fileList && fileList.length > 0 && (
|
||||||
<div className="max-h-40 overflow-y-auto bg-gray-50 rounded p-3">
|
<div className="max-h-40 overflow-y-auto bg-gray-50 rounded p-3">
|
||||||
<p className="text-sm font-medium mb-2">Archivos a eliminar:</p>
|
<p className="text-sm font-medium mb-2">Files to delete:</p>
|
||||||
<ul className="text-sm space-y-1">
|
<ul className="text-sm space-y-1">
|
||||||
{fileList.map((filename, index) => (
|
{fileList.map((filename, index) => (
|
||||||
<li key={index} className="flex items-center gap-2">
|
<li key={index} className="flex items-center gap-2">
|
||||||
@@ -59,17 +59,13 @@ export function DeleteConfirmDialog({
|
|||||||
onClick={() => onOpenChange(false)}
|
onClick={() => onOpenChange(false)}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
>
|
>
|
||||||
Cancelar
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button variant="destructive" onClick={onConfirm} disabled={loading}>
|
||||||
variant="destructive"
|
{loading ? "Deleting…" : "Delete"}
|
||||||
onClick={onConfirm}
|
|
||||||
disabled={loading}
|
|
||||||
>
|
|
||||||
{loading ? 'Eliminando...' : 'Eliminar'}
|
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ export function FilesTab({
|
|||||||
const [deleting, setDeleting] = useState(false);
|
const [deleting, setDeleting] = useState(false);
|
||||||
const [downloading, setDownloading] = useState(false);
|
const [downloading, setDownloading] = useState(false);
|
||||||
|
|
||||||
// Estados para el modal de preview de PDF
|
// PDF preview modal state
|
||||||
const [previewModalOpen, setPreviewModalOpen] = useState(false);
|
const [previewModalOpen, setPreviewModalOpen] = useState(false);
|
||||||
const [previewFileUrl, setPreviewFileUrl] = useState<string | null>(null);
|
const [previewFileUrl, setPreviewFileUrl] = useState<string | null>(null);
|
||||||
const [previewFileName, setPreviewFileName] = useState("");
|
const [previewFileName, setPreviewFileName] = useState("");
|
||||||
@@ -69,12 +69,12 @@ export function FilesTab({
|
|||||||
);
|
);
|
||||||
const [loadingPreview, setLoadingPreview] = useState(false);
|
const [loadingPreview, setLoadingPreview] = useState(false);
|
||||||
|
|
||||||
// Estados para el modal de chunks
|
// Chunk viewer modal state
|
||||||
const [chunkViewerOpen, setChunkViewerOpen] = useState(false);
|
const [chunkViewerOpen, setChunkViewerOpen] = useState(false);
|
||||||
const [chunkFileName, setChunkFileName] = useState("");
|
const [chunkFileName, setChunkFileName] = useState("");
|
||||||
const [chunkFileTema, setChunkFileTema] = useState("");
|
const [chunkFileTema, setChunkFileTema] = useState("");
|
||||||
|
|
||||||
// Estados para chunking
|
// LandingAI chunking state
|
||||||
const [chunkingConfigOpen, setChunkingConfigOpen] = useState(false);
|
const [chunkingConfigOpen, setChunkingConfigOpen] = useState(false);
|
||||||
const [chunkingFileName, setChunkingFileName] = useState("");
|
const [chunkingFileName, setChunkingFileName] = useState("");
|
||||||
const [chunkingFileTema, setChunkingFileTema] = useState("");
|
const [chunkingFileTema, setChunkingFileTema] = useState("");
|
||||||
@@ -123,10 +123,10 @@ export function FilesTab({
|
|||||||
setDeleting(true);
|
setDeleting(true);
|
||||||
|
|
||||||
if (fileToDelete) {
|
if (fileToDelete) {
|
||||||
// Eliminar archivo individual
|
// Delete single file
|
||||||
await api.deleteFile(fileToDelete, selectedTema || undefined);
|
await api.deleteFile(fileToDelete, selectedTema || undefined);
|
||||||
} else {
|
} else {
|
||||||
// Eliminar archivos seleccionados
|
// Delete selected files
|
||||||
const filesToDelete = Array.from(selectedFiles);
|
const filesToDelete = Array.from(selectedFiles);
|
||||||
await api.deleteFiles(filesToDelete, selectedTema || undefined);
|
await api.deleteFiles(filesToDelete, selectedTema || undefined);
|
||||||
clearSelection();
|
clearSelection();
|
||||||
@@ -159,9 +159,7 @@ export function FilesTab({
|
|||||||
try {
|
try {
|
||||||
setDownloading(true);
|
setDownloading(true);
|
||||||
const filesToDownload = Array.from(selectedFiles);
|
const filesToDownload = Array.from(selectedFiles);
|
||||||
const zipName = selectedTema
|
const zipName = selectedTema ? `${selectedTema}_files` : "selected_files";
|
||||||
? `${selectedTema}_archivos`
|
|
||||||
: "archivos_seleccionados";
|
|
||||||
await api.downloadMultipleFiles(
|
await api.downloadMultipleFiles(
|
||||||
filesToDownload,
|
filesToDownload,
|
||||||
selectedTema || undefined,
|
selectedTema || undefined,
|
||||||
@@ -234,7 +232,7 @@ export function FilesTab({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Filtrar archivos por término de búsqueda
|
// Filter files by search term
|
||||||
const filteredFiles = files.filter((file) =>
|
const filteredFiles = files.filter((file) =>
|
||||||
file.name.toLowerCase().includes(searchTerm.toLowerCase()),
|
file.name.toLowerCase().includes(searchTerm.toLowerCase()),
|
||||||
);
|
);
|
||||||
@@ -250,7 +248,7 @@ export function FilesTab({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const formatDate = (dateString: string): string => {
|
const formatDate = (dateString: string): string => {
|
||||||
return new Date(dateString).toLocaleDateString("es-ES", {
|
return new Date(dateString).toLocaleDateString("en-US", {
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
month: "short",
|
month: "short",
|
||||||
day: "numeric",
|
day: "numeric",
|
||||||
@@ -262,15 +260,15 @@ export function FilesTab({
|
|||||||
const getDeleteDialogProps = () => {
|
const getDeleteDialogProps = () => {
|
||||||
if (fileToDelete) {
|
if (fileToDelete) {
|
||||||
return {
|
return {
|
||||||
title: "Eliminar archivo",
|
title: "Delete file",
|
||||||
message: `¿Estás seguro de que deseas eliminar el archivo "${fileToDelete}"?`,
|
message: `Are you sure you want to delete "${fileToDelete}"?`,
|
||||||
fileList: [fileToDelete],
|
fileList: [fileToDelete],
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const filesToDelete = Array.from(selectedFiles);
|
const filesToDelete = Array.from(selectedFiles);
|
||||||
return {
|
return {
|
||||||
title: "Eliminar archivos seleccionados",
|
title: "Delete selected files",
|
||||||
message: `¿Estás seguro de que deseas eliminar ${filesToDelete.length} archivo${filesToDelete.length > 1 ? "s" : ""}?`,
|
message: `Are you sure you want to delete ${filesToDelete.length} file${filesToDelete.length > 1 ? "s" : ""}?`,
|
||||||
fileList: filesToDelete,
|
fileList: filesToDelete,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -280,9 +278,7 @@ export function FilesTab({
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center h-64">
|
<div className="flex flex-col items-center justify-center h-64">
|
||||||
<FileText className="w-12 h-12 text-gray-400 mb-4" />
|
<FileText className="w-12 h-12 text-gray-400 mb-4" />
|
||||||
<p className="text-gray-500">
|
<p className="text-gray-500">Select a dataroom to view its files</p>
|
||||||
Selecciona un dataroom para ver sus archivos
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -294,7 +290,7 @@ export function FilesTab({
|
|||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"></div>
|
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"></div>
|
||||||
<span className="text-sm text-blue-800">
|
<span className="text-sm text-blue-800">
|
||||||
Procesando archivos con LandingAI...
|
Processing files with LandingAI…
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -305,7 +301,7 @@ export function FilesTab({
|
|||||||
<div className="relative flex-1 max-w-md">
|
<div className="relative flex-1 max-w-md">
|
||||||
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4" />
|
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4" />
|
||||||
<Input
|
<Input
|
||||||
placeholder="Buscar archivos..."
|
placeholder="Search files..."
|
||||||
value={searchTerm}
|
value={searchTerm}
|
||||||
onChange={(e) => setSearchTerm(e.target.value)}
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
className="pl-10"
|
className="pl-10"
|
||||||
@@ -324,7 +320,7 @@ export function FilesTab({
|
|||||||
className="gap-2"
|
className="gap-2"
|
||||||
>
|
>
|
||||||
<Download className="w-4 h-4" />
|
<Download className="w-4 h-4" />
|
||||||
Descargar ({selectedFiles.size})
|
Download ({selectedFiles.size})
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
@@ -334,7 +330,7 @@ export function FilesTab({
|
|||||||
className="gap-2 text-red-600 hover:text-red-700"
|
className="gap-2 text-red-600 hover:text-red-700"
|
||||||
>
|
>
|
||||||
<Trash2 className="w-4 h-4" />
|
<Trash2 className="w-4 h-4" />
|
||||||
Eliminar ({selectedFiles.size})
|
Delete ({selectedFiles.size})
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
@@ -345,7 +341,7 @@ export function FilesTab({
|
|||||||
className="gap-2"
|
className="gap-2"
|
||||||
>
|
>
|
||||||
<Upload className="w-4 h-4" />
|
<Upload className="w-4 h-4" />
|
||||||
Subir archivo
|
Upload files
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -355,17 +351,17 @@ export function FilesTab({
|
|||||||
<div className="p-6">
|
<div className="p-6">
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<div className="flex items-center justify-center h-64">
|
<div className="flex items-center justify-center h-64">
|
||||||
<p className="text-gray-500">Cargando archivos...</p>
|
<p className="text-gray-500">Loading files…</p>
|
||||||
</div>
|
</div>
|
||||||
) : filteredFiles.length === 0 ? (
|
) : filteredFiles.length === 0 ? (
|
||||||
<div className="flex flex-col items-center justify-center h-64">
|
<div className="flex flex-col items-center justify-center h-64">
|
||||||
<FileText className="w-12 h-12 text-gray-400 mb-4" />
|
<FileText className="w-12 h-12 text-gray-400 mb-4" />
|
||||||
<p className="text-gray-500">
|
<p className="text-gray-500">
|
||||||
{!selectedTema
|
{!selectedTema
|
||||||
? "Selecciona un dataroom para ver sus archivos"
|
? "Select a dataroom to view its files"
|
||||||
: searchTerm
|
: searchTerm
|
||||||
? "No se encontraron archivos"
|
? "No files match your search"
|
||||||
: "No hay archivos en este dataroom"}
|
: "This dataroom has no files yet"}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@@ -387,10 +383,10 @@ export function FilesTab({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableHead>Archivo</TableHead>
|
<TableHead>File</TableHead>
|
||||||
<TableHead>Tamaño</TableHead>
|
<TableHead>Size</TableHead>
|
||||||
<TableHead>Modificado</TableHead>
|
<TableHead>Modified</TableHead>
|
||||||
<TableHead className="text-right">Acciones</TableHead>
|
<TableHead className="text-right">Actions</TableHead>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
@@ -418,7 +414,7 @@ export function FilesTab({
|
|||||||
onClick={() => handlePreviewFile(file.name)}
|
onClick={() => handlePreviewFile(file.name)}
|
||||||
disabled={loadingPreview}
|
disabled={loadingPreview}
|
||||||
className="h-8 w-8 p-0"
|
className="h-8 w-8 p-0"
|
||||||
title="Vista previa"
|
title="Preview"
|
||||||
>
|
>
|
||||||
<Eye className="w-4 h-4" />
|
<Eye className="w-4 h-4" />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -427,7 +423,7 @@ export function FilesTab({
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => handleViewChunks(file.name)}
|
onClick={() => handleViewChunks(file.name)}
|
||||||
className="h-8 w-8 p-0"
|
className="h-8 w-8 p-0"
|
||||||
title="Ver chunks"
|
title="View chunks"
|
||||||
>
|
>
|
||||||
<MessageSquare className="w-4 h-4" />
|
<MessageSquare className="w-4 h-4" />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -436,7 +432,7 @@ export function FilesTab({
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => handleStartChunking(file.name)}
|
onClick={() => handleStartChunking(file.name)}
|
||||||
className="h-8 w-8 p-0"
|
className="h-8 w-8 p-0"
|
||||||
title="Procesar con LandingAI"
|
title="Process with LandingAI"
|
||||||
>
|
>
|
||||||
<Scissors className="w-4 h-4" />
|
<Scissors className="w-4 h-4" />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -446,7 +442,7 @@ export function FilesTab({
|
|||||||
onClick={() => handleDownloadFile(file.name)}
|
onClick={() => handleDownloadFile(file.name)}
|
||||||
disabled={downloading}
|
disabled={downloading}
|
||||||
className="h-8 w-8 p-0"
|
className="h-8 w-8 p-0"
|
||||||
title="Descargar"
|
title="Download"
|
||||||
>
|
>
|
||||||
<Download className="w-4 h-4" />
|
<Download className="w-4 h-4" />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -456,7 +452,7 @@ export function FilesTab({
|
|||||||
onClick={() => handleDeleteFile(file.name)}
|
onClick={() => handleDeleteFile(file.name)}
|
||||||
disabled={deleting}
|
disabled={deleting}
|
||||||
className="h-8 w-8 p-0 text-red-600 hover:text-red-700 hover:bg-red-50"
|
className="h-8 w-8 p-0 text-red-600 hover:text-red-700 hover:bg-red-50"
|
||||||
title="Eliminar"
|
title="Delete"
|
||||||
>
|
>
|
||||||
<Trash2 className="w-4 h-4" />
|
<Trash2 className="w-4 h-4" />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -503,7 +499,7 @@ export function FilesTab({
|
|||||||
tema={chunkFileTema}
|
tema={chunkFileTema}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Modal de configuración de chunking con LandingAI */}
|
{/* LandingAI chunking config modal */}
|
||||||
<ChunkingConfigModalLandingAI
|
<ChunkingConfigModalLandingAI
|
||||||
isOpen={chunkingConfigOpen}
|
isOpen={chunkingConfigOpen}
|
||||||
onClose={() => setChunkingConfigOpen(false)}
|
onClose={() => setChunkingConfigOpen(false)}
|
||||||
|
|||||||
@@ -1,25 +1,20 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from "react";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogDescription
|
DialogDescription,
|
||||||
} from '@/components/ui/dialog'
|
} from "@/components/ui/dialog";
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import { Download, Loader2, FileText, ExternalLink } from "lucide-react";
|
||||||
Download,
|
|
||||||
Loader2,
|
|
||||||
FileText,
|
|
||||||
ExternalLink
|
|
||||||
} from 'lucide-react'
|
|
||||||
|
|
||||||
interface PDFPreviewModalProps {
|
interface PDFPreviewModalProps {
|
||||||
open: boolean
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void
|
onOpenChange: (open: boolean) => void;
|
||||||
fileUrl: string | null
|
fileUrl: string | null;
|
||||||
fileName: string
|
fileName: string;
|
||||||
onDownload?: () => void
|
onDownload?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PDFPreviewModal({
|
export function PDFPreviewModal({
|
||||||
@@ -27,45 +22,40 @@ export function PDFPreviewModal({
|
|||||||
onOpenChange,
|
onOpenChange,
|
||||||
fileUrl,
|
fileUrl,
|
||||||
fileName,
|
fileName,
|
||||||
onDownload
|
onDownload,
|
||||||
}: PDFPreviewModalProps) {
|
}: PDFPreviewModalProps) {
|
||||||
// Estado para manejar el loading del iframe
|
// Track iframe loading state
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
// Efecto para manejar el timeout del loading
|
// Hide loading if iframe never fires onLoad
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (open && fileUrl) {
|
if (open && fileUrl) {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
|
|
||||||
// Timeout para ocultar loading automáticamente después de 3 segundos
|
|
||||||
// Algunos iframes no disparan onLoad correctamente
|
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
}, 3000)
|
}, 3000);
|
||||||
|
|
||||||
return () => clearTimeout(timeout)
|
return () => clearTimeout(timeout);
|
||||||
}
|
}
|
||||||
}, [open, fileUrl])
|
}, [open, fileUrl]);
|
||||||
|
|
||||||
// Manejar cuando el iframe termina de cargar
|
|
||||||
const handleIframeLoad = () => {
|
const handleIframeLoad = () => {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
}
|
};
|
||||||
|
|
||||||
// Abrir PDF en nueva pestaña
|
|
||||||
const openInNewTab = () => {
|
const openInNewTab = () => {
|
||||||
if (fileUrl) {
|
if (fileUrl) {
|
||||||
window.open(fileUrl, '_blank')
|
window.open(fileUrl, "_blank");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Reiniciar loading cuando cambia el archivo
|
|
||||||
const handleOpenChange = (open: boolean) => {
|
const handleOpenChange = (open: boolean) => {
|
||||||
if (open) {
|
if (open) {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
}
|
|
||||||
onOpenChange(open)
|
|
||||||
}
|
}
|
||||||
|
onOpenChange(open);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||||
@@ -75,81 +65,68 @@ export function PDFPreviewModal({
|
|||||||
<FileText className="w-5 h-5" />
|
<FileText className="w-5 h-5" />
|
||||||
{fileName}
|
{fileName}
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>PDF preview</DialogDescription>
|
||||||
Vista previa del documento PDF
|
|
||||||
</DialogDescription>
|
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
{/* Barra de controles */}
|
{/* Controls */}
|
||||||
<div className="flex items-center justify-between gap-4 px-6 py-3 border-b bg-gray-50">
|
<div className="flex items-center justify-between gap-4 px-6 py-3 border-b bg-gray-50">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={openInNewTab}
|
onClick={openInNewTab}
|
||||||
title="Abrir en nueva pestaña"
|
title="Open in new tab"
|
||||||
>
|
>
|
||||||
<ExternalLink className="w-4 h-4 mr-2" />
|
<ExternalLink className="w-4 h-4 mr-2" />
|
||||||
Abrir en pestaña nueva
|
Open in new tab
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Botón de descarga */}
|
{/* Download button */}
|
||||||
{onDownload && (
|
{onDownload && (
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={onDownload}
|
onClick={onDownload}
|
||||||
title="Descargar archivo"
|
title="Download file"
|
||||||
>
|
>
|
||||||
<Download className="w-4 h-4 mr-2" />
|
<Download className="w-4 h-4 mr-2" />
|
||||||
Descargar
|
Download
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Área de visualización del PDF con iframe */}
|
{/* PDF iframe */}
|
||||||
<div className="flex-1 relative bg-gray-100">
|
<div className="flex-1 relative bg-gray-100 overflow-hidden min-h-0">
|
||||||
{!fileUrl ? (
|
{!fileUrl ? (
|
||||||
<div className="flex items-center justify-center h-full text-center text-gray-500 p-8">
|
<div className="flex items-center justify-center h-full text-center text-gray-500 p-8">
|
||||||
<div>
|
<div>
|
||||||
<FileText className="w-16 h-16 mx-auto mb-4 text-gray-400" />
|
<FileText className="w-16 h-16 mx-auto mb-4 text-gray-400" />
|
||||||
<p>No se ha proporcionado un archivo para previsualizar</p>
|
<p>No file available for preview</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{/* Indicador de carga */}
|
{/* Loading state */}
|
||||||
{loading && (
|
{loading && (
|
||||||
<div className="absolute inset-0 flex items-center justify-center bg-white z-10">
|
<div className="absolute inset-0 flex items-center justify-center bg-white z-10">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<Loader2 className="w-12 h-12 animate-spin text-blue-500 mx-auto mb-4" />
|
<Loader2 className="w-12 h-12 animate-spin text-blue-500 mx-auto mb-4" />
|
||||||
<p className="text-gray-600">Cargando PDF...</p>
|
<p className="text-gray-600">Loading PDF…</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/*
|
|
||||||
Iframe para mostrar el PDF
|
|
||||||
El navegador maneja toda la visualización, zoom, scroll, etc.
|
|
||||||
Esto muestra el PDF exactamente como se vería si lo abrieras directamente
|
|
||||||
*/}
|
|
||||||
<iframe
|
<iframe
|
||||||
src={fileUrl}
|
src={fileUrl}
|
||||||
className="w-full h-full border-0"
|
className="w-full h-full border-0"
|
||||||
title={`Vista previa de ${fileName}`}
|
title={`Preview of ${fileName}`}
|
||||||
onLoad={handleIframeLoad}
|
onLoad={handleIframeLoad}
|
||||||
style={{ minHeight: '600px' }}
|
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Footer con información */}
|
|
||||||
<div className="px-6 py-3 border-t bg-gray-50 text-xs text-gray-500 text-center">
|
|
||||||
{fileName}
|
|
||||||
</div>
|
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export function Sidebar({
|
|||||||
const handleCreateDataroom = async () => {
|
const handleCreateDataroom = async () => {
|
||||||
const trimmed = newDataroomName.trim();
|
const trimmed = newDataroomName.trim();
|
||||||
if (!trimmed) {
|
if (!trimmed) {
|
||||||
setCreateError("El nombre es obligatorio");
|
setCreateError("Name is required");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ export function Sidebar({
|
|||||||
setCreateError(
|
setCreateError(
|
||||||
error instanceof Error
|
error instanceof Error
|
||||||
? error.message
|
? error.message
|
||||||
: "No se pudo crear el dataroom. Inténtalo nuevamente.",
|
: "Could not create the dataroom. Please try again.",
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
setCreatingDataroom(false);
|
setCreatingDataroom(false);
|
||||||
@@ -168,15 +168,15 @@ export function Sidebar({
|
|||||||
tema: string,
|
tema: string,
|
||||||
e: React.MouseEvent<HTMLButtonElement>,
|
e: React.MouseEvent<HTMLButtonElement>,
|
||||||
) => {
|
) => {
|
||||||
e.stopPropagation(); // Evitar que se seleccione el tema al hacer clic en el icono
|
e.stopPropagation(); // Prevent selecting the dataroom when clicking delete
|
||||||
|
|
||||||
const confirmed = window.confirm(
|
const confirmed = window.confirm(
|
||||||
`¿Estás seguro de que deseas eliminar el dataroom "${tema}"?\n\n` +
|
`Are you sure you want to delete the dataroom "${tema}"?\n\n` +
|
||||||
`Esto eliminará:\n` +
|
`This will remove:\n` +
|
||||||
`• El dataroom de la base de datos\n` +
|
`• The dataroom from the database\n` +
|
||||||
`• Todos los archivos del tema en Azure Blob Storage\n` +
|
`• All files stored for this topic in Azure Blob Storage\n` +
|
||||||
`• La colección "${tema}" en Qdrant (si existe)\n\n` +
|
`• The "${tema}" collection in Qdrant (if it exists)\n\n` +
|
||||||
`Esta acción no se puede deshacer.`,
|
`This action cannot be undone.`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!confirmed) return;
|
if (!confirmed) return;
|
||||||
@@ -191,10 +191,10 @@ export function Sidebar({
|
|||||||
console.error(`Error deleting dataroom "${tema}":`, error);
|
console.error(`Error deleting dataroom "${tema}":`, error);
|
||||||
// If dataroom deletion fails, fall back to legacy deletion
|
// If dataroom deletion fails, fall back to legacy deletion
|
||||||
|
|
||||||
// Eliminar todos los archivos del tema en Azure Blob Storage
|
// Delete all topic files in Azure Blob Storage
|
||||||
await api.deleteTema(tema);
|
await api.deleteTema(tema);
|
||||||
|
|
||||||
// Intentar eliminar la colección en Qdrant (si existe)
|
// Attempt to delete the Qdrant collection (if it exists)
|
||||||
try {
|
try {
|
||||||
const collectionExists = await api.checkCollectionExists(tema);
|
const collectionExists = await api.checkCollectionExists(tema);
|
||||||
if (collectionExists.exists) {
|
if (collectionExists.exists) {
|
||||||
@@ -202,7 +202,7 @@ export function Sidebar({
|
|||||||
}
|
}
|
||||||
} catch (collectionError) {
|
} catch (collectionError) {
|
||||||
console.warn(
|
console.warn(
|
||||||
`No se pudo eliminar la colección "${tema}" de Qdrant:`,
|
`Could not delete the "${tema}" collection from Qdrant:`,
|
||||||
collectionError,
|
collectionError,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -216,9 +216,9 @@ export function Sidebar({
|
|||||||
setSelectedTema(null);
|
setSelectedTema(null);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error eliminando dataroom "${tema}":`, error);
|
console.error(`Error deleting dataroom "${tema}":`, error);
|
||||||
alert(
|
alert(
|
||||||
`Error al eliminar el dataroom: ${error instanceof Error ? error.message : "Error desconocido"}`,
|
`Unable to delete dataroom: ${error instanceof Error ? error.message : "Unknown error"}`,
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
setDeletingTema(null);
|
setDeletingTema(null);
|
||||||
@@ -251,9 +251,7 @@ export function Sidebar({
|
|||||||
className="text-slate-400 hover:text-slate-100"
|
className="text-slate-400 hover:text-slate-100"
|
||||||
onClick={onToggleCollapse}
|
onClick={onToggleCollapse}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
aria-label={
|
aria-label={collapsed ? "Expand sidebar" : "Collapse sidebar"}
|
||||||
collapsed ? "Expandir barra lateral" : "Contraer barra lateral"
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{collapsed ? (
|
{collapsed ? (
|
||||||
<ChevronRight className="h-4 w-4" />
|
<ChevronRight className="h-4 w-4" />
|
||||||
@@ -279,7 +277,7 @@ export function Sidebar({
|
|||||||
</h2>
|
</h2>
|
||||||
)}
|
)}
|
||||||
{renderWithTooltip(
|
{renderWithTooltip(
|
||||||
"Crear dataroom",
|
"Create",
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -293,15 +291,15 @@ export function Sidebar({
|
|||||||
disabled={disabled || creatingDataroom}
|
disabled={disabled || creatingDataroom}
|
||||||
>
|
>
|
||||||
<Plus className="h-4 w-4" />
|
<Plus className="h-4 w-4" />
|
||||||
{!collapsed && <span>Crear dataroom</span>}
|
{!collapsed && <span>Create</span>}
|
||||||
</Button>,
|
</Button>,
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Lista de temas */}
|
{/* Dataroom list */}
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<div className="text-sm text-slate-400 px-3 py-2 text-center">
|
<div className="text-sm text-slate-400 px-3 py-2 text-center">
|
||||||
{collapsed ? "..." : "Cargando..."}
|
{collapsed ? "..." : "Loading..."}
|
||||||
</div>
|
</div>
|
||||||
) : Array.isArray(temas) && temas.length > 0 ? (
|
) : Array.isArray(temas) && temas.length > 0 ? (
|
||||||
temas.map((tema) => (
|
temas.map((tema) => (
|
||||||
@@ -331,7 +329,7 @@ export function Sidebar({
|
|||||||
onClick={(e) => handleDeleteTema(tema, e)}
|
onClick={(e) => handleDeleteTema(tema, e)}
|
||||||
disabled={deletingTema === tema || disabled}
|
disabled={deletingTema === tema || disabled}
|
||||||
className="absolute right-2 top-1/2 -translate-y-1/2 p-1.5 rounded hover:bg-red-500/20 opacity-0 group-hover:opacity-100 transition-opacity disabled:opacity-50"
|
className="absolute right-2 top-1/2 -translate-y-1/2 p-1.5 rounded hover:bg-red-500/20 opacity-0 group-hover:opacity-100 transition-opacity disabled:opacity-50"
|
||||||
title="Eliminar dataroom y colección"
|
title="Delete dataroom and collection"
|
||||||
>
|
>
|
||||||
<Trash2 className="h-4 w-4 text-red-400" />
|
<Trash2 className="h-4 w-4 text-red-400" />
|
||||||
</button>
|
</button>
|
||||||
@@ -341,8 +339,8 @@ export function Sidebar({
|
|||||||
) : (
|
) : (
|
||||||
<div className="text-sm text-slate-400 px-3 py-2 text-center">
|
<div className="text-sm text-slate-400 px-3 py-2 text-center">
|
||||||
{Array.isArray(temas) && temas.length === 0
|
{Array.isArray(temas) && temas.length === 0
|
||||||
? "No hay datarooms"
|
? "No datarooms found"
|
||||||
: "Cargando datarooms..."}
|
: "Loading datarooms..."}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -357,7 +355,7 @@ export function Sidebar({
|
|||||||
>
|
>
|
||||||
{onNavigateToSchemas &&
|
{onNavigateToSchemas &&
|
||||||
renderWithTooltip(
|
renderWithTooltip(
|
||||||
"Gestionar Schemas",
|
"Manage schemas",
|
||||||
<Button
|
<Button
|
||||||
variant="default"
|
variant="default"
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -370,12 +368,12 @@ export function Sidebar({
|
|||||||
>
|
>
|
||||||
<Database className={cn("h-4 w-4", !collapsed && "mr-2")} />
|
<Database className={cn("h-4 w-4", !collapsed && "mr-2")} />
|
||||||
<span className={cn(collapsed && "sr-only")}>
|
<span className={cn(collapsed && "sr-only")}>
|
||||||
Gestionar Schemas
|
Manage Schemas
|
||||||
</span>
|
</span>
|
||||||
</Button>,
|
</Button>,
|
||||||
)}
|
)}
|
||||||
{renderWithTooltip(
|
{renderWithTooltip(
|
||||||
"Actualizar datarooms",
|
"Refresh datarooms",
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -388,7 +386,7 @@ export function Sidebar({
|
|||||||
>
|
>
|
||||||
<RefreshCcw className={cn("mr-2 h-4 w-4", collapsed && "mr-0")} />
|
<RefreshCcw className={cn("mr-2 h-4 w-4", collapsed && "mr-0")} />
|
||||||
<span className={cn(collapsed && "sr-only")}>
|
<span className={cn(collapsed && "sr-only")}>
|
||||||
Actualizar datarooms
|
Refresh datarooms
|
||||||
</span>
|
</span>
|
||||||
</Button>,
|
</Button>,
|
||||||
)}
|
)}
|
||||||
@@ -403,14 +401,14 @@ export function Sidebar({
|
|||||||
aria-describedby="create-dataroom-description"
|
aria-describedby="create-dataroom-description"
|
||||||
>
|
>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>Crear dataroom</DialogTitle>
|
<DialogTitle>Create dataroom</DialogTitle>
|
||||||
<DialogDescription id="create-dataroom-description">
|
<DialogDescription id="create-dataroom-description">
|
||||||
Define un nombre único para organizar tus archivos.
|
Choose a unique name to organize your files.
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label htmlFor="dataroom-name">Nombre del dataroom</Label>
|
<Label htmlFor="dataroom-name">Dataroom name</Label>
|
||||||
<Input
|
<Input
|
||||||
id="dataroom-name"
|
id="dataroom-name"
|
||||||
value={newDataroomName}
|
value={newDataroomName}
|
||||||
@@ -420,7 +418,7 @@ export function Sidebar({
|
|||||||
setCreateError(null);
|
setCreateError(null);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
placeholder="Ej: normativa, contratos, fiscal..."
|
placeholder="e.g., policies, contracts, finance..."
|
||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
{createError && (
|
{createError && (
|
||||||
@@ -434,13 +432,13 @@ export function Sidebar({
|
|||||||
onClick={() => handleCreateDialogOpenChange(false)}
|
onClick={() => handleCreateDialogOpenChange(false)}
|
||||||
disabled={creatingDataroom}
|
disabled={creatingDataroom}
|
||||||
>
|
>
|
||||||
Cancelar
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={handleCreateDataroom}
|
onClick={handleCreateDataroom}
|
||||||
disabled={creatingDataroom || newDataroomName.trim() === ""}
|
disabled={creatingDataroom || newDataroomName.trim() === ""}
|
||||||
>
|
>
|
||||||
{creatingDataroom ? "Creando..." : "Crear dataroom"}
|
{creatingDataroom ? "Creating…" : "Create"}
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|||||||
@@ -721,3 +721,71 @@ $20
|
|||||||
extraction_timestamp
|
extraction_timestamp
|
||||||
$26
|
$26
|
||||||
2025-11-09T16:12:46.318554
|
2025-11-09T16:12:46.318554
|
||||||
|
*2
|
||||||
|
$3
|
||||||
|
DEL
|
||||||
|
$56
|
||||||
|
:app.models.dataroom.DataRoom:01K9J2R5ZGS96G60P0G80W248Z
|
||||||
|
*10
|
||||||
|
$4
|
||||||
|
HSET
|
||||||
|
$56
|
||||||
|
:app.models.dataroom.DataRoom:01K9MSH70T90HY2VB6DPJVQZFQ
|
||||||
|
$2
|
||||||
|
pk
|
||||||
|
$26
|
||||||
|
01K9MSH70T90HY2VB6DPJVQZFQ
|
||||||
|
$4
|
||||||
|
name
|
||||||
|
$9
|
||||||
|
NEW HEART
|
||||||
|
$10
|
||||||
|
collection
|
||||||
|
$9
|
||||||
|
new_heart
|
||||||
|
$7
|
||||||
|
storage
|
||||||
|
$9
|
||||||
|
new_heart
|
||||||
|
*10
|
||||||
|
$4
|
||||||
|
HSET
|
||||||
|
$56
|
||||||
|
:app.models.dataroom.DataRoom:01K9MSJ57MS3DZFBG5TQXBDD6W
|
||||||
|
$2
|
||||||
|
pk
|
||||||
|
$26
|
||||||
|
01K9MSJ57MS3DZFBG5TQXBDD6W
|
||||||
|
$4
|
||||||
|
name
|
||||||
|
$5
|
||||||
|
OHANA
|
||||||
|
$10
|
||||||
|
collection
|
||||||
|
$5
|
||||||
|
ohana
|
||||||
|
$7
|
||||||
|
storage
|
||||||
|
$5
|
||||||
|
ohana
|
||||||
|
*10
|
||||||
|
$4
|
||||||
|
HSET
|
||||||
|
$56
|
||||||
|
:app.models.dataroom.DataRoom:01K9MSJJTH48BR7KQ27PXB2C3S
|
||||||
|
$2
|
||||||
|
pk
|
||||||
|
$26
|
||||||
|
01K9MSJJTH48BR7KQ27PXB2C3S
|
||||||
|
$4
|
||||||
|
name
|
||||||
|
$5
|
||||||
|
SOSFS
|
||||||
|
$10
|
||||||
|
collection
|
||||||
|
$5
|
||||||
|
sosfs
|
||||||
|
$7
|
||||||
|
storage
|
||||||
|
$5
|
||||||
|
sosfs
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user