mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-16 09:49:49 +00:00
linting and cleanup
This commit is contained in:
parent
7f041e8303
commit
f74e8b9d32
51 changed files with 464 additions and 349 deletions
|
@ -8,28 +8,32 @@ import Docker from "./widgets/service/docker";
|
|||
function resolveIcon(icon) {
|
||||
if (icon.startsWith("http")) {
|
||||
return `/api/proxy?url=${encodeURIComponent(icon)}`;
|
||||
} else if (icon.startsWith("/")) {
|
||||
return icon;
|
||||
} else {
|
||||
if (icon.endsWith(".png")) {
|
||||
return `https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/${icon}`;
|
||||
} else {
|
||||
return `https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/${icon}.png`;
|
||||
}
|
||||
}
|
||||
|
||||
if (icon.startsWith("/")) {
|
||||
return icon;
|
||||
}
|
||||
|
||||
if (icon.endsWith(".png")) {
|
||||
return `https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/${icon}`;
|
||||
}
|
||||
|
||||
return `https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/${icon}.png`;
|
||||
}
|
||||
|
||||
export default function Item({ service }) {
|
||||
return (
|
||||
<li key={service.name}>
|
||||
<Disclosure>
|
||||
<div className={
|
||||
(service.href && service.href !== "#" ? 'cursor-pointer ' : 'cursor-default ') +
|
||||
'transition-all h-15 overflow-hidden mb-3 p-1 rounded-md font-medium text-theme-700 hover:text-theme-800 dark:text-theme-200 dark:hover:text-theme-300 shadow-md shadow-theme-900/10 dark:shadow-theme-900/40 bg-white/50 hover:bg-theme-300/10 dark:bg-white/5 dark:hover:bg-white/10'
|
||||
}>
|
||||
<div
|
||||
className={`${
|
||||
service.href && service.href !== "#" ? "cursor-pointer " : "cursor-default "
|
||||
}transition-all h-15 overflow-hidden mb-3 p-1 rounded-md font-medium text-theme-700 hover:text-theme-800 dark:text-theme-200 dark:hover:text-theme-300 shadow-md shadow-theme-900/10 dark:shadow-theme-900/40 bg-white/50 hover:bg-theme-300/10 dark:bg-white/5 dark:hover:bg-white/10`}
|
||||
>
|
||||
<div className="flex">
|
||||
{service.icon && (
|
||||
<div
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
if (service.href && service.href !== "#") {
|
||||
window.open(service.href, "_blank").focus();
|
||||
|
@ -38,10 +42,11 @@ export default function Item({ service }) {
|
|||
className="flex-shrink-0 flex items-center justify-center w-12 "
|
||||
>
|
||||
<Image src={resolveIcon(service.icon)} width={32} height={32} alt="logo" />
|
||||
</div>
|
||||
</button>
|
||||
)}
|
||||
|
||||
<div
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
if (service.href && service.href !== "#") {
|
||||
window.open(service.href, "_blank").focus();
|
||||
|
@ -53,9 +58,12 @@ export default function Item({ service }) {
|
|||
{service.name}
|
||||
<p className="text-theme-500 dark:text-theme-400 text-xs font-extralight">{service.description}</p>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
{service.container && (
|
||||
<Disclosure.Button as="div" className="flex-shrink-0 flex items-center justify-center w-12 cursor-pointer">
|
||||
<Disclosure.Button
|
||||
as="div"
|
||||
className="flex-shrink-0 flex items-center justify-center w-12 cursor-pointer"
|
||||
>
|
||||
<Status service={service} />
|
||||
</Disclosure.Button>
|
||||
)}
|
||||
|
|
|
@ -2,7 +2,7 @@ import Item from "components/services/item";
|
|||
|
||||
export default function List({ services }) {
|
||||
return (
|
||||
<ul role="list" className="mt-3 flex flex-col">
|
||||
<ul className="mt-3 flex flex-col">
|
||||
{services.map((service) => (
|
||||
<Item key={service.name} service={service} />
|
||||
))}
|
||||
|
|
|
@ -1,28 +1,18 @@
|
|||
import useSWR from "swr";
|
||||
|
||||
export default function Status({ service }) {
|
||||
const { data, error } = useSWR(
|
||||
`/api/docker/status/${service.container}/${service.server || ""}`
|
||||
);
|
||||
const { data, error } = useSWR(`/api/docker/status/${service.container}/${service.server || ""}`);
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<div className="w-3 h-3 bg-rose-300 dark:bg-rose-500 rounded-full" />
|
||||
);
|
||||
return <div className="w-3 h-3 bg-rose-300 dark:bg-rose-500 rounded-full" />;
|
||||
}
|
||||
|
||||
if (data && data.status === "running") {
|
||||
return (
|
||||
<div className="w-3 h-3 bg-emerald-300 dark:bg-emerald-500 rounded-full" />
|
||||
);
|
||||
return <div className="w-3 h-3 bg-emerald-300 dark:bg-emerald-500 rounded-full" />;
|
||||
}
|
||||
|
||||
if (data && data.status === "not found") {
|
||||
return (
|
||||
<>
|
||||
<div className="h-2.5 w-2.5 bg-orange-400/50 dark:bg-yellow-200/40 -rotate-45"></div>
|
||||
</>
|
||||
);
|
||||
return <div className="h-2.5 w-2.5 bg-orange-400/50 dark:bg-yellow-200/40 -rotate-45" />;
|
||||
}
|
||||
|
||||
return <div className="w-3 h-3 bg-black/20 dark:bg-white/40 rounded-full" />;
|
||||
|
|
|
@ -24,9 +24,9 @@ export default function Emby({ service, title = "Emby" }) {
|
|||
);
|
||||
}
|
||||
|
||||
const playing = sessionsData.filter((session) => session.hasOwnProperty("NowPlayingItem"));
|
||||
const playing = sessionsData.filter((session) => session?.NowPlayingItem);
|
||||
const transcoding = sessionsData.filter(
|
||||
(session) => session.hasOwnProperty("PlayState") && session.PlayState.PlayMethod === "Transcode"
|
||||
(session) => session?.PlayState && session.PlayState.PlayMethod === "Transcode"
|
||||
);
|
||||
const bitrate = playing.reduce((acc, session) => acc + session.NowPlayingItem.Bitrate, 0);
|
||||
|
||||
|
|
|
@ -25,13 +25,9 @@ export default function Rutorrent({ service }) {
|
|||
);
|
||||
}
|
||||
|
||||
const upload = statusData.reduce((acc, torrent) => {
|
||||
return acc + parseInt(torrent["d.get_up_rate"]);
|
||||
}, 0);
|
||||
const upload = statusData.reduce((acc, torrent) => acc + parseInt(torrent["d.get_up_rate"], 10), 0);
|
||||
|
||||
const download = statusData.reduce((acc, torrent) => {
|
||||
return acc + parseInt(torrent["d.get_down_rate"]);
|
||||
}, 0);
|
||||
const download = statusData.reduce((acc, torrent) => acc + parseInt(torrent["d.get_down_rate"], 10), 0);
|
||||
|
||||
const active = statusData.filter((torrent) => torrent["d.get_state"] === "1");
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ export default function Tautulli({ service }) {
|
|||
);
|
||||
}
|
||||
|
||||
const data = statsData.response.data;
|
||||
const { data } = statsData.response;
|
||||
|
||||
return (
|
||||
<Widget>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue