parent
9f082c849a
commit
533919ccdd
@ -0,0 +1,125 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import isBefore from 'Utilities/Date/isBefore';
|
||||
import { icons, kinds, sizes } from 'Helpers/Props';
|
||||
import Icon from 'Components/Icon';
|
||||
import ProgressBar from 'Components/ProgressBar';
|
||||
import QueueDetails from 'Activity/Queue/QueueDetails';
|
||||
// import TrackQuality from './TrackQuality';
|
||||
import styles from './AlbumStatus.css';
|
||||
|
||||
function AlbumStatus(props) {
|
||||
const {
|
||||
releaseDate,
|
||||
monitored,
|
||||
grabbed,
|
||||
queueItem
|
||||
} = props;
|
||||
|
||||
// const hasTrackFile = !!trackFile;
|
||||
const isQueued = !!queueItem;
|
||||
const hasReleased = isBefore(releaseDate);
|
||||
|
||||
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}`}
|
||||
progress={progress}
|
||||
kind={kinds.PURPLE}
|
||||
size={sizes.MEDIUM}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (grabbed) {
|
||||
return (
|
||||
<div className={styles.center}>
|
||||
<Icon
|
||||
name={icons.DOWNLOADING}
|
||||
title="Album is downloading"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// if (hasTrackFile) {
|
||||
// const quality = trackFile.quality;
|
||||
// const isCutoffNotMet = trackFile.qualityCutoffNotMet;
|
||||
|
||||
// return (
|
||||
// <div className={styles.center}>
|
||||
// <TrackQuality
|
||||
// quality={quality}
|
||||
// size={trackFile.size}
|
||||
// isCutoffNotMet={isCutoffNotMet}
|
||||
// title="Track Downloaded"
|
||||
// />
|
||||
// </div>
|
||||
// );
|
||||
// }
|
||||
|
||||
if (!releaseDate) {
|
||||
return (
|
||||
<div className={styles.center}>
|
||||
<Icon
|
||||
name={icons.TBA}
|
||||
title="TBA"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!monitored) {
|
||||
return (
|
||||
<div className={styles.center}>
|
||||
<Icon
|
||||
name={icons.UNMONITORED}
|
||||
title="Album is not monitored"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (hasReleased) {
|
||||
return (
|
||||
<div className={styles.center}>
|
||||
<Icon
|
||||
name={icons.MISSING}
|
||||
title="Album missing from disk"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.center}>
|
||||
<Icon
|
||||
name={icons.NOT_AIRED}
|
||||
title="Album has not released"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
AlbumStatus.propTypes = {
|
||||
releaseDate: PropTypes.string,
|
||||
monitored: PropTypes.bool,
|
||||
grabbed: PropTypes.bool,
|
||||
queueItem: PropTypes.object
|
||||
};
|
||||
|
||||
export default AlbumStatus;
|
@ -0,0 +1,50 @@
|
||||
import _ from 'lodash';
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import createAlbumSelector from 'Store/Selectors/createAlbumSelector';
|
||||
import createQueueItemSelector from 'Store/Selectors/createQueueItemSelector';
|
||||
// import createTrackFileSelector from 'Store/Selectors/createTrackFileSelector';
|
||||
import AlbumStatus from './AlbumStatus';
|
||||
|
||||
function createMapStateToProps() {
|
||||
return createSelector(
|
||||
createAlbumSelector(),
|
||||
createQueueItemSelector(),
|
||||
(album, queueItem) => {
|
||||
const result = _.pick(album, [
|
||||
'releaseDate',
|
||||
'monitored',
|
||||
'grabbed'
|
||||
]);
|
||||
|
||||
result.queueItem = queueItem;
|
||||
|
||||
return result;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const mapDispatchToProps = {
|
||||
};
|
||||
|
||||
class AlbumStatusConnector extends Component {
|
||||
|
||||
//
|
||||
// Render
|
||||
|
||||
render() {
|
||||
return (
|
||||
<AlbumStatus
|
||||
{...this.props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
AlbumStatusConnector.propTypes = {
|
||||
albumId: PropTypes.number.isRequired
|
||||
};
|
||||
|
||||
export default connect(createMapStateToProps, mapDispatchToProps)(AlbumStatusConnector);
|
@ -0,0 +1,4 @@
|
||||
.center {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
function createAlbumTrackFilesSelector() {
|
||||
return createSelector(
|
||||
(state, { albumId }) => albumId,
|
||||
(state) => state.trackFiles(),
|
||||
(albumId, trackFiles) => {
|
||||
return trackFiles.find((trackFile) => trackFile.albumId === albumId );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default createAlbumTrackFilesSelector;
|
Loading…
Reference in new issue