Skip to content

Commit

Permalink
requested changes
Browse files Browse the repository at this point in the history
Signed-off-by: JahnabDutta <[email protected]>
  • Loading branch information
JahnabDutta committed Sep 6, 2023
1 parent 1968986 commit 3df9221
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 34 deletions.
13 changes: 7 additions & 6 deletions src/Components/Assets/AssetType/ONVIFCamera.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ const ONVIFCamera = (props: ONVIFCameraProps) => {
const [toUpdateBoundary, setToUpdateBoundary] = useState<boolean>(false);
const [loadingAddBoundaryPreset, setLoadingAddBoundaryPreset] =
useState<boolean>(false);
const [updateBoundaryError, setUpdateBoundaryError] =
useState<boolean>(false);
const [updateBoundaryNotif, setUpdateBoundaryNotif] =
useState<string>("notUpdated");
const [presets, setPresets] = useState<any[]>([]);
const dispatch = useDispatch<any>();

Expand All @@ -75,7 +75,7 @@ const ONVIFCamera = (props: ONVIFCameraProps) => {
};

const calcBoundary = (presets: any[]): BoundaryRange => {
const INT_MAX = 3;
const INT_MAX = 0.9;
const boundary: BoundaryRange = {
max_x: -INT_MAX,
min_x: INT_MAX,
Expand Down Expand Up @@ -287,9 +287,9 @@ const ONVIFCamera = (props: ONVIFCameraProps) => {
dispatch(partialUpdateAssetBed(data, boundaryPreset.id as string))
);
if (res?.status === 200) {
setUpdateBoundaryError(false);
setUpdateBoundaryNotif("updated");
} else {
setUpdateBoundaryError(true);
setUpdateBoundaryNotif("error");
Notification.Error({
msg: "Failed to modify Boundary Preset",
});
Expand Down Expand Up @@ -442,7 +442,8 @@ const ONVIFCamera = (props: ONVIFCameraProps) => {
toUpdateBoundary={toUpdateBoundary}
setToUpdateBoundary={setToUpdateBoundary}
loadingAddBoundaryPreset={loadingAddBoundaryPreset}
updateBoundaryError={updateBoundaryError}
updateBoundaryNotif={updateBoundaryNotif}
setUpdateBoundaryNotif={setUpdateBoundaryNotif}
/>
</Card>
</>
Expand Down
26 changes: 12 additions & 14 deletions src/Components/Assets/configure/CameraBoundaryConfigure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ interface UpdateCameraBoundaryConfigureProps {
setToUpdateBoundary: (toUpdate: boolean) => void;
updateBoundaryInfo: Record<string, boolean>;
setUpdateBoundaryInfo: (info: Record<string, boolean>) => void;
updateBoundaryError: boolean;
updateBoundaryNotif: string;
setUpdateBoundaryNotif: (notif: string) => void;
}
export default function CameraBoundaryConfigure(
props: CameraBoundaryConfigureProps
Expand Down Expand Up @@ -144,7 +145,8 @@ export function UpdateCameraBoundaryConfigure(
setToUpdateBoundary,
updateBoundaryInfo,
setUpdateBoundaryInfo,
updateBoundaryError,
updateBoundaryNotif,
setUpdateBoundaryNotif,
} = props;

const translation: Record<string, string> = {
Expand All @@ -155,6 +157,12 @@ export function UpdateCameraBoundaryConfigure(
};

const handlePrevButtonClick = () => {
if (updateBoundaryNotif === "updated") {
Notification.Success({
msg: `${translation[direction as string]} boundary updated`,
});
}
setUpdateBoundaryNotif("notUpdated");
switch (direction) {
case "left":
setToUpdateBoundary(false);
Expand Down Expand Up @@ -207,22 +215,12 @@ export function UpdateCameraBoundaryConfigure(
};

const handleNextButtonClick = () => {
const prevDir: any = {
left: null,
right: "left",
up: "right",
down: "up",
};

if (
!updateBoundaryError &&
prevDir[direction as string] &&
updateBoundaryInfo[prevDir[direction as string]]
) {
if (updateBoundaryNotif === "updated") {
Notification.Success({
msg: `${translation[direction as string]} boundary updated`,
});
}
setUpdateBoundaryNotif("notUpdated");
switch (direction) {
case "left":
setDirection("right");
Expand Down
45 changes: 33 additions & 12 deletions src/Components/Facility/Consultations/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ export const Feed: React.FC<IFeedProps> = ({ consultationId, facilityId }) => {
// display subscription info
const subscriptionInfo = () => {
return (
<div className="relative mb-1 flex flex-col justify-end">
<div
className="relative mb-1 flex flex-col justify-end"
onMouseLeave={() => {
setShowSubscriptionInfo(false);
}}
>
{showSubscriptionInfo && (
<div
className="absolute z-10 flex -translate-x-16 translate-y-10 flex-col gap-2 rounded-md bg-white p-2 drop-shadow-md"
onMouseLeave={() => {
setShowSubscriptionInfo(false);
}}
>
<div className="absolute z-10 flex -translate-x-16 translate-y-32 flex-col gap-2 rounded-md bg-white p-2 drop-shadow-md">
<div className="text-xs">
{isSubscribed != "SubscribedOnThisDevice"
? "Subscribe to get real time information about camera access"
Expand Down Expand Up @@ -136,13 +136,13 @@ export const Feed: React.FC<IFeedProps> = ({ consultationId, facilityId }) => {
const currentCameraOccupierInfo = () => {
return (
<div
className="relative mb-1 flex flex-row-reverse"
className="relative flex flex-row-reverse"
onMouseLeave={() => {
setShowCameraOccupierInfo(false);
}}
>
{showCameraOccupierInfo && (
<div className="absolute z-10 flex w-48 -translate-x-12 flex-col gap-2 rounded-md bg-white p-2 drop-shadow-md">
<div className="absolute z-10 flex w-48 -translate-x-8 flex-col gap-2 rounded-md bg-white p-2 drop-shadow-md">
<div className="text-xs text-gray-600">
Camera is being used by...
</div>
Expand Down Expand Up @@ -179,12 +179,12 @@ export const Feed: React.FC<IFeedProps> = ({ consultationId, facilityId }) => {
</div>
)}
<div
className="h-12 w-12 flex-col items-center justify-center rounded-full border-2 border-green-500 bg-white text-center"
className="h-8 w-8 items-center rounded-full border-2 border-green-500 bg-white text-center"
onMouseEnter={() => {
setShowCameraOccupierInfo(true);
}}
>
<div className="text-4xl font-bold text-green-600">
<div className="mb-1 text-2xl font-bold text-green-600">
{cameraOccupier?.firstName?.[0] ? (
cameraOccupier?.firstName?.[0].toUpperCase()
) : (
Expand Down Expand Up @@ -375,6 +375,9 @@ export const Feed: React.FC<IFeedProps> = ({ consultationId, facilityId }) => {
onError: (resp) => {
if (resp.status === 409) {
setCameraOccupier(resp.data as cameraOccupier);
Notification.Error({
msg: `Camera is being used by ${cameraOccupier?.firstName} ${cameraOccupier?.lastName}`,
});
} else {
setCameraOccupier({});
}
Expand Down Expand Up @@ -528,12 +531,15 @@ export const Feed: React.FC<IFeedProps> = ({ consultationId, facilityId }) => {
onError: (err: Record<any, any>) => {
if (err.status === 409) {
setCameraOccupier(err.data as cameraOccupier);
Notification.Error({
msg: `Camera is being used by ${cameraOccupier?.firstName} ${cameraOccupier?.lastName}`,
});
} else {
setCameraOccupier({});
}
setLoading(CAMERA_STATES.IDLE);
const responseData = err.data.result;
if (responseData.status) {
if (responseData?.status) {
switch (responseData.status) {
case "error":
if (responseData.error.code === "EHOSTUNREACH") {
Expand Down Expand Up @@ -621,6 +627,9 @@ export const Feed: React.FC<IFeedProps> = ({ consultationId, facilityId }) => {
onError: (resp) => {
if (resp.status === 409) {
setCameraOccupier(resp.data as cameraOccupier);
Notification.Error({
msg: `Camera is being used by ${cameraOccupier?.firstName} ${cameraOccupier?.lastName}`,
});
} else {
setCameraOccupier({});
}
Expand All @@ -633,6 +642,9 @@ export const Feed: React.FC<IFeedProps> = ({ consultationId, facilityId }) => {
onError: (resp) => {
if (resp.status === 409) {
setCameraOccupier(resp.data as cameraOccupier);
Notification.Error({
msg: `Camera is being used by ${cameraOccupier?.firstName} ${cameraOccupier?.lastName}`,
});
} else {
setCameraOccupier({});
}
Expand Down Expand Up @@ -695,6 +707,9 @@ export const Feed: React.FC<IFeedProps> = ({ consultationId, facilityId }) => {
onError: async (resp) => {
if (resp.status === 409) {
setCameraOccupier(resp.data as cameraOccupier);
Notification.Error({
msg: `Camera is being used by ${cameraOccupier?.firstName} ${cameraOccupier?.lastName}`,
});
} else {
setCameraOccupier({});
}
Expand Down Expand Up @@ -800,6 +815,9 @@ export const Feed: React.FC<IFeedProps> = ({ consultationId, facilityId }) => {
onError: async (resp) => {
if (resp.status === 409) {
setCameraOccupier(resp.data as cameraOccupier);
Notification.Error({
msg: `Camera is being used by ${cameraOccupier?.firstName} ${cameraOccupier?.lastName}`,
});
} else {
setCameraOccupier({});
}
Expand All @@ -823,6 +841,9 @@ export const Feed: React.FC<IFeedProps> = ({ consultationId, facilityId }) => {
onError: (resp) => {
if (resp.status === 409) {
setCameraOccupier(resp.data as cameraOccupier);
Notification.Error({
msg: `Camera is being used by ${cameraOccupier?.firstName} ${cameraOccupier?.lastName}`,
});
} else {
setCameraOccupier({});
}
Expand Down
7 changes: 5 additions & 2 deletions src/Components/Facility/Consultations/LiveFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ const LiveFeed = (props: any) => {
const setBoundaryPreset: (preset: any) => void = props?.setBoundaryPreset;
const fetchBoundaryBedPreset: () => void = props?.fetchBoundaryBedPreset;
const updateBoundaryPreset: () => void = props?.updateBoundaryPreset;
const updateBoundaryError: boolean = props.updateBoundaryError;
const updateBoundaryNotif: string = props.updateBoundaryNotif;
const setUpdateBoundaryNotif: (notif: string) => void =
props.setUpdateBoundaryNotif;
const [updateBoundaryInfo, setUpdateBoundaryInfo] = useState<
Record<string, boolean>
>({
Expand Down Expand Up @@ -660,7 +662,8 @@ const LiveFeed = (props: any) => {
setToUpdateBoundary={setToUpdateBoundary}
updateBoundaryInfo={updateBoundaryInfo}
setUpdateBoundaryInfo={setUpdateBoundaryInfo}
updateBoundaryError={updateBoundaryError}
updateBoundaryNotif={updateBoundaryNotif}
setUpdateBoundaryNotif={setUpdateBoundaryNotif}
/>
) : (
<>
Expand Down

0 comments on commit 3df9221

Please sign in to comment.