mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Use compact now playing format
This commit is contained in:
parent
31b644c939
commit
3e73fb65ea
@ -169,10 +169,8 @@
|
|||||||
"middleware": "Middleware"
|
"middleware": "Middleware"
|
||||||
},
|
},
|
||||||
"navidrome": {
|
"navidrome": {
|
||||||
"user": "User",
|
"nothing_streaming": "No Active Streams",
|
||||||
"artist": "Artist",
|
"please_wait": "Please Wait"
|
||||||
"song": "Song",
|
|
||||||
"album": "Album"
|
|
||||||
},
|
},
|
||||||
"npm": {
|
"npm": {
|
||||||
"enabled": "Enabled",
|
"enabled": "Enabled",
|
||||||
|
@ -1,9 +1,24 @@
|
|||||||
import { useTranslation } from "next-i18next";
|
import { useTranslation } from "next-i18next";
|
||||||
|
|
||||||
import Container from "components/services/widget/container";
|
import Container from "components/services/widget/container";
|
||||||
import Block from "components/services/widget/block";
|
|
||||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
|
|
||||||
|
function SinglePlayingEntry({ entry }) {
|
||||||
|
const { username, artist, title, album } = entry;
|
||||||
|
let fullTitle = title;
|
||||||
|
if (artist) fullTitle = `${artist} - ${title}`;
|
||||||
|
if (album) fullTitle += ` — ${album}`;
|
||||||
|
if (username) fullTitle += ` (${username})`;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="text-theme-700 dark:text-theme-200 relative h-5 w-full rounded-md bg-theme-200/50 dark:bg-theme-900/20 mt-1 flex">
|
||||||
|
<div className="text-xs z-10 self-center ml-2 relative w-full h-4 grow mr-2">
|
||||||
|
<div className="absolute w-full whitespace-nowrap text-ellipsis overflow-hidden">{fullTitle}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default function Component({ service }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@ -17,37 +32,25 @@ export default function Component({ service }) {
|
|||||||
|
|
||||||
if (!navidromeData) {
|
if (!navidromeData) {
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<SinglePlayingEntry entry={{ title: t("navidrome.please_wait") }} />
|
||||||
<Block label="navidrome.user" />
|
|
||||||
<Block label="navidrome.artist" />
|
|
||||||
<Block label="navidrome.song" />
|
|
||||||
<Block label="navidrome.album" />
|
|
||||||
</Container>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const nowPlaying = navidromeData["subsonic-response"].nowPlaying;
|
const { nowPlaying } = navidromeData["subsonic-response"];
|
||||||
if (!nowPlaying.entry) {
|
if (!nowPlaying.entry) {
|
||||||
// nothing playing
|
// nothing playing
|
||||||
return (
|
return (
|
||||||
<Container service={service} />
|
<SinglePlayingEntry entry={{ title: t("navidrome.nothing_streaming") }} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const nowPlayingEntries = Object.values(nowPlaying.entry);
|
const nowPlayingEntries = Object.values(nowPlaying.entry);
|
||||||
const songList = [];
|
|
||||||
|
|
||||||
nowPlayingEntries.forEach(userPlay => {
|
return (
|
||||||
const playing = (
|
<div className="flex flex-col pb-1 mx-1">
|
||||||
<Container service={service}>
|
{nowPlayingEntries.map((entry) => (
|
||||||
<Block label="navidrome.user" value={userPlay.username} />
|
<SinglePlayingEntry key={entry.id} entry={entry} />
|
||||||
<Block label="navidrome.artist" value={userPlay.artist} />
|
))}
|
||||||
<Block label="navidrome.song" value={userPlay.title} />
|
</div>
|
||||||
<Block label="navidrome.album" value={userPlay.album} />
|
|
||||||
</Container>
|
|
||||||
);
|
);
|
||||||
songList.unshift(playing);
|
|
||||||
});
|
|
||||||
|
|
||||||
return songList;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user