Jury inline doc preview, download fix, category tags, admin eval reset
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m55s

- Replace MultiWindowDocViewer with FileViewer for inline previews (PDF/image/video/Office)
- Fix cross-origin download using fetch+blob instead of <a download>
- Show Startup/Business Concept badge on jury project detail + evaluate pages
- Add admin resetEvaluation procedure with audit logging
- Add dropdown menu on admin assignment rows with Reset Evaluation + Delete
- Make file action buttons responsive on mobile (separate row below file info)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt
2026-02-18 14:03:38 +01:00
parent 9ce56f13fd
commit 0f6473c999
6 changed files with 318 additions and 248 deletions

View File

@@ -252,75 +252,104 @@ function FileItem({ file }: { file: ProjectFile }) {
return (
<div className="space-y-2">
<div className="flex items-center gap-3 rounded-lg border p-3">
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-muted">
<Icon className="h-5 w-5 text-muted-foreground" />
</div>
<div className="rounded-lg border p-3">
<div className="flex items-start gap-3">
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-muted">
<Icon className="h-5 w-5 text-muted-foreground" />
</div>
<div className="flex-1 min-w-0">
{file.requirement && (
<p className="text-xs font-semibold text-primary/80 mb-0.5 uppercase tracking-wide">
{file.requirement.name}
</p>
)}
<div className="flex items-center gap-2">
<p className="font-medium truncate">{file.fileName}</p>
<div className="flex-1 min-w-0">
{file.requirement && (
<p className="text-xs font-semibold text-primary/80 mb-0.5 uppercase tracking-wide">
{file.requirement.name}
</p>
)}
<div className="flex items-center gap-2">
<p className="font-medium truncate">{file.fileName}</p>
{file.version != null && file.version > 1 && (
<Badge variant="outline" className="text-xs shrink-0">
v{file.version}
</Badge>
)}
</div>
<div className="flex items-center gap-2 text-sm text-muted-foreground flex-wrap">
<Badge variant="secondary" className="text-xs">
{getFileTypeLabel(file.fileType)}
</Badge>
{file.isLate && (
<Badge variant="destructive" className="text-xs">
Late
</Badge>
)}
<span>{formatFileSize(file.size)}</span>
{file.pageCount != null && (
<Badge variant="outline" className="text-xs gap-1">
<FileText className="h-3 w-3" />
{file.pageCount} {file.pageCount === 1 ? 'page' : 'pages'}
</Badge>
)}
{file.detectedLang && file.detectedLang !== 'und' && (
<Badge
variant="outline"
className={cn('text-xs font-mono uppercase', {
'border-green-300 text-green-700 bg-green-50': file.langConfidence != null && file.langConfidence >= 0.8,
'border-amber-300 text-amber-700 bg-amber-50': file.langConfidence != null && file.langConfidence >= 0.4 && file.langConfidence < 0.8,
'border-red-300 text-red-700 bg-red-50': file.langConfidence != null && file.langConfidence < 0.4,
})}
title={`Language: ${file.detectedLang} (${Math.round((file.langConfidence ?? 0) * 100)}% confidence)`}
>
{file.detectedLang.toUpperCase()}
</Badge>
)}
</div>
</div>
{/* Desktop action buttons — hidden on mobile */}
<div className="hidden md:flex items-center gap-1 shrink-0">
{file.version != null && file.version > 1 && (
<Badge variant="outline" className="text-xs shrink-0">
v{file.version}
</Badge>
<VersionHistoryButton fileId={file.id} />
)}
</div>
<div className="flex items-center gap-2 text-sm text-muted-foreground flex-wrap">
<Badge variant="secondary" className="text-xs">
{getFileTypeLabel(file.fileType)}
</Badge>
{file.isLate && (
<Badge variant="destructive" className="text-xs">
Late
</Badge>
)}
<span>{formatFileSize(file.size)}</span>
{file.pageCount != null && (
<Badge variant="outline" className="text-xs gap-1">
<FileText className="h-3 w-3" />
{file.pageCount} {file.pageCount === 1 ? 'page' : 'pages'}
</Badge>
)}
{file.detectedLang && file.detectedLang !== 'und' && (
<Badge
{canPreview && (
<Button
variant="outline"
className={cn('text-xs font-mono uppercase', {
'border-green-300 text-green-700 bg-green-50': file.langConfidence != null && file.langConfidence >= 0.8,
'border-amber-300 text-amber-700 bg-amber-50': file.langConfidence != null && file.langConfidence >= 0.4 && file.langConfidence < 0.8,
'border-red-300 text-red-700 bg-red-50': file.langConfidence != null && file.langConfidence < 0.4,
})}
title={`Language: ${file.detectedLang} (${Math.round((file.langConfidence ?? 0) * 100)}% confidence)`}
size="sm"
onClick={() => setShowPreview(!showPreview)}
>
{file.detectedLang.toUpperCase()}
</Badge>
{showPreview ? (
<>
<X className="mr-2 h-4 w-4" />
Close
</>
) : (
<>
<Play className="mr-2 h-4 w-4" />
Preview
</>
)}
</Button>
)}
<FileOpenButton file={file} />
<FileDownloadButton file={file} />
</div>
</div>
<div className="flex items-center gap-1">
{file.version != null && file.version > 1 && (
<VersionHistoryButton fileId={file.id} />
)}
{/* Mobile action buttons — visible only on small screens */}
<div className="flex md:hidden items-center gap-2 mt-3 pt-3 border-t">
{canPreview && (
<Button
variant="outline"
size="sm"
className="flex-1"
onClick={() => setShowPreview(!showPreview)}
>
{showPreview ? (
<>
<X className="mr-2 h-4 w-4" />
<X className="mr-1.5 h-4 w-4" />
Close
</>
) : (
<>
<Play className="mr-2 h-4 w-4" />
<Play className="mr-1.5 h-4 w-4" />
Preview
</>
)}
@@ -481,21 +510,28 @@ function BulkDownloadButton({ projectId, fileIds }: { projectId: string; fileIds
try {
const result = await refetch()
if (result.data && Array.isArray(result.data)) {
// Open each download URL with a small delay to avoid popup blocking
// Download each file via fetch+blob to handle cross-origin URLs
for (let i = 0; i < result.data.length; i++) {
const item = result.data[i] as { downloadUrl: string }
const item = result.data[i] as { downloadUrl: string; fileName?: string }
if (item.downloadUrl) {
// Use link element to trigger download without popup
const link = document.createElement('a')
link.href = item.downloadUrl
link.target = '_blank'
link.rel = 'noopener noreferrer'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
try {
const response = await fetch(item.downloadUrl)
const blob = await response.blob()
const blobUrl = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = blobUrl
link.download = item.fileName || `file-${i + 1}`
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
URL.revokeObjectURL(blobUrl)
} catch {
// Fall back to opening in new tab if fetch fails
window.open(item.downloadUrl, '_blank')
}
// Small delay between downloads
if (i < result.data.length - 1) {
await new Promise((resolve) => setTimeout(resolve, 300))
await new Promise((resolve) => setTimeout(resolve, 500))
}
}
}
@@ -577,17 +613,21 @@ function FileDownloadButton({ file }: { file: ProjectFile }) {
try {
const result = await refetch()
if (result.data?.url) {
// Force browser download via <a download>
// Fetch as blob to force download (cross-origin URLs ignore <a download>)
const response = await fetch(result.data.url)
const blob = await response.blob()
const blobUrl = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = result.data.url
link.href = blobUrl
link.download = file.fileName
link.rel = 'noopener noreferrer'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
URL.revokeObjectURL(blobUrl)
}
} catch (error) {
console.error('Failed to get download URL:', error)
console.error('Failed to download file:', error)
toast.error('Failed to download file')
} finally {
setDownloading(false)
}