Connect annotator to real API: JWT login, services real-mode, Konva canvas, autosave, paginated images, tracing
This commit is contained in:
parent
59fc3efca6
commit
e010bb5558
38 changed files with 1880 additions and 529 deletions
|
|
@ -1,11 +1,11 @@
|
|||
import React, { useState, useRef } from 'react'
|
||||
import { ImageItem, Project } from '@/types'
|
||||
import { Project } from '@/types'
|
||||
import { ImageTable } from './ImageTable'
|
||||
|
||||
interface DataTabProps {
|
||||
project: Project
|
||||
images: ImageItem[]
|
||||
onUploadImages: (fileNames: string[]) => void
|
||||
onUploadImages: (fileNames: string[], files?: File[]) => void
|
||||
hideSampleUpload?: boolean
|
||||
}
|
||||
|
||||
interface DatasetBatch {
|
||||
|
|
@ -19,9 +19,10 @@ interface DatasetBatch {
|
|||
|
||||
export const DataTab: React.FC<DataTabProps> = ({
|
||||
project,
|
||||
images,
|
||||
onUploadImages,
|
||||
hideSampleUpload = false,
|
||||
}) => {
|
||||
const imageCount = project.stats.totalImages
|
||||
const fileInputRef = useRef<HTMLInputElement | null>(null)
|
||||
const [isDragging, setIsDragging] = useState(false)
|
||||
const [batches, setBatches] = useState<DatasetBatch[]>([
|
||||
|
|
@ -53,15 +54,18 @@ export const DataTab: React.FC<DataTabProps> = ({
|
|||
|
||||
const handleFilesSelected = (files: FileList | null) => {
|
||||
if (!files || files.length === 0) return
|
||||
const names = Array.from(files).map((f) => f.name)
|
||||
onUploadImages(names)
|
||||
const list = Array.from(files)
|
||||
onUploadImages(
|
||||
list.map((f) => f.name),
|
||||
list
|
||||
)
|
||||
setBatches((prev) => [
|
||||
{
|
||||
id: `batch-${Date.now()}`,
|
||||
batchName: `upload_batch_${new Date().toISOString().slice(0, 10).replace(/-/g, '_')}`,
|
||||
uploadedBy: 'Minh Anh',
|
||||
uploadedAt: 'Vừa tải lên',
|
||||
imageCount: names.length,
|
||||
imageCount: list.length,
|
||||
status: 'Đã phân công',
|
||||
},
|
||||
...prev,
|
||||
|
|
@ -70,9 +74,9 @@ export const DataTab: React.FC<DataTabProps> = ({
|
|||
|
||||
const handleSimulatedSampleUpload = () => {
|
||||
const sampleNames = [
|
||||
`traffic_${String(327 + images.length).padStart(5, '0')}.jpg`,
|
||||
`traffic_${String(328 + images.length).padStart(5, '0')}.jpg`,
|
||||
`traffic_${String(329 + images.length).padStart(5, '0')}.jpg`,
|
||||
`traffic_${String(327 + imageCount).padStart(5, '0')}.jpg`,
|
||||
`traffic_${String(328 + imageCount).padStart(5, '0')}.jpg`,
|
||||
`traffic_${String(329 + imageCount).padStart(5, '0')}.jpg`,
|
||||
]
|
||||
onUploadImages(sampleNames)
|
||||
setBatches((prev) => [
|
||||
|
|
@ -146,13 +150,15 @@ export const DataTab: React.FC<DataTabProps> = ({
|
|||
>
|
||||
Chọn tệp từ máy tính
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleSimulatedSampleUpload}
|
||||
className="rounded-xl border border-slate-200 bg-white px-4 py-2 text-xs font-semibold text-slate-700 transition hover:bg-slate-50"
|
||||
>
|
||||
+ Nhập nhanh 3 ảnh mẫu
|
||||
</button>
|
||||
{!hideSampleUpload && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleSimulatedSampleUpload}
|
||||
className="rounded-xl border border-slate-200 bg-white px-4 py-2 text-xs font-semibold text-slate-700 transition hover:bg-slate-50"
|
||||
>
|
||||
+ Nhập nhanh 3 ảnh mẫu
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -203,13 +209,13 @@ export const DataTab: React.FC<DataTabProps> = ({
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{/* Full Image Table */}
|
||||
{/* Full Image Table (self-paginated) */}
|
||||
<ImageTable
|
||||
projectId={project.id}
|
||||
projectSlug={project.slug}
|
||||
images={images}
|
||||
stats={project.stats}
|
||||
classes={project.classes}
|
||||
memberNames={project.members.map((m) => m.name)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue