import React from 'react'; import { RouteComponentProps } from 'react-router'; import { withRouter } from 'react-router-dom'; import Text from 'antd/lib/typography/Text'; import { Col, Row, Button, Icon, Progress, Dropdown, } from 'antd'; import moment from 'moment'; import ActionsMenuContainer from 'containers/actions-menu/actions-menu'; import { ActiveInference } from 'reducers/interfaces'; import { MenuIcon } from 'icons'; export interface TaskItemProps { taskInstance: any; previewImage: string; deleted: boolean; hidden: boolean; activeInference: ActiveInference | null; } class TaskItemComponent extends React.PureComponent { private renderPreview(): JSX.Element { const { previewImage } = this.props; return (
Preview
); } private renderDescription(): JSX.Element { // Task info const { taskInstance } = this.props; const { id } = taskInstance; const owner = taskInstance.owner ? taskInstance.owner.username : null; const updated = moment(taskInstance.updatedDate).fromNow(); const created = moment(taskInstance.createdDate).format('MMMM Do YYYY'); // Get and truncate a task name const name = `${taskInstance.name.substring(0, 70)}${taskInstance.name.length > 70 ? '...' : ''}`; return ( {`#${id}: `} {name}
{ owner && ( <> {`Created ${owner ? `by ${owner}` : ''} on ${created}`}
) } {`Last updated ${updated}`} ); } private renderProgress(): JSX.Element { const { taskInstance, activeInference, } = this.props; // Count number of jobs and performed jobs const numOfJobs = taskInstance.jobs.length; const numOfCompleted = taskInstance.jobs.filter( (job: any): boolean => job.status === 'completed', ).length; // Progress appearence depends on number of jobs let progressColor = null; let progressText = null; if (numOfCompleted === numOfJobs) { progressColor = 'cvat-task-completed-progress'; progressText = Completed; } else if (numOfCompleted) { progressColor = 'cvat-task-progress-progress'; progressText = In Progress; } else { progressColor = 'cvat-task-pending-progress'; progressText = Pending; } return ( { progressText } {`${numOfCompleted} of ${numOfJobs} jobs`} { activeInference && ( <> Automatic annotation ) } ); } private renderNavigation(): JSX.Element { const { taskInstance, history, } = this.props; const { id } = taskInstance; return ( Actions }> ); } public render(): JSX.Element { const { deleted, hidden, } = this.props; const style = {}; if (deleted) { (style as any).pointerEvents = 'none'; (style as any).opacity = 0.5; } if (hidden) { (style as any).display = 'none'; } return ( {this.renderPreview()} {this.renderDescription()} {this.renderProgress()} {this.renderNavigation()} ); } } export default withRouter(TaskItemComponent);