|
|
@ -2,6 +2,7 @@ import { useTranslation } from "next-i18next";
|
|
|
|
import { BsVolumeMuteFill, BsFillPlayFill, BsPauseFill, BsCpu, BsFillCpuFill } from "react-icons/bs";
|
|
|
|
import { BsVolumeMuteFill, BsFillPlayFill, BsPauseFill, BsCpu, BsFillCpuFill } from "react-icons/bs";
|
|
|
|
import { MdOutlineSmartDisplay } from "react-icons/md";
|
|
|
|
import { MdOutlineSmartDisplay } from "react-icons/md";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import Block from "components/services/widget/block";
|
|
|
|
import Container from "components/services/widget/container";
|
|
|
|
import Container from "components/services/widget/container";
|
|
|
|
import { formatProxyUrlWithSegments } from "utils/proxy/api-helpers";
|
|
|
|
import { formatProxyUrlWithSegments } from "utils/proxy/api-helpers";
|
|
|
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
|
|
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
|
|
@ -148,6 +149,33 @@ function SessionEntry({ playCommand, session }) {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function CountBlocks({ service, countData }) {
|
|
|
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
// allows filtering
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-param-reassign
|
|
|
|
|
|
|
|
if (service.widget?.type === 'jellyfin') service.widget.type = 'emby'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!countData) {
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<Container service={service}>
|
|
|
|
|
|
|
|
<Block label="emby.movies" />
|
|
|
|
|
|
|
|
<Block label="emby.series" />
|
|
|
|
|
|
|
|
<Block label="emby.episodes" />
|
|
|
|
|
|
|
|
<Block label="emby.songs" />
|
|
|
|
|
|
|
|
</Container>
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<Container service={service}>
|
|
|
|
|
|
|
|
<Block label="emby.movies" value={t("common.number", { value: countData.MovieCount })} />
|
|
|
|
|
|
|
|
<Block label="emby.series" value={t("common.number", { value: countData.SeriesCount })} />
|
|
|
|
|
|
|
|
<Block label="emby.episodes" value={t("common.number", { value: countData.EpisodeCount })} />
|
|
|
|
|
|
|
|
<Block label="emby.songs" value={t("common.number", { value: countData.SongCount })} />
|
|
|
|
|
|
|
|
</Container>
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default function Component({ service }) {
|
|
|
|
export default function Component({ service }) {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
|
|
|
@ -161,6 +189,12 @@ export default function Component({ service }) {
|
|
|
|
refreshInterval: 5000,
|
|
|
|
refreshInterval: 5000,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
|
|
|
data: countData,
|
|
|
|
|
|
|
|
error: countError,
|
|
|
|
|
|
|
|
} = useWidgetAPI(widget, "Count", {
|
|
|
|
|
|
|
|
refreshInterval: 60000,});
|
|
|
|
|
|
|
|
|
|
|
|
async function handlePlayCommand(session, command) {
|
|
|
|
async function handlePlayCommand(session, command) {
|
|
|
|
const url = formatProxyUrlWithSegments(widget, "PlayControl", {
|
|
|
|
const url = formatProxyUrlWithSegments(widget, "PlayControl", {
|
|
|
|
sessionId: session.Id,
|
|
|
|
sessionId: session.Id,
|
|
|
@ -171,23 +205,30 @@ export default function Component({ service }) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (sessionsError) {
|
|
|
|
if (sessionsError || countError) {
|
|
|
|
return <Container error={sessionsError} />;
|
|
|
|
return <Container error={sessionsError ?? countError} />;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!sessionsData) {
|
|
|
|
const enableBlocks = service.widget?.enableBlocks
|
|
|
|
|
|
|
|
const enableNowPlaying = service.widget?.enableNowPlaying ?? true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!sessionsData || !countData) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="flex flex-col pb-1">
|
|
|
|
<>
|
|
|
|
|
|
|
|
{enableBlocks && <CountBlocks service={service} countData={null} />}
|
|
|
|
|
|
|
|
{enableNowPlaying && <div className="flex flex-col pb-1">
|
|
|
|
<div className="text-theme-700 dark:text-theme-200 text-xs relative h-5 w-full rounded-md bg-theme-200/50 dark:bg-theme-900/20 mt-1">
|
|
|
|
<div className="text-theme-700 dark:text-theme-200 text-xs relative h-5 w-full rounded-md bg-theme-200/50 dark:bg-theme-900/20 mt-1">
|
|
|
|
<span className="absolute left-2 text-xs mt-[2px]">-</span>
|
|
|
|
<span className="absolute left-2 text-xs mt-[2px]">-</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="text-theme-700 dark:text-theme-200 text-xs relative h-5 w-full rounded-md bg-theme-200/50 dark:bg-theme-900/20 mt-1">
|
|
|
|
<div className="text-theme-700 dark:text-theme-200 text-xs relative h-5 w-full rounded-md bg-theme-200/50 dark:bg-theme-900/20 mt-1">
|
|
|
|
<span className="absolute left-2 text-xs mt-[2px]">-</span>
|
|
|
|
<span className="absolute left-2 text-xs mt-[2px]">-</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>}
|
|
|
|
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (enableNowPlaying) {
|
|
|
|
const playing = sessionsData
|
|
|
|
const playing = sessionsData
|
|
|
|
.filter((session) => session?.NowPlayingItem)
|
|
|
|
.filter((session) => session?.NowPlayingItem)
|
|
|
|
.sort((a, b) => {
|
|
|
|
.sort((a, b) => {
|
|
|
@ -202,6 +243,8 @@ export default function Component({ service }) {
|
|
|
|
|
|
|
|
|
|
|
|
if (playing.length === 0) {
|
|
|
|
if (playing.length === 0) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
{enableBlocks && <CountBlocks service={service} countData={countData} />}
|
|
|
|
<div className="flex flex-col pb-1 mx-1">
|
|
|
|
<div className="flex flex-col pb-1 mx-1">
|
|
|
|
<div className="text-theme-700 dark:text-theme-200 text-xs relative h-5 w-full rounded-md bg-theme-200/50 dark:bg-theme-900/20 mt-1">
|
|
|
|
<div className="text-theme-700 dark:text-theme-200 text-xs relative h-5 w-full rounded-md bg-theme-200/50 dark:bg-theme-900/20 mt-1">
|
|
|
|
<span className="absolute left-2 text-xs mt-[2px]">{t("emby.no_active")}</span>
|
|
|
|
<span className="absolute left-2 text-xs mt-[2px]">{t("emby.no_active")}</span>
|
|
|
@ -210,22 +253,29 @@ export default function Component({ service }) {
|
|
|
|
<span className="absolute left-2 text-xs mt-[2px]">-</span>
|
|
|
|
<span className="absolute left-2 text-xs mt-[2px]">-</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (playing.length === 1) {
|
|
|
|
if (playing.length === 1) {
|
|
|
|
const session = playing[0];
|
|
|
|
const session = playing[0];
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
{enableBlocks && <CountBlocks service={service} countData={countData} />}
|
|
|
|
<div className="flex flex-col pb-1 mx-1">
|
|
|
|
<div className="flex flex-col pb-1 mx-1">
|
|
|
|
<SingleSessionEntry
|
|
|
|
<SingleSessionEntry
|
|
|
|
playCommand={(currentSession, command) => handlePlayCommand(currentSession, command)}
|
|
|
|
playCommand={(currentSession, command) => handlePlayCommand(currentSession, command)}
|
|
|
|
session={session}
|
|
|
|
session={session}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (playing.length === -1)
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
{enableBlocks && <CountBlocks service={service} countData={countData} />}
|
|
|
|
<div className="flex flex-col pb-1 mx-1">
|
|
|
|
<div className="flex flex-col pb-1 mx-1">
|
|
|
|
{playing.map((session) => (
|
|
|
|
{playing.map((session) => (
|
|
|
|
<SessionEntry
|
|
|
|
<SessionEntry
|
|
|
@ -235,5 +285,13 @@ export default function Component({ service }) {
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (enableBlocks) {
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<CountBlocks service={service} countData={countData} />
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|