@7365admin1/layer-common 4.97.1-staging.745 → 4.97.1-staging.747

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.
@@ -159,18 +159,35 @@
159
159
  <!-- Entry content -->
160
160
  <div class="d-flex flex-column ga-1 pb-4 flex-grow-1">
161
161
  <div class="d-flex align-center justify-space-between">
162
- <StatusChip :status="isAssignment(entry) ? 'Assigned' : 'Returned'">
162
+ <StatusChip
163
+ :status="historyEntryKind(entry).label"
164
+ :tone="isChangeEntry(entry) ? historyEntryKind(entry).tone : ''"
165
+ >
163
166
  <v-icon
164
167
  size="13"
165
168
  class="mr-1"
166
- :icon="isAssignment(entry) ? 'mdi-account-arrow-right' : 'mdi-arrow-u-left-top'"
167
- />{{ isAssignment(entry) ? "Assigned" : "Returned" }}
169
+ :icon="historyEntryKind(entry).icon"
170
+ />{{ historyEntryKind(entry).label }}
168
171
  </StatusChip>
169
172
  <span class="card-details__label">{{ formatDate(entry.createdAt) }}</span>
170
173
  </div>
171
174
 
175
+ <!-- Replace / Delete entry (DV-2277): who, the other card, remarks -->
176
+ <template v-if="isChangeEntry(entry)">
177
+ <div class="card-details__sub">
178
+ By {{ entry.performedByName || "Not recorded" }}
179
+ </div>
180
+ <div v-if="entry.relatedCardNo" class="card-details__sub">
181
+ {{ historyEntryKind(entry).kind === "replaced" ? "Replaced by" : "Replaces" }}
182
+ card {{ entry.relatedCardNo }}
183
+ </div>
184
+ <div v-if="entry.remarks" class="card-details__sub">
185
+ Remarks: {{ entry.remarks }}
186
+ </div>
187
+ </template>
188
+
172
189
  <!-- Assignment entry -->
173
- <template v-if="entry.type === 'assigned' || entry.visitorId">
190
+ <template v-else-if="entry.type === 'assigned' || entry.visitorId">
174
191
  <div class="card-details__value">{{ entry.name ?? "N/A" }}</div>
175
192
  <div class="card-details__sub">
176
193
  <span v-if="entry.nric">NRIC: {{ maskNRIC(entry.nric) }}</span>
@@ -204,6 +221,7 @@
204
221
  </template>
205
222
 
206
223
  <script setup lang="ts">
224
+ import { historyEntryKind } from "../utils/card-history-entry";
207
225
  const { maskNRIC } = useUtils();
208
226
  const props = defineProps({
209
227
  modelValue: {
@@ -309,6 +327,12 @@ function isAssignment(entry: Record<string, any>) {
309
327
  return entry.type === "assigned" || Boolean(entry.visitorId);
310
328
  }
311
329
 
330
+ /** A Replace or Delete entry (DV-2277), shown with who did it and the remarks. */
331
+ function isChangeEntry(entry: Record<string, any>) {
332
+ const kind = historyEntryKind(entry).kind;
333
+ return kind === "replaced" || kind === "replacement" || kind === "deleted";
334
+ }
335
+
312
336
  function formatDate(date: string) {
313
337
  if (!date) return "N/A";
314
338
  return new Intl.DateTimeFormat("en-GB", {
@@ -31,6 +31,42 @@
31
31
  </v-radio-group>
32
32
  </v-col>
33
33
 
34
+ <!-- Brand decides which protocol every later field is used with, so
35
+ it is asked first. Picked once on Add and READ-ONLY on Edit
36
+ (owner, 2026-11-25): swapping a saved camera to another brand
37
+ would strand its plates on the old unit, so that is a delete and
38
+ re-add, not an edit. -->
39
+ <v-col v-if="isANPR" cols="12">
40
+ <InputLabel class="text-capitalize" title="Brand" :required="!isEdit" />
41
+
42
+ <v-select
43
+ v-if="!isEdit"
44
+ v-model="camera.brand"
45
+ :items="brandOptions"
46
+ class="filter-field"
47
+ density="comfortable"
48
+ placeholder="Select brand"
49
+ :rules="[requiredRule]"
50
+ data-test="camera-brand"
51
+ />
52
+
53
+ <template v-else>
54
+ <v-text-field
55
+ :model-value="brandLabel"
56
+ class="filter-field"
57
+ density="comfortable"
58
+ readonly
59
+ variant="solo-filled"
60
+ flat
61
+ prepend-inner-icon="mdi-lock-outline"
62
+ data-test="camera-brand"
63
+ />
64
+ <div class="text-caption text-medium-emphasis mb-2">
65
+ To change the brand, delete this camera and add it again.
66
+ </div>
67
+ </template>
68
+ </v-col>
69
+
34
70
  <template v-if="showRecorderFields">
35
71
  <v-col cols="12">
36
72
  <InputLabel
@@ -83,6 +119,8 @@
83
119
  density="comfortable"
84
120
  :rules="[requiredRule, hostRule]"
85
121
  placeholder="Enter camera URL"
122
+ :hint="addressHint"
123
+ :persistent-hint="!!addressHint"
86
124
  />
87
125
  </v-col>
88
126
 
@@ -425,6 +463,9 @@ const camera = ref<TSiteCamera>({
425
463
  username: "",
426
464
  password: "",
427
465
  type: "ip",
466
+ // Deliberately unset: on Add the person picks, because a camera saved with
467
+ // the wrong brand never talks to its device and the failure is silent.
468
+ brand: undefined,
428
469
  category: "standard",
429
470
  direction: "both",
430
471
  name: "",
@@ -465,6 +506,35 @@ const message = ref("");
465
506
  const isANPR = computed(() => prop.type === "anpr");
466
507
  const isCCTV = computed(() => prop.type === "ip");
467
508
 
509
+ /** The ANPR brands the server will accept (DV-2436). */
510
+ const brandOptions = [
511
+ { title: "Dahua", value: "dahua" },
512
+ { title: "Hikvision", value: "hikvision" },
513
+ ];
514
+
515
+ /**
516
+ * What an edited camera's brand is called on screen. A camera saved before the
517
+ * field existed has none stored, and the server reads that as Dahua, so that
518
+ * is what is shown rather than a blank box.
519
+ */
520
+ const brandLabel = computed(
521
+ () =>
522
+ brandOptions.find((option) => option.value === camera.value.brand)?.title ??
523
+ "Dahua",
524
+ );
525
+
526
+ /** Per-brand wording for the address field; nothing for CCTV. */
527
+ const addressHint = computed(() => {
528
+ if (!isANPR.value) return "";
529
+ if (camera.value.brand === "hikvision") {
530
+ return "The camera's own address, reachable from the internet - e.g. http://site.dyndns.org:7020";
531
+ }
532
+ if (camera.value.brand === "dahua") {
533
+ return "The camera's own address, reachable from the internet - e.g. http://site.dyndns.org:8080";
534
+ }
535
+ return "";
536
+ });
537
+
468
538
  const { addCamera, updateSiteCamera, testSiteCamera, getAllSiteCameras } = useSiteSettings();
469
539
 
470
540
  /**
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.745",
5
+ "version": "4.97.1-staging.747",
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/types/camera.d.ts CHANGED
@@ -24,6 +24,12 @@ declare type TSiteCamera = {
24
24
  username: string;
25
25
  password: string;
26
26
  type: "ip" | "anpr";
27
+ /**
28
+ * ANPR cameras: which vendor's protocol the camera speaks (DV-2436). Absent
29
+ * on every camera stored before the field existed, which the server reads as
30
+ * Dahua. Picked once when the camera is added and never editable after.
31
+ */
32
+ brand?: "dahua" | "hikvision";
27
33
  category: "standard" | "resident" | "visitor";
28
34
  direction: "entry" | "exit" | "both" | "none";
29
35
  name?: string;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * What a Card Details > History entry is, for its chip and icon.
3
+ *
4
+ * Assign and visitor issue have always written history; a return/checkout is
5
+ * the other old kind. Replace and Delete add three more (DV-2277), written by
6
+ * core as `type: "replaced" | "replacement" | "deleted"`.
7
+ */
8
+ export type HistoryKind = "assigned" | "replaced" | "replacement" | "deleted" | "returned";
9
+
10
+ export type HistoryKindInfo = {
11
+ kind: HistoryKind;
12
+ label: string;
13
+ tone: "ok" | "warn" | "err" | "info" | "neutral";
14
+ icon: string;
15
+ };
16
+
17
+ const KINDS: Record<Exclude<HistoryKind, "returned" | "assigned">, HistoryKindInfo> = {
18
+ replaced: { kind: "replaced", label: "Replaced", tone: "warn", icon: "mdi-swap-horizontal" },
19
+ replacement: { kind: "replacement", label: "Issued as replacement", tone: "info", icon: "mdi-card-plus-outline" },
20
+ deleted: { kind: "deleted", label: "Deleted", tone: "err", icon: "mdi-delete-outline" },
21
+ };
22
+
23
+ export function historyEntryKind(entry: Record<string, any> | null | undefined): HistoryKindInfo {
24
+ const type = entry?.type;
25
+ if (type === "assigned" || entry?.visitorId) {
26
+ return { kind: "assigned", label: "Assigned", tone: "ok", icon: "mdi-account-arrow-right" };
27
+ }
28
+ if (type === "replaced" || type === "replacement" || type === "deleted") return KINDS[type];
29
+ return { kind: "returned", label: "Returned", tone: "neutral", icon: "mdi-arrow-u-left-top" };
30
+ }