Lidarr/frontend/src/Album/EpisodeStatus.js

128 lines
2.6 KiB
JavaScript
Raw Normal View History

2017-09-04 02:20:56 +00:00
import PropTypes from 'prop-types';
import React from 'react';
2020-09-07 01:33:10 +00:00
import QueueDetails from 'Activity/Queue/QueueDetails';
2017-09-04 02:20:56 +00:00
import Icon from 'Components/Icon';
import ProgressBar from 'Components/ProgressBar';
2020-09-07 01:33:10 +00:00
import { icons, kinds, sizes } from 'Helpers/Props';
import isBefore from 'Utilities/Date/isBefore';
import TrackQuality from './TrackQuality';
2017-09-04 02:20:56 +00:00
import styles from './EpisodeStatus.css';
function EpisodeStatus(props) {
const {
airDateUtc,
monitored,
grabbed,
queueItem,
2017-09-25 02:58:13 +00:00
trackFile
2017-09-04 02:20:56 +00:00
} = props;
2017-09-25 02:58:13 +00:00
const hasTrackFile = !!trackFile;
2017-09-04 02:20:56 +00:00
const isQueued = !!queueItem;
const hasAired = isBefore(airDateUtc);
if (isQueued) {
const {
sizeleft,
size
} = queueItem;
const progress = (100 - sizeleft / size * 100);
return (
<div className={styles.center}>
<QueueDetails
{...queueItem}
progressBar={
<ProgressBar
title={`Album is downloading - ${progress.toFixed(1)}% ${queueItem.title}`}
2017-09-04 02:20:56 +00:00
progress={progress}
kind={kinds.PURPLE}
size={sizes.MEDIUM}
/>
}
/>
</div>
);
}
if (grabbed) {
return (
<div className={styles.center}>
2017-09-04 02:20:56 +00:00
<Icon
name={icons.DOWNLOADING}
title="Album is downloading"
2017-09-04 02:20:56 +00:00
/>
</div>
);
}
2017-09-25 02:58:13 +00:00
if (hasTrackFile) {
const quality = trackFile.quality;
const isCutoffNotMet = trackFile.qualityCutoffNotMet;
2017-09-04 02:20:56 +00:00
return (
<div className={styles.center}>
<TrackQuality
2017-09-04 02:20:56 +00:00
quality={quality}
2017-09-25 02:58:13 +00:00
size={trackFile.size}
2017-09-04 02:20:56 +00:00
isCutoffNotMet={isCutoffNotMet}
title="Track Downloaded"
2017-09-04 02:20:56 +00:00
/>
</div>
);
}
if (!airDateUtc) {
return (
<div className={styles.center}>
2017-09-04 02:20:56 +00:00
<Icon
name={icons.TBA}
title="TBA"
2017-09-04 02:20:56 +00:00
/>
</div>
);
}
if (!monitored) {
return (
<div className={styles.center}>
2017-09-04 02:20:56 +00:00
<Icon
name={icons.UNMONITORED}
title="Album is not monitored"
2017-09-04 02:20:56 +00:00
/>
</div>
);
}
if (hasAired) {
return (
<div className={styles.center}>
2017-09-04 02:20:56 +00:00
<Icon
name={icons.MISSING}
title="Track missing from disk"
2017-09-04 02:20:56 +00:00
/>
</div>
);
}
return (
<div className={styles.center}>
2017-09-04 02:20:56 +00:00
<Icon
name={icons.NOT_AIRED}
title="Album has not aired"
2017-09-04 02:20:56 +00:00
/>
</div>
);
}
EpisodeStatus.propTypes = {
airDateUtc: PropTypes.string,
2017-09-24 19:44:25 +00:00
monitored: PropTypes.bool,
2017-09-04 02:20:56 +00:00
grabbed: PropTypes.bool,
queueItem: PropTypes.object,
2017-09-25 02:58:13 +00:00
trackFile: PropTypes.object
2017-09-04 02:20:56 +00:00
};
export default EpisodeStatus;