@7365admin1/layer-common 3.1.4-staging.49 → 3.1.4-staging.51

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.
@@ -168,13 +168,13 @@
168
168
  <template v-if="passType === 'HID_QR'">
169
169
  <v-alert
170
170
  v-if="!hidQrPrinterConfigured"
171
- type="warning"
171
+ type="info"
172
172
  variant="tonal"
173
173
  density="compact"
174
174
  class="mt-3"
175
- icon="mdi-printer-alert"
175
+ icon="mdi-qrcode"
176
176
  >
177
- No printer is configured on HID settings. QR Pass may not print.
177
+ HID QR Code will be generated and shown on screen. You can download it after continuing.
178
178
  </v-alert>
179
179
  <v-alert
180
180
  v-else
@@ -184,7 +184,7 @@
184
184
  class="mt-3"
185
185
  icon="mdi-qrcode-scan"
186
186
  >
187
- HID QR Code will be generated and printed when you continue.
187
+ HID QR Code will be generated and shown on screen. Printing is also available.
188
188
  </v-alert>
189
189
  </template>
190
190
  </template>
@@ -418,8 +418,17 @@ const selectedHistoryRows = computed<AccessRow[]>(() => {
418
418
  if (!selectedHistoryRow.value) return [];
419
419
 
420
420
  const selectedKey = selectedHistoryRow.value.identityKey;
421
- const matchedLogs = logs.value.filter((log) => getLogIdentityKey(log) === selectedKey);
422
- const matchedLiveLogs = liveAccessLogs.value.filter((log) => getAccessLogIdentityKey(log) === selectedKey);
421
+ const selectedIdentity = findIdentityByKey(selectedKey);
422
+ const matchedLogs = logs.value.filter((log) =>
423
+ selectedIdentity
424
+ ? accessLogMatchesIdentity(log, selectedIdentity)
425
+ : getLogIdentityKey(log) === selectedKey,
426
+ );
427
+ const matchedLiveLogs = liveAccessLogs.value.filter((log) =>
428
+ selectedIdentity
429
+ ? accessLogMatchesIdentity(log, selectedIdentity)
430
+ : getAccessLogIdentityKey(log) === selectedKey,
431
+ );
423
432
 
424
433
  if (!matchedLogs.length && !matchedLiveLogs.length) {
425
434
  return rows.value.filter((row) => row.identityKey === selectedKey);
@@ -835,7 +844,7 @@ function getIdentityKey(identity: Record<string, any>) {
835
844
  return [
836
845
  identity.hidUserId,
837
846
  identity.registration,
838
- identity.cardNo,
847
+ identity.cardNo || identity.metadata?.qrCodeValue,
839
848
  ].filter(Boolean).join("|");
840
849
  }
841
850
 
@@ -851,7 +860,7 @@ function getLogIdentityKey(log: Record<string, any>) {
851
860
  return [
852
861
  identity.hidUserId || lookup.hidUserId || rawLog.user_id || rawLog.userId || rawLog.hidUserId,
853
862
  identity.registration || lookup.registration,
854
- identity.cardNo || lookup.cardNo || rawLog.card_value || rawLog.cardNo,
863
+ identity.cardNo || lookup.cardNo || rawLog.card_value || rawLog.cardNo || rawLog.qrcode_value,
855
864
  ].filter(Boolean).join("|");
856
865
  }
857
866
 
@@ -1173,25 +1182,26 @@ function findIdentityForAccessLog(rawLog: Record<string, any>, event: Record<str
1173
1182
  const hidUserId = rawLog.user_id ?? rawLog.userId ?? rawLog.hidUserId ?? event.payload?.identity?.hidUserId ?? event.payload?.identityLookup?.hidUserId;
1174
1183
  const registration = rawLog.registration ?? event.payload?.identity?.registration ?? event.payload?.identityLookup?.registration;
1175
1184
  const cardNo = rawLog.card_value || rawLog.cardNo || event.payload?.identity?.cardNo || event.payload?.identityLookup?.cardNo;
1185
+ const qrCodeValue = rawLog.qrcode_value || rawLog.qrCode || rawLog.qrcode;
1176
1186
 
1177
1187
  return identities.value.find((identity) => {
1178
1188
  return (
1179
1189
  (hidUserId !== undefined && hidUserId !== null && String(identity.hidUserId) === String(hidUserId)) ||
1180
1190
  (registration && identity.registration === registration) ||
1181
- (cardNo && String(identity.cardNo) === String(cardNo))
1191
+ (cardNo && String(identity.cardNo) === String(cardNo)) ||
1192
+ (qrCodeValue && String(identity.metadata?.qrCodeValue || "") === String(qrCodeValue))
1182
1193
  );
1183
1194
  });
1184
1195
  }
1185
1196
 
1186
1197
  function getLatestAccessLogForIdentity(identity: Record<string, any>) {
1187
- const identityKey = getIdentityKey(identity);
1188
1198
  const accessLogs = [
1189
1199
  ...liveAccessLogs.value,
1190
1200
  ...logs.value.flatMap((event) => getRawAccessLogs(event)),
1191
1201
  ];
1192
1202
 
1193
1203
  return accessLogs
1194
- .filter((log) => getAccessLogIdentityKey(log) === identityKey)
1204
+ .filter((log) => accessLogMatchesIdentity(log, identity))
1195
1205
  .sort((a, b) => {
1196
1206
  const aTime = parseDate(getAccessLogTime(a, {}))?.getTime() || 0;
1197
1207
  const bTime = parseDate(getAccessLogTime(b, {}))?.getTime() || 0;
@@ -1199,11 +1209,46 @@ function getLatestAccessLogForIdentity(identity: Record<string, any>) {
1199
1209
  })[0];
1200
1210
  }
1201
1211
 
1212
+ function toUnknownRecord(value: unknown): Record<string, unknown> {
1213
+ return typeof value === "object" && value !== null && !Array.isArray(value)
1214
+ ? value as Record<string, unknown>
1215
+ : {};
1216
+ }
1217
+
1218
+ function accessLogMatchesIdentity(log: unknown, identity: unknown) {
1219
+ const logRecord = toUnknownRecord(log);
1220
+ const identityRecord = toUnknownRecord(identity);
1221
+ const payload = toUnknownRecord(logRecord.payload);
1222
+ const rawLog = Object.keys(toUnknownRecord(payload.rawAccessLog)).length
1223
+ ? toUnknownRecord(payload.rawAccessLog)
1224
+ : logRecord;
1225
+ const eventIdentity = Object.keys(toUnknownRecord(payload.identity)).length
1226
+ ? toUnknownRecord(payload.identity)
1227
+ : toUnknownRecord(payload.identityLookup);
1228
+ const metadata = toUnknownRecord(identityRecord.metadata);
1229
+ const hidUserId = rawLog.user_id ?? rawLog.userId ?? rawLog.hidUserId ?? eventIdentity.hidUserId;
1230
+ const registration = rawLog.registration || eventIdentity.registration;
1231
+ const credential =
1232
+ rawLog.card_value ||
1233
+ rawLog.cardNo ||
1234
+ rawLog.qrcode_value ||
1235
+ rawLog.qrCode ||
1236
+ rawLog.qrcode ||
1237
+ eventIdentity.cardNo;
1238
+ const identityCredential = identityRecord.cardNo || metadata.qrCodeValue;
1239
+
1240
+ return Boolean(
1241
+ (hidUserId !== undefined && hidUserId !== null && String(identityRecord.hidUserId) === String(hidUserId)) ||
1242
+ (registration && identityRecord.registration === registration) ||
1243
+ (credential && identityCredential && String(identityCredential) === String(credential)),
1244
+ );
1245
+ }
1246
+
1202
1247
  function getAccessLogIdentityKey(rawLog: Record<string, any>) {
1203
1248
  return [
1204
1249
  rawLog.user_id ?? rawLog.userId ?? rawLog.hidUserId,
1205
1250
  rawLog.registration,
1206
- rawLog.card_value || rawLog.cardNo,
1251
+ rawLog.card_value || rawLog.cardNo || rawLog.qrcode_value,
1207
1252
  ].filter(Boolean).join("|");
1208
1253
  }
1209
1254