|
|
|
@ -5,45 +5,105 @@ import getRelativeDate from 'Utilities/Date/getRelativeDate';
|
|
|
|
|
import formatBytes from 'Utilities/Number/formatBytes';
|
|
|
|
|
import { icons } from 'Helpers/Props';
|
|
|
|
|
import dimensions from 'Styles/Variables/dimensions';
|
|
|
|
|
import Icon from 'Components/Icon';
|
|
|
|
|
import ArtistIndexOverviewInfoRow from './ArtistIndexOverviewInfoRow';
|
|
|
|
|
import styles from './ArtistIndexOverviewInfo.css';
|
|
|
|
|
|
|
|
|
|
const infoRowHeight = parseInt(dimensions.artistIndexOverviewInfoRowHeight);
|
|
|
|
|
|
|
|
|
|
function isVisible(name, show, value, sortKey, index) {
|
|
|
|
|
if (value == null) {
|
|
|
|
|
const rows = [
|
|
|
|
|
{
|
|
|
|
|
name: 'monitored',
|
|
|
|
|
showProp: 'showMonitored',
|
|
|
|
|
valueProp: 'monitored'
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'qualityProfileId',
|
|
|
|
|
showProp: 'showQualityProfile',
|
|
|
|
|
valueProp: 'qualityProfileId'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'added',
|
|
|
|
|
showProp: 'showAdded',
|
|
|
|
|
valueProp: 'added'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'albumCount',
|
|
|
|
|
showProp: 'showAlbumCount',
|
|
|
|
|
valueProp: 'albumCount'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'path',
|
|
|
|
|
showProp: 'showPath',
|
|
|
|
|
valueProp: 'path'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'sizeOnDisk',
|
|
|
|
|
showProp: 'showSizeOnDisk',
|
|
|
|
|
valueProp: 'sizeOnDisk'
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
function isVisible(row, props) {
|
|
|
|
|
const {
|
|
|
|
|
name,
|
|
|
|
|
showProp,
|
|
|
|
|
valueProp
|
|
|
|
|
} = row;
|
|
|
|
|
|
|
|
|
|
if (props[valueProp] == null) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return show || sortKey === name;
|
|
|
|
|
return props[showProp] || props.sortKey === name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ArtistIndexOverviewInfo(props) {
|
|
|
|
|
function getInfoRowProps(row, props) {
|
|
|
|
|
const { name } = row;
|
|
|
|
|
|
|
|
|
|
if (name === 'monitored') {
|
|
|
|
|
const monitoredText = props.monitored ? 'Monitored' : 'Unmonitored';
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
title: monitoredText,
|
|
|
|
|
iconName: props.monitored ? icons.MONITORED : icons.UNMONITORED,
|
|
|
|
|
label: monitoredText
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (name === 'qualityProfileId') {
|
|
|
|
|
return {
|
|
|
|
|
title: 'Quality PROFILE',
|
|
|
|
|
iconName: icons.PROFILE,
|
|
|
|
|
label: props.qualityProfile.name
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (name === 'added') {
|
|
|
|
|
const {
|
|
|
|
|
height,
|
|
|
|
|
showMonitored,
|
|
|
|
|
showQualityProfile,
|
|
|
|
|
showAdded,
|
|
|
|
|
showAlbumCount,
|
|
|
|
|
showPath,
|
|
|
|
|
showSizeOnDisk,
|
|
|
|
|
monitored,
|
|
|
|
|
nextAiring,
|
|
|
|
|
qualityProfile,
|
|
|
|
|
added,
|
|
|
|
|
statistics,
|
|
|
|
|
path,
|
|
|
|
|
sortKey,
|
|
|
|
|
showRelativeDates,
|
|
|
|
|
shortDateFormat,
|
|
|
|
|
showRelativeDates,
|
|
|
|
|
timeFormat
|
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
albumCount,
|
|
|
|
|
sizeOnDisk
|
|
|
|
|
} = statistics;
|
|
|
|
|
return {
|
|
|
|
|
title: 'Added',
|
|
|
|
|
iconName: icons.ADD,
|
|
|
|
|
label: getRelativeDate(
|
|
|
|
|
added,
|
|
|
|
|
shortDateFormat,
|
|
|
|
|
showRelativeDates,
|
|
|
|
|
{
|
|
|
|
|
timeFormat,
|
|
|
|
|
timeForToday: true
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (name === 'albumCount') {
|
|
|
|
|
const { albumCount } = props;
|
|
|
|
|
let albums = '1 album';
|
|
|
|
|
|
|
|
|
|
if (albumCount === 0) {
|
|
|
|
@ -52,143 +112,84 @@ function ArtistIndexOverviewInfo(props) {
|
|
|
|
|
albums = `${albumCount} albums`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const maxRows = Math.floor(height / (infoRowHeight + 4));
|
|
|
|
|
const monitoredText = monitored ? 'Monitored' : 'Unmonitored';
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={styles.infos}>
|
|
|
|
|
{
|
|
|
|
|
!!nextAiring &&
|
|
|
|
|
<div
|
|
|
|
|
className={styles.info}
|
|
|
|
|
title="Next Airing"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.icon}
|
|
|
|
|
name={icons.SCHEDULED}
|
|
|
|
|
size={14}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
getRelativeDate(
|
|
|
|
|
nextAiring,
|
|
|
|
|
shortDateFormat,
|
|
|
|
|
showRelativeDates,
|
|
|
|
|
{
|
|
|
|
|
timeFormat,
|
|
|
|
|
timeForToday: true
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
return {
|
|
|
|
|
title: 'Album Count',
|
|
|
|
|
iconName: icons.CIRCLE,
|
|
|
|
|
label: albums
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
isVisible('monitored', showMonitored, monitored, sortKey) && maxRows > 1 &&
|
|
|
|
|
<div
|
|
|
|
|
className={styles.info}
|
|
|
|
|
title={monitoredText}
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.icon}
|
|
|
|
|
name={monitored ? icons.MONITORED : icons.UNMONITORED}
|
|
|
|
|
size={14}
|
|
|
|
|
/>
|
|
|
|
|
if (name === 'path') {
|
|
|
|
|
return {
|
|
|
|
|
title: 'Path',
|
|
|
|
|
iconName: icons.FOLDER,
|
|
|
|
|
label: props.path
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{monitoredText}
|
|
|
|
|
</div>
|
|
|
|
|
if (name === 'sizeOnDisk') {
|
|
|
|
|
return {
|
|
|
|
|
title: 'Size on Disk',
|
|
|
|
|
iconName: icons.DRIVE,
|
|
|
|
|
label: formatBytes(props.sizeOnDisk)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
isVisible('qualityProfileId', showQualityProfile, qualityProfile, sortKey) && maxRows > 2 &&
|
|
|
|
|
<div
|
|
|
|
|
className={styles.info}
|
|
|
|
|
title="Quality Profile"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.icon}
|
|
|
|
|
name={icons.PROFILE}
|
|
|
|
|
size={14}
|
|
|
|
|
/>
|
|
|
|
|
function ArtistIndexOverviewInfo(props) {
|
|
|
|
|
const {
|
|
|
|
|
height,
|
|
|
|
|
nextAiring,
|
|
|
|
|
showRelativeDates,
|
|
|
|
|
shortDateFormat,
|
|
|
|
|
timeFormat
|
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
{qualityProfile.name}
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
let shownRows = 1;
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
isVisible('added', showAdded, added, sortKey) && maxRows > 3 &&
|
|
|
|
|
<div
|
|
|
|
|
className={styles.info}
|
|
|
|
|
title="Date Added"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.icon}
|
|
|
|
|
name={icons.ADD}
|
|
|
|
|
size={14}
|
|
|
|
|
/>
|
|
|
|
|
const maxRows = Math.floor(height / (infoRowHeight + 4));
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={styles.infos}>
|
|
|
|
|
{
|
|
|
|
|
getRelativeDate(
|
|
|
|
|
added,
|
|
|
|
|
!!nextAiring &&
|
|
|
|
|
<ArtistIndexOverviewInfoRow
|
|
|
|
|
title={nextAiring}
|
|
|
|
|
iconName={icons.SCHEDULED}
|
|
|
|
|
label={getRelativeDate(
|
|
|
|
|
nextAiring,
|
|
|
|
|
shortDateFormat,
|
|
|
|
|
showRelativeDates,
|
|
|
|
|
{
|
|
|
|
|
timeFormat,
|
|
|
|
|
timeForToday: true
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
isVisible('albumCount', showAlbumCount, albumCount, sortKey) && maxRows > 4 &&
|
|
|
|
|
<div
|
|
|
|
|
className={styles.info}
|
|
|
|
|
title="Album Count"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.icon}
|
|
|
|
|
name={icons.CIRCLE}
|
|
|
|
|
size={14}
|
|
|
|
|
/>
|
|
|
|
|
rows.map((row) => {
|
|
|
|
|
if (!isVisible(row, props)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{albums}
|
|
|
|
|
</div>
|
|
|
|
|
if (shownRows >= maxRows) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
isVisible('path', showPath, path, sortKey) && maxRows > 5 &&
|
|
|
|
|
<div
|
|
|
|
|
className={styles.info}
|
|
|
|
|
title="Path"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.icon}
|
|
|
|
|
name={icons.FOLDER}
|
|
|
|
|
size={14}
|
|
|
|
|
/>
|
|
|
|
|
shownRows++;
|
|
|
|
|
|
|
|
|
|
{path}
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
const infoRowProps = getInfoRowProps(row, props);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
isVisible('sizeOnDisk', showSizeOnDisk, sizeOnDisk, sortKey) && maxRows > 6 &&
|
|
|
|
|
<div
|
|
|
|
|
className={styles.info}
|
|
|
|
|
title="Size on Disk"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.icon}
|
|
|
|
|
name={icons.DRIVE}
|
|
|
|
|
size={14}
|
|
|
|
|
return (
|
|
|
|
|
<ArtistIndexOverviewInfoRow
|
|
|
|
|
key={row.name}
|
|
|
|
|
{...infoRowProps}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{formatBytes(sizeOnDisk)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -207,8 +208,9 @@ ArtistIndexOverviewInfo.propTypes = {
|
|
|
|
|
qualityProfile: PropTypes.object.isRequired,
|
|
|
|
|
previousAiring: PropTypes.string,
|
|
|
|
|
added: PropTypes.string,
|
|
|
|
|
statistics: PropTypes.object.isRequired,
|
|
|
|
|
albumCount: PropTypes.number.isRequired,
|
|
|
|
|
path: PropTypes.string.isRequired,
|
|
|
|
|
sizeOnDisk: PropTypes.number,
|
|
|
|
|
sortKey: PropTypes.string.isRequired,
|
|
|
|
|
showRelativeDates: PropTypes.bool.isRequired,
|
|
|
|
|
shortDateFormat: PropTypes.string.isRequired,
|
|
|
|
|