@7365admin1/layer-common 3.2.2-staging.108 → 3.2.2-staging.109
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.
|
@@ -630,7 +630,7 @@ async function loadDashboard() {
|
|
|
630
630
|
administratorUserIds.value = getAdministratorRoleUserIds(roleResponse);
|
|
631
631
|
allIdentities.value = mergedIdentities;
|
|
632
632
|
identities.value = mergedIdentities.filter(
|
|
633
|
-
(identity: Record<string,
|
|
633
|
+
(identity: Record<string, unknown>) => classifyIdentity(identity) === activeTab.value,
|
|
634
634
|
);
|
|
635
635
|
logs.value = logResponse?.items ?? logResponse?.data?.items ?? logResponse?.data?.logs ?? [];
|
|
636
636
|
liveAccessLogs.value = hidAccessLogs;
|
|
@@ -840,7 +840,7 @@ function isVisitorIdentity(identity: Record<string, unknown> | undefined) {
|
|
|
840
840
|
));
|
|
841
841
|
}
|
|
842
842
|
|
|
843
|
-
function classifyIdentity(identity?: Record<string,
|
|
843
|
+
function classifyIdentity(identity?: Record<string, unknown>, row?: AccessRow): AccessTab {
|
|
844
844
|
const hidUserId = toHidNumericId(identity?.hidUserId ?? row?.identityKey.split("|")[0]);
|
|
845
845
|
if (hidUserId && administratorUserIds.value.has(hidUserId)) return "administrator";
|
|
846
846
|
if (row?.identityType === "visitor" || row?.visitorId || isVisitorIdentity(identity)) return "visitor";
|
|
@@ -1197,15 +1197,15 @@ function getRawAccessLogs(event: Record<string, any>) {
|
|
|
1197
1197
|
|
|
1198
1198
|
if (Array.isArray(accessLogs)) return accessLogs;
|
|
1199
1199
|
|
|
1200
|
-
const objectChanges = payload.object_changes || result.object_changes || [];
|
|
1200
|
+
const objectChanges: unknown = payload.object_changes || result.object_changes || [];
|
|
1201
1201
|
return Array.isArray(objectChanges)
|
|
1202
|
-
? objectChanges
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1202
|
+
? objectChanges.flatMap((change: unknown) => {
|
|
1203
|
+
const record = toUnknownRecord(change);
|
|
1204
|
+
const values = toUnknownRecord(record.values);
|
|
1205
|
+
return record.object === "access_logs" && record.type !== "deleted" && Object.keys(values).length
|
|
1206
|
+
? [values]
|
|
1207
|
+
: [];
|
|
1208
|
+
})
|
|
1209
1209
|
: [];
|
|
1210
1210
|
}
|
|
1211
1211
|
|
|
@@ -239,16 +239,33 @@ async function connectReader() {
|
|
|
239
239
|
username: draft.username.trim(),
|
|
240
240
|
password: draft.password,
|
|
241
241
|
});
|
|
242
|
-
const
|
|
242
|
+
const nestedData = response?.data;
|
|
243
|
+
const data = typeof nestedData === "object" && nestedData !== null
|
|
244
|
+
? nestedData as Record<string, unknown>
|
|
245
|
+
: response;
|
|
243
246
|
draft.deviceId = String(data?.deviceId || "");
|
|
244
|
-
portals.value = Array.isArray(data?.portals)
|
|
247
|
+
portals.value = Array.isArray(data?.portals)
|
|
248
|
+
? data.portals.flatMap((portal: unknown) => {
|
|
249
|
+
if (typeof portal !== "object" || portal === null) return [];
|
|
250
|
+
const item = portal as Record<string, unknown>;
|
|
251
|
+
const id = Number(item.id);
|
|
252
|
+
const name = String(item.name || "").trim();
|
|
253
|
+
return Number.isSafeInteger(id) && id > 0 && name ? [{ id, name }] : [];
|
|
254
|
+
})
|
|
255
|
+
: [];
|
|
245
256
|
draft.portalId = portals.value.length === 1 ? portals.value[0].id : null;
|
|
246
257
|
discoveredConnection.value = [draft.baseUrl.trim(), draft.username.trim(), draft.password].join("\n");
|
|
247
|
-
} catch (error:
|
|
258
|
+
} catch (error: unknown) {
|
|
248
259
|
draft.deviceId = "";
|
|
249
260
|
draft.portalId = null;
|
|
250
261
|
portals.value = [];
|
|
251
|
-
|
|
262
|
+
const record = typeof error === "object" && error !== null ? error as Record<string, unknown> : {};
|
|
263
|
+
const errorData = typeof record.data === "object" && record.data !== null
|
|
264
|
+
? record.data as Record<string, unknown>
|
|
265
|
+
: {};
|
|
266
|
+
discoveryError.value = String(
|
|
267
|
+
errorData.message || record.message || "Unable to connect to the HID reader.",
|
|
268
|
+
);
|
|
252
269
|
} finally {
|
|
253
270
|
discovering.value = false;
|
|
254
271
|
}
|
|
@@ -883,7 +883,13 @@ const hidQrValidityMinutes = computed(() => {
|
|
|
883
883
|
});
|
|
884
884
|
|
|
885
885
|
const hidQrReaderId = computed(() => String(hidQrCodePassConfig.value?.readerId || ""));
|
|
886
|
-
|
|
886
|
+
type HidQrReaderSummary = {
|
|
887
|
+
_id: string;
|
|
888
|
+
name?: string;
|
|
889
|
+
portalId?: number;
|
|
890
|
+
portalName?: string;
|
|
891
|
+
};
|
|
892
|
+
const hidQrReader = ref<HidQrReaderSummary | null>(null);
|
|
887
893
|
|
|
888
894
|
watch(
|
|
889
895
|
[hidQrReaderId, () => prop.site],
|
|
@@ -892,8 +898,14 @@ watch(
|
|
|
892
898
|
if (!readerId || !site) return;
|
|
893
899
|
try {
|
|
894
900
|
const response = await getReaders({ site, page: 1, limit: 100 });
|
|
895
|
-
const readers = response?.items ?? response?.data?.items ?? response?.data?.readers ?? [];
|
|
896
|
-
hidQrReader.value =
|
|
901
|
+
const readers: unknown = response?.items ?? response?.data?.items ?? response?.data?.readers ?? [];
|
|
902
|
+
hidQrReader.value = Array.isArray(readers)
|
|
903
|
+
? readers.find((reader: unknown): reader is HidQrReaderSummary => (
|
|
904
|
+
typeof reader === "object"
|
|
905
|
+
&& reader !== null
|
|
906
|
+
&& String((reader as Record<string, unknown>)._id || "") === readerId
|
|
907
|
+
)) || null
|
|
908
|
+
: null;
|
|
897
909
|
} catch {
|
|
898
910
|
hidQrReader.value = null;
|
|
899
911
|
}
|
|
@@ -195,7 +195,7 @@ export default function useHidAmico() {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
function discoverReader(payload: Pick<HidReaderPayload, "baseUrl" | "username" | "password">) {
|
|
198
|
-
return useNuxtApp().$api<Record<string,
|
|
198
|
+
return useNuxtApp().$api<Record<string, unknown>>(`${basePath}/readers/discover`, {
|
|
199
199
|
method: "POST",
|
|
200
200
|
body: payload,
|
|
201
201
|
});
|