Skip to content

NVR with realtime local object detection for IP cameras

Merge remote-tracking branch 'origin/master' into dev

Blake Blacksheara8b7e5dd24de
diff --cc web/src/views/settings/NotificationsSettingsView.tsx
index 3b2c89f059,7381c20dc7..37e555dfa6
--- a/web/src/views/settings/NotificationsSettingsView.tsx
+++ b/web/src/views/settings/NotificationsSettingsView.tsx
@@@ -45,7 -46,8 +45,9 @@@ import { Alert, AlertDescription, Alert
import { Trans, useTranslation } from "react-i18next";
import { useDateLocale } from "@/hooks/use-date-locale";
import { useDocDomain } from "@/hooks/use-doc-domain";
+import { CameraNameLabel } from "@/components/camera/CameraNameLabel";
+ import { useIsAdmin } from "@/hooks/use-is-admin";
+ import { cn } from "@/lib/utils";
const NOTIFICATION_SERVICE_WORKER = "notifications-worker.js";
@@@ -403,132 -413,135 +413,136 @@@ export default function NotificationVie
</div>
</div>
- <Form {...form}>
- <form
- onSubmit={form.handleSubmit(onSubmit)}
- className="mt-2 space-y-6"
- >
- <FormField
- control={form.control}
- name="email"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("notification.email.title")}</FormLabel>
- <FormControl>
- <Input
- className="text-md w-full border border-input bg-background p-2 hover:bg-accent hover:text-accent-foreground dark:[color-scheme:dark] md:w-72"
- placeholder={t("notification.email.placeholder")}
- {...field}
- />
- </FormControl>
- <FormDescription>
- {t("notification.email.desc")}
- </FormDescription>
- <FormMessage />
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="cameras"
- render={({ field }) => (
- <FormItem>
- {allCameras && allCameras?.length > 0 ? (
- <>
- <div className="mb-2">
- <FormLabel className="flex flex-row items-center text-base">
- {t("notification.cameras.title")}
- </FormLabel>
- </div>
- <div className="max-w-md space-y-2 rounded-lg bg-secondary p-4">
- <FormField
- control={form.control}
- name="allEnabled"
- render={({ field }) => (
+ {isAdmin && (
+ <Form {...form}>
+ <form
+ onSubmit={form.handleSubmit(onSubmit)}
+ className="mt-2 space-y-6"
+ >
+ <FormField
+ control={form.control}
+ name="email"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>{t("notification.email.title")}</FormLabel>
+ <FormControl>
+ <Input
+ className="text-md w-full border border-input bg-background p-2 hover:bg-accent hover:text-accent-foreground dark:[color-scheme:dark] md:w-72"
+ placeholder={t("notification.email.placeholder")}
+ {...field}
+ />
+ </FormControl>
+ <FormDescription>
+ {t("notification.email.desc")}
+ </FormDescription>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+
+ <FormField
+ control={form.control}
+ name="cameras"
+ render={({ field }) => (
+ <FormItem>
+ {allCameras && allCameras?.length > 0 ? (
+ <>
+ <div className="mb-2">
+ <FormLabel className="flex flex-row items-center text-base">
+ {t("notification.cameras.title")}
+ </FormLabel>
+ </div>
+ <div className="max-w-md space-y-2 rounded-lg bg-secondary p-4">
+ <FormField
+ control={form.control}
+ name="allEnabled"
+ render={({ field }) => (
+ <FilterSwitch
+ label={t("cameras.all.title", {
+ ns: "components/filter",
+ })}
+ isChecked={field.value}
+ onCheckedChange={(checked) => {
+ setChangedValue(true);
+ if (checked) {
+ form.setValue("cameras", []);
+ }
+ field.onChange(checked);
+ }}
+ />
+ )}
+ />
+ {allCameras?.map((camera) => (
<FilterSwitch
- label={t("cameras.all.title", {
- ns: "components/filter",
- })}
- isChecked={field.value}
+ key={camera.name}
- label={camera.name.replaceAll("_", " ")}
++ label={camera.name}
++ isCameraName={true}
+ isChecked={field.value?.includes(
+ camera.name,
+ )}
onCheckedChange={(checked) => {
setChangedValue(true);
+ let newCameras;
if (checked) {
- form.setValue("cameras", []);
+ newCameras = [
+ ...field.value,
+ camera.name,
+ ];
+ } else {
+ newCameras = field.value?.filter(
+ (value) => value !== camera.name,
+ );
}
- field.onChange(checked);
+ field.onChange(newCameras);
+ form.setValue("allEnabled", false);
}}
/>
- )}
- />
- {allCameras?.map((camera) => (
- <FilterSwitch
- key={camera.name}
- label={camera.name}
- isCameraName={true}
- isChecked={field.value?.includes(camera.name)}
- onCheckedChange={(checked) => {
- setChangedValue(true);
- let newCameras;
- if (checked) {
- newCameras = [
- ...field.value,
- camera.name,
- ];
- } else {
- newCameras = field.value?.filter(
- (value) => value !== camera.name,
- );
- }
- field.onChange(newCameras);
- form.setValue("allEnabled", false);
- }}
- />
- ))}
+ ))}
+ </div>
+ </>
+ ) : (
+ <div className="font-normal text-destructive">
+ {t("notification.cameras.noCameras")}
</div>
- </>
- ) : (
- <div className="font-normal text-destructive">
- {t("notification.cameras.noCameras")}
- </div>
- )}
+ )}
- <FormMessage />
- <FormDescription>
- {t("notification.cameras.desc")}
- </FormDescription>
- </FormItem>
- )}
- />
-
- <div className="flex w-full flex-row items-center gap-2 pt-2 md:w-[50%]">
- <Button
- className="flex flex-1"
- aria-label={t("button.cancel", { ns: "common" })}
- onClick={onCancel}
- type="button"
- >
- {t("button.cancel", { ns: "common" })}
- </Button>
- <Button
- variant="select"
- disabled={isLoading}
- className="flex flex-1"
- aria-label={t("button.save", { ns: "common" })}
- type="submit"
- >
- {isLoading ? (
- <div className="flex flex-row items-center gap-2">
- <ActivityIndicator />
- <span>{t("button.saving", { ns: "common" })}</span>
- </div>
- ) : (
- t("button.save", { ns: "common" })
+ <FormMessage />
+ <FormDescription>
+ {t("notification.cameras.desc")}
+ </FormDescription>
+ </FormItem>
)}
- </Button>
- </div>
- </form>
- </Form>
+ />
+
+ <div className="flex w-full flex-row items-center gap-2 pt-2 md:w-[50%]">
+ <Button
+ className="flex flex-1"
+ aria-label={t("button.cancel", { ns: "common" })}
+ onClick={onCancel}
+ type="button"
+ >
+ {t("button.cancel", { ns: "common" })}
+ </Button>
+ <Button
+ variant="select"
+ disabled={isLoading}
+ className="flex flex-1"
+ aria-label={t("button.save", { ns: "common" })}
+ type="submit"
+ >
+ {isLoading ? (
+ <div className="flex flex-row items-center gap-2">
+ <ActivityIndicator />
+ <span>{t("button.saving", { ns: "common" })}</span>
+ </div>
+ ) : (
+ t("button.save", { ns: "common" })
+ )}
+ </Button>
+ </div>
+ </form>
+ </Form>
+ )}
</div>
<div className="col-span-1">