mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-09 14:58:47 +00:00
Feature: nested groups (#4346)
This commit is contained in:
parent
907abee1aa
commit
be8363cc35
10 changed files with 119 additions and 55 deletions
|
@ -3,12 +3,13 @@ import classNames from "classnames";
|
|||
import { Disclosure, Transition } from "@headlessui/react";
|
||||
import { MdKeyboardArrowDown } from "react-icons/md";
|
||||
|
||||
import { columnMap } from "../../utils/layout/columns";
|
||||
|
||||
import List from "components/services/list";
|
||||
import ResolvedIcon from "components/resolvedicon";
|
||||
|
||||
export default function ServicesGroup({
|
||||
group,
|
||||
services,
|
||||
layout,
|
||||
fiveColumns,
|
||||
disableCollapse,
|
||||
|
@ -23,7 +24,7 @@ export default function ServicesGroup({
|
|||
|
||||
return (
|
||||
<div
|
||||
key={services.name}
|
||||
key={group.name}
|
||||
className={classNames(
|
||||
"services-group",
|
||||
layout?.style === "row" ? "basis-full" : "basis-full md:basis-1/2 lg:basis-1/3 xl:basis-1/4",
|
||||
|
@ -42,7 +43,7 @@ export default function ServicesGroup({
|
|||
</div>
|
||||
)}
|
||||
<h2 className="flex text-theme-800 dark:text-theme-300 text-xl font-medium service-group-name">
|
||||
{services.name}
|
||||
{group.name}
|
||||
</h2>
|
||||
<MdKeyboardArrowDown
|
||||
className={classNames(
|
||||
|
@ -74,7 +75,31 @@ export default function ServicesGroup({
|
|||
}}
|
||||
>
|
||||
<Disclosure.Panel className="transition-all overflow-hidden duration-300 ease-out" ref={panel} static>
|
||||
<List group={group} services={services.services} layout={layout} useEqualHeights={useEqualHeights} />
|
||||
<List
|
||||
groupName={group.name}
|
||||
services={group.services}
|
||||
layout={layout}
|
||||
useEqualHeights={useEqualHeights}
|
||||
/>
|
||||
{group.groups?.length > 0 && (
|
||||
<div
|
||||
className={`grid ${
|
||||
layout?.style === "row" ? `grid ${columnMap[layout?.columns]} gap-x-2` : "flex flex-col"
|
||||
} gap-2`}
|
||||
>
|
||||
{group.groups.map((subgroup) => (
|
||||
<ServicesGroup
|
||||
key={subgroup.name}
|
||||
group={subgroup}
|
||||
layout={layout?.[subgroup.name]}
|
||||
fiveColumns={fiveColumns}
|
||||
disableCollapse={disableCollapse}
|
||||
useEqualHeights={useEqualHeights}
|
||||
groupsInitiallyCollapsed={groupsInitiallyCollapsed}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Disclosure.Panel>
|
||||
</Transition>
|
||||
</>
|
||||
|
|
|
@ -12,7 +12,7 @@ import Kubernetes from "widgets/kubernetes/component";
|
|||
import { SettingsContext } from "utils/contexts/settings";
|
||||
import ResolvedIcon from "components/resolvedicon";
|
||||
|
||||
export default function Item({ service, group, useEqualHeights }) {
|
||||
export default function Item({ service, groupName, useEqualHeights }) {
|
||||
const hasLink = service.href && service.href !== "#";
|
||||
const { settings } = useContext(SettingsContext);
|
||||
const showStats = service.showStats === false ? false : settings.showStats;
|
||||
|
@ -90,14 +90,14 @@ export default function Item({ service, group, useEqualHeights }) {
|
|||
>
|
||||
{service.ping && (
|
||||
<div className="flex-shrink-0 flex items-center justify-center service-tag service-ping">
|
||||
<Ping group={group} service={service.name} style={statusStyle} />
|
||||
<Ping groupName={groupName} serviceName={service.name} style={statusStyle} />
|
||||
<span className="sr-only">Ping status</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{service.siteMonitor && (
|
||||
<div className="flex-shrink-0 flex items-center justify-center service-tag service-site-monitor">
|
||||
<SiteMonitor group={group} service={service.name} style={statusStyle} />
|
||||
<SiteMonitor groupName={groupName} serviceName={service.name} style={statusStyle} />
|
||||
<span className="sr-only">Site monitor status</span>
|
||||
</div>
|
||||
)}
|
||||
|
|
|
@ -4,7 +4,7 @@ import { columnMap } from "../../utils/layout/columns";
|
|||
|
||||
import Item from "components/services/item";
|
||||
|
||||
export default function List({ group, services, layout, useEqualHeights }) {
|
||||
export default function List({ groupName, services, layout, useEqualHeights }) {
|
||||
return (
|
||||
<ul
|
||||
className={classNames(
|
||||
|
@ -16,7 +16,7 @@ export default function List({ group, services, layout, useEqualHeights }) {
|
|||
<Item
|
||||
key={[service.container, service.app, service.name].filter((s) => s).join("-")}
|
||||
service={service}
|
||||
group={group}
|
||||
groupName={groupName}
|
||||
useEqualHeights={layout?.useEqualHeights ?? useEqualHeights}
|
||||
/>
|
||||
))}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { useTranslation } from "react-i18next";
|
||||
import useSWR from "swr";
|
||||
|
||||
export default function Ping({ group, service, style }) {
|
||||
export default function Ping({ groupName, serviceName, style }) {
|
||||
const { t } = useTranslation();
|
||||
const { data, error } = useSWR(`/api/ping?${new URLSearchParams({ group, service }).toString()}`, {
|
||||
const { data, error } = useSWR(`/api/ping?${new URLSearchParams({ groupName, serviceName }).toString()}`, {
|
||||
refreshInterval: 30000,
|
||||
});
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { useTranslation } from "react-i18next";
|
||||
import useSWR from "swr";
|
||||
|
||||
export default function SiteMonitor({ group, service, style }) {
|
||||
export default function SiteMonitor({ groupName, serviceName, style }) {
|
||||
const { t } = useTranslation();
|
||||
const { data, error } = useSWR(`/api/siteMonitor?${new URLSearchParams({ group, service }).toString()}`, {
|
||||
const { data, error } = useSWR(`/api/siteMonitor?${new URLSearchParams({ groupName, serviceName }).toString()}`, {
|
||||
refreshInterval: 30000,
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue