Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Uptime tracking to Location Management #7230

Merged
merged 8 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Components/Assets/AssetManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ const AssetManage = (props: AssetManageProps) => {
<Uptime
route={routes.listAssetAvailability}
params={{ external_id: asset.id }}
header={
<div className="text-xl font-semibold">Availability History</div>
}
parentClassNames="mt-8 flex w-full flex-col bg-white p-4 shadow-sm sm:rounded-lg"
/>
)}
<div className="mb-4 mt-8 text-xl font-semibold">Service History</div>
Expand Down
8 changes: 5 additions & 3 deletions src/Components/Common/Uptime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ export default function Uptime(
props: Readonly<{
route: QueryRoute<PaginatedResponse<AvailabilityRecord>>;
params?: Record<string, string | number>;
header?: React.ReactNode;
parentClassNames?: string;
}>
) {
const [summary, setSummary] = useState<{
Expand Down Expand Up @@ -361,10 +363,10 @@ export default function Uptime(
);
} else if (summary) {
return (
<div className="mt-8 flex w-full flex-col bg-white p-4 shadow-sm sm:rounded-lg">
<div className="mx-2 w-full">
<div className={props.parentClassNames}>
<div className="w-full">
<div className="grid grid-cols-1">
<div className="text-xl font-semibold">Availability History</div>
{props.header}
<div>
<div className="mt-2 overflow-x-clip px-5">
<div className="mb-1 mt-2 flex justify-center text-xs text-gray-700 opacity-70">
Expand Down
15 changes: 13 additions & 2 deletions src/Components/Facility/LocationManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import routes from "../../Redux/api";
import PaginatedList from "../../CAREUI/misc/PaginatedList";
import { LocationModel } from "./models";
import RecordMeta from "../../CAREUI/display/RecordMeta";
import Uptime from "../Common/Uptime";

const Loading = lazy(() => import("../Common/Loading"));

Expand Down Expand Up @@ -55,7 +56,7 @@ export default function LocationManagement({ facilityId }: Props) {
<Loading />
</PaginatedList.WhenLoading>
<PaginatedList.Items<LocationModel> className="my-8 grid gap-3 @4xl:grid-cols-2 @6xl:grid-cols-3 @[100rem]:grid-cols-4 lg:mx-8">
{(item) => <Location {...item} />}
{(item) => <Location {...item} facilityId={facilityId} />}
</PaginatedList.Items>
</div>

Expand All @@ -76,7 +77,8 @@ const Location = ({
created_date,
modified_date,
id,
}: LocationModel) => (
facilityId,
}: LocationModel & { facilityId: string }) => (
<div className="flex h-full w-full flex-col rounded border border-gray-300 bg-white p-6 shadow-sm transition-all duration-200 ease-in-out hover:border-primary-400">
<div className="flex-1">
<div className="flex w-full items-center justify-between gap-2">
Expand Down Expand Up @@ -122,6 +124,15 @@ const Location = ({
>
{middleware_address || "-"}
</p>
<Uptime
route={routes.listFacilityAssetLocationAvailability}
params={{ external_id: id, facility_external_id: facilityId }}
header={
<p className="mt-3 text-sm font-semibold text-gray-700">
Middleware Uptime
</p>
}
/>
</div>

<ButtonV2
Expand Down
2 changes: 1 addition & 1 deletion src/Redux/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ const routes = {
path: "/api/v1/facility/{facility_external_id}/asset_location/{external_id}/",
method: "PATCH",
},
getFacilityAssetLocationAvailability: {
listFacilityAssetLocationAvailability: {
path: "/api/v1/facility/{facility_external_id}/asset_location/{external_id}/availability/",
method: "GET",
TRes: Type<PaginatedResponse<AvailabilityRecord>>(),
Expand Down
Loading