|
|
@ -1,10 +1,12 @@
|
|
|
|
import Spinner from '@app/assets/spinner.svg';
|
|
|
|
import Spinner from '@app/assets/spinner.svg';
|
|
|
|
import Badge from '@app/components/Common/Badge';
|
|
|
|
import Badge from '@app/components/Common/Badge';
|
|
|
|
import Tooltip from '@app/components/Common/Tooltip';
|
|
|
|
import Tooltip from '@app/components/Common/Tooltip';
|
|
|
|
|
|
|
|
import DownloadBlock from '@app/components/DownloadBlock';
|
|
|
|
import useSettings from '@app/hooks/useSettings';
|
|
|
|
import useSettings from '@app/hooks/useSettings';
|
|
|
|
import { Permission, useUser } from '@app/hooks/useUser';
|
|
|
|
import { Permission, useUser } from '@app/hooks/useUser';
|
|
|
|
import globalMessages from '@app/i18n/globalMessages';
|
|
|
|
import globalMessages from '@app/i18n/globalMessages';
|
|
|
|
import { MediaStatus } from '@server/constants/media';
|
|
|
|
import { MediaStatus } from '@server/constants/media';
|
|
|
|
|
|
|
|
import type { DownloadingItem } from '@server/lib/downloadtracker';
|
|
|
|
import { defineMessages, useIntl } from 'react-intl';
|
|
|
|
import { defineMessages, useIntl } from 'react-intl';
|
|
|
|
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
const messages = defineMessages({
|
|
|
@ -13,26 +15,31 @@ const messages = defineMessages({
|
|
|
|
playonplex: 'Play on Plex',
|
|
|
|
playonplex: 'Play on Plex',
|
|
|
|
openinarr: 'Open in {arr}',
|
|
|
|
openinarr: 'Open in {arr}',
|
|
|
|
managemedia: 'Manage {mediaType}',
|
|
|
|
managemedia: 'Manage {mediaType}',
|
|
|
|
|
|
|
|
seasonepisodenumber: 'S{seasonNumber}E{episodeNumber}',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
interface StatusBadgeProps {
|
|
|
|
interface StatusBadgeProps {
|
|
|
|
status?: MediaStatus;
|
|
|
|
status?: MediaStatus;
|
|
|
|
|
|
|
|
downloadItem?: DownloadingItem[];
|
|
|
|
is4k?: boolean;
|
|
|
|
is4k?: boolean;
|
|
|
|
inProgress?: boolean;
|
|
|
|
inProgress?: boolean;
|
|
|
|
plexUrl?: string;
|
|
|
|
plexUrl?: string;
|
|
|
|
serviceUrl?: string;
|
|
|
|
serviceUrl?: string;
|
|
|
|
tmdbId?: number;
|
|
|
|
tmdbId?: number;
|
|
|
|
mediaType?: 'movie' | 'tv';
|
|
|
|
mediaType?: 'movie' | 'tv';
|
|
|
|
|
|
|
|
title?: string | string[];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const StatusBadge = ({
|
|
|
|
const StatusBadge = ({
|
|
|
|
status,
|
|
|
|
status,
|
|
|
|
|
|
|
|
downloadItem = [],
|
|
|
|
is4k = false,
|
|
|
|
is4k = false,
|
|
|
|
inProgress = false,
|
|
|
|
inProgress = false,
|
|
|
|
plexUrl,
|
|
|
|
plexUrl,
|
|
|
|
serviceUrl,
|
|
|
|
serviceUrl,
|
|
|
|
tmdbId,
|
|
|
|
tmdbId,
|
|
|
|
mediaType,
|
|
|
|
mediaType,
|
|
|
|
|
|
|
|
title,
|
|
|
|
}: StatusBadgeProps) => {
|
|
|
|
}: StatusBadgeProps) => {
|
|
|
|
const intl = useIntl();
|
|
|
|
const intl = useIntl();
|
|
|
|
const { hasPermission } = useUser();
|
|
|
|
const { hasPermission } = useUser();
|
|
|
@ -41,6 +48,10 @@ const StatusBadge = ({
|
|
|
|
let mediaLink: string | undefined;
|
|
|
|
let mediaLink: string | undefined;
|
|
|
|
let mediaLinkDescription: string | undefined;
|
|
|
|
let mediaLinkDescription: string | undefined;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const calculateDownloadProgress = (media: DownloadingItem) => {
|
|
|
|
|
|
|
|
return Math.round(((media?.size - media?.sizeLeft) / media?.size) * 100);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
mediaType &&
|
|
|
|
mediaType &&
|
|
|
|
plexUrl &&
|
|
|
|
plexUrl &&
|
|
|
@ -85,21 +96,87 @@ const StatusBadge = ({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const tooltipContent = downloadItem ? (
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
|
|
{downloadItem.map((status, index) => (
|
|
|
|
|
|
|
|
<li
|
|
|
|
|
|
|
|
key={`dl-status-${status.externalId}-${index}`}
|
|
|
|
|
|
|
|
className="border-b border-gray-700 last:border-b-0"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<DownloadBlock
|
|
|
|
|
|
|
|
downloadItem={status}
|
|
|
|
|
|
|
|
title={Array.isArray(title) ? title[index] : title}
|
|
|
|
|
|
|
|
is4k={is4k}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
) : (
|
|
|
|
|
|
|
|
mediaLinkDescription
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const badgeDownloadProgress = (
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
|
|
|
className={`
|
|
|
|
|
|
|
|
absolute top-0 left-0 z-10 flex h-full ${
|
|
|
|
|
|
|
|
status === MediaStatus.PROCESSING ? 'bg-indigo-500' : 'bg-green-500'
|
|
|
|
|
|
|
|
} transition-all duration-200 ease-in-out
|
|
|
|
|
|
|
|
`}
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
width: `${
|
|
|
|
|
|
|
|
downloadItem ? calculateDownloadProgress(downloadItem[0]) : 0
|
|
|
|
|
|
|
|
}%`,
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
switch (status) {
|
|
|
|
switch (status) {
|
|
|
|
case MediaStatus.AVAILABLE:
|
|
|
|
case MediaStatus.AVAILABLE:
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Tooltip content={mediaLinkDescription}>
|
|
|
|
<Tooltip
|
|
|
|
<Badge badgeType="success" href={mediaLink}>
|
|
|
|
content={inProgress && tooltipContent}
|
|
|
|
<div className="flex items-center">
|
|
|
|
className={`${
|
|
|
|
|
|
|
|
inProgress && 'hidden max-h-96 w-96 overflow-scroll sm:block'
|
|
|
|
|
|
|
|
}`}
|
|
|
|
|
|
|
|
tooltipConfig={{ interactive: true, delayHide: 100 }}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Badge
|
|
|
|
|
|
|
|
badgeType="success"
|
|
|
|
|
|
|
|
href={mediaLink}
|
|
|
|
|
|
|
|
className={`${
|
|
|
|
|
|
|
|
inProgress &&
|
|
|
|
|
|
|
|
'relative !bg-gray-700 !bg-opacity-80 !px-0 hover:!bg-gray-700'
|
|
|
|
|
|
|
|
} overflow-hidden`}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{inProgress && badgeDownloadProgress}
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
|
|
|
className={`relative z-20 flex items-center ${
|
|
|
|
|
|
|
|
inProgress && 'px-2'
|
|
|
|
|
|
|
|
}`}
|
|
|
|
|
|
|
|
>
|
|
|
|
<span>
|
|
|
|
<span>
|
|
|
|
{intl.formatMessage(
|
|
|
|
{intl.formatMessage(
|
|
|
|
is4k ? messages.status4k : messages.status,
|
|
|
|
is4k ? messages.status4k : messages.status,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
status: intl.formatMessage(globalMessages.available),
|
|
|
|
status: inProgress
|
|
|
|
|
|
|
|
? intl.formatMessage(globalMessages.processing)
|
|
|
|
|
|
|
|
: intl.formatMessage(globalMessages.available),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
{inProgress && <Spinner className="ml-1 h-3 w-3" />}
|
|
|
|
{inProgress && (
|
|
|
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
{mediaType === 'tv' && (
|
|
|
|
|
|
|
|
<span className="ml-1">
|
|
|
|
|
|
|
|
{intl.formatMessage(messages.seasonepisodenumber, {
|
|
|
|
|
|
|
|
seasonNumber: downloadItem[0].episode?.seasonNumber,
|
|
|
|
|
|
|
|
episodeNumber: downloadItem[0].episode?.episodeNumber,
|
|
|
|
|
|
|
|
})}
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
<Spinner className="ml-1 h-3 w-3" />
|
|
|
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Badge>
|
|
|
|
</Badge>
|
|
|
|
</Tooltip>
|
|
|
|
</Tooltip>
|
|
|
@ -107,20 +184,50 @@ const StatusBadge = ({
|
|
|
|
|
|
|
|
|
|
|
|
case MediaStatus.PARTIALLY_AVAILABLE:
|
|
|
|
case MediaStatus.PARTIALLY_AVAILABLE:
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Tooltip content={mediaLinkDescription}>
|
|
|
|
<Tooltip
|
|
|
|
<Badge badgeType="success" href={mediaLink}>
|
|
|
|
content={inProgress && tooltipContent}
|
|
|
|
<div className="flex items-center">
|
|
|
|
className={`${
|
|
|
|
|
|
|
|
inProgress && 'hidden max-h-96 w-96 overflow-scroll sm:block'
|
|
|
|
|
|
|
|
}`}
|
|
|
|
|
|
|
|
tooltipConfig={{ interactive: true, delayHide: 100 }}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Badge
|
|
|
|
|
|
|
|
badgeType="success"
|
|
|
|
|
|
|
|
href={mediaLink}
|
|
|
|
|
|
|
|
className={`${
|
|
|
|
|
|
|
|
inProgress &&
|
|
|
|
|
|
|
|
'relative !bg-gray-700 !bg-opacity-80 !px-0 hover:!bg-gray-700'
|
|
|
|
|
|
|
|
} overflow-hidden`}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{inProgress && badgeDownloadProgress}
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
|
|
|
className={`relative z-20 flex items-center ${
|
|
|
|
|
|
|
|
inProgress && 'px-2'
|
|
|
|
|
|
|
|
}`}
|
|
|
|
|
|
|
|
>
|
|
|
|
<span>
|
|
|
|
<span>
|
|
|
|
{intl.formatMessage(
|
|
|
|
{intl.formatMessage(
|
|
|
|
is4k ? messages.status4k : messages.status,
|
|
|
|
is4k ? messages.status4k : messages.status,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
status: intl.formatMessage(
|
|
|
|
status: inProgress
|
|
|
|
globalMessages.partiallyavailable
|
|
|
|
? intl.formatMessage(globalMessages.processing)
|
|
|
|
),
|
|
|
|
: intl.formatMessage(globalMessages.partiallyavailable),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
{inProgress && <Spinner className="ml-1 h-3 w-3" />}
|
|
|
|
{inProgress && (
|
|
|
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
{mediaType === 'tv' && (
|
|
|
|
|
|
|
|
<span className="ml-1">
|
|
|
|
|
|
|
|
{intl.formatMessage(messages.seasonepisodenumber, {
|
|
|
|
|
|
|
|
seasonNumber: downloadItem[0].episode?.seasonNumber,
|
|
|
|
|
|
|
|
episodeNumber: downloadItem[0].episode?.episodeNumber,
|
|
|
|
|
|
|
|
})}
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
<Spinner className="ml-1 h-3 w-3" />
|
|
|
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Badge>
|
|
|
|
</Badge>
|
|
|
|
</Tooltip>
|
|
|
|
</Tooltip>
|
|
|
@ -128,9 +235,27 @@ const StatusBadge = ({
|
|
|
|
|
|
|
|
|
|
|
|
case MediaStatus.PROCESSING:
|
|
|
|
case MediaStatus.PROCESSING:
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Tooltip content={mediaLinkDescription}>
|
|
|
|
<Tooltip
|
|
|
|
<Badge badgeType="primary" href={mediaLink}>
|
|
|
|
content={inProgress && tooltipContent}
|
|
|
|
<div className="flex items-center">
|
|
|
|
className={`${
|
|
|
|
|
|
|
|
inProgress && 'hidden max-h-96 w-96 overflow-scroll sm:block'
|
|
|
|
|
|
|
|
}`}
|
|
|
|
|
|
|
|
tooltipConfig={{ interactive: true, delayHide: 100 }}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Badge
|
|
|
|
|
|
|
|
badgeType="primary"
|
|
|
|
|
|
|
|
href={mediaLink}
|
|
|
|
|
|
|
|
className={`${
|
|
|
|
|
|
|
|
inProgress &&
|
|
|
|
|
|
|
|
'relative !bg-gray-700 !bg-opacity-80 !px-0 hover:!bg-gray-700'
|
|
|
|
|
|
|
|
} overflow-hidden`}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{inProgress && badgeDownloadProgress}
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
|
|
|
className={`relative z-20 flex items-center ${
|
|
|
|
|
|
|
|
inProgress && 'px-2'
|
|
|
|
|
|
|
|
}`}
|
|
|
|
|
|
|
|
>
|
|
|
|
<span>
|
|
|
|
<span>
|
|
|
|
{intl.formatMessage(
|
|
|
|
{intl.formatMessage(
|
|
|
|
is4k ? messages.status4k : messages.status,
|
|
|
|
is4k ? messages.status4k : messages.status,
|
|
|
@ -141,7 +266,19 @@ const StatusBadge = ({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
{inProgress && <Spinner className="ml-1 h-3 w-3" />}
|
|
|
|
{inProgress && (
|
|
|
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
{mediaType === 'tv' && (
|
|
|
|
|
|
|
|
<span className="ml-1">
|
|
|
|
|
|
|
|
{intl.formatMessage(messages.seasonepisodenumber, {
|
|
|
|
|
|
|
|
seasonNumber: downloadItem[0].episode?.seasonNumber,
|
|
|
|
|
|
|
|
episodeNumber: downloadItem[0].episode?.episodeNumber,
|
|
|
|
|
|
|
|
})}
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
<Spinner className="ml-1 h-3 w-3" />
|
|
|
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Badge>
|
|
|
|
</Badge>
|
|
|
|
</Tooltip>
|
|
|
|
</Tooltip>
|
|
|
|