@7365admin1/layer-common 4.97.1-staging.637 → 4.97.1-staging.639
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/CctvEngine/Alerts.vue +1 -1
- package/components/CctvEngine/Events.vue +2 -2
- package/components/CctvEngine/Start.vue +2 -2
- package/components/Input/DatePicker.vue +5 -1
- package/components/VisitorManagement.vue +57 -7
- package/package.json +1 -1
- package/utils/cctv-engine.ts +12 -9
- package/utils/visitor-date-default.ts +46 -0
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
id="alerts"
|
|
10
10
|
:steps="[
|
|
11
11
|
'Turn on Send phone notifications. Leave the roles empty to tell everyone who can see CCTV events at this site, or choose roles to tell only them.',
|
|
12
|
-
'
|
|
12
|
+
'Type the objects that matter (e.g. person, car). Only these are saved in Events and raise alerts. Empty means every object.',
|
|
13
13
|
'Optional: limit to zones or cameras, and set quiet hours. Then press Save alert settings.',
|
|
14
14
|
]"
|
|
15
15
|
results="Alerts appear in Events marked Alert. With Send phone notifications on, people also get a notification with the picture."
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
<template>
|
|
3
3
|
<div>
|
|
4
4
|
<p class="hero-muted mt-0 mb-2">
|
|
5
|
-
|
|
6
|
-
and the time. Use the boxes to narrow the list, then press Search. Click a row to see the photo and details.
|
|
5
|
+
What you set up to be saved, newest first: matching people and vehicles (see Alerts), watch-list plates, known faces and
|
|
6
|
+
smart detection results, each with a photo and the time. Use the boxes to narrow the list, then press Search. Click a row to see the photo and details.
|
|
7
7
|
</p>
|
|
8
8
|
<v-row dense>
|
|
9
9
|
<v-col cols="6" sm="4" md="3"><v-text-field v-model="f.camera" label="Camera" density="comfortable" hide-details clearable /></v-col>
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<template>
|
|
8
8
|
<div>
|
|
9
9
|
<p class="hero-muted mt-0">
|
|
10
|
-
Set up the steps below once.
|
|
11
|
-
|
|
10
|
+
Set up the steps below once. Only what you set up is saved: it appears in <strong>Events</strong> with a photo, and the
|
|
11
|
+
people you choose get a phone notification. Nothing set up = nothing saved.
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
14
|
<v-progress-linear v-if="loading" indeterminate class="mb-3" />
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
</template>
|
|
8
8
|
</v-text-field>
|
|
9
9
|
<div class="w-100 d-flex align-end ga-3 hidden-input">
|
|
10
|
-
<input ref="dateInput" type="date" v-model="date" :min="min" />
|
|
10
|
+
<input ref="dateInput" type="date" v-model="date" :min="min" :max="max" />
|
|
11
11
|
</div>
|
|
12
12
|
</div>
|
|
13
13
|
</template>
|
|
@@ -26,6 +26,10 @@ const prop = defineProps({
|
|
|
26
26
|
min: {
|
|
27
27
|
type: String,
|
|
28
28
|
default: undefined
|
|
29
|
+
},
|
|
30
|
+
max: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: undefined
|
|
29
33
|
}
|
|
30
34
|
})
|
|
31
35
|
|
|
@@ -127,8 +127,14 @@
|
|
|
127
127
|
v-model="dateFrom"
|
|
128
128
|
density="compact"
|
|
129
129
|
hide-details
|
|
130
|
+
:max="todayOnly ? sgToday : undefined"
|
|
131
|
+
/>
|
|
132
|
+
<InputDatePicker
|
|
133
|
+
v-model="dateTo"
|
|
134
|
+
density="compact"
|
|
135
|
+
hide-details
|
|
136
|
+
:max="todayOnly ? sgToday : undefined"
|
|
130
137
|
/>
|
|
131
|
-
<InputDatePicker v-model="dateTo" density="compact" hide-details />
|
|
132
138
|
<!-- iSecure: every tab but Unregistered; the Guests tab offers
|
|
133
139
|
Guest / Contractor, the Visitors tab the eight types. -->
|
|
134
140
|
<AppSelect
|
|
@@ -1882,6 +1888,7 @@ import { isVisitorPassSmsOn } from "../composables/useVisitor";
|
|
|
1882
1888
|
import { barrierCameraOf, barrierMessage, barrierOf, VISITOR_ACTION_SUCCESS } from "../utils/visitor-barrier";
|
|
1883
1889
|
import useVisitorCameraChoices from "../composables/useVisitorCameraChoices";
|
|
1884
1890
|
import { VISITOR_CAMERA_LABEL } from "../utils/visitor-camera";
|
|
1891
|
+
import { notAfterToday, sgDateOf, type VisitorDateDefault } from "../utils/visitor-date-default";
|
|
1885
1892
|
import usePassKey from "../composables/usePassKey";
|
|
1886
1893
|
import {
|
|
1887
1894
|
VISITOR_SEARCH_DEBOUNCE_MS,
|
|
@@ -1893,6 +1900,11 @@ import {
|
|
|
1893
1900
|
const { downloadPDF } = usePDFDownload();
|
|
1894
1901
|
|
|
1895
1902
|
const props = defineProps({
|
|
1903
|
+
// The date filter's opening range: "last30" (iSecure) or "today" (Property).
|
|
1904
|
+
defaultDateRange: {
|
|
1905
|
+
type: String as PropType<VisitorDateDefault>,
|
|
1906
|
+
default: "last30",
|
|
1907
|
+
},
|
|
1896
1908
|
canAddVisitor: {
|
|
1897
1909
|
type: Boolean,
|
|
1898
1910
|
default: false,
|
|
@@ -2246,8 +2258,15 @@ function daysAgo(days: number) {
|
|
|
2246
2258
|
date.setDate(date.getDate() - days);
|
|
2247
2259
|
return date;
|
|
2248
2260
|
}
|
|
2249
|
-
|
|
2250
|
-
|
|
2261
|
+
// defaultDateRange "today" (Property, DV-0886): both dates are today in
|
|
2262
|
+
// Singapore, nothing after today can be picked, and a fresh open ignores dates
|
|
2263
|
+
// left in the URL. "last30" keeps the lines below exactly as they were.
|
|
2264
|
+
const todayOnly = computed(() => props.defaultDateRange === "today");
|
|
2265
|
+
const sgToday = ref(sgDateOf());
|
|
2266
|
+
const defaultDateTo = () =>
|
|
2267
|
+
todayOnly.value ? sgToday.value : normalizeDateOnly(new Date().toISOString());
|
|
2268
|
+
const defaultDateFrom = () =>
|
|
2269
|
+
todayOnly.value ? sgToday.value : normalizeDateOnly(daysAgo(30).toISOString());
|
|
2251
2270
|
|
|
2252
2271
|
const dateTo = ref(defaultDateTo());
|
|
2253
2272
|
const dateFrom = ref(defaultDateFrom());
|
|
@@ -4224,11 +4243,37 @@ watch(
|
|
|
4224
4243
|
// iSecure: the dates cannot be cleared - a cleared one goes back to its default.
|
|
4225
4244
|
watch(dateFrom, (value) => {
|
|
4226
4245
|
if (!value) dateFrom.value = defaultDateFrom();
|
|
4246
|
+
else if (todayOnly.value && value > sgToday.value) dateFrom.value = sgToday.value;
|
|
4227
4247
|
});
|
|
4228
4248
|
watch(dateTo, (value) => {
|
|
4229
4249
|
if (!value) dateTo.value = defaultDateTo();
|
|
4250
|
+
else if (todayOnly.value && value > sgToday.value) dateTo.value = sgToday.value;
|
|
4230
4251
|
});
|
|
4231
4252
|
|
|
4253
|
+
// "today" only: a page left open past midnight moves an untouched today to
|
|
4254
|
+
// the new day. A range the user picked is left alone.
|
|
4255
|
+
let sgDayTimer: ReturnType<typeof setInterval> | null = null;
|
|
4256
|
+
onMounted(() => {
|
|
4257
|
+
if (!todayOnly.value) return;
|
|
4258
|
+
sgDayTimer = setInterval(() => {
|
|
4259
|
+
const next = sgDateOf();
|
|
4260
|
+
if (next === sgToday.value) return;
|
|
4261
|
+
const previous = sgToday.value;
|
|
4262
|
+
sgToday.value = next;
|
|
4263
|
+
if (dateFrom.value === previous && dateTo.value === previous) {
|
|
4264
|
+
dateFrom.value = next;
|
|
4265
|
+
dateTo.value = next;
|
|
4266
|
+
}
|
|
4267
|
+
}, 60_000);
|
|
4268
|
+
});
|
|
4269
|
+
onBeforeUnmount(() => {
|
|
4270
|
+
if (sgDayTimer) clearInterval(sgDayTimer);
|
|
4271
|
+
});
|
|
4272
|
+
|
|
4273
|
+
// "today" only: the first read of the route is a fresh open, so dates left in
|
|
4274
|
+
// the URL (bookmark, back navigation, yesterday's tab) do not replace today.
|
|
4275
|
+
let routeDatesSeen = false;
|
|
4276
|
+
|
|
4232
4277
|
const syncVisitorFiltersFromRoute = () => {
|
|
4233
4278
|
const requestedTab = (route.query.tab as string) || "registered";
|
|
4234
4279
|
const nextTab =
|
|
@@ -4254,15 +4299,20 @@ const syncVisitorFiltersFromRoute = () => {
|
|
|
4254
4299
|
searchQuery.value = nextSearch;
|
|
4255
4300
|
}
|
|
4256
4301
|
|
|
4257
|
-
|
|
4258
|
-
|
|
4302
|
+
const skipRouteDates = todayOnly.value && !routeDatesSeen;
|
|
4303
|
+
routeDatesSeen = true;
|
|
4304
|
+
const fromRoute = (value: string) =>
|
|
4305
|
+
todayOnly.value ? notAfterToday(value, sgToday.value) : value;
|
|
4306
|
+
|
|
4307
|
+
if (route.query.dateFrom && !skipRouteDates) {
|
|
4308
|
+
const nextDateFrom = fromRoute(normalizeDateOnly(route.query.dateFrom as string));
|
|
4259
4309
|
if (dateFrom.value !== nextDateFrom) {
|
|
4260
4310
|
dateFrom.value = nextDateFrom;
|
|
4261
4311
|
}
|
|
4262
4312
|
}
|
|
4263
4313
|
|
|
4264
|
-
if (route.query.dateTo) {
|
|
4265
|
-
const nextDateTo = normalizeDateOnly(route.query.dateTo as string);
|
|
4314
|
+
if (route.query.dateTo && !skipRouteDates) {
|
|
4315
|
+
const nextDateTo = fromRoute(normalizeDateOnly(route.query.dateTo as string));
|
|
4266
4316
|
if (dateTo.value !== nextDateTo) {
|
|
4267
4317
|
dateTo.value = nextDateTo;
|
|
4268
4318
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.639",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
|
package/utils/cctv-engine.ts
CHANGED
|
@@ -493,7 +493,7 @@ export function setupSteps(input: {
|
|
|
493
493
|
can: (perm: TCctvPermission) => boolean;
|
|
494
494
|
faceEnabled: boolean;
|
|
495
495
|
engines: { status?: string; name?: string }[] | null;
|
|
496
|
-
alertSettings: { notifyRoles?: string[]; notifyGuards?: boolean; labels?: string[] } | null;
|
|
496
|
+
alertSettings: { notifyRoles?: string[]; notifyGuards?: boolean; labels?: string[]; zones?: string[]; cameras?: string[]; createIncident?: boolean } | null;
|
|
497
497
|
classifiers: TClassifier[] | null;
|
|
498
498
|
plates: number | null;
|
|
499
499
|
faces: number | null;
|
|
@@ -525,19 +525,22 @@ export function setupSteps(input: {
|
|
|
525
525
|
const a = input.alertSettings;
|
|
526
526
|
// Server rule (core onAlert / NotificationService.cctvAlert): the `notifyGuards` switch turns phone notifications on;
|
|
527
527
|
// they go to everyone at the site holding cctv-engine:view-events, or only to `notifyRoles` when some are chosen.
|
|
528
|
+
// Server rules (core keepEvent / onAlert): only objects matching what is set up here are saved; `notifyGuards`
|
|
529
|
+
// turns phone notifications on, for everyone with cctv-engine:view-events or only `notifyRoles` when chosen.
|
|
528
530
|
const roles = a?.notifyRoles?.length ?? 0;
|
|
529
531
|
const told = a?.notifyGuards === true;
|
|
530
|
-
const
|
|
531
|
-
const
|
|
532
|
+
const setUp = !!(a && (a.labels?.length || a.zones?.length || a.cameras?.length || told || a.createIncident));
|
|
533
|
+
const what = a?.labels?.length ? a.labels.join(", ") : "every object";
|
|
534
|
+
const who = roles ? `people in ${plural(roles, "role", "roles")}` : "everyone who can see CCTV events";
|
|
532
535
|
steps.push({
|
|
533
536
|
key: "alerts",
|
|
534
|
-
title: "
|
|
535
|
-
what: "Choose who gets a phone notification with the picture
|
|
536
|
-
state: a === null || !
|
|
537
|
+
title: "What to save and who to tell",
|
|
538
|
+
what: "Choose which objects (e.g. person, car) are saved in Events, and who gets a phone notification with the picture.",
|
|
539
|
+
state: a === null || !setUp ? "attention" : told ? "done" : "attention",
|
|
537
540
|
now:
|
|
538
541
|
a === null ? unread
|
|
539
|
-
: !
|
|
540
|
-
:
|
|
542
|
+
: !setUp ? "Nothing set up yet, so no people or vehicles are being saved."
|
|
543
|
+
: `Saving: ${what}. ${told ? `Phone notification to ${who}.` : "Phone notifications are off."}`,
|
|
541
544
|
section: "alerts",
|
|
542
545
|
action: "Set up alerts",
|
|
543
546
|
});
|
|
@@ -601,7 +604,7 @@ export function setupSteps(input: {
|
|
|
601
604
|
|
|
602
605
|
/** Where each kind of result appears. `query` pre-fills the Events filters. */
|
|
603
606
|
export const RESULT_PLACES: { title: string; body: string; section: TCctvSection; query?: Record<string, string>; needs: TCctvPermission }[] = [
|
|
604
|
-
{ title: "Everything
|
|
607
|
+
{ title: "Everything saved", body: "What you set up: matching people and vehicles, watch-list plates, known faces and smart detection results, newest first, each with a photo.", section: "events", needs: CCTV_PERMISSIONS.viewEvents },
|
|
605
608
|
{ title: "Alerts only", body: "The events that raised an alert. With phone notifications on, people were also told on their phones.", section: "events", query: { severity: "alert" }, needs: CCTV_PERMISSIONS.viewEvents },
|
|
606
609
|
{ title: "Smart detection results", body: "What your smart detections saw (e.g. rubbish), with the photo and time.", section: "events", query: { kind: "classification" }, needs: CCTV_PERMISSIONS.viewEvents },
|
|
607
610
|
{ title: "Find a past moment", body: "Describe it in words, e.g. person in orange shirt, and pick the dates.", section: "search", needs: CCTV_PERMISSIONS.viewEvents },
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Visitor Mgmt date filter's default range.
|
|
3
|
+
*
|
|
4
|
+
* - "last30" (the default): the last 30 days through today. iSecure (Security
|
|
5
|
+
* web) keeps this; it is the behaviour before DV-0886.
|
|
6
|
+
* - "today": From and To are both today. The Property app asks for this.
|
|
7
|
+
*
|
|
8
|
+
* "Today" is the Singapore date, not the browser's: a browser in another time
|
|
9
|
+
* zone, or with a wrong clock, would otherwise show yesterday or tomorrow.
|
|
10
|
+
* Dates are YYYY-MM-DD strings, so they compare correctly as text.
|
|
11
|
+
*/
|
|
12
|
+
export type VisitorDateDefault = "last30" | "today";
|
|
13
|
+
|
|
14
|
+
export const VISITOR_DATE_TIME_ZONE = "Asia/Singapore";
|
|
15
|
+
|
|
16
|
+
/** The Singapore date of `now`, as YYYY-MM-DD. */
|
|
17
|
+
export function sgDateOf(now: Date = new Date()): string {
|
|
18
|
+
return new Intl.DateTimeFormat("en-CA", {
|
|
19
|
+
timeZone: VISITOR_DATE_TIME_ZONE,
|
|
20
|
+
year: "numeric",
|
|
21
|
+
month: "2-digit",
|
|
22
|
+
day: "2-digit",
|
|
23
|
+
}).format(now);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** YYYY-MM-DD `days` before `day`. */
|
|
27
|
+
export function daysBefore(day: string, days: number): string {
|
|
28
|
+
const date = new Date(`${day}T00:00:00Z`);
|
|
29
|
+
date.setUTCDate(date.getUTCDate() - days);
|
|
30
|
+
return date.toISOString().slice(0, 10);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The [from, to] a fresh page opens with. */
|
|
34
|
+
export function visitorDefaultRange(
|
|
35
|
+
mode: VisitorDateDefault,
|
|
36
|
+
today: string,
|
|
37
|
+
): { from: string; to: string } {
|
|
38
|
+
return mode === "today"
|
|
39
|
+
? { from: today, to: today }
|
|
40
|
+
: { from: daysBefore(today, 30), to: today };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** A date after today becomes today; anything else is kept. */
|
|
44
|
+
export function notAfterToday(day: string, today: string): string {
|
|
45
|
+
return day && day > today ? today : day;
|
|
46
|
+
}
|