@7365admin1/layer-common 4.163.6 → 4.163.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 4.163.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 42c6eed: CCTV Engine: hide "Confidence" on smart detection results (the engine sends no score, so it always read 0%), and show a loading spinner instead of an empty picture while smart detection photos load (a broken-picture icon only when a photo really failed).
8
+ - 33f15ff: Visitor Mgmt: optional "today" default for the date filter
9
+
10
+ VisitorManagement takes a new `defaultDateRange` prop. "last30" (the default)
11
+ keeps iSecure's last 30 days through today, unchanged. "today" opens on today
12
+ to today in Singapore time, stops either picker going past today, ignores dates
13
+ left in the URL on a fresh open, and moves an untouched today to the new day
14
+ when the page is left open past midnight. InputDatePicker gains an optional
15
+ `max`.
16
+
3
17
  ## 4.163.6
4
18
 
5
19
  ### Patch Changes
@@ -3734,11 +3748,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
3734
3748
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
3735
3749
  own rule from two endpoints the console already calls, unprojected:
3736
3750
 
3737
- GET /api/members/user/:user/app/admin the Seven365 staff membership
3738
- GET /api/roles/id/:role that membership's role document
3751
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
3752
+ GET /api/roles/id/:role that membership's role document
3739
3753
 
3740
- owner = member.type === "admin" && role.type === "admin" && role.default === true
3741
- staff = member.type === "admin" && role.type === "admin"
3754
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
3755
+ staff = member.type === "admin" && role.type === "admin"
3742
3756
 
3743
3757
  `role.default` is the marker because it is the only property of a platform
3744
3758
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -57,7 +57,8 @@
57
57
  <v-card variant="outlined" :class="{ 'cctv-dd__picked': picked.has(p.file) }">
58
58
  <div class="cctv-dd__thumb" @click="togglePick(p.file)">
59
59
  <img v-if="thumbs[key(p.file)]" :src="thumbs[key(p.file)]" :alt="`Waiting photo from ${when(p.at)}`" />
60
- <v-icon v-else icon="mdi-image-outline" size="28" />
60
+ <v-icon v-else-if="thumbFailed.has(key(p.file))" icon="mdi-image-broken-variant" size="28" />
61
+ <v-progress-circular v-else indeterminate size="24" width="2" aria-label="Loading photo" />
61
62
  <v-checkbox-btn :model-value="picked.has(p.file)" class="cctv-dd__check" density="compact" aria-label="Select photo" @click.stop @update:model-value="togglePick(p.file)" />
62
63
  </div>
63
64
  <div class="pa-2">
@@ -84,7 +85,8 @@
84
85
  <v-col v-for="f in data.sorted[s]" :key="f" cols="4" sm="3" md="2">
85
86
  <div class="cctv-dd__thumb cctv-dd__thumb--sm">
86
87
  <img v-if="thumbs[key(f, s)]" :src="thumbs[key(f, s)]" :alt="`Photo sorted as ${s}`" />
87
- <v-icon v-else icon="mdi-image-outline" size="24" />
88
+ <v-icon v-else-if="thumbFailed.has(key(f, s))" icon="mdi-image-broken-variant" size="24" />
89
+ <v-progress-circular v-else indeterminate size="20" width="2" aria-label="Loading photo" />
88
90
  <v-btn icon="mdi-close" size="x-small" variant="flat" class="cctv-dd__remove" :disabled="busy" :aria-label="`Remove this photo from ${s}`" @click="discard([f], s)" />
89
91
  </div>
90
92
  </v-col>
@@ -122,6 +124,8 @@ const loading = ref(false);
122
124
  const error = ref<unknown>(null);
123
125
  const busy = ref(false);
124
126
  const thumbs = ref<Record<string, string>>({});
127
+ // Photos that could not be fetched (shown as a broken picture instead of a spinner).
128
+ const thumbFailed = ref<Set<string>>(new Set());
125
129
  const picked = ref<Set<string>>(new Set());
126
130
  const alerts = ref<string[]>([]);
127
131
  const confirmDiscard = ref(false);
@@ -158,7 +162,7 @@ async function loadThumbs() {
158
162
  const url = await classifierPhoto(props.engine, props.name, t.file, t.state);
159
163
  thumbs.value = { ...thumbs.value, [t.k]: url };
160
164
  } catch {
161
- /* placeholder stays */
165
+ thumbFailed.value = new Set(thumbFailed.value).add(t.k);
162
166
  }
163
167
  }
164
168
  };
@@ -33,7 +33,8 @@
33
33
  <tr v-if="event.faceName"><th>Face</th><td>{{ event.faceName }}</td></tr>
34
34
  <tr v-if="event.plate"><th>Plate</th><td>{{ event.plate }}</td></tr>
35
35
  <tr v-if="!isClassification"><th>Zones</th><td>{{ (event.zones ?? []).join(", ") || "None" }}<template v-if="(event.enteredZones ?? []).length"> (entered: {{ event.enteredZones.join(" then ") }})</template></td></tr>
36
- <tr><th>Confidence</th><td>{{ scoreText(event.score) }}</td></tr>
36
+ <!-- A smart detection result carries no score from the engine. -->
37
+ <tr v-if="!isClassification"><th>Confidence</th><td>{{ scoreText(event.score) }}</td></tr>
37
38
  <tr v-if="event.incident"><th>Incident</th><td>An incident report was created for this alert.</td></tr>
38
39
  </tbody>
39
40
  </v-table>
@@ -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
@@ -1883,6 +1889,7 @@ import { isVisitorPassSmsOn } from "../composables/useVisitor";
1883
1889
  import { barrierCameraOf, barrierMessage, barrierOf, VISITOR_ACTION_SUCCESS } from "../utils/visitor-barrier";
1884
1890
  import useVisitorCameraChoices from "../composables/useVisitorCameraChoices";
1885
1891
  import { VISITOR_CAMERA_LABEL } from "../utils/visitor-camera";
1892
+ import { notAfterToday, sgDateOf, type VisitorDateDefault } from "../utils/visitor-date-default";
1886
1893
  import usePassKey from "../composables/usePassKey";
1887
1894
  import {
1888
1895
  VISITOR_SEARCH_DEBOUNCE_MS,
@@ -1894,6 +1901,11 @@ import {
1894
1901
  const { downloadPDF } = usePDFDownload();
1895
1902
 
1896
1903
  const props = defineProps({
1904
+ // The date filter's opening range: "last30" (iSecure) or "today" (Property).
1905
+ defaultDateRange: {
1906
+ type: String as PropType<VisitorDateDefault>,
1907
+ default: "last30",
1908
+ },
1897
1909
  canAddVisitor: {
1898
1910
  type: Boolean,
1899
1911
  default: false,
@@ -2275,8 +2287,15 @@ function daysAgo(days: number) {
2275
2287
  date.setDate(date.getDate() - days);
2276
2288
  return date;
2277
2289
  }
2278
- const defaultDateTo = () => normalizeDateOnly(new Date().toISOString());
2279
- const defaultDateFrom = () => normalizeDateOnly(daysAgo(30).toISOString());
2290
+ // defaultDateRange "today" (Property, DV-0886): both dates are today in
2291
+ // Singapore, nothing after today can be picked, and a fresh open ignores dates
2292
+ // left in the URL. "last30" keeps the lines below exactly as they were.
2293
+ const todayOnly = computed(() => props.defaultDateRange === "today");
2294
+ const sgToday = ref(sgDateOf());
2295
+ const defaultDateTo = () =>
2296
+ todayOnly.value ? sgToday.value : normalizeDateOnly(new Date().toISOString());
2297
+ const defaultDateFrom = () =>
2298
+ todayOnly.value ? sgToday.value : normalizeDateOnly(daysAgo(30).toISOString());
2280
2299
 
2281
2300
  const dateTo = ref(defaultDateTo());
2282
2301
  const dateFrom = ref(defaultDateFrom());
@@ -4263,11 +4282,37 @@ watch(
4263
4282
  // iSecure: the dates cannot be cleared - a cleared one goes back to its default.
4264
4283
  watch(dateFrom, (value) => {
4265
4284
  if (!value) dateFrom.value = defaultDateFrom();
4285
+ else if (todayOnly.value && value > sgToday.value) dateFrom.value = sgToday.value;
4266
4286
  });
4267
4287
  watch(dateTo, (value) => {
4268
4288
  if (!value) dateTo.value = defaultDateTo();
4289
+ else if (todayOnly.value && value > sgToday.value) dateTo.value = sgToday.value;
4269
4290
  });
4270
4291
 
4292
+ // "today" only: a page left open past midnight moves an untouched today to
4293
+ // the new day. A range the user picked is left alone.
4294
+ let sgDayTimer: ReturnType<typeof setInterval> | null = null;
4295
+ onMounted(() => {
4296
+ if (!todayOnly.value) return;
4297
+ sgDayTimer = setInterval(() => {
4298
+ const next = sgDateOf();
4299
+ if (next === sgToday.value) return;
4300
+ const previous = sgToday.value;
4301
+ sgToday.value = next;
4302
+ if (dateFrom.value === previous && dateTo.value === previous) {
4303
+ dateFrom.value = next;
4304
+ dateTo.value = next;
4305
+ }
4306
+ }, 60_000);
4307
+ });
4308
+ onBeforeUnmount(() => {
4309
+ if (sgDayTimer) clearInterval(sgDayTimer);
4310
+ });
4311
+
4312
+ // "today" only: the first read of the route is a fresh open, so dates left in
4313
+ // the URL (bookmark, back navigation, yesterday's tab) do not replace today.
4314
+ let routeDatesSeen = false;
4315
+
4271
4316
  const syncVisitorFiltersFromRoute = () => {
4272
4317
  const requestedTab = (route.query.tab as string) || "registered";
4273
4318
  const nextTab =
@@ -4293,15 +4338,20 @@ const syncVisitorFiltersFromRoute = () => {
4293
4338
  searchQuery.value = nextSearch;
4294
4339
  }
4295
4340
 
4296
- if (route.query.dateFrom) {
4297
- const nextDateFrom = normalizeDateOnly(route.query.dateFrom as string);
4341
+ const skipRouteDates = todayOnly.value && !routeDatesSeen;
4342
+ routeDatesSeen = true;
4343
+ const fromRoute = (value: string) =>
4344
+ todayOnly.value ? notAfterToday(value, sgToday.value) : value;
4345
+
4346
+ if (route.query.dateFrom && !skipRouteDates) {
4347
+ const nextDateFrom = fromRoute(normalizeDateOnly(route.query.dateFrom as string));
4298
4348
  if (dateFrom.value !== nextDateFrom) {
4299
4349
  dateFrom.value = nextDateFrom;
4300
4350
  }
4301
4351
  }
4302
4352
 
4303
- if (route.query.dateTo) {
4304
- const nextDateTo = normalizeDateOnly(route.query.dateTo as string);
4353
+ if (route.query.dateTo && !skipRouteDates) {
4354
+ const nextDateTo = fromRoute(normalizeDateOnly(route.query.dateTo as string));
4305
4355
  if (dateTo.value !== nextDateTo) {
4306
4356
  dateTo.value = nextDateTo;
4307
4357
  }
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.163.6",
5
+ "version": "4.163.7",
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.",
@@ -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
+ }