ente/src/components/ExportInProgress.tsx

90 lines
3.1 KiB
TypeScript
Raw Normal View History

2021-07-06 09:20:59 +00:00
import React from 'react';
import { Button, ProgressBar } from 'react-bootstrap';
import { ExportProgress, ExportStage } from 'services/exportService';
2021-07-06 09:20:59 +00:00
import styled from 'styled-components';
import constants from 'utils/strings/constants';
2021-07-06 11:23:13 +00:00
export const ComfySpan = styled.span`
2021-08-11 08:00:59 +00:00
word-spacing: 1rem;
color: #ddd;
2021-07-06 09:20:59 +00:00
`;
2021-07-07 07:44:26 +00:00
interface Props {
2021-08-11 08:00:59 +00:00
show: boolean;
onHide: () => void;
exportFolder: string;
exportSize: string;
exportStage: ExportStage;
exportProgress: ExportProgress;
resumeExport: () => void;
2021-08-11 08:00:59 +00:00
cancelExport: () => void;
2021-07-08 06:42:28 +00:00
pauseExport: () => void;
2021-07-07 07:44:26 +00:00
}
2021-08-11 08:00:59 +00:00
2021-07-07 07:44:26 +00:00
export default function ExportInProgress(props: Props) {
2021-07-06 09:20:59 +00:00
return (
2021-07-07 09:20:59 +00:00
<>
2021-08-11 08:00:59 +00:00
<div
style={{
marginBottom: '30px',
padding: '0 5%',
display: 'flex',
alignItems: 'center',
flexDirection: 'column',
}}>
2021-07-06 09:20:59 +00:00
<div style={{ marginBottom: '10px' }}>
2021-08-11 08:00:59 +00:00
<ComfySpan>
{' '}
{props.exportProgress.current} /{' '}
{props.exportProgress.total}{' '}
</ComfySpan>{' '}
<span style={{ marginLeft: '10px' }}>
{' '}
files exported{' '}
{props.exportStage === ExportStage.PAUSED && `(paused)`}
</span>
2021-07-06 09:20:59 +00:00
</div>
<div style={{ width: '100%', marginBottom: '30px' }}>
<ProgressBar
2021-08-11 08:00:59 +00:00
now={Math.round(
(props.exportProgress.current * 100) /
2021-08-13 02:38:38 +00:00
props.exportProgress.total
2021-08-11 08:00:59 +00:00
)}
2021-07-09 03:35:33 +00:00
animated={!(props.exportStage === ExportStage.PAUSED)}
2021-07-06 09:20:59 +00:00
variant="upload-progress-bar"
/>
</div>
2021-08-11 08:00:59 +00:00
<div
style={{
width: '100%',
display: 'flex',
justifyContent: 'space-around',
}}>
{props.exportStage === ExportStage.PAUSED ? (
<Button
block
variant={'outline-secondary'}
onClick={props.resumeExport}>
{constants.RESUME}
</Button>
) : (
<Button
block
variant={'outline-secondary'}
onClick={props.pauseExport}>
{constants.PAUSE}
</Button>
)}
2021-07-06 09:20:59 +00:00
<div style={{ width: '30px' }} />
2021-08-11 08:00:59 +00:00
<Button
block
variant={'outline-danger'}
onClick={props.cancelExport}>
{constants.CANCEL}
</Button>
2021-07-06 09:20:59 +00:00
</div>
</div>
2021-07-07 09:20:59 +00:00
</>
2021-07-06 09:20:59 +00:00
);
}