mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-17 21:59:52 +00:00
Add the status to the resources and ajust location
This commit is contained in:
@@ -62,6 +62,7 @@ import { GetResourceResponse } from "@server/routers/resource/getResource";
|
||||
import type { ResourceContextType } from "@app/contexts/resourceContext";
|
||||
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
||||
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||
import UptimeBar from "@app/components/UptimeBar";
|
||||
|
||||
type MaintenanceSectionFormProps = {
|
||||
resource: GetResourceResponse;
|
||||
@@ -578,6 +579,19 @@ export default function GeneralForm() {
|
||||
return (
|
||||
<>
|
||||
<SettingsContainer>
|
||||
<SettingsSection>
|
||||
<SettingsSectionHeader>
|
||||
<SettingsSectionTitle>Uptime</SettingsSectionTitle>
|
||||
<SettingsSectionDescription>
|
||||
Site availability over the last 90 days.
|
||||
</SettingsSectionDescription>
|
||||
</SettingsSectionHeader>
|
||||
<SettingsSectionBody>
|
||||
{resource?.resourceId && (
|
||||
<UptimeBar resourceId={resource.resourceId} days={90} />
|
||||
)}
|
||||
</SettingsSectionBody>
|
||||
</SettingsSection>
|
||||
<SettingsSection>
|
||||
<SettingsSectionHeader>
|
||||
<SettingsSectionTitle>
|
||||
|
||||
@@ -113,6 +113,19 @@ export default function GeneralPage() {
|
||||
|
||||
return (
|
||||
<SettingsContainer>
|
||||
<SettingsSection>
|
||||
<SettingsSectionHeader>
|
||||
<SettingsSectionTitle>Uptime</SettingsSectionTitle>
|
||||
<SettingsSectionDescription>
|
||||
Site availability over the last 90 days.
|
||||
</SettingsSectionDescription>
|
||||
</SettingsSectionHeader>
|
||||
<SettingsSectionBody>
|
||||
{site?.siteId && (
|
||||
<UptimeBar siteId={site.siteId} days={90} />
|
||||
)}
|
||||
</SettingsSectionBody>
|
||||
</SettingsSection>
|
||||
<SettingsSection>
|
||||
<SettingsSectionHeader>
|
||||
<SettingsSectionTitle>
|
||||
@@ -225,19 +238,6 @@ export default function GeneralPage() {
|
||||
</Button>
|
||||
</SettingsSectionFooter>
|
||||
</SettingsSection>
|
||||
<SettingsSection>
|
||||
<SettingsSectionHeader>
|
||||
<SettingsSectionTitle>Uptime</SettingsSectionTitle>
|
||||
<SettingsSectionDescription>
|
||||
Site availability over the last 90 days.
|
||||
</SettingsSectionDescription>
|
||||
</SettingsSectionHeader>
|
||||
<SettingsSectionBody>
|
||||
{site?.siteId && (
|
||||
<UptimeBar siteId={site.siteId} days={90} />
|
||||
)}
|
||||
</SettingsSectionBody>
|
||||
</SettingsSection>
|
||||
</SettingsContainer>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -516,7 +516,7 @@ export default function ProxyResourcesTable({
|
||||
},
|
||||
{
|
||||
id: "statusHistory",
|
||||
friendlyName: t("statusHistory"),
|
||||
friendlyName: t("uptime30d"),
|
||||
header: () => <span className="p-3">{t("statusHistory")}</span>,
|
||||
cell: ({ row }) => {
|
||||
const resourceRow = row.original;
|
||||
|
||||
@@ -47,6 +47,7 @@ const barColorClass: Record<string, string> = {
|
||||
type UptimeBarProps = {
|
||||
orgId?: string;
|
||||
siteId?: number;
|
||||
resourceId?: number;
|
||||
healthCheckId?: number;
|
||||
days?: number;
|
||||
title?: string;
|
||||
@@ -56,6 +57,7 @@ type UptimeBarProps = {
|
||||
export default function UptimeBar({
|
||||
orgId,
|
||||
siteId,
|
||||
resourceId,
|
||||
healthCheckId,
|
||||
days = 90,
|
||||
title,
|
||||
@@ -71,11 +73,20 @@ export default function UptimeBar({
|
||||
|
||||
const hcQuery = useQuery({
|
||||
...orgQueries.healthCheckStatusHistory({ orgId: orgId ?? "", healthCheckId: healthCheckId ?? 0, days }),
|
||||
enabled: healthCheckId != null && siteId == null,
|
||||
enabled: healthCheckId != null && siteId == null && resourceId == null,
|
||||
meta: { api }
|
||||
});
|
||||
|
||||
const { data, isLoading } = siteId != null ? siteQuery : hcQuery;
|
||||
const resourceQuery = useQuery({
|
||||
...orgQueries.resourceStatusHistory({ resourceId, days }),
|
||||
enabled: resourceId != null && siteId == null && healthCheckId == null,
|
||||
meta: { api }
|
||||
});
|
||||
|
||||
const { data, isLoading } =
|
||||
siteId != null ? siteQuery :
|
||||
resourceId != null ? resourceQuery :
|
||||
hcQuery;
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
|
||||
@@ -323,6 +323,23 @@ export const orgQueries = {
|
||||
}
|
||||
}),
|
||||
|
||||
resourceStatusHistory: ({
|
||||
resourceId,
|
||||
days = 90
|
||||
}: {
|
||||
resourceId?: number;
|
||||
days?: number;
|
||||
}) =>
|
||||
queryOptions({
|
||||
queryKey: ["RESOURCE_STATUS_HISTORY", resourceId, days] as const,
|
||||
queryFn: async ({ signal, meta }) => {
|
||||
const res = await meta!.api.get<
|
||||
AxiosResponse<StatusHistoryResponse>
|
||||
>(`/resource/${resourceId}/status-history?days=${days}`, { signal });
|
||||
return res.data.data;
|
||||
}
|
||||
}),
|
||||
|
||||
healthCheckStatusHistory: ({
|
||||
orgId,
|
||||
healthCheckId,
|
||||
|
||||
Reference in New Issue
Block a user