ExportInProgress.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import React from 'react';
  2. import { Button, ProgressBar } from 'react-bootstrap';
  3. import { ExportProgress } from 'types/export';
  4. import styled from 'styled-components';
  5. import constants from 'utils/strings/constants';
  6. import { ExportStage } from 'constants/export';
  7. export const ComfySpan = styled.span`
  8. word-spacing: 1rem;
  9. color: #ddd;
  10. `;
  11. interface Props {
  12. show: boolean;
  13. onHide: () => void;
  14. exportFolder: string;
  15. exportSize: string;
  16. exportStage: ExportStage;
  17. exportProgress: ExportProgress;
  18. resumeExport: () => void;
  19. cancelExport: () => void;
  20. pauseExport: () => void;
  21. }
  22. export default function ExportInProgress(props: Props) {
  23. return (
  24. <>
  25. <div
  26. style={{
  27. marginBottom: '30px',
  28. padding: '0 5%',
  29. display: 'flex',
  30. alignItems: 'center',
  31. flexDirection: 'column',
  32. }}>
  33. <div style={{ marginBottom: '10px' }}>
  34. <ComfySpan>
  35. {' '}
  36. {props.exportProgress.current} /{' '}
  37. {props.exportProgress.total}{' '}
  38. </ComfySpan>{' '}
  39. <span style={{ marginLeft: '10px' }}>
  40. {' '}
  41. files exported{' '}
  42. {props.exportStage === ExportStage.PAUSED && `(paused)`}
  43. </span>
  44. </div>
  45. <div style={{ width: '100%', marginBottom: '30px' }}>
  46. <ProgressBar
  47. now={Math.round(
  48. (props.exportProgress.current * 100) /
  49. props.exportProgress.total
  50. )}
  51. animated={!(props.exportStage === ExportStage.PAUSED)}
  52. variant="upload-progress-bar"
  53. />
  54. </div>
  55. <div
  56. style={{
  57. width: '100%',
  58. display: 'flex',
  59. justifyContent: 'space-around',
  60. }}>
  61. {props.exportStage === ExportStage.PAUSED ? (
  62. <Button
  63. block
  64. variant={'outline-secondary'}
  65. onClick={props.resumeExport}>
  66. {constants.RESUME}
  67. </Button>
  68. ) : (
  69. <Button
  70. block
  71. variant={'outline-secondary'}
  72. onClick={props.pauseExport}>
  73. {constants.PAUSE}
  74. </Button>
  75. )}
  76. <div style={{ width: '30px' }} />
  77. <Button
  78. block
  79. variant={'outline-danger'}
  80. onClick={props.cancelExport}>
  81. {constants.CANCEL}
  82. </Button>
  83. </div>
  84. </div>
  85. </>
  86. );
  87. }