mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-10 10:11:33 -06:00
only allow admins to save annotation offset
This commit is contained in:
parent
8d5349ca85
commit
9b85e66608
@ -10,6 +10,7 @@ import { Trans, useTranslation } from "react-i18next";
|
|||||||
import { LuInfo } from "react-icons/lu";
|
import { LuInfo } from "react-icons/lu";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { isMobile } from "react-device-detect";
|
import { isMobile } from "react-device-detect";
|
||||||
|
import { useIsAdmin } from "@/hooks/use-is-admin";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -17,6 +18,7 @@ type Props = {
|
|||||||
|
|
||||||
export default function AnnotationOffsetSlider({ className }: Props) {
|
export default function AnnotationOffsetSlider({ className }: Props) {
|
||||||
const { annotationOffset, setAnnotationOffset, camera } = useDetailStream();
|
const { annotationOffset, setAnnotationOffset, camera } = useDetailStream();
|
||||||
|
const isAdmin = useIsAdmin();
|
||||||
const { mutate } = useSWRConfig();
|
const { mutate } = useSWRConfig();
|
||||||
const { t } = useTranslation(["views/explore"]);
|
const { t } = useTranslation(["views/explore"]);
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
@ -101,11 +103,13 @@ export default function AnnotationOffsetSlider({ className }: Props) {
|
|||||||
<Button size="sm" variant="ghost" onClick={reset}>
|
<Button size="sm" variant="ghost" onClick={reset}>
|
||||||
{t("button.reset", { ns: "common" })}
|
{t("button.reset", { ns: "common" })}
|
||||||
</Button>
|
</Button>
|
||||||
<Button size="sm" onClick={save} disabled={isSaving}>
|
{isAdmin && (
|
||||||
{isSaving
|
<Button size="sm" onClick={save} disabled={isSaving}>
|
||||||
? t("button.saving", { ns: "common" })
|
{isSaving
|
||||||
: t("button.save", { ns: "common" })}
|
? t("button.saving", { ns: "common" })
|
||||||
</Button>
|
: t("button.save", { ns: "common" })}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import { Input } from "@/components/ui/input";
|
|||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import { Trans, useTranslation } from "react-i18next";
|
import { Trans, useTranslation } from "react-i18next";
|
||||||
import { useDocDomain } from "@/hooks/use-doc-domain";
|
import { useDocDomain } from "@/hooks/use-doc-domain";
|
||||||
|
import { useIsAdmin } from "@/hooks/use-is-admin";
|
||||||
|
|
||||||
type AnnotationSettingsPaneProps = {
|
type AnnotationSettingsPaneProps = {
|
||||||
event: Event;
|
event: Event;
|
||||||
@ -36,6 +37,7 @@ export function AnnotationSettingsPane({
|
|||||||
setAnnotationOffset,
|
setAnnotationOffset,
|
||||||
}: AnnotationSettingsPaneProps) {
|
}: AnnotationSettingsPaneProps) {
|
||||||
const { t } = useTranslation(["views/explore"]);
|
const { t } = useTranslation(["views/explore"]);
|
||||||
|
const isAdmin = useIsAdmin();
|
||||||
const { getLocaleDocUrl } = useDocDomain();
|
const { getLocaleDocUrl } = useDocDomain();
|
||||||
|
|
||||||
const { data: config, mutate: updateConfig } =
|
const { data: config, mutate: updateConfig } =
|
||||||
@ -201,22 +203,24 @@ export function AnnotationSettingsPane({
|
|||||||
>
|
>
|
||||||
{t("button.apply", { ns: "common" })}
|
{t("button.apply", { ns: "common" })}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
{isAdmin && (
|
||||||
variant="select"
|
<Button
|
||||||
aria-label={t("button.save", { ns: "common" })}
|
variant="select"
|
||||||
disabled={isLoading}
|
aria-label={t("button.save", { ns: "common" })}
|
||||||
className="flex flex-1"
|
disabled={isLoading}
|
||||||
type="submit"
|
className="flex flex-1"
|
||||||
>
|
type="submit"
|
||||||
{isLoading ? (
|
>
|
||||||
<div className="flex flex-row items-center gap-2">
|
{isLoading ? (
|
||||||
<ActivityIndicator />
|
<div className="flex flex-row items-center gap-2">
|
||||||
<span>{t("button.saving", { ns: "common" })}</span>
|
<ActivityIndicator />
|
||||||
</div>
|
<span>{t("button.saving", { ns: "common" })}</span>
|
||||||
) : (
|
</div>
|
||||||
t("button.save", { ns: "common" })
|
) : (
|
||||||
)}
|
t("button.save", { ns: "common" })
|
||||||
</Button>
|
)}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user