Radarr/frontend/src/Activity/Queue/QueueDetails.js

99 lines
2.1 KiB
JavaScript
Raw Normal View History

2018-11-23 07:04:42 +00:00
import moment from 'moment';
import PropTypes from 'prop-types';
import React from 'react';
import Icon from 'Components/Icon';
import { icons, kinds } from 'Helpers/Props';
2020-08-29 03:56:13 +00:00
import translate from 'Utilities/String/translate';
2018-11-23 07:04:42 +00:00
function QueueDetails(props) {
const {
title,
size,
sizeleft,
estimatedCompletionTime,
status: queueStatus,
errorMessage,
progressBar
} = props;
const status = queueStatus.toLowerCase();
const progress = (100 - sizeleft / size * 100);
if (status === 'pending') {
return (
<Icon
name={icons.PENDING}
2020-09-01 03:41:20 +00:00
title={translate('ReleaseWillBeProcessedInterp', [moment(estimatedCompletionTime).fromNow()])}
2018-11-23 07:04:42 +00:00
/>
);
}
if (status === 'completed') {
if (errorMessage) {
return (
<Icon
name={icons.DOWNLOAD}
kind={kinds.DANGER}
2020-09-01 03:41:20 +00:00
title={translate('ImportFailedInterp', [errorMessage])}
2018-11-23 07:04:42 +00:00
/>
);
}
// TODO: show an icon when download is complete, but not imported yet?
}
if (errorMessage) {
return (
<Icon
name={icons.DOWNLOADING}
kind={kinds.DANGER}
2020-09-01 03:41:20 +00:00
title={translate('DownloadFailedInterp', [errorMessage])}
2018-11-23 07:04:42 +00:00
/>
);
}
if (status === 'failed') {
return (
<Icon
name={icons.DOWNLOADING}
kind={kinds.DANGER}
2020-08-29 03:56:13 +00:00
title={translate('DownloadFailedCheckDownloadClientForMoreDetails')}
2018-11-23 07:04:42 +00:00
/>
);
}
if (status === 'warning') {
return (
<Icon
name={icons.DOWNLOADING}
kind={kinds.WARNING}
2020-08-29 03:56:13 +00:00
title={translate('DownloadWarningCheckDownloadClientForMoreDetails')}
2018-11-23 07:04:42 +00:00
/>
);
}
if (progress < 5) {
return (
<Icon
name={icons.DOWNLOADING}
2020-09-01 03:41:20 +00:00
title={translate('MovieIsDownloadingInterp', [progress.toFixed(1), title])}
2018-11-23 07:04:42 +00:00
/>
);
}
return progressBar;
}
QueueDetails.propTypes = {
title: PropTypes.string.isRequired,
size: PropTypes.number.isRequired,
sizeleft: PropTypes.number.isRequired,
estimatedCompletionTime: PropTypes.string,
status: PropTypes.string.isRequired,
errorMessage: PropTypes.string,
progressBar: PropTypes.node.isRequired
};
export default QueueDetails;