automatic-annotation-progress.tsx 2.3 KB
Newer Older
1 2 3 4 5 6
// Copyright (C) 2020 Intel Corporation
//
// SPDX-License-Identifier: MIT

import React from 'react';
import { Row, Col } from 'antd/lib/grid';
B
Boris Sekachev 已提交
7
import { CloseOutlined } from '@ant-design/icons';
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
import Text from 'antd/lib/typography/Text';
import Progress from 'antd/lib/progress';
import Tooltip from 'antd/lib/tooltip';
import Modal from 'antd/lib/modal';
import { ActiveInference } from 'reducers/interfaces';

interface Props {
    activeInference: ActiveInference | null;
    cancelAutoAnnotation(): void;
}

export default function AutomaticAnnotationProgress(props: Props): JSX.Element | null {
    const { activeInference, cancelAutoAnnotation } = props;
    if (!activeInference) return null;

    return (
        <>
            <Row>
                <Col>
                    <Text strong>Automatic annotation</Text>
                </Col>
            </Row>
B
Boris Sekachev 已提交
30
            <Row justify='space-between'>
31 32 33 34 35 36 37 38 39 40 41 42 43 44
                <Col span={22}>
                    <Progress
                        percent={Math.floor(activeInference.progress)}
                        strokeColor={{
                            from: '#108ee9',
                            to: '#87d068',
                        }}
                        showInfo={false}
                        strokeWidth={5}
                        size='small'
                    />
                </Col>
                <Col span={1} className='close-auto-annotation-icon'>
                    <Tooltip title='Cancel automatic annotation' mouseLeaveDelay={0}>
B
Boris Sekachev 已提交
45
                        <CloseOutlined
46 47 48 49
                            onClick={() => {
                                Modal.confirm({
                                    title: 'You are going to cancel automatic annotation?',
                                    content: 'Reached progress will be lost. Continue?',
B
Boris Sekachev 已提交
50
                                    okButtonProps: {
B
Boris Sekachev 已提交
51
                                        type: 'primary',
B
Boris Sekachev 已提交
52 53
                                        danger: true,
                                    },
54 55 56 57 58 59 60 61 62 63 64 65
                                    onOk() {
                                        cancelAutoAnnotation();
                                    },
                                });
                            }}
                        />
                    </Tooltip>
                </Col>
            </Row>
        </>
    );
}