Skip to content

Commit

Permalink
get initial lock status and add notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranshu1902 committed Nov 24, 2023
1 parent 8f86f98 commit 8abb23e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/Components/Assets/configure/CameraConfigure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ export default function CameraConfigure(props: CameraConfigureProps) {
</Card>
<Card className="mt-4">
<LiveFeed
asset={asset}
middlewareHostname={facilityMiddlewareHostname}
asset={getCameraConfig(asset)}
cameraAsset={getCameraConfig(asset)}
showRefreshButton={true}
refreshPresetsHash={refreshPresetsHash}
/>
Expand Down
19 changes: 12 additions & 7 deletions src/Components/Facility/Consultations/LiveFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const LiveFeed = (props: any) => {
const middlewareHostname =
props.middlewareHostname || "dev_middleware.coronasafe.live";
const [presetsPage, setPresetsPage] = useState(0);
const cameraAsset = props.asset;
const cameraAsset = props.cameraAsset;
const [presets, setPresets] = useState<any>([]);
const [bedPresets, setBedPresets] = useState<any>([]);
const [showDefaultPresets, setShowDefaultPresets] = useState<boolean>(false);
Expand All @@ -52,7 +52,9 @@ const LiveFeed = (props: any) => {
const [toDelete, setToDelete] = useState<any>(null);
const [toUpdate, setToUpdate] = useState<any>(null);
const [_isFullscreen, setFullscreen] = useFullscreen();
const [lockStatus, setLockStatus] = useState(false);

// inital lock asset status
const [lockStatus, setLockStatus] = useState(props.asset.is_locked);

const { width } = useWindowDimensions();
const extremeSmallScreenBreakpoint = 320;
Expand Down Expand Up @@ -296,25 +298,27 @@ const LiveFeed = (props: any) => {

// lock and unlock asset methods
const lockAsset = async () => {
const { data } = await request(routes.lockAsset, {
const { data }: any = await request(routes.lockAsset, {
pathParams: {
asset_external_id: props.asset?.id ?? "",
},
});
console.log(data);

Notification.Success({ msg: data?.message });

// useQuery(routes.lockAsset, {
// pathParams: { asset_external_id: "assetId" },
// });
};

const unlockAsset = async () => {
const { data } = await request(routes.unlockAsset, {
const { data }: any = await request(routes.unlockAsset, {
pathParams: {
asset_external_id: props.asset?.id ?? "",
},
});
console.log(data);

Notification.Success({ msg: data?.message });

// useQuery(routes.unlockAsset, {
// pathParams: { asset_external_id: "assetId" },
Expand Down Expand Up @@ -503,8 +507,9 @@ const LiveFeed = (props: any) => {
setLockStatus(!lockStatus);
}}
>
: Lock Status: <b>{lockStatus ? "Locked" : "Unlocked"}</b>
Lock Status: <b>{lockStatus ? "Locked" : "Unlocked"}</b>
</button>
<button>Refresh</button>
</div>
<nav className="flex flex-wrap">
<button
Expand Down

0 comments on commit 8abb23e

Please sign in to comment.