mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-25 18:23:11 +00:00
fix uptime graph styles
This commit is contained in:
@@ -165,7 +165,12 @@ export default function UptimeAlertSection({
|
|||||||
rulesListSearch.toString() ? `?${rulesListSearch}` : ""
|
rulesListSearch.toString() ? `?${rulesListSearch}` : ""
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
const alertButton = alertRulesLoading ? null : hasRules ? (
|
const alertButton = alertRulesLoading ? (
|
||||||
|
<Button variant="outline" type="button" loading aria-busy="true">
|
||||||
|
<BellPlus className="size-4 mr-2" />
|
||||||
|
Add Alert
|
||||||
|
</Button>
|
||||||
|
) : hasRules ? (
|
||||||
<Button variant="outline" asChild>
|
<Button variant="outline" asChild>
|
||||||
<Link href={rulesListHref}>
|
<Link href={rulesListHref}>
|
||||||
<BellRing className="size-4 mr-2" />
|
<BellRing className="size-4 mr-2" />
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const barColorClass: Record<string, string> = {
|
|||||||
good: "bg-green-500",
|
good: "bg-green-500",
|
||||||
degraded: "bg-yellow-500",
|
degraded: "bg-yellow-500",
|
||||||
bad: "bg-red-500",
|
bad: "bg-red-500",
|
||||||
no_data: "bg-zinc-700"
|
no_data: "bg-neutral-200 dark:bg-neutral-700"
|
||||||
};
|
};
|
||||||
|
|
||||||
type UptimeBarProps = {
|
type UptimeBarProps = {
|
||||||
@@ -72,7 +72,11 @@ export default function UptimeBar({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const hcQuery = useQuery({
|
const hcQuery = useQuery({
|
||||||
...orgQueries.healthCheckStatusHistory({ orgId: orgId ?? "", healthCheckId: healthCheckId ?? 0, days }),
|
...orgQueries.healthCheckStatusHistory({
|
||||||
|
orgId: orgId ?? "",
|
||||||
|
healthCheckId: healthCheckId ?? 0,
|
||||||
|
days
|
||||||
|
}),
|
||||||
enabled: healthCheckId != null && siteId == null && resourceId == null,
|
enabled: healthCheckId != null && siteId == null && resourceId == null,
|
||||||
meta: { api }
|
meta: { api }
|
||||||
});
|
});
|
||||||
@@ -84,24 +88,43 @@ export default function UptimeBar({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { data, isLoading } =
|
const { data, isLoading } =
|
||||||
siteId != null ? siteQuery :
|
siteId != null
|
||||||
resourceId != null ? resourceQuery :
|
? siteQuery
|
||||||
hcQuery;
|
: resourceId != null
|
||||||
|
? resourceQuery
|
||||||
|
: hcQuery;
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className={cn("space-y-2", className)}>
|
<div className={cn("space-y-3", className)}>
|
||||||
{title && (
|
<div className="flex items-center justify-between">
|
||||||
<div className="text-sm font-medium">{title}</div>
|
{title && (
|
||||||
)}
|
<span className="text-sm font-medium">{title}</span>
|
||||||
|
)}
|
||||||
|
<div
|
||||||
|
className="flex items-center gap-4 text-sm ml-auto"
|
||||||
|
aria-busy="true"
|
||||||
|
aria-label="Loading uptime summary"
|
||||||
|
>
|
||||||
|
<span className="h-4 w-[4.5rem] shrink-0 rounded-md bg-muted animate-pulse" />
|
||||||
|
<span className="h-4 w-[7rem] shrink-0 rounded-md bg-muted animate-pulse" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div className="flex gap-0.5 h-8">
|
<div className="flex gap-0.5 h-8">
|
||||||
{Array.from({ length: days }).map((_, i) => (
|
{Array.from({ length: days }).map((_, i) => (
|
||||||
<div
|
<div
|
||||||
key={i}
|
key={i}
|
||||||
className="flex-1 rounded-sm bg-zinc-800 animate-pulse"
|
className={cn(
|
||||||
|
"flex-1 rounded-sm animate-pulse",
|
||||||
|
barColorClass.no_data
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex justify-between text-xs text-muted-foreground">
|
||||||
|
<span>{days} days ago</span>
|
||||||
|
<span>Today</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -114,9 +137,7 @@ export default function UptimeBar({
|
|||||||
<div className={cn("space-y-3", className)}>
|
<div className={cn("space-y-3", className)}>
|
||||||
{/* Header row */}
|
{/* Header row */}
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
{title && (
|
{title && <span className="text-sm font-medium">{title}</span>}
|
||||||
<span className="text-sm font-medium">{title}</span>
|
|
||||||
)}
|
|
||||||
<div className="flex items-center gap-4 text-sm ml-auto">
|
<div className="flex items-center gap-4 text-sm ml-auto">
|
||||||
{!allNoData && (
|
{!allNoData && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const barColorClass: Record<string, string> = {
|
|||||||
good: "bg-green-500",
|
good: "bg-green-500",
|
||||||
degraded: "bg-yellow-500",
|
degraded: "bg-yellow-500",
|
||||||
bad: "bg-red-500",
|
bad: "bg-red-500",
|
||||||
no_data: "bg-zinc-700"
|
no_data: "bg-neutral-200 dark:bg-neutral-700"
|
||||||
};
|
};
|
||||||
|
|
||||||
type UptimeMiniBarProps = {
|
type UptimeMiniBarProps = {
|
||||||
@@ -61,7 +61,11 @@ export default function UptimeMiniBar({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const hcQuery = useQuery({
|
const hcQuery = useQuery({
|
||||||
...orgQueries.healthCheckStatusHistory({ orgId: orgId ?? "", healthCheckId: healthCheckId ?? 0, days }),
|
...orgQueries.healthCheckStatusHistory({
|
||||||
|
orgId: orgId ?? "",
|
||||||
|
healthCheckId: healthCheckId ?? 0,
|
||||||
|
days
|
||||||
|
}),
|
||||||
enabled: healthCheckId != null && siteId == null && resourceId == null,
|
enabled: healthCheckId != null && siteId == null && resourceId == null,
|
||||||
meta: { api },
|
meta: { api },
|
||||||
staleTime: 5 * 60 * 1000
|
staleTime: 5 * 60 * 1000
|
||||||
@@ -75,22 +79,36 @@ export default function UptimeMiniBar({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { data, isLoading } =
|
const { data, isLoading } =
|
||||||
siteId != null ? siteQuery :
|
siteId != null
|
||||||
resourceId != null ? resourceQuery :
|
? siteQuery
|
||||||
hcQuery;
|
: resourceId != null
|
||||||
|
? resourceQuery
|
||||||
|
: hcQuery;
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<div className="flex gap-px h-5 w-24">
|
<div
|
||||||
|
className="flex gap-px h-5"
|
||||||
|
style={{ width: `${days * 5}px` }}
|
||||||
|
>
|
||||||
{Array.from({ length: days }).map((_, i) => (
|
{Array.from({ length: days }).map((_, i) => (
|
||||||
<div
|
<div
|
||||||
key={i}
|
key={i}
|
||||||
className="flex-1 rounded-[2px] bg-zinc-800 animate-pulse"
|
className={cn(
|
||||||
|
"flex-1 rounded-[2px] animate-pulse",
|
||||||
|
barColorClass.no_data
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<span className="text-xs text-muted-foreground w-12">—</span>
|
<span
|
||||||
|
className="inline-flex min-w-[7ch] items-center justify-end text-xs text-muted-foreground whitespace-nowrap"
|
||||||
|
aria-busy="true"
|
||||||
|
aria-label="Loading uptime"
|
||||||
|
>
|
||||||
|
<span className="h-4 w-[5.5ch] max-w-full rounded bg-muted animate-pulse" />
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -101,10 +119,7 @@ export default function UptimeMiniBar({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<div
|
<div className="flex gap-px h-5" style={{ width: `${days * 5}px` }}>
|
||||||
className="flex gap-px h-5"
|
|
||||||
style={{ width: `${days * 5}px` }}
|
|
||||||
>
|
|
||||||
{data.days.map((day, i) => (
|
{data.days.map((day, i) => (
|
||||||
<Tooltip key={i}>
|
<Tooltip key={i}>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
|
|||||||
Reference in New Issue
Block a user