mirror of
https://github.com/moghtech/komodo.git
synced 2026-04-30 14:25:22 -05:00
show none when none
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
import { Accessor, Component, createMemo, For, Show } from "solid-js";
|
import { Accessor, Component, createMemo } from "solid-js";
|
||||||
import { useAppState } from "../../state/StateProvider";
|
import { useAppState } from "../../state/StateProvider";
|
||||||
import { DockerContainerState, ServerStatus } from "../../types";
|
import { DockerContainerState, ServerStatus } from "../../types";
|
||||||
import Grid from "../shared/layout/Grid";
|
import Grid from "../shared/layout/Grid";
|
||||||
import Flex from "../shared/layout/Flex";
|
|
||||||
import PieChart, { PieChartSection } from "../shared/PieChart";
|
import PieChart, { PieChartSection } from "../shared/PieChart";
|
||||||
import { COLORS } from "../../style/colors";
|
import { COLORS } from "../../style/colors";
|
||||||
import { useAppDimensions } from "../../state/DimensionProvider";
|
import { useAppDimensions } from "../../state/DimensionProvider";
|
||||||
@@ -41,45 +40,6 @@ const Summary: Component<{}> = (p) => {
|
|||||||
|
|
||||||
export default Summary;
|
export default Summary;
|
||||||
|
|
||||||
const SummaryItem: Component<{
|
|
||||||
title: string;
|
|
||||||
metrics: Array<{ title: string; class: string; count?: number }>;
|
|
||||||
}> = (p) => {
|
|
||||||
return (
|
|
||||||
<Flex
|
|
||||||
class="card light shadow wrap"
|
|
||||||
justifyContent="space-between"
|
|
||||||
alignItems="center"
|
|
||||||
>
|
|
||||||
<h2>{p.title}</h2>
|
|
||||||
<Flex class="wrap">
|
|
||||||
<For each={p.metrics}>
|
|
||||||
{(metric) => (
|
|
||||||
<Show when={metric?.count && metric.count > 0}>
|
|
||||||
<Flex gap="0.4rem" alignItems="center">
|
|
||||||
<div>{metric.title}</div>
|
|
||||||
<h2 class={metric.class}>{metric.count}</h2>
|
|
||||||
</Flex>
|
|
||||||
</Show>
|
|
||||||
)}
|
|
||||||
</For>
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const BuildsSummary = () => {
|
|
||||||
const { builds } = useAppState();
|
|
||||||
return (
|
|
||||||
<SummaryItem
|
|
||||||
title="builds"
|
|
||||||
metrics={[
|
|
||||||
{ title: "total", class: "text-green", count: builds.ids()?.length },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
function useDeploymentCount(): Accessor<PieChartSection[]> {
|
function useDeploymentCount(): Accessor<PieChartSection[]> {
|
||||||
const { deployments } = useAppState();
|
const { deployments } = useAppState();
|
||||||
const count = createMemo(() => {
|
const count = createMemo(() => {
|
||||||
@@ -148,3 +108,42 @@ function useServerCount(): Accessor<PieChartSection[]> {
|
|||||||
});
|
});
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// const SummaryItem: Component<{
|
||||||
|
// title: string;
|
||||||
|
// metrics: Array<{ title: string; class: string; count?: number }>;
|
||||||
|
// }> = (p) => {
|
||||||
|
// return (
|
||||||
|
// <Flex
|
||||||
|
// class="card light shadow wrap"
|
||||||
|
// justifyContent="space-between"
|
||||||
|
// alignItems="center"
|
||||||
|
// >
|
||||||
|
// <h2>{p.title}</h2>
|
||||||
|
// <Flex class="wrap">
|
||||||
|
// <For each={p.metrics}>
|
||||||
|
// {(metric) => (
|
||||||
|
// <Show when={metric?.count && metric.count > 0}>
|
||||||
|
// <Flex gap="0.4rem" alignItems="center">
|
||||||
|
// <div>{metric.title}</div>
|
||||||
|
// <h2 class={metric.class}>{metric.count}</h2>
|
||||||
|
// </Flex>
|
||||||
|
// </Show>
|
||||||
|
// )}
|
||||||
|
// </For>
|
||||||
|
// </Flex>
|
||||||
|
// </Flex>
|
||||||
|
// );
|
||||||
|
// };
|
||||||
|
|
||||||
|
// const BuildsSummary = () => {
|
||||||
|
// const { builds } = useAppState();
|
||||||
|
// return (
|
||||||
|
// <SummaryItem
|
||||||
|
// title="builds"
|
||||||
|
// metrics={[
|
||||||
|
// { title: "total", class: "text-green", count: builds.ids()?.length },
|
||||||
|
// ]}
|
||||||
|
// />
|
||||||
|
// );
|
||||||
|
// };
|
||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
For,
|
For,
|
||||||
onCleanup,
|
onCleanup,
|
||||||
onMount,
|
onMount,
|
||||||
|
Show,
|
||||||
} from "solid-js";
|
} from "solid-js";
|
||||||
import Grid from "./layout/Grid";
|
import Grid from "./layout/Grid";
|
||||||
|
|
||||||
@@ -89,10 +90,7 @@ const PieChart: Component<{
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
opacity:
|
opacity: selected() === index() ? 1 : 0.7,
|
||||||
selected() === index()
|
|
||||||
? 1
|
|
||||||
: 0.7,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{section.title}:
|
{section.title}:
|
||||||
@@ -101,6 +99,9 @@ const PieChart: Component<{
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</For>
|
</For>
|
||||||
|
<Show when={sections().length === 0}>
|
||||||
|
<div style={{ opacity: 0.7 }}>none</div>
|
||||||
|
</Show>
|
||||||
</div>
|
</div>
|
||||||
</Grid>
|
</Grid>
|
||||||
<canvas ref={canvas!} style={{ "z-index": 1 }} />
|
<canvas ref={canvas!} style={{ "z-index": 1 }} />
|
||||||
|
|||||||
Reference in New Issue
Block a user