Compare commits
4 Commits
enhancemen
...
enhancemen
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f9923167e | |||
| 018203b203 | |||
| 173b1d0e51 | |||
| 9b35deaf12 |
@@ -47,9 +47,9 @@ const DashboardGrid = () => {
|
|||||||
refetch={refetch}
|
refetch={refetch}
|
||||||
/>
|
/>
|
||||||
<div className="grid grid-cols-1 md:col-span-2 md:grid-cols-3">
|
<div className="grid grid-cols-1 md:col-span-2 md:grid-cols-3">
|
||||||
<CameraStatus title="Camera A" category={categoryA} />
|
<CameraStatus title="Camera A" category={categoryA} isError={isError} />
|
||||||
<CameraStatus title="Camera B" category={categoryB} />
|
<CameraStatus title="Camera B" category={categoryB} isError={isError} />
|
||||||
<CameraStatus title="Camera C" category={categoryC} />
|
<CameraStatus title="Camera C" category={categoryC} isError={isError} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ import CameraStatusGridItem from "./CameraStatusGridItem";
|
|||||||
type CameraStatusProps = {
|
type CameraStatusProps = {
|
||||||
title: string;
|
title: string;
|
||||||
category: SystemHealthStatus[];
|
category: SystemHealthStatus[];
|
||||||
|
isError?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const CameraStatus = ({ title, category }: CameraStatusProps) => {
|
const CameraStatus = ({ title, category, isError }: CameraStatusProps) => {
|
||||||
const isAllGood = category?.every((status) => status.tags.includes("RUNNING"));
|
const isAllGood = category && category.length > 0 && category.every((status) => status.tags.includes("RUNNING"));
|
||||||
// check if some are down
|
// check if some are down
|
||||||
// check if all are down
|
// check if all are down
|
||||||
//check if offline
|
//check if offline
|
||||||
@@ -18,10 +19,22 @@ const CameraStatus = ({ title, category }: CameraStatusProps) => {
|
|||||||
<Card className="p-4">
|
<Card className="p-4">
|
||||||
<div className="border-b border-gray-600">
|
<div className="border-b border-gray-600">
|
||||||
<h3 className="text-lg flex flex-row items-center">
|
<h3 className="text-lg flex flex-row items-center">
|
||||||
{isAllGood ? <StatusIndicators status={"bg-green-500"} /> : <StatusIndicators status={"bg-amber-500"} />}
|
{isError ? (
|
||||||
|
<StatusIndicators status={"bg-red-500"} />
|
||||||
|
) : isAllGood ? (
|
||||||
|
<StatusIndicators status={"bg-green-500"} />
|
||||||
|
) : (
|
||||||
|
<StatusIndicators status={"bg-amber-500"} />
|
||||||
|
)}
|
||||||
{capitalize(title)}
|
{capitalize(title)}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-sm text-slate-300">{isAllGood ? "All systems running" : "Some systems down"}</p>
|
{isError ? (
|
||||||
|
<p className="text-sm text-red-500">Error loading camera health.</p>
|
||||||
|
) : isAllGood ? (
|
||||||
|
<p className="text-sm text-green-500">All systems running</p>
|
||||||
|
) : (
|
||||||
|
<p className="text-sm text-amber-500">Some systems down</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{category && category?.length <= 0 ? (
|
{category && category?.length <= 0 ? (
|
||||||
<p className=" text-gray-500">Loading Camera health...</p>
|
<p className=" text-gray-500">Loading Camera health...</p>
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ type StatusGridItemProps = {
|
|||||||
|
|
||||||
const StatusGridItem = ({ title, statusCategory }: StatusGridItemProps) => {
|
const StatusGridItem = ({ title, statusCategory }: StatusGridItemProps) => {
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const isAllGood = statusCategory.every((status) => status.tags.includes("RUNNING"));
|
const isAllGood =
|
||||||
|
statusCategory && statusCategory.length > 0 && statusCategory.every((status) => status.tags.includes("RUNNING"));
|
||||||
|
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
|
|||||||
@@ -13,12 +13,21 @@ const SystemStatusCard = () => {
|
|||||||
const { storeQuery } = useGetStore();
|
const { storeQuery } = useGetStore();
|
||||||
|
|
||||||
const reads = storeQuery?.data;
|
const reads = storeQuery?.data;
|
||||||
const isReadsLoading = storeQuery.isFetching;
|
const isReadsLoading = storeQuery?.isFetching;
|
||||||
|
const isError = storeQuery?.isError || !storeQuery?.data;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
storeQuery.refetch();
|
storeQuery.refetch();
|
||||||
}, [reads]);
|
}, [reads]);
|
||||||
|
|
||||||
|
if (isError) {
|
||||||
|
return (
|
||||||
|
<Card className="p-4">
|
||||||
|
<CardHeader title="System Status" />
|
||||||
|
<span className="text-red-500">Error loading system status.</span>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<Card className="p-4">
|
<Card className="p-4">
|
||||||
<CardHeader title="System Status" />
|
<CardHeader title="System Status" />
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Field } from "formik";
|
import { Field, FieldArray } from "formik";
|
||||||
import type { FormTypes, InitialValuesFormErrors, OutputDataResponse } from "../../../types/types";
|
import type { FormTypes, InitialValuesFormErrors, OutputDataResponse } from "../../../types/types";
|
||||||
import { useEffect, useMemo } from "react";
|
import { useEffect, useMemo } from "react";
|
||||||
import { useOptionalConstants } from "../hooks/useOptionalConstants";
|
import { useOptionalConstants } from "../hooks/useOptionalConstants";
|
||||||
@@ -17,6 +17,7 @@ type ChannelFieldsProps = {
|
|||||||
const ChannelFields = ({ errors, touched, values, outputData, onSetFieldValue }: ChannelFieldsProps) => {
|
const ChannelFields = ({ errors, touched, values, outputData, onSetFieldValue }: ChannelFieldsProps) => {
|
||||||
const { optionalConstantsQuery } = useOptionalConstants(outputData?.id?.split("-")[1] || "");
|
const { optionalConstantsQuery } = useOptionalConstants(outputData?.id?.split("-")[1] || "");
|
||||||
const optionalConstants = optionalConstantsQuery?.data;
|
const optionalConstants = optionalConstantsQuery?.data;
|
||||||
|
|
||||||
const channelFieldsObject = useMemo(() => {
|
const channelFieldsObject = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
connectTimeoutSeconds: outputData?.propConnectTimeoutSeconds?.value || "5",
|
connectTimeoutSeconds: outputData?.propConnectTimeoutSeconds?.value || "5",
|
||||||
@@ -261,6 +262,47 @@ const ChannelFields = ({ errors, touched, values, outputData, onSetFieldValue }:
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
<div className="border-b border-gray-500 my-3">
|
||||||
|
<h2 className="font-bold">Custom Fields</h2>
|
||||||
|
</div>
|
||||||
|
<div className="items-center mb-4">
|
||||||
|
<FieldArray name="customFields">
|
||||||
|
{(arrayHelpers) => (
|
||||||
|
<>
|
||||||
|
{values?.customFields?.map((_, index) => (
|
||||||
|
<div key={index} className="flex flex-row justify-between items-center mb-4">
|
||||||
|
<label htmlFor={`customFields.${index}`} className="mr-2">
|
||||||
|
Custom Field {index + 1}
|
||||||
|
</label>
|
||||||
|
<Field
|
||||||
|
name={`customFields.${index}`}
|
||||||
|
key={index}
|
||||||
|
className="p-2 border border-gray-400 rounded-lg w-full max-w-xs"
|
||||||
|
placeholder={`Enter Custom Field ${index + 1}`}
|
||||||
|
autoComplete="off"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => arrayHelpers.push("")}
|
||||||
|
className="mr-2 border p-2 rounded-lg hover:bg-gray-700 hover:cursor-pointer"
|
||||||
|
>
|
||||||
|
Add Custom Field
|
||||||
|
</button>
|
||||||
|
{values?.customFields && values?.customFields?.length > 0 && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => arrayHelpers.pop()}
|
||||||
|
className="border p-2 rounded-lg hover:bg-gray-700 hover:cursor-pointer"
|
||||||
|
>
|
||||||
|
Remove Custom Field
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</FieldArray>
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ const OutputForms = () => {
|
|||||||
LID2: "",
|
LID2: "",
|
||||||
|
|
||||||
// ftp - fields
|
// ftp - fields
|
||||||
|
|
||||||
|
//custom fields
|
||||||
|
customFields: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async (values: FormTypes) => {
|
const handleSubmit = async (values: FormTypes) => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Formik, Form, Field } from "formik";
|
import { Formik, Form, Field, FieldArray } from "formik";
|
||||||
import { useSystemSettings } from "../hooks/useSystemSettings";
|
import { useSystemSettings } from "../hooks/useSystemSettings";
|
||||||
import type { SystemSettings } from "../../../types/types";
|
import type { SystemSettings } from "../../../types/types";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
@@ -28,18 +28,22 @@ const SystemConfig = () => {
|
|||||||
primaryServer: "",
|
primaryServer: "",
|
||||||
secondaryServer: "",
|
secondaryServer: "",
|
||||||
timeSource: timeSource ?? "",
|
timeSource: timeSource ?? "",
|
||||||
|
customFields: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async (values: SystemSettings) => {
|
const handleSubmit = async (values: SystemSettings) => {
|
||||||
const result = await systemSettingsMutation.mutateAsync(values);
|
const result = await systemSettingsMutation.mutateAsync(values);
|
||||||
console.log(result);
|
|
||||||
if (result.id) {
|
if (result.id) {
|
||||||
toast.success("System settings updated successfully");
|
toast.success("System settings updated successfully");
|
||||||
|
} else {
|
||||||
|
toast.error("Failed to update system settings");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Formik initialValues={initialValues} onSubmit={handleSubmit} enableReinitialize>
|
<Formik initialValues={initialValues} onSubmit={handleSubmit} enableReinitialize>
|
||||||
|
{({ values }) => (
|
||||||
<Form>
|
<Form>
|
||||||
<div className="flex flex-row justify-between items-center mb-4">
|
<div className="flex flex-row justify-between items-center mb-4">
|
||||||
<label htmlFor="deviceName">Device Name</label>
|
<label htmlFor="deviceName">Device Name</label>
|
||||||
@@ -122,10 +126,52 @@ const SystemConfig = () => {
|
|||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="border-b border-gray-500 my-3">
|
||||||
|
<h2 className="font-bold">Custom Fields</h2>
|
||||||
|
</div>
|
||||||
|
<div className="items-center mb-4">
|
||||||
|
<FieldArray name="customFields">
|
||||||
|
{(arrayHelpers) => (
|
||||||
|
<>
|
||||||
|
{values.customFields.map((field, index) => (
|
||||||
|
<div key={index} className="flex flex-row justify-between items-center mb-4">
|
||||||
|
<label htmlFor={`customFields.${index}`} className="mr-2">
|
||||||
|
Custom Field {index + 1}
|
||||||
|
</label>
|
||||||
|
<Field
|
||||||
|
name={`customFields.${index}`}
|
||||||
|
key={index}
|
||||||
|
className="p-2 border border-gray-400 rounded-lg w-full max-w-xs"
|
||||||
|
placeholder={`Enter Custom Field ${index + 1}`}
|
||||||
|
autoComplete="off"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => arrayHelpers.push("")}
|
||||||
|
className="mr-2 border p-2 rounded-lg hover:bg-gray-700 hover:cursor-pointer"
|
||||||
|
>
|
||||||
|
Add Custom Field
|
||||||
|
</button>
|
||||||
|
{values.customFields.length > 0 && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => arrayHelpers.pop()}
|
||||||
|
className="border p-2 rounded-lg hover:bg-gray-700 hover:cursor-pointer"
|
||||||
|
>
|
||||||
|
Remove Custom Field
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</FieldArray>
|
||||||
|
</div>
|
||||||
<button type="submit" className="px-4 py-2 bg-green-700 text-white rounded-lg">
|
<button type="submit" className="px-4 py-2 bg-green-700 text-white rounded-lg">
|
||||||
Save Settings
|
Save Settings
|
||||||
</button>
|
</button>
|
||||||
</Form>
|
</Form>
|
||||||
|
)}
|
||||||
</Formik>
|
</Formik>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ export type OptionalLaneIDs = {
|
|||||||
LID3?: string;
|
LID3?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type CustomFields = {
|
||||||
|
customFields?: string[];
|
||||||
|
};
|
||||||
|
|
||||||
export type InitialValuesFormErrors = {
|
export type InitialValuesFormErrors = {
|
||||||
backOfficeURL?: string;
|
backOfficeURL?: string;
|
||||||
username?: string;
|
username?: string;
|
||||||
@@ -64,7 +68,7 @@ export type InitialValuesFormErrors = {
|
|||||||
readTimeoutSeconds?: string;
|
readTimeoutSeconds?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FormTypes = BearerTypeFields & OptionalConstants & OptionalLaneIDs;
|
export type FormTypes = BearerTypeFields & OptionalConstants & OptionalLaneIDs & CustomFields;
|
||||||
type FieldProperty = {
|
type FieldProperty = {
|
||||||
datatype: string;
|
datatype: string;
|
||||||
value: string;
|
value: string;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const ModalComponent = ({ isModalOpen, children, close }: ModalComponentProps) =
|
|||||||
<Modal
|
<Modal
|
||||||
isOpen={isModalOpen}
|
isOpen={isModalOpen}
|
||||||
onRequestClose={close}
|
onRequestClose={close}
|
||||||
className="bg-[#1e2a38] p-6 rounded-lg shadow-lg w-[95%] mt-[2%] md:w-[40%] z-100 overflow-y-auto border border-gray-600"
|
className="bg-[#1e2a38] p-6 rounded-lg shadow-lg w-[95%] mt-[2%] md:w-[40%] z-100 overflow-y-auto border border-gray-600 max-h-[90%]"
|
||||||
overlayClassName="fixed inset-0 bg-[#1e2a38]/70 flex justify-center items-start z-100"
|
overlayClassName="fixed inset-0 bg-[#1e2a38]/70 flex justify-center items-start z-100"
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
Reference in New Issue
Block a user