New: Show size on disk for each season

Closes #3432
This commit is contained in:
Mark McDowall 2020-05-24 14:38:37 -07:00
parent 41dfb677e7
commit ebe2ad1520
4 changed files with 39 additions and 6 deletions

View File

@ -1,5 +1,6 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
import formatBytes from 'Utilities/Number/formatBytes';
import DescriptionList from 'Components/DescriptionList/DescriptionList'; import DescriptionList from 'Components/DescriptionList/DescriptionList';
import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem';
import styles from './SeasonInfo.css'; import styles from './SeasonInfo.css';
@ -8,7 +9,8 @@ function SeasonInfo(props) {
const { const {
totalEpisodeCount, totalEpisodeCount,
monitoredEpisodeCount, monitoredEpisodeCount,
episodeFileCount episodeFileCount,
sizeOnDisk
} = props; } = props;
return ( return (
@ -33,6 +35,13 @@ function SeasonInfo(props) {
title="With Files" title="With Files"
data={episodeFileCount} data={episodeFileCount}
/> />
<DescriptionListItem
titleClassName={styles.title}
descriptionClassName={styles.description}
title="Size on Disk"
data={formatBytes(sizeOnDisk)}
/>
</DescriptionList> </DescriptionList>
); );
} }
@ -40,7 +49,8 @@ function SeasonInfo(props) {
SeasonInfo.propTypes = { SeasonInfo.propTypes = {
totalEpisodeCount: PropTypes.number.isRequired, totalEpisodeCount: PropTypes.number.isRequired,
monitoredEpisodeCount: PropTypes.number.isRequired, monitoredEpisodeCount: PropTypes.number.isRequired,
episodeFileCount: PropTypes.number.isRequired episodeFileCount: PropTypes.number.isRequired,
sizeOnDisk: PropTypes.number.isRequired
}; };
export default SeasonInfo; export default SeasonInfo;

View File

@ -26,6 +26,12 @@
display: flex; display: flex;
} }
.sizeOnDisk {
margin-left: 10px;
color: #777;
font-size: $defaultFontSize;
}
.expandButton { .expandButton {
composes: link from '~Components/Link/Link.css'; composes: link from '~Components/Link/Link.css';
@ -115,4 +121,8 @@
position: static; position: static;
margin: 0; margin: 0;
} }
.sizeOnDisk {
display: none;
}
} }

View File

@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import isAfter from 'Utilities/Date/isAfter'; import isAfter from 'Utilities/Date/isAfter';
import isBefore from 'Utilities/Date/isBefore'; import isBefore from 'Utilities/Date/isBefore';
import formatBytes from 'Utilities/Number/formatBytes';
import getToggledRange from 'Utilities/Table/getToggledRange'; import getToggledRange from 'Utilities/Table/getToggledRange';
import { align, icons, kinds, sizes, tooltipPositions } from 'Helpers/Props'; import { align, icons, kinds, sizes, tooltipPositions } from 'Helpers/Props';
import Icon from 'Components/Icon'; import Icon from 'Components/Icon';
@ -33,6 +34,7 @@ function getSeasonStatistics(episodes) {
let totalEpisodeCount = 0; let totalEpisodeCount = 0;
let monitoredEpisodeCount = 0; let monitoredEpisodeCount = 0;
let hasMonitoredEpisodes = false; let hasMonitoredEpisodes = false;
const sizeOnDisk = 0;
episodes.forEach((episode) => { episodes.forEach((episode) => {
if (episode.episodeFileId || (episode.monitored && isBefore(episode.airDateUtc))) { if (episode.episodeFileId || (episode.monitored && isBefore(episode.airDateUtc))) {
@ -56,7 +58,8 @@ function getSeasonStatistics(episodes) {
episodeFileCount, episodeFileCount,
totalEpisodeCount, totalEpisodeCount,
monitoredEpisodeCount, monitoredEpisodeCount,
hasMonitoredEpisodes hasMonitoredEpisodes,
sizeOnDisk
}; };
} }
@ -205,6 +208,7 @@ class SeriesDetailsSeason extends Component {
seasonNumber, seasonNumber,
items, items,
columns, columns,
statistics,
isSaving, isSaving,
isExpanded, isExpanded,
isSearching, isSearching,
@ -271,11 +275,20 @@ class SeriesDetailsSeason extends Component {
totalEpisodeCount={totalEpisodeCount} totalEpisodeCount={totalEpisodeCount}
monitoredEpisodeCount={monitoredEpisodeCount} monitoredEpisodeCount={monitoredEpisodeCount}
episodeFileCount={episodeFileCount} episodeFileCount={episodeFileCount}
sizeOnDisk={statistics.sizeOnDisk}
/> />
</div> </div>
} }
position={tooltipPositions.BOTTOM} position={tooltipPositions.BOTTOM}
/> />
{
statistics.sizeOnDisk ?
<div className={styles.sizeOnDisk}>
{formatBytes(statistics.sizeOnDisk)}
</div> :
null
}
</div> </div>
<Link <Link
@ -504,6 +517,7 @@ SeriesDetailsSeason.propTypes = {
seasonNumber: PropTypes.number.isRequired, seasonNumber: PropTypes.number.isRequired,
items: PropTypes.arrayOf(PropTypes.object).isRequired, items: PropTypes.arrayOf(PropTypes.object).isRequired,
columns: PropTypes.arrayOf(PropTypes.object).isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired,
statistics: PropTypes.object.isRequired,
isSaving: PropTypes.bool, isSaving: PropTypes.bool,
isExpanded: PropTypes.bool, isExpanded: PropTypes.bool,
isSearching: PropTypes.bool.isRequired, isSearching: PropTypes.bool.isRequired,

View File

@ -1,4 +1,3 @@
import _ from 'lodash';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
@ -27,8 +26,8 @@ function createMapStateToProps() {
seasonNumber seasonNumber
})); }));
const episodesInSeason = _.filter(episodes.items, { seasonNumber }); const episodesInSeason = episodes.items.filter((episode) => episode.seasonNumber === seasonNumber);
const sortedEpisodes = _.orderBy(episodesInSeason, 'episodeNumber', 'desc'); const sortedEpisodes = episodesInSeason.sort((a, b) => b.episodeNumber - a.episodeNumber);
return { return {
items: sortedEpisodes, items: sortedEpisodes,