fix(rgi): fast download with fileVisibility gate + clear error message
Download route simplified: 1. fileVisibility check — if 404, returns "indisponibil" + eTerra URL 2. Single download pattern (the one that works) When document not available server-side, response includes direct eTerra URL as fallback. No more 7 pattern attempts = much faster. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -295,30 +295,21 @@ function IssuedDocsPanel({
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-1 shrink-0">
|
||||
{/* Server-side download (works when fileVisibility returns OK) */}
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="gap-1"
|
||||
onClick={() => {
|
||||
// Open eTerra directly — user's browser session has download permission
|
||||
// First open confirmOnView, then download
|
||||
const base = "https://eterra.ancpi.ro/eterra/api";
|
||||
const wid = doc.workspaceId || workspaceId;
|
||||
const appId = doc.applicationId || applicationPk;
|
||||
const dpk = doc.documentPk;
|
||||
// Open confirm in hidden iframe, then download
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.style.display = "none";
|
||||
iframe.src = `${base}/rgi/appdetail/issueddocs/confirmOnView/${wid}/${appId}/${dpk}`;
|
||||
document.body.appendChild(iframe);
|
||||
setTimeout(() => {
|
||||
window.open(`${base}/rgi/appdetail/loadDocument/downloadFile/${wid}/${dpk}`, "_blank");
|
||||
iframe.remove();
|
||||
}, 500);
|
||||
}}
|
||||
asChild
|
||||
>
|
||||
<Download className="h-3.5 w-3.5" />
|
||||
Descarca
|
||||
<a
|
||||
href={`/api/eterra/rgi/download-doc?workspaceId=${doc.workspaceId || workspaceId}&applicationId=${doc.applicationId || applicationPk}&documentPk=${doc.documentPk}&documentTypeId=${doc.documentTypeId}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Download className="h-3.5 w-3.5" />
|
||||
Descarca
|
||||
</a>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user