|
|
|
@ -5,190 +5,191 @@ 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 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 {
|
|
|
|
|
added,
|
|
|
|
|
shortDateFormat,
|
|
|
|
|
showRelativeDates,
|
|
|
|
|
timeFormat
|
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
albums = 'No albums';
|
|
|
|
|
} else if (albumCount > 1) {
|
|
|
|
|
albums = `${albumCount} albums`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
title: 'Album Count',
|
|
|
|
|
iconName: icons.CIRCLE,
|
|
|
|
|
label: albums
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (name === 'path') {
|
|
|
|
|
return {
|
|
|
|
|
title: 'Path',
|
|
|
|
|
iconName: icons.FOLDER,
|
|
|
|
|
label: props.path
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (name === 'sizeOnDisk') {
|
|
|
|
|
return {
|
|
|
|
|
title: 'Size on Disk',
|
|
|
|
|
iconName: icons.DRIVE,
|
|
|
|
|
label: formatBytes(props.sizeOnDisk)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ArtistIndexOverviewInfo(props) {
|
|
|
|
|
const {
|
|
|
|
|
height,
|
|
|
|
|
showMonitored,
|
|
|
|
|
showQualityProfile,
|
|
|
|
|
showAdded,
|
|
|
|
|
showAlbumCount,
|
|
|
|
|
showPath,
|
|
|
|
|
showSizeOnDisk,
|
|
|
|
|
monitored,
|
|
|
|
|
nextAiring,
|
|
|
|
|
qualityProfile,
|
|
|
|
|
added,
|
|
|
|
|
statistics,
|
|
|
|
|
path,
|
|
|
|
|
sortKey,
|
|
|
|
|
showRelativeDates,
|
|
|
|
|
shortDateFormat,
|
|
|
|
|
timeFormat
|
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
albumCount,
|
|
|
|
|
sizeOnDisk
|
|
|
|
|
} = statistics;
|
|
|
|
|
|
|
|
|
|
let albums = '1 album';
|
|
|
|
|
|
|
|
|
|
if (albumCount === 0) {
|
|
|
|
|
albums = 'No albums';
|
|
|
|
|
} else if (albumCount > 1) {
|
|
|
|
|
albums = `${albumCount} albums`;
|
|
|
|
|
}
|
|
|
|
|
let shownRows = 1;
|
|
|
|
|
|
|
|
|
|
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}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<ArtistIndexOverviewInfoRow
|
|
|
|
|
title={nextAiring}
|
|
|
|
|
iconName={icons.SCHEDULED}
|
|
|
|
|
label={getRelativeDate(
|
|
|
|
|
nextAiring,
|
|
|
|
|
shortDateFormat,
|
|
|
|
|
showRelativeDates,
|
|
|
|
|
{
|
|
|
|
|
getRelativeDate(
|
|
|
|
|
nextAiring,
|
|
|
|
|
shortDateFormat,
|
|
|
|
|
showRelativeDates,
|
|
|
|
|
{
|
|
|
|
|
timeFormat,
|
|
|
|
|
timeForToday: true
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
timeFormat,
|
|
|
|
|
timeForToday: true
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
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}
|
|
|
|
|
/>
|
|
|
|
|
rows.map((row) => {
|
|
|
|
|
if (!isVisible(row, props)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{monitoredText}
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
if (shownRows >= maxRows) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
isVisible('qualityProfileId', showQualityProfile, qualityProfile, sortKey) && maxRows > 2 &&
|
|
|
|
|
<div
|
|
|
|
|
className={styles.info}
|
|
|
|
|
title="Quality Profile"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.icon}
|
|
|
|
|
name={icons.PROFILE}
|
|
|
|
|
size={14}
|
|
|
|
|
/>
|
|
|
|
|
shownRows++;
|
|
|
|
|
|
|
|
|
|
{qualityProfile.name}
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
const infoRowProps = getInfoRowProps(row, props);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
isVisible('added', showAdded, added, sortKey) && maxRows > 3 &&
|
|
|
|
|
<div
|
|
|
|
|
className={styles.info}
|
|
|
|
|
title="Date Added"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.icon}
|
|
|
|
|
name={icons.ADD}
|
|
|
|
|
size={14}
|
|
|
|
|
return (
|
|
|
|
|
<ArtistIndexOverviewInfoRow
|
|
|
|
|
key={row.name}
|
|
|
|
|
{...infoRowProps}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
getRelativeDate(
|
|
|
|
|
added,
|
|
|
|
|
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}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{albums}
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
isVisible('path', showPath, path, sortKey) && maxRows > 5 &&
|
|
|
|
|
<div
|
|
|
|
|
className={styles.info}
|
|
|
|
|
title="Path"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.icon}
|
|
|
|
|
name={icons.FOLDER}
|
|
|
|
|
size={14}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{path}
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
isVisible('sizeOnDisk', showSizeOnDisk, sizeOnDisk, sortKey) && maxRows > 6 &&
|
|
|
|
|
<div
|
|
|
|
|
className={styles.info}
|
|
|
|
|
title="Size on Disk"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
className={styles.icon}
|
|
|
|
|
name={icons.DRIVE}
|
|
|
|
|
size={14}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{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,
|
|
|
|
|