Spaces:
Running
Running
Pulastya B
commited on
Commit
·
48520bd
1
Parent(s):
8405b58
fix: Resolve blank modal issue when viewing YData Profiling reports
Browse files- Normalize report paths by removing leading './' before constructing URLs
- Add proper Content-Type headers for HTML files in /outputs endpoint
- Add media type detection for different file types (HTML, CSV, JSON, images)
- Rebuild frontend with path normalization fix
The issue was that report paths like './outputs/reports/file.html' were being
used directly in URLs, creating invalid URLs like 'http://localhost:8080./outputs/'.
Now paths are normalized to '/outputs/reports/file.html' format.
Fixes: Blank white modal when clicking 'View Report' button
- FRRONTEEEND/components/ChatInterface.tsx +14 -10
- src/api/app.py +14 -1
FRRONTEEEND/components/ChatInterface.tsx
CHANGED
|
@@ -419,16 +419,20 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 419 |
)}
|
| 420 |
{msg.reports && msg.reports.length > 0 && (
|
| 421 |
<div className="mt-4 flex flex-wrap gap-2">
|
| 422 |
-
{msg.reports.map((report, idx) =>
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 432 |
</div>
|
| 433 |
)}
|
| 434 |
<div className="mt-2 text-[10px] opacity-20 font-mono">
|
|
|
|
| 419 |
)}
|
| 420 |
{msg.reports && msg.reports.length > 0 && (
|
| 421 |
<div className="mt-4 flex flex-wrap gap-2">
|
| 422 |
+
{msg.reports.map((report, idx) => {
|
| 423 |
+
// Normalize the report path: remove leading ./ and ensure it starts with /
|
| 424 |
+
const normalizedPath = report.path.replace(/^\.\//, '/');
|
| 425 |
+
return (
|
| 426 |
+
<button
|
| 427 |
+
key={idx}
|
| 428 |
+
onClick={() => setReportModalUrl(`${window.location.origin}${normalizedPath}`)}
|
| 429 |
+
className="flex items-center gap-2 px-4 py-2 rounded-lg bg-indigo-500/20 hover:bg-indigo-500/30 border border-indigo-500/30 text-indigo-200 text-xs font-medium transition-all group"
|
| 430 |
+
>
|
| 431 |
+
<Sparkles className="w-3.5 h-3.5 group-hover:scale-110 transition-transform" />
|
| 432 |
+
View {report.name} Report
|
| 433 |
+
</button>
|
| 434 |
+
);
|
| 435 |
+
})}
|
| 436 |
</div>
|
| 437 |
)}
|
| 438 |
<div className="mt-2 text-[10px] opacity-20 font-mono">
|
src/api/app.py
CHANGED
|
@@ -471,7 +471,20 @@ async def serve_output_files(file_path: str):
|
|
| 471 |
except ValueError:
|
| 472 |
raise HTTPException(status_code=403, detail="Access denied")
|
| 473 |
|
| 474 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 475 |
|
| 476 |
|
| 477 |
@app.get("/{full_path:path}")
|
|
|
|
| 471 |
except ValueError:
|
| 472 |
raise HTTPException(status_code=403, detail="Access denied")
|
| 473 |
|
| 474 |
+
# Determine media type based on file extension
|
| 475 |
+
media_type = None
|
| 476 |
+
if file_path.endswith('.html'):
|
| 477 |
+
media_type = "text/html"
|
| 478 |
+
elif file_path.endswith('.csv'):
|
| 479 |
+
media_type = "text/csv"
|
| 480 |
+
elif file_path.endswith('.json'):
|
| 481 |
+
media_type = "application/json"
|
| 482 |
+
elif file_path.endswith('.png'):
|
| 483 |
+
media_type = "image/png"
|
| 484 |
+
elif file_path.endswith('.jpg') or file_path.endswith('.jpeg'):
|
| 485 |
+
media_type = "image/jpeg"
|
| 486 |
+
|
| 487 |
+
return FileResponse(output_path, media_type=media_type)
|
| 488 |
|
| 489 |
|
| 490 |
@app.get("/{full_path:path}")
|