mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-13 06:35:24 +03:00
Use js
This commit is contained in:
parent
fa8a0cc5fc
commit
367555ba98
@ -90,7 +90,7 @@ class WebPushClient(Communicator): # type: ignore[misc]
|
|||||||
|
|
||||||
title = f"{', '.join(sorted_objects).replace('_', ' ').title()}{' was' if state == 'end' else ''} detected in {', '.join(payload['after']['data']['zones']).replace('_', ' ').title()}"
|
title = f"{', '.join(sorted_objects).replace('_', ' ').title()}{' was' if state == 'end' else ''} detected in {', '.join(payload['after']['data']['zones']).replace('_', ' ').title()}"
|
||||||
message = f"Detected on {payload['after']['camera'].replace('_', ' ').title()}"
|
message = f"Detected on {payload['after']['camera'].replace('_', ' ').title()}"
|
||||||
direct_url = f"/review?id={reviewId}"
|
link = f"/review?id={reviewId}"
|
||||||
image = f'{payload["after"]["thumb_path"].replace("/media/frigate", "")}'
|
image = f'{payload["after"]["thumb_path"].replace("/media/frigate", "")}'
|
||||||
|
|
||||||
for pusher in self.web_pushers:
|
for pusher in self.web_pushers:
|
||||||
@ -101,7 +101,7 @@ class WebPushClient(Communicator): # type: ignore[misc]
|
|||||||
{
|
{
|
||||||
"title": title,
|
"title": title,
|
||||||
"message": message,
|
"message": message,
|
||||||
"direct_url": direct_url,
|
"link": link,
|
||||||
"image": image,
|
"image": image,
|
||||||
"id": reviewId,
|
"id": reviewId,
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 4.8 KiB |
@ -28,10 +28,9 @@ self.addEventListener("notificationclick", (event) => {
|
|||||||
|
|
||||||
// @ts-expect-error we know this exists
|
// @ts-expect-error we know this exists
|
||||||
if (event.notification.data) {
|
if (event.notification.data) {
|
||||||
// @ts-expect-error we know this exists
|
|
||||||
const url = event.notification.data.link;
|
const url = event.notification.data.link;
|
||||||
|
|
||||||
// @ts-expect-error we know this exists
|
// eslint-disable-next-line no-undef
|
||||||
clients.matchAll({ type: "window" }).then((windowClients) => {
|
clients.matchAll({ type: "window" }).then((windowClients) => {
|
||||||
// Check if there is already a window/tab open with the target URL
|
// Check if there is already a window/tab open with the target URL
|
||||||
for (let i = 0; i < windowClients.length; i++) {
|
for (let i = 0; i < windowClients.length; i++) {
|
||||||
@ -42,9 +41,9 @@ self.addEventListener("notificationclick", (event) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If not, then open the target URL in a new window/tab.
|
// If not, then open the target URL in a new window/tab.
|
||||||
// @ts-expect-error we know this exists
|
// eslint-disable-next-line no-undef
|
||||||
if (clients.openWindow) {
|
if (clients.openWindow) {
|
||||||
// @ts-expect-error we know this exists
|
// eslint-disable-next-line no-undef
|
||||||
return clients.openWindow(url);
|
return clients.openWindow(url);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -25,7 +25,7 @@ import { toast } from "sonner";
|
|||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
const NOTIFICATION_SERVICE_WORKER = "notifications-worker.ts";
|
const NOTIFICATION_SERVICE_WORKER = "notifications-worker.js";
|
||||||
|
|
||||||
type NotificationSettingsValueType = {
|
type NotificationSettingsValueType = {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
@ -220,11 +220,11 @@ export default function NotificationView({
|
|||||||
name="email"
|
name="email"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Loitering Time</FormLabel>
|
<FormLabel>Email</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
className="w-full border border-input bg-background p-2 hover:bg-accent hover:text-accent-foreground dark:[color-scheme:dark]"
|
className="w-full border border-input bg-background p-2 hover:bg-accent hover:text-accent-foreground dark:[color-scheme:dark]"
|
||||||
placeholder="0"
|
placeholder="example@email.com"
|
||||||
{...field}
|
{...field}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user