mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Support per-service stats control
This commit is contained in:
parent
1a374dec3c
commit
7e012993d8
@ -14,7 +14,8 @@ import ResolvedIcon from "components/resolvedicon";
|
|||||||
export default function Item({ service }) {
|
export default function Item({ service }) {
|
||||||
const hasLink = service.href && service.href !== "#";
|
const hasLink = service.href && service.href !== "#";
|
||||||
const { settings } = useContext(SettingsContext);
|
const { settings } = useContext(SettingsContext);
|
||||||
const [statsOpen, setStatsOpen] = useState(false);
|
const showStats = (service.showStats === false) ? false : settings.showStats;
|
||||||
|
const [statsOpen, setStatsOpen] = useState(service.showStats);
|
||||||
const [statsClosing, setStatsClosing] = useState(false);
|
const [statsClosing, setStatsClosing] = useState(false);
|
||||||
|
|
||||||
// set stats to closed after 300ms
|
// set stats to closed after 300ms
|
||||||
@ -107,21 +108,21 @@ export default function Item({ service }) {
|
|||||||
{service.container && service.server && (
|
{service.container && service.server && (
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
settings.showStats || (statsOpen && !statsClosing) ? "max-h-[110px] opacity-100" : " max-h-[0] opacity-0",
|
showStats || (statsOpen && !statsClosing) ? "max-h-[110px] opacity-100" : " max-h-[0] opacity-0",
|
||||||
"w-full overflow-hidden transition-all duration-300 ease-in-out"
|
"w-full overflow-hidden transition-all duration-300 ease-in-out"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{(settings.showStats || statsOpen) && <Docker service={{ widget: { container: service.container, server: service.server } }} />}
|
{(showStats || statsOpen) && <Docker service={{ widget: { container: service.container, server: service.server } }} />}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{service.app && (
|
{service.app && (
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
settings.showStats || (statsOpen && !statsClosing) ? "max-h-[55px] opacity-100" : " max-h-[0] opacity-0",
|
showStats || (statsOpen && !statsClosing) ? "max-h-[55px] opacity-100" : " max-h-[0] opacity-0",
|
||||||
"w-full overflow-hidden transition-all duration-300 ease-in-out"
|
"w-full overflow-hidden transition-all duration-300 ease-in-out"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{(settings.showStats || statsOpen) && <Kubernetes service={{ widget: { namespace: service.namespace, app: service.app, podSelector: service.podSelector } }} />}
|
{(showStats || statsOpen) && <Kubernetes service={{ widget: { namespace: service.namespace, app: service.app, podSelector: service.podSelector } }} />}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
@ -236,6 +236,7 @@ export function cleanServiceGroups(groups) {
|
|||||||
name: serviceGroup.name,
|
name: serviceGroup.name,
|
||||||
services: serviceGroup.services.map((service) => {
|
services: serviceGroup.services.map((service) => {
|
||||||
const cleanedService = { ...service };
|
const cleanedService = { ...service };
|
||||||
|
if (cleanedService.showStats !== undefined) cleanedService.showStats = JSON.parse(cleanedService.showStats);
|
||||||
if (typeof service.weight === 'string') {
|
if (typeof service.weight === 'string') {
|
||||||
const weight = parseInt(service.weight, 10);
|
const weight = parseInt(service.weight, 10);
|
||||||
if (Number.isNaN(weight)) {
|
if (Number.isNaN(weight)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user