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

129 lines
2.9 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,
trackedDownloadState,
trackedDownloadStatus,
2018-11-23 07:04:42 +00:00
errorMessage,
progressBar
} = props;
const progress = size ? (100 - sizeleft / size * 100) : 0;
2018-11-23 07:04:42 +00:00
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}
title={translate('ImportFailedInterp', { errorMessage })}
2018-11-23 07:04:42 +00:00
/>
);
}
if (trackedDownloadStatus === 'warning') {
return (
<Icon
name={icons.DOWNLOAD}
kind={kinds.WARNING}
2020-11-23 03:34:51 +00:00
title={translate('UnableToImportCheckLogs')}
/>
);
}
if (trackedDownloadState === 'importPending') {
return (
<Icon
name={icons.DOWNLOAD}
kind={kinds.PURPLE}
title={`${translate('Downloaded')} - ${translate('WaitingToImport')}`}
/>
);
}
if (trackedDownloadState === 'importing') {
return (
<Icon
name={icons.DOWNLOAD}
kind={kinds.PURPLE}
title={`${translate('Downloaded')} - ${translate('Importing')}`}
/>
);
}
2018-11-23 07:04:42 +00:00
}
if (errorMessage) {
return (
<Icon
name={icons.DOWNLOADING}
kind={kinds.DANGER}
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,
trackedDownloadState: PropTypes.string.isRequired,
trackedDownloadStatus: PropTypes.string.isRequired,
2018-11-23 07:04:42 +00:00
errorMessage: PropTypes.string,
progressBar: PropTypes.node.isRequired
};
export default QueueDetails;