mirror of
https://github.com/XFox111/bonch-calendar.git
synced 2026-06-30 10:52:41 +03:00
feat!: native AOT for api app #26
This commit is contained in:
@@ -25,7 +25,7 @@ async function fetchApi<T>(path: string, defaultValue: T, alwaysReturnResponse:
|
||||
if (!res.ok && !alwaysReturnResponse)
|
||||
return defaultValue;
|
||||
|
||||
return await res.json()
|
||||
return await res.json();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -40,21 +40,20 @@ export type StatsResponse =
|
||||
|
||||
export type HealthResponse =
|
||||
{
|
||||
status: ServiceStatus;
|
||||
status: HealthStatus;
|
||||
totalDuration: string;
|
||||
entries: {
|
||||
["timetable_website"]: TimetableHealth;
|
||||
["timetable_website"]: TimetableHealthResponseEntry;
|
||||
};
|
||||
};
|
||||
|
||||
export type ServiceStatus = "Healthy" | "Unhealthy" | "Degraded";
|
||||
export type HealthStatus = "healthy" | "unhealthy" | "degraded";
|
||||
|
||||
export type TimetableHealth =
|
||||
export type TimetableHealthResponseEntry =
|
||||
{
|
||||
status: HealthStatus;
|
||||
description?: string;
|
||||
duration: string;
|
||||
status: "Healthy" | "Unhealthy",
|
||||
tags: unknown[],
|
||||
data:
|
||||
{
|
||||
"/faculties"?: false,
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { type TimetableHealth, fetchFaculties, fetchGroups } from "./api";
|
||||
import { type TimetableHealthResponseEntry, fetchFaculties, fetchGroups } from "./api";
|
||||
import strings from "./strings";
|
||||
|
||||
export async function tryFormatNamesForReport(report?: TimetableHealth): Promise<TimetableHealth | undefined>
|
||||
export async function tryFormatNamesForReport(report?: TimetableHealthResponseEntry): Promise<TimetableHealthResponseEntry | undefined>
|
||||
{
|
||||
if (report === undefined)
|
||||
return report;
|
||||
|
||||
if (report.status === "Healthy")
|
||||
if (report.status === "healthy")
|
||||
return report;
|
||||
|
||||
const isGroupsDown: boolean = report.data["/groups"] !== undefined;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Button, Dialog, DialogBody, DialogContent, DialogSurface, DialogTitle, DialogTrigger, Divider, Subtitle2 } from "@fluentui/react-components";
|
||||
import { ArrowTrendingLinesFilled, CheckmarkCircleFilled, Dismiss24Regular, WarningFilled } from "@fluentui/react-icons";
|
||||
import { use, useMemo, type ReactElement } from "react";
|
||||
import { fetchHealth, fetchStats, type StatsResponse, type TimetableHealth } from "../utils/api";
|
||||
import { fetchHealth, fetchStats, type StatsResponse, type TimetableHealthResponseEntry } from "../utils/api";
|
||||
import strings from "../utils/strings";
|
||||
import { tryFormatNamesForReport } from "../utils/tryFormatNamesForReport";
|
||||
import { useStyles } from "./StatsView.styles";
|
||||
@@ -13,7 +13,7 @@ export default function StatsView(): ReactElement
|
||||
{
|
||||
const cls = useStyles();
|
||||
|
||||
const health: TimetableHealth | undefined = use(healthPromise);
|
||||
const health: TimetableHealthResponseEntry | undefined = use(healthPromise);
|
||||
const stats: StatsResponse = use(statsPromise);
|
||||
|
||||
const issueCounter: number = useMemo(() =>
|
||||
@@ -49,7 +49,7 @@ export default function StatsView(): ReactElement
|
||||
}
|
||||
<Dialog>
|
||||
<DialogTrigger>
|
||||
{ health?.status === "Healthy" ?
|
||||
{ health?.status === "healthy" ?
|
||||
<Button icon={ <CheckmarkCircleFilled className={ cls.statusIconHealthy } /> } appearance="subtle">
|
||||
{ strings.status_ok }
|
||||
</Button>
|
||||
@@ -76,7 +76,7 @@ export default function StatsView(): ReactElement
|
||||
{ strings.report_title }
|
||||
</DialogTitle>
|
||||
<DialogContent className={ cls.reportContent }>
|
||||
{ health?.status === "Healthy" ?
|
||||
{ health?.status === "healthy" ?
|
||||
<div className={ cls.reportSubtitle }>
|
||||
<CheckmarkCircleFilled className={ cls.statusIconHealthy } fontSize={ 24 } />
|
||||
<Subtitle2>{ strings.report_subtitle_ok }</Subtitle2>
|
||||
@@ -89,7 +89,7 @@ export default function StatsView(): ReactElement
|
||||
</Subtitle2>
|
||||
</div>
|
||||
}
|
||||
{ health?.status !== "Healthy" &&
|
||||
{ health?.status !== "healthy" &&
|
||||
<ul>
|
||||
{ health === undefined &&
|
||||
<li>{ strings.report_issue_backend }</li>
|
||||
|
||||
Reference in New Issue
Block a user