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

Live Feed: Hide sorting filter #6577

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all 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
67 changes: 0 additions & 67 deletions src/Components/Facility/LiveFeedScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,55 +14,18 @@ import { AssetData } from "../Assets/AssetTypes";
import { Popover, Transition } from "@headlessui/react";
import { FieldLabel } from "../Form/FormFields/FormField";
import CheckBoxFormField from "../Form/FormFields/CheckBoxFormField";
import { useTranslation } from "react-i18next";
import { SortOption } from "../Common/SortDropdown";
import { SelectFormField } from "../Form/FormFields/SelectFormField";
import LiveFeedTile from "./LiveFeedTile";
import { getCameraConfig } from "../../Utils/transformUtils";
import { getPermittedFacility, listAssets } from "../../Redux/actions";
import { useDispatch } from "react-redux";

const PER_PAGE_LIMIT = 6;

const SORT_OPTIONS: SortOption[] = [
{ isAscending: true, value: "bed__name" },
{ isAscending: false, value: "-bed__name" },
{ isAscending: false, value: "-created_date" },
{ isAscending: true, value: "created_date" },
];

interface Props {
facilityId: string;
}

const getOrderingList = async (
facilityId: string,
setOrdering: (order: string) => void
) => {
const orderData = localStorage.getItem("live-feed-order");
if (orderData) {
const order = JSON.parse(orderData);
const orderValue = order.find((item: any) => item.facility === facilityId);
setOrdering(orderValue.order);
}
};

const setOrderingList = async (facilityId: string, order: string) => {
const orderData = localStorage.getItem("live-feed-order") || "[]";
const orderList = JSON.parse(orderData);
const index = orderList.findIndex(
(item: any) => item.facility === facilityId
);
if (index !== -1) {
orderList[index].order = order;
} else {
orderList.push({ facility: facilityId, order });
}
localStorage.setItem("live-feed-order", JSON.stringify(orderList));
};

export default function LiveFeedScreen({ facilityId }: Props) {
const { t } = useTranslation();
const dispatch = useDispatch<any>();
const [isFullscreen, setFullscreen] = useFullscreen();
const sidebar = useContext(SidebarShrinkContext);
Expand All @@ -73,7 +36,6 @@ export default function LiveFeedScreen({ facilityId }: Props) {
const { qParams, updateQuery, removeFilter, updatePage } = useFilters({
limit: PER_PAGE_LIMIT,
});
const [ordering, setOrdering] = useState<string>("bed__name");

const [refresh_presets_hash, setRefreshPresetsHash] = useState<number>(
Number(new Date())
Expand All @@ -88,10 +50,6 @@ export default function LiveFeedScreen({ facilityId }: Props) {
};
}, []);

useEffect(() => {
getOrderingList(facilityId, setOrdering);
}, [facilityId]);

useEffect(() => {
async function fetchFacilityOrObject() {
if (facility) return facility;
Expand All @@ -112,7 +70,6 @@ export default function LiveFeedScreen({ facilityId }: Props) {
asset_class: "ONVIF",
facility: facilityId || "",
location: qParams.location,
ordering: qParams.ordering || ordering,
bed_is_occupied: qParams.bed_is_occupied,
};

Expand Down Expand Up @@ -204,30 +161,6 @@ export default function LiveFeedScreen({ facilityId }: Props) {
)}
</div>
</div>
<SelectFormField
name="ordering"
label={t("sort_by")}
required
value={qParams.ordering || ordering}
onChange={({ value }) => {
updateQuery({ ordering: value });
setOrderingList(facilityId, value);
}}
options={SORT_OPTIONS}
optionLabel={({ value }) => t("SortOptions." + value)}
optionIcon={({ isAscending }) => (
<CareIcon
className={
isAscending
? "care-l-sort-amount-up"
: "care-l-sort-amount-down"
}
/>
)}
optionValue={({ value }) => value}
labelClassName="text-sm"
errorClassName="hidden"
/>
<CheckBoxFormField
name="bed_is_occupied"
label="Hide Cameras without Patient"
Expand Down
Loading