import React from 'react'; import Text from 'antd/lib/typography/Text'; import { Col, Row, Button, Icon, Progress, Menu, Dropdown, Upload, } from 'antd'; import { ClickParam } from 'antd/lib/menu/index'; import { UploadChangeParam } from 'antd/lib/upload'; import { RcFile } from 'antd/lib/upload'; import moment from 'moment'; export interface TaskItemProps { taskInstance: any; previewImage: string; dumpActivities: string[] | null; loadActivity: string | null; loaders: any[]; dumpers: any[]; onDumpAnnotation: (task: any, dumper: any) => void; onLoadAnnotation: (task: any, loader: any, file: File) => void; } function isDefaultFormat(dumperName: string, taskMode: string): boolean { return (dumperName === 'CVAT XML 1.1 for videos' && taskMode === 'interpolation') || (dumperName === 'CVAT XML 1.1 for images' && taskMode === 'annotation'); } export default class TaskItemComponent extends React.PureComponent { constructor(props: TaskItemProps) { super(props); } private handleMenuClick = (params: ClickParam) => { const tracker = this.props.taskInstance.bugTracker; if (params.keyPath.length === 2) { // dump or upload if (params.keyPath[1] === 'dump') { } } else { switch (params.key) { case 'tracker': { window.open(`${tracker}`, '_blank') return; } case 'auto': { return; } case 'tf': { return; } case 'update': { return; } case 'delete': { return; } default: { return; } } } } private renderPreview() { return (
Preview
) } private renderDescription() { // Task info const task = this.props.taskInstance; const { id } = task; const owner = task.owner ? task.owner.username : null; const updated = moment(task.updatedDate).fromNow(); const created = moment(task.createdDate).format('MMMM Do YYYY'); // Get and truncate a task name const name = `${task.name.substring(0, 70)}${task.name.length > 70 ? '...' : ''}`; return ( {id} {name}
{ owner ? <> Created { owner ? 'by ' + owner : '' } on {created}
: null } Last updated {updated} ) } private renderProgress() { const task = this.props.taskInstance; // Count number of jobs and performed jobs const numOfJobs = task.jobs.length; const numOfCompleted = task.jobs.filter( (job: any) => job.status === 'completed' ).length; // Progress appearence depends on number of jobs const progressColor = numOfCompleted === numOfJobs ? 'cvat-task-completed-progress': numOfCompleted ? 'cvat-task-progress-progress' : 'cvat-task-pending-progress'; return ( { numOfCompleted === numOfJobs ? Completed : numOfCompleted ? In Progress : Pending } {numOfCompleted} of {numOfJobs} jobs ) } private renderDumperItem(dumper: any) { const task = this.props.taskInstance; const { mode } = task; const dumpingWithThisDumper = (this.props.dumpActivities || []) .filter((_dumper: string) => _dumper === dumper.name)[0]; const pending = !!dumpingWithThisDumper; return ( ); } private renderLoaderItem(loader: any) { const loadingWithThisLoader = this.props.loadActivity && this.props.loadActivity === loader.name ? this.props.loadActivity : null; const pending = !!loadingWithThisLoader; return ( { this.props.onLoadAnnotation( this.props.taskInstance, loader, file as File, ); return false; }}> ); } private renderMenu() { const tracker = this.props.taskInstance.bugTracker; return ( {this.props.dumpers.map((dumper) => this.renderDumperItem(dumper))} {this.props.loaders.map((loader) => this.renderLoaderItem(loader))} {tracker ? Open bug tracker : null} Run auto annotation Run TF annotation
Update Delete
); } private renderNavigation() { const subMenuIcon = () => (); return ( Actions ) } public render() { return ( {this.renderPreview()} {this.renderDescription()} {this.renderProgress()} {this.renderNavigation()} ) }; }