diff --git a/cvat-ui/src/actions/grades-actions.ts b/cvat-ui/src/actions/grades-actions.ts index b9124273cd4c..edb47cbf0ee7 100644 --- a/cvat-ui/src/actions/grades-actions.ts +++ b/cvat-ui/src/actions/grades-actions.ts @@ -136,10 +136,9 @@ interface SubmitAnnotationFrameInput { certificateId?: string | null; } -export const submitAnnotationFrameToGradeAsync = (input: SubmitAnnotationFrameInput): ThunkAction => async ( - dispatch, - getState, -) => { +export const submitAnnotationFrameToGradeAsync = ( + input: SubmitAnnotationFrameInput & { withMasks?: boolean }, +): ThunkAction => async (dispatch, getState) => { if (!input.orientation) { dispatch(setWarningAsync(orientationNotFound)); } @@ -147,11 +146,13 @@ export const submitAnnotationFrameToGradeAsync = (input: SubmitAnnotationFrameIn const state = getState() as CombinedState; const { states } = state.annotation.annotations; const { frame } = state.annotation.player; - const job = state.annotation.job.instance; - const image = await job.frames.frameData(frame.number); - const formData = new FormData(); - formData.append('image', image, frame.filename); + + if (input.withMasks) { + const job = state.annotation.job.instance; + const image = await job.frames.frameData(frame.number); + formData.append('image', image, frame.filename); + } formData.append( 'payload', diff --git a/cvat-ui/src/components/annotation-page/grades-form/grades-form-advanced-controls.scss b/cvat-ui/src/components/annotation-page/grades-form/grades-form-advanced-controls.scss new file mode 100644 index 000000000000..c5d48d02535c --- /dev/null +++ b/cvat-ui/src/components/annotation-page/grades-form/grades-form-advanced-controls.scss @@ -0,0 +1,3 @@ +.grades-form-advanced-controls { + position: relative; +} diff --git a/cvat-ui/src/components/annotation-page/grades-form/grades-form-advanced-controls.tsx b/cvat-ui/src/components/annotation-page/grades-form/grades-form-advanced-controls.tsx new file mode 100644 index 000000000000..ff05608818c3 --- /dev/null +++ b/cvat-ui/src/components/annotation-page/grades-form/grades-form-advanced-controls.tsx @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Intel Corporation +// +// SPDX-License-Identifier: MIT +import React, { useCallback } from 'react'; +import './grades-form-advanced-controls.scss'; +import Button from 'antd/lib/button'; + +interface Props { + onRobogradesAndMasks(): void; +} + +function GradesFormAdvancedControls({ onRobogradesAndMasks }: Props): JSX.Element { + const [isExpanded, setIsExpanded] = React.useState(false); + + const handleToggle = useCallback((): void => { + setIsExpanded((prev) => !prev); + }, []); + + return ( + <> +
+ +
+ {isExpanded && ( + + )} + + ); +} + +export default GradesFormAdvancedControls; diff --git a/cvat-ui/src/components/annotation-page/grades-form/grades-form.tsx b/cvat-ui/src/components/annotation-page/grades-form/grades-form.tsx index b156e2cfdcd5..69574308ef57 100644 --- a/cvat-ui/src/components/annotation-page/grades-form/grades-form.tsx +++ b/cvat-ui/src/components/annotation-page/grades-form/grades-form.tsx @@ -13,6 +13,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState, } from 'react'; import { useDispatch, useSelector } from 'react-redux'; +import Space from 'antd/lib/space'; import { setGradesFormState } from '../../../actions/annotation-actions'; import { gradesActions, @@ -23,6 +24,7 @@ import { } from '../../../actions/grades-actions'; import { CombinedState } from '../../../reducers/interfaces'; import { parseFilename } from '../../../utils/grades'; +import GradesFormAdvancedControls from './grades-form-advanced-controls'; interface Props { task: { @@ -63,11 +65,16 @@ export function GradesForm({ task }: Props): JSX.Element | null { dispatch(setGradesFormState(false)); }, [dispatch]); - const handleSubmit = useCallback(async () => { + const handleRobogrades = useCallback(async () => { dispatch(submitAnnotationFrameToGradeAsync(frameOptions)); formRef.current?.setFieldsValue({}); }, [frameOptions]); + const handleRobogradesAndMasks = useCallback(async () => { + dispatch(submitAnnotationFrameToGradeAsync({ ...frameOptions, withMasks: true })); + formRef.current?.setFieldsValue({}); + }, [frameOptions]); + const handleUpdate = useCallback(async () => { const formValues = await formRef.current?.validateFields(); if (formValues) { @@ -368,12 +375,15 @@ export function GradesForm({ task }: Props): JSX.Element | null { Loading... ) : null} - - + + + + +