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

Migrate Consultation Camera Feed to use newer camera feed components #7654

Merged
merged 23 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
13f5f76
Migrate consultation feed to use newer camera feed components
rithviknishad Apr 18, 2024
03b4673
remove console logs
rithviknishad Apr 18, 2024
2e5b196
adds plausible tracking
rithviknishad Apr 18, 2024
ab47c1c
remove unused code
rithviknishad Apr 18, 2024
a9c924b
Revert "remove unused code"
rithviknishad Apr 18, 2024
d3af2ec
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad Apr 18, 2024
2ebc89a
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad Apr 22, 2024
7d8bb6a
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad Apr 24, 2024
07235c0
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad Apr 25, 2024
0d9ff72
fix responsiveness and full screen issues
rithviknishad Apr 25, 2024
c6fa212
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
nihal467 Apr 29, 2024
bf09845
Adds support for updating presets in consultation camera feed
rithviknishad Apr 30, 2024
e718b46
disable update preset if camera not moved
rithviknishad Apr 30, 2024
05869a0
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad May 7, 2024
ac1d00b
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad May 17, 2024
a6ff6da
fix loading state issue
rithviknishad May 17, 2024
7682993
revert unintended changes
rithviknishad May 17, 2024
75fc5b0
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
nihal467 May 21, 2024
8e8a357
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad May 22, 2024
69436e0
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad May 22, 2024
f61661f
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad May 22, 2024
c164ab7
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad May 22, 2024
b3ecfa4
fix responsiveness of tooltip
rithviknishad May 22, 2024
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
1 change: 0 additions & 1 deletion src/Common/hooks/useMSEplayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ export const useMSEMediaPlayer = ({
const ws = wsRef.current;
ws.binaryType = "arraybuffer";
ws.onopen = function (_event) {
console.log("Connected to ws");
onSuccess && onSuccess(undefined);
};
ws.onmessage = function (event) {
Expand Down
37 changes: 15 additions & 22 deletions src/Components/CameraFeed/AssetBedSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,28 @@
import { Fragment } from "react";
import useSlug from "../../Common/hooks/useSlug";
import routes from "../../Redux/api";
import useQuery from "../../Utils/request/useQuery";
import { AssetBedModel, AssetData } from "../Assets/AssetTypes";
import { BedModel } from "../Facility/models";
import { AssetBedModel } from "../Assets/AssetTypes";
import { Listbox, Transition } from "@headlessui/react";
import CareIcon from "../../CAREUI/icons/CareIcon";

interface Props {
asset?: AssetData;
bed?: BedModel;
options: AssetBedModel[];
value?: AssetBedModel;
label?: (value: AssetBedModel) => string;
onChange?: (value: AssetBedModel) => void;
}

export default function AssetBedSelect(props: Props) {
const facility = useSlug("facility");
const selected = props.value;

const { data, loading } = useQuery(routes.listAssetBeds, {
query: {
limit: 100,
facility,
asset: props.asset?.id,
bed: props.bed?.id,
},
});
const options = props.options.filter(({ meta }) => meta.type !== "boundary");

const selected = props.value;
const label = props.label ?? defaultLabel;

return (
<Listbox value={selected} onChange={props.onChange} disabled={loading}>
<div className="relative">
<Listbox value={selected} onChange={props.onChange}>
<div className="relative flex-1">
<Listbox.Button className="relative w-full cursor-default pr-6 text-right text-xs text-zinc-400 focus:outline-none disabled:cursor-not-allowed disabled:bg-transparent disabled:text-zinc-700 sm:text-sm">
<span className="block truncate">
{selected?.bed_object.name ?? "No Preset"}
{selected ? label(selected) : "No Preset"}
</span>
<span className="pointer-events-none absolute inset-y-0 right-0 mt-1 flex items-center">
<CareIcon icon="l-angle-down" className="text-lg text-zinc-500" />
Expand All @@ -46,7 +35,7 @@ export default function AssetBedSelect(props: Props) {
leaveTo="opacity-0"
>
<Listbox.Options className="absolute z-20 mt-1 max-h-48 w-full overflow-auto rounded-b-lg bg-zinc-900/75 py-1 text-base shadow-lg ring-1 ring-white/5 backdrop-blur-sm focus:outline-none sm:text-sm md:max-h-60">
{data?.results.map((obj) => (
{options?.map((obj) => (
<Listbox.Option
key={obj.id}
className={({ active }) =>
Expand All @@ -63,7 +52,7 @@ export default function AssetBedSelect(props: Props) {
selected ? "font-bold text-white" : "font-normal"
}`}
>
{obj.bed_object.name}: {obj.meta.preset_name}
{label(obj)}
</span>
</>
)}
Expand All @@ -75,3 +64,7 @@ export default function AssetBedSelect(props: Props) {
</Listbox>
);
}

const defaultLabel = ({ bed_object, meta }: AssetBedModel) => {
return `${bed_object.name}: ${meta.preset_name}`;
};
6 changes: 4 additions & 2 deletions src/Components/CameraFeed/CameraFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface Props {
// Controls
constrolsDisabled?: boolean;
shortcutsDisabled?: boolean;
onMove?: () => void;
}

export default function CameraFeed(props: Props) {
Expand Down Expand Up @@ -76,7 +77,7 @@ export default function CameraFeed(props: Props) {
},
onError: props.onStreamError,
});
}, [player.initializeStream, props.onStreamSuccess, props.onStreamError]);
}, [player.initializeStream]);

// Start stream on mount
useEffect(() => initializeStream(), [initializeStream]);
Expand All @@ -90,7 +91,7 @@ export default function CameraFeed(props: Props) {
<Fullscreen fullscreen={isFullscreen} onExit={() => setFullscreen(false)}>
<div
className={classNames(
"flex flex-col overflow-clip rounded-xl bg-black",
"flex max-h-screen flex-col overflow-clip rounded-xl bg-black",
props.className,
)}
>
Expand Down Expand Up @@ -180,6 +181,7 @@ export default function CameraFeed(props: Props) {
setFullscreen={setFullscreen}
onReset={resetStream}
onMove={async (data) => {
props.onMove?.();
setState("moving");
const { res } = await operate({ type: "relative_move", data });
setTimeout(() => {
Expand Down
22 changes: 17 additions & 5 deletions src/Components/CameraFeed/CameraFeedWithBedPresets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ import { useState } from "react";
import { AssetBedModel, AssetData } from "../Assets/AssetTypes";
import CameraFeed from "./CameraFeed";
import AssetBedSelect from "./AssetBedSelect";
import useQuery from "../../Utils/request/useQuery";
import routes from "../../Redux/api";
import useSlug from "../../Common/hooks/useSlug";

interface Props {
asset: AssetData;
}

export default function LocationFeedTile(props: Props) {
const facility = useSlug("facility");
const [preset, setPreset] = useState<AssetBedModel>();

const { data, loading } = useQuery(routes.listAssetBeds, {
query: { limit: 100, facility, asset: props.asset?.id },
});

return (
<CameraFeed
asset={props.asset}
Expand All @@ -18,11 +26,15 @@ export default function LocationFeedTile(props: Props) {
shortcutsDisabled
>
<div className="w-64">
<AssetBedSelect
asset={props.asset}
value={preset}
onChange={setPreset}
/>
{loading ? (
<span>loading presets...</span>
) : (
<AssetBedSelect
options={data?.results ?? []}
value={preset}
onChange={setPreset}
/>
)}
</div>
</CameraFeed>
);
Expand Down
16 changes: 5 additions & 11 deletions src/Components/CameraFeed/FeedControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default function FeedControls({ shortcutsDisabled, ...props }: Props) {
helpText="Up"
shortcut={Shortcuts.MoveUp}
shortcutsDisabled={shortcutsDisabled}
tooltipClassName="-translate-y-20 md:translate-y-0"
>
<CareIcon icon="l-triangle" className="rotate-0" />
</FeedButton>
Expand All @@ -102,6 +103,7 @@ export default function FeedControls({ shortcutsDisabled, ...props }: Props) {
helpText="Left"
shortcut={Shortcuts.MoveLeft}
shortcutsDisabled={shortcutsDisabled}
tooltipClassName="-translate-y-20 -translate-x-1 md:translate-x-0 md:translate-y-0"
>
<CareIcon icon="l-triangle" className="-rotate-90" />
</FeedButton>
Expand All @@ -114,6 +116,7 @@ export default function FeedControls({ shortcutsDisabled, ...props }: Props) {
shortcut={Shortcuts.TogglePrecision}
className="font-bold"
shortcutsDisabled={shortcutsDisabled}
tooltipClassName="-translate-y-20 -translate-x-20 md:translate-x-0 md:translate-y-0"
>
{precision}x
</FeedButton>
Expand All @@ -125,6 +128,7 @@ export default function FeedControls({ shortcutsDisabled, ...props }: Props) {
helpText="Right"
shortcut={Shortcuts.MoveRight}
shortcutsDisabled={shortcutsDisabled}
tooltipClassName="-translate-y-20 -translate-x-2 md:translate-x-0 md:translate-y-0"
>
<CareIcon icon="l-triangle" className="rotate-90" />
</FeedButton>
Expand All @@ -142,7 +146,7 @@ export default function FeedControls({ shortcutsDisabled, ...props }: Props) {
helpText="Down"
shortcut={Shortcuts.MoveDown}
shortcutsDisabled={shortcutsDisabled}
tooltipClassName="tooltip-top"
tooltipClassName="-translate-y-20 -translate-x-2 md:-translate-x-14"
>
<CareIcon icon="l-triangle" className="rotate-180" />
</FeedButton>
Expand Down Expand Up @@ -185,16 +189,6 @@ export default function FeedControls({ shortcutsDisabled, ...props }: Props) {
>
<CareIcon icon="l-redo" />
</FeedButton>
{/* TODO: implement this when this is used in where presets can be saved. */}
{/* <FeedButton
shortcut={Shortcuts.SavePreset}
tooltipClassName="tooltip-left translate-y-2 translate-x-1"
helpText="Save current view to preset"
onTrigger={() => console.error("Not implemented")}
shortcutsDisabled={shortcutsDisabled}
>
<CareIcon icon="l-save" />
</FeedButton> */}
<FeedButton
shortcut={Shortcuts.Fullscreen}
tooltipClassName="tooltip-left translate-y-2 translate-x-1"
Expand Down
2 changes: 1 addition & 1 deletion src/Components/CameraFeed/FeedNetworkSignal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function FeedNetworkSignal(props: Props) {
if (-5 > delay || delay > 5) {
props.onReset();
}
}, 500);
}, 1000);

return () => {
clearInterval(interval);
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Common/PageTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function PageTitle({

useEffect(() => {
if (divRef.current && focusOnLoad) {
divRef.current.scrollIntoView();
divRef.current.scrollIntoView({ behavior: "smooth" });
}
}, [divRef, focusOnLoad]);

Expand Down
Loading
Loading