@7365admin1/layer-common 4.97.1-staging.559 → 4.97.1-staging.561

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.
@@ -129,7 +129,11 @@
129
129
  </span>
130
130
  <v-spacer />
131
131
  <AppButton variant="ghost" :disabled="saving" @click="open = false">Cancel</AppButton>
132
+ <!-- Reachable only from a menu item the users right draws; the same
133
+ right is asked again here so the dialog stays read only if it is
134
+ ever opened some other way. -->
132
135
  <AppButton
136
+ v-if="canManageHidUsers"
133
137
  icon="mdi-content-save-outline"
134
138
  :loading="saving"
135
139
  :disabled="!readerLocation || !dirty || saving"
@@ -185,6 +189,8 @@ const props = defineProps<{
185
189
  reader: Record<string, unknown> | null;
186
190
  }>();
187
191
 
192
+ const { canManageHidUsers } = useHidAccessPermission();
193
+
188
194
  const emit = defineEmits<{
189
195
  (event: "update:modelValue", value: boolean): void;
190
196
  (event: "saved"): void;
@@ -22,16 +22,14 @@
22
22
  denial here would flash "no permission" at the owner on every load. -->
23
23
  <template v-if="!isAppRoleResolved" />
24
24
 
25
- <slot v-else-if="hidEnabled && canAccessHidScreens" />
25
+ <slot v-else-if="hidEnabled && permitted" />
26
26
 
27
27
  <div v-else-if="hidEnabled" class="screen-empty hid-gate">
28
28
  <span class="hid-gate__icon tone-info">
29
29
  <v-icon icon="mdi-lock-outline" size="24" />
30
30
  </span>
31
- <h2 class="hid-gate__title">You do not have permission for HID access management</h2>
32
- <p class="hid-gate__body">
33
- Ask an administrator to grant your role access card management for this site.
34
- </p>
31
+ <h2 class="hid-gate__title">{{ deniedTitle }}</h2>
32
+ <p class="hid-gate__body">{{ deniedBody }}</p>
35
33
  </div>
36
34
 
37
35
  <div v-else class="screen-empty hid-gate">
@@ -50,10 +48,18 @@ const props = withDefaults(
50
48
  org: string;
51
49
  message?: string;
52
50
  redirectToSettings?: boolean;
51
+ /**
52
+ * Which HID right opens the screen behind this gate. `view` is the admin
53
+ * screens (readers, users, cards, intercom, access logs: `canViewHid`);
54
+ * `use` is the member's own HID QR Code page (`canUseHid`). Defaults to the
55
+ * stricter one, so a page that forgets to say is an admin page.
56
+ */
57
+ level?: "view" | "use";
53
58
  }>(),
54
59
  {
55
60
  message: "Enable HID as a service for this site before accessing this screen.",
56
61
  redirectToSettings: true,
62
+ level: "view",
57
63
  },
58
64
  );
59
65
 
@@ -61,13 +67,26 @@ const { getSiteById } = useSiteSettings();
61
67
  const { getHidServiceEnabled } = useOptionalServices();
62
68
 
63
69
  // The permission half of the same gate. This component is the only thing all
64
- // six `access-mgmt` pages have in common, so putting the check here governs all
65
- // six -- and all 66 inherited routes across the eleven apps -- without a page
66
- // guard per screen. See `composables/useHidAccessPermission.ts` for why the
67
- // gate cannot remove access that currently works.
68
- const { canAccessHidScreens } = useHidAccessPermission();
70
+ // seven `access-mgmt` HID pages have in common, so putting the check here
71
+ // governs all of them, and every inherited route across the eleven apps,
72
+ // without a page guard per screen. See `composables/useHidAccessPermission.ts`
73
+ // for the five flags and the alias period.
74
+ const { canViewHid, canUseHid } = useHidAccessPermission();
69
75
  const { isAppRoleResolved } = useLocalSetup();
70
76
 
77
+ const permitted = computed(() => (props.level === "use" ? canUseHid.value : canViewHid.value));
78
+
79
+ const deniedTitle = computed(() =>
80
+ props.level === "use"
81
+ ? "You do not have permission for HID access"
82
+ : "You do not have permission for HID access management",
83
+ );
84
+ const deniedBody = computed(() =>
85
+ props.level === "use"
86
+ ? "Ask an administrator to grant your role HID access for this site."
87
+ : "Ask an administrator to grant your role HID management for this site.",
88
+ );
89
+
71
90
  // Do not await this request during route setup. Every HID page uses this gate;
72
91
  // awaiting it makes Nuxt Suspense keep rendering the previous page until the
73
92
  // site request finishes, so the URL changes while the visible module appears
@@ -46,16 +46,18 @@
46
46
  @update:page="page = $event"
47
47
  >
48
48
  <!-- The action swaps with the tab, as it did in the old top bar. -->
49
+ <!-- Contacts are reader objects, so adding one is the readers right.
50
+ The web call is a member level call and stays for everyone. -->
49
51
  <template #actions>
50
52
  <AppButton
51
- v-if="activeTab === 'contacts'"
53
+ v-if="activeTab === 'contacts' && canManageHidReaders"
52
54
  icon="mdi-plus"
53
55
  @click="openContactDialog()"
54
56
  >
55
57
  Add Contacts
56
58
  </AppButton>
57
59
  <AppButton
58
- v-else
60
+ v-else-if="activeTab !== 'contacts'"
59
61
  icon="mdi-phone-in-talk-outline"
60
62
  class="web-call-button"
61
63
  :class="webPhoneButtonClass"
@@ -151,23 +153,30 @@
151
153
  <template #activator="{ props: menuProps }">
152
154
  <AppButton v-bind="menuProps" variant="row" icon="mdi-dots-vertical" />
153
155
  </template>
156
+ <!-- The reader's SIP settings, call settings, dial code and contacts
157
+ are reader configuration: the readers right. View and the status
158
+ check stay for the view right. -->
154
159
  <v-list v-if="activeTab === 'intercom'" density="compact" class="screen-menu">
155
160
  <v-list-item class="screen-menu__item" title="View" prepend-icon="mdi-eye" @click="openViewDialog(item)" />
156
- <v-list-item
157
- class="screen-menu__item"
158
- title="Test Connection with SIP"
159
- prepend-icon="mdi-lan-check"
160
- :disabled="testingSipReaderId === item.reader._id"
161
- @click="testSipConnection(item)"
162
- />
163
- <v-list-item class="screen-menu__item" title="Call Settings" prepend-icon="mdi-cog" @click="openCallDialog(item)" />
164
- <v-list-item class="screen-menu__item" title="Dial Code" prepend-icon="mdi-dialpad" @click="openDialCodeDialog(item)" />
161
+ <template v-if="canManageHidReaders">
162
+ <v-list-item
163
+ class="screen-menu__item"
164
+ title="Test Connection with SIP"
165
+ prepend-icon="mdi-lan-check"
166
+ :disabled="testingSipReaderId === item.reader._id"
167
+ @click="testSipConnection(item)"
168
+ />
169
+ <v-list-item class="screen-menu__item" title="Call Settings" prepend-icon="mdi-cog" @click="openCallDialog(item)" />
170
+ <v-list-item class="screen-menu__item" title="Dial Code" prepend-icon="mdi-dialpad" @click="openDialCodeDialog(item)" />
171
+ </template>
165
172
  </v-list>
166
173
  <v-list v-else density="compact" class="screen-menu">
167
174
  <v-list-item class="screen-menu__item" title="Check reader SIP status" prepend-icon="mdi-lan-check" @click="testContactSipStatus(item)" />
168
175
  <v-list-item class="screen-menu__item" title="View" prepend-icon="mdi-eye" @click="openContactView(item)" />
169
- <v-list-item class="screen-menu__item" title="Edit" prepend-icon="mdi-pencil" @click="openContactDialog(item)" />
170
- <v-list-item class="screen-menu__item screen-menu__item--danger" title="Delete" prepend-icon="mdi-delete-outline" @click="openDeleteContact(item)" />
176
+ <template v-if="canManageHidReaders">
177
+ <v-list-item class="screen-menu__item" title="Edit" prepend-icon="mdi-pencil" @click="openContactDialog(item)" />
178
+ <v-list-item class="screen-menu__item screen-menu__item--danger" title="Delete" prepend-icon="mdi-delete-outline" @click="openDeleteContact(item)" />
179
+ </template>
171
180
  </v-list>
172
181
  </v-menu>
173
182
  </template>
@@ -749,6 +758,10 @@ type IntercomRow = {
749
758
  pjsip: Record<string, unknown>;
750
759
  };
751
760
 
761
+ // Reader configuration (SIP, call settings, dial code, contacts) is the readers
762
+ // right. The screen itself is behind `HidEnabledGate` (the view right).
763
+ const { canManageHidReaders } = useHidAccessPermission();
764
+
752
765
  const {
753
766
  getReaders,
754
767
  getReaderConfiguration,
@@ -121,7 +121,7 @@ import type { HidProfileQr } from "../composables/useHidAmico";
121
121
 
122
122
  const props = defineProps<{ site: string }>();
123
123
 
124
- const { getReaders, getProfileQr, issueProfileQr, deleteProfileQr } = useHidAmico();
124
+ const { getEnrollmentReaders, getProfileQr, issueProfileQr, deleteProfileQr } = useHidAmico();
125
125
 
126
126
  type HidReaderOption = { _id: string; name?: string; portalName?: string };
127
127
 
@@ -200,7 +200,11 @@ function downloadQr() {
200
200
 
201
201
  async function loadReaders() {
202
202
  if (!props.site) return;
203
- const response = toRecord(await getReaders({ site: props.site, page: 1, limit: 100 }));
203
+ /* The self service list, not the admin one. `GET /readers` sits behind the
204
+ HID view right, so a member holding only `hid-mgmt:use-hid-access` (the
205
+ right this page is drawn for) was refused before the picker could fill.
206
+ `enrollment-readers` is the same site's enabled readers, for members. */
207
+ const response = toRecord(await getEnrollmentReaders(props.site));
204
208
  const data = toRecord(response.data);
205
209
  const items = response.items ?? data.items ?? data.readers ?? [];
206
210
  readers.value = (Array.isArray(items) ? items : []).filter((reader) => reader?._id);
@@ -29,7 +29,10 @@
29
29
  show-header
30
30
  @refresh="loadReaders"
31
31
  >
32
- <template #actions>
32
+ <!-- Hidden, not disabled, for a member without the right: the server
33
+ refuses the call anyway, and a button that cannot work is noise.
34
+ `hid-mgmt:manage-hid-readers` (`useHidAccessPermission`). -->
35
+ <template v-if="canManageHidReaders" #actions>
33
36
  <AppButton icon="mdi-plus" @click="openAdd">Add HID Reader</AppButton>
34
37
  </template>
35
38
 
@@ -85,14 +88,23 @@
85
88
  <AppButton v-bind="menuProps" variant="row" icon="mdi-dots-vertical" />
86
89
  </template>
87
90
 
91
+ <!-- View is the view right. Access Permissions assigns people to the
92
+ reader's group, so it is the users right; everything else acts on
93
+ the reader itself and is the readers right. -->
88
94
  <v-list density="compact" min-width="180">
89
95
  <v-list-item title="View" @click="openView(item)" />
90
- <v-list-item title="Access Permissions" @click="openPermissions(item)" />
91
- <v-list-item title="Identification Methods" @click="openIdentification(item)" />
92
- <v-list-item title="Sync HID Reader" @click="openSyncConfirm(item)" />
93
- <v-list-item title="Test Connection" @click="openTestConfirm(item)" />
94
- <v-list-item title="Edit" @click="openEdit(item)" />
95
- <v-list-item title="Delete" class="text-error" @click="openDeleteConfirm(item)" />
96
+ <v-list-item
97
+ v-if="canManageHidUsers"
98
+ title="Access Permissions"
99
+ @click="openPermissions(item)"
100
+ />
101
+ <template v-if="canManageHidReaders">
102
+ <v-list-item title="Identification Methods" @click="openIdentification(item)" />
103
+ <v-list-item title="Sync HID Reader" @click="openSyncConfirm(item)" />
104
+ <v-list-item title="Test Connection" @click="openTestConfirm(item)" />
105
+ <v-list-item title="Edit" @click="openEdit(item)" />
106
+ <v-list-item title="Delete" class="text-error" @click="openDeleteConfirm(item)" />
107
+ </template>
96
108
  </v-list>
97
109
  </v-menu>
98
110
  </template>
@@ -136,7 +148,7 @@
136
148
  <span>Username</span><strong>{{ selectedReader?.username || "N/A" }}</strong>
137
149
  </div>
138
150
 
139
- <div class="dialog-actions-inline">
151
+ <div v-if="canManageHidReaders" class="dialog-actions-inline">
140
152
  <AppButton variant="ghost" @click="openTestConfirm(selectedReader)">Test Connection</AppButton>
141
153
  <AppButton variant="ghost" @click="openSyncConfirm(selectedReader)">Sync Reader</AppButton>
142
154
  </div>
@@ -481,6 +493,10 @@ const props = defineProps({
481
493
  },
482
494
  });
483
495
 
496
+ // Which buttons this member gets. The screen itself is behind `HidEnabledGate`
497
+ // (the view right); these two decide the write actions on it.
498
+ const { canManageHidReaders, canManageHidUsers } = useHidAccessPermission();
499
+
484
500
  const {
485
501
  getReaders,
486
502
  createReader,
@@ -68,7 +68,8 @@
68
68
  </span>
69
69
  </template>
70
70
 
71
- <template #[`item.action-table`]="{ item }">
71
+ <!-- Setting a PIN is the users right; the roster itself is the view right. -->
72
+ <template v-if="canManageHidUsers" #[`item.action-table`]="{ item }">
72
73
  <AppButton
73
74
  variant="row"
74
75
  icon="mdi-form-textbox-password"
@@ -199,6 +200,7 @@ type HidReaderUser = Record<string, unknown> & {
199
200
  metadata?: HidMetadata;
200
201
  };
201
202
 
203
+ const { canManageHidUsers } = useHidAccessPermission();
202
204
  const {
203
205
  getReaders,
204
206
  getReaderUsers,
@@ -53,7 +53,9 @@
53
53
  @refresh="loadUsers"
54
54
  @update:page="goToPage"
55
55
  >
56
- <template v-if="!props.cardManagement" #actions>
56
+ <!-- Enrolling is the users right (`hid-mgmt:manage-hid-users`). Hidden,
57
+ not disabled: the server refuses the call for a member without it. -->
58
+ <template v-if="!props.cardManagement && canManageHidUsers" #actions>
57
59
  <AppButton icon="mdi-account-plus" @click="openEnroll"
58
60
  >Enroll</AppButton
59
61
  >
@@ -141,14 +143,14 @@
141
143
 
142
144
  <template #[`item.action-table`]="{ item }">
143
145
  <AppButton
144
- v-if="props.cardManagement"
146
+ v-if="props.cardManagement && canManageHidUsers"
145
147
  variant="secondary"
146
148
  icon="mdi-card-account-details-outline"
147
149
  @click="openCardManager(item)"
148
150
  >
149
151
  Manage
150
152
  </AppButton>
151
- <v-menu v-else>
153
+ <v-menu v-else-if="!props.cardManagement">
152
154
  <template #activator="{ props: menuProps }">
153
155
  <AppButton
154
156
  v-bind="menuProps"
@@ -159,16 +161,18 @@
159
161
 
160
162
  <v-list density="compact" min-width="150">
161
163
  <v-list-item title="View" @click="openView(item)" />
162
- <v-list-item title="Edit" @click="openEdit(item)" />
163
- <v-list-item
164
- title="Manage HID Cards"
165
- @click="openCardManager(item)"
166
- />
167
- <v-list-item
168
- title="Delete"
169
- class="text-error"
170
- @click="openDelete(item)"
171
- />
164
+ <template v-if="canManageHidUsers">
165
+ <v-list-item title="Edit" @click="openEdit(item)" />
166
+ <v-list-item
167
+ title="Manage HID Cards"
168
+ @click="openCardManager(item)"
169
+ />
170
+ <v-list-item
171
+ title="Delete"
172
+ class="text-error"
173
+ @click="openDelete(item)"
174
+ />
175
+ </template>
172
176
  </v-list>
173
177
  </v-menu>
174
178
  </template>
@@ -1261,6 +1265,10 @@ const props = defineProps({
1261
1265
  },
1262
1266
  });
1263
1267
 
1268
+ // Enrol, edit, delete, cards and PINs are all the users right. The screen
1269
+ // itself is behind `HidEnabledGate` (the view right).
1270
+ const { canManageHidUsers } = useHidAccessPermission();
1271
+
1264
1272
  const {
1265
1273
  getReaders,
1266
1274
  getIdentities,
@@ -143,6 +143,18 @@ async function refresh() {
143
143
  await loadLifts();
144
144
  }
145
145
 
146
+ // Declared BEFORE `steps`: the progress watch below runs at once and reads it (a later `const` is a TDZ error).
147
+ // Floor names: the list the panel loaded or saved; a save re-reads the robots so the checklist shows the new floors.
148
+ const floorsEl = ref<HTMLElement | null>(null);
149
+ const siteFloors = ref<Array<{ key: number; name: string }>>([]);
150
+ const mapFloors = computed(() => [...new Set<number>(((saved.value?.levels ?? []) as any[]).map((l) => Number(l?.floorNo)).filter(Number.isInteger))]);
151
+ let firstFloors = true;
152
+ function floorsSaved(list: Array<{ key: number; name: string }>) {
153
+ siteFloors.value = list;
154
+ if (firstFloors) return void (firstFloors = false);
155
+ void refresh();
156
+ }
157
+
146
158
  const steps = computed(() =>
147
159
  robotSetupSteps({
148
160
  orgModules: orgModules.value,
@@ -165,16 +177,6 @@ function go(target: TSetupTarget) {
165
177
  if (target) emit("go", target);
166
178
  }
167
179
 
168
- // Floor names: the list the panel loaded or saved; a save re-reads the robots so the checklist shows the new floors.
169
- const floorsEl = ref<HTMLElement | null>(null);
170
- const siteFloors = ref<Array<{ key: number; name: string }>>([]);
171
- const mapFloors = computed(() => [...new Set<number>(((saved.value?.levels ?? []) as any[]).map((l) => Number(l?.floorNo)).filter(Number.isInteger))]);
172
- let firstFloors = true;
173
- function floorsSaved(list: Array<{ key: number; name: string }>) {
174
- siteFloors.value = list;
175
- if (firstFloors) return void (firstFloors = false);
176
- void refresh();
177
- }
178
180
  </script>
179
181
 
180
182
  <style scoped>
@@ -186,7 +186,9 @@
186
186
  </v-expansion-panel-text>
187
187
  </v-expansion-panel>
188
188
 
189
- <v-expansion-panel>
189
+ <!-- HID on or off for the site and the HID QR configuration:
190
+ `hid-mgmt:manage-hid-settings` (`useHidAccessPermission`). -->
191
+ <v-expansion-panel v-if="canManageHidSettings">
190
192
  <v-expansion-panel-title>
191
193
  <v-icon class="mr-2">mdi-face-recognition</v-icon>
192
194
  HID Face Reader
@@ -304,6 +306,7 @@ const { canManageSiteInformation,
304
306
  canManageVehicleQr,
305
307
  canManageSiteSettings: canManageAnySiteSetting,
306
308
  } = useSettingsPermission();
309
+ const { canManageHidSettings } = useHidAccessPermission();
307
310
 
308
311
  const { getSiteById, updateSitebyId, updateSiteInformation } =
309
312
  useSiteSettings();
@@ -673,7 +673,7 @@ const {
673
673
  const { getBySiteId: getEntryPassSettingsBySiteId } =
674
674
  useSiteEntryPassSettings();
675
675
  const { createVisitorPass, signQr, visitorCheckout } = useAccessManagement();
676
- const { getReaders, issueVisitorQr } = useHidAmico();
676
+ const { getEnrollmentReaders, issueVisitorQr } = useHidAmico();
677
677
  const { testConnection } = useWebUsb();
678
678
  const {
679
679
  findPersonByNRIC,
@@ -1561,8 +1561,14 @@ watch(
1561
1561
  hidQrReader.value = null;
1562
1562
  if (!site) return;
1563
1563
  try {
1564
- const response = await getReaders({ site, page: 1, limit: 100 });
1565
- const readers: unknown = response?.items ?? response?.data?.items ?? response?.data?.readers ?? [];
1564
+ /* The member's list, not the admin one. `POST /readers/:id/visitor-qr`
1565
+ asks for membership plus `hid-mgmt:use-hid-access` (API-core #1772),
1566
+ while `GET /readers` asks for the HID view right, so a member who may
1567
+ issue a visitor pass but holds no admin right got the pass route and
1568
+ not the reader it needs. `enrollment-readers` is the site's enabled
1569
+ readers with a portal, `{ data: { items } }`, for any member. */
1570
+ const response = await getEnrollmentReaders(site);
1571
+ const readers: unknown = response?.data?.items ?? [];
1566
1572
  const availableReaders = Array.isArray(readers)
1567
1573
  ? readers.filter((reader: unknown): reader is HidQrReaderSummary => (
1568
1574
  typeof reader === "object"
@@ -83,6 +83,17 @@ export default function useCleaningPermission() {
83
83
  description: "Allows the user to manage and update site settings.",
84
84
  },
85
85
  },
86
+ // HID access, user side only (decision of 2026-10-16). The service apps
87
+ // have no HID admin screens yet, so a role here can be prepared with the
88
+ // one string that lets a member use their own QR code, face, PIN, card and
89
+ // intercom. Mirrored from core `src/utils/hid-access.util.ts`.
90
+ "hid-mgmt": {
91
+ "use-hid-access": {
92
+ check: true,
93
+ description:
94
+ "Allows the user to see HID Access in the app and use their own QR code, face, PIN, card and intercom at this site.",
95
+ },
96
+ },
86
97
  toilet_locations: {
87
98
  "create-toilet-location": {
88
99
  check: true,