Merge pull request #1334 from benphelps/feature-stats-control

Feature: Global & per-service docker stats control
pull/1335/head
shamoon 2 years ago committed by GitHub
commit 6dcec48669
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -14,7 +14,8 @@ import ResolvedIcon from "components/resolvedicon";
export default function Item({ service }) {
const hasLink = service.href && service.href !== "#";
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);
// set stats to closed after 300ms
@ -107,21 +108,21 @@ export default function Item({ service }) {
{service.container && service.server && (
<div
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"
)}
>
{(settings.showStats || statsOpen) && <Docker service={{ widget: { container: service.container, server: service.server } }} />}
{(showStats || statsOpen) && <Docker service={{ widget: { container: service.container, server: service.server } }} />}
</div>
)}
{service.app && (
<div
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"
)}
>
{(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>
)}

@ -236,6 +236,7 @@ export function cleanServiceGroups(groups) {
name: serviceGroup.name,
services: serviceGroup.services.map((service) => {
const cleanedService = { ...service };
if (cleanedService.showStats !== undefined) cleanedService.showStats = JSON.parse(cleanedService.showStats);
if (typeof service.weight === 'string') {
const weight = parseInt(service.weight, 10);
if (Number.isNaN(weight)) {

Loading…
Cancel
Save