@7365admin1/layer-common 4.5.1-staging.298 → 4.5.1-staging.300
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/components/Chat/Bubbles.vue +94 -30
- package/components/Chat/Message.vue +281 -67
- package/components/FeedbackDetail.vue +1 -1
- package/components/HidProfileQrCode.vue +323 -0
- package/components/HidReaderUserRoster.vue +32 -2
- package/components/HidUserEnrollment.vue +59 -65
- package/components/WorkOrder/Detail.vue +1 -1
- package/composables/useComment.ts +9 -1
- package/composables/useHidAmico.ts +49 -0
- package/composables/useHidNavigation.ts +20 -12
- package/package.json +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +23 -0
- package/types/comment.d.ts +2 -0
- package/utils/chat-sender.ts +47 -0
|
@@ -28,6 +28,22 @@ export type HidReaderPayload = {
|
|
|
28
28
|
lastCallbackType?: string;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
export type HidProfileQr = {
|
|
32
|
+
readerId: string;
|
|
33
|
+
userId: string;
|
|
34
|
+
memberId: string;
|
|
35
|
+
hidUserId: string;
|
|
36
|
+
registration: string;
|
|
37
|
+
readerName: string;
|
|
38
|
+
portalName: string;
|
|
39
|
+
qrEnabled: boolean;
|
|
40
|
+
issued: boolean;
|
|
41
|
+
qrValue: string;
|
|
42
|
+
issuedAt: string;
|
|
43
|
+
/** null when the permission lookup itself failed, so "unknown" stays distinct from "no". */
|
|
44
|
+
assigned: boolean | null;
|
|
45
|
+
};
|
|
46
|
+
|
|
31
47
|
type HidIdentityPayload = {
|
|
32
48
|
site?: string;
|
|
33
49
|
hidUserId?: string | number;
|
|
@@ -166,6 +182,36 @@ export default function useHidAmico() {
|
|
|
166
182
|
});
|
|
167
183
|
}
|
|
168
184
|
|
|
185
|
+
/**
|
|
186
|
+
* The signed-in member's own QR code on one reader.
|
|
187
|
+
*
|
|
188
|
+
* No user id in the path: the server takes the caller from the session, so
|
|
189
|
+
* these cannot be pointed at somebody else. `assigned` in the response says
|
|
190
|
+
* whether the HID permissions screen actually admits this member to the
|
|
191
|
+
* reader - issuing a code does not grant access, and the screen has to be
|
|
192
|
+
* able to say so.
|
|
193
|
+
*/
|
|
194
|
+
function getProfileQr(readerId: string) {
|
|
195
|
+
return useNuxtApp().$api<{ data: HidProfileQr }>(
|
|
196
|
+
`${basePath}/readers/${readerId}/profile-qr`,
|
|
197
|
+
{ method: "GET" },
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function issueProfileQr(readerId: string) {
|
|
202
|
+
return useNuxtApp().$api<{ data: HidProfileQr }>(
|
|
203
|
+
`${basePath}/readers/${readerId}/profile-qr`,
|
|
204
|
+
{ method: "POST" },
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function deleteProfileQr(readerId: string) {
|
|
209
|
+
return useNuxtApp().$api<{ data: HidProfileQr }>(
|
|
210
|
+
`${basePath}/readers/${readerId}/profile-qr`,
|
|
211
|
+
{ method: "DELETE" },
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
169
215
|
function createReader(payload: HidReaderPayload) {
|
|
170
216
|
return useNuxtApp().$api<HidApiRecord>(`${basePath}/readers`, {
|
|
171
217
|
method: "POST",
|
|
@@ -526,6 +572,9 @@ export default function useHidAmico() {
|
|
|
526
572
|
|
|
527
573
|
return {
|
|
528
574
|
getReaders,
|
|
575
|
+
getProfileQr,
|
|
576
|
+
issueProfileQr,
|
|
577
|
+
deleteProfileQr,
|
|
529
578
|
discoverReader,
|
|
530
579
|
createReader,
|
|
531
580
|
updateReader,
|
|
@@ -46,25 +46,33 @@ export default function useHidNavigation() {
|
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
|
+
// "HID Reader Users" now points at `access-mgmt/administrator`, not at
|
|
50
|
+
// `access-mgmt/hid-users`.
|
|
51
|
+
//
|
|
52
|
+
// Both routes mount a roster of the reader's users, but only this one
|
|
53
|
+
// can act on them. `administrator` renders HidUserEnrollment WITHOUT
|
|
54
|
+
// `card-management`, and that prop is what gates the Enroll action:
|
|
55
|
+
// <template v-if="!props.cardManagement" #actions>
|
|
56
|
+
// `hid-users` renders HidReaderUserRoster, which is read-only apart
|
|
57
|
+
// from PIN management. So the menu entry with this name used to lead
|
|
58
|
+
// to the screen that cannot enrol, while the screen that can was
|
|
59
|
+
// reachable only by typing the URL.
|
|
60
|
+
//
|
|
61
|
+
// `hid-users` is left in place and simply unlisted - the same state
|
|
62
|
+
// `administrator` was in - so any existing link to it still resolves.
|
|
49
63
|
title: "HID Reader Users",
|
|
50
64
|
route: {
|
|
51
|
-
name: "org-site-access-mgmt-
|
|
65
|
+
name: "org-site-access-mgmt-administrator",
|
|
52
66
|
params: { org, site },
|
|
53
67
|
},
|
|
54
68
|
},
|
|
55
69
|
{
|
|
56
|
-
// The
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
// <template v-if="!props.cardManagement" #actions>
|
|
61
|
-
// HID Cards mounts the same component WITH `card-management`, so it
|
|
62
|
-
// deliberately hides Enroll. Until now nothing linked to
|
|
63
|
-
// `administrator`, so the only screen that draws Enroll was
|
|
64
|
-
// reachable by typing the URL and Enroll looked missing entirely.
|
|
65
|
-
title: "Administrator",
|
|
70
|
+
// The signed-in member's own pass, not somebody else's. Every other
|
|
71
|
+
// entry in this group acts on a resident or a visitor; this one has
|
|
72
|
+
// no subject but the caller.
|
|
73
|
+
title: "HID QR Code",
|
|
66
74
|
route: {
|
|
67
|
-
name: "org-site-access-mgmt-
|
|
75
|
+
name: "org-site-access-mgmt-hid-qr-code",
|
|
68
76
|
params: { org, site },
|
|
69
77
|
},
|
|
70
78
|
},
|
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.5.1-staging.
|
|
5
|
+
"version": "4.5.1-staging.300",
|
|
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,23 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-container fluid>
|
|
3
|
+
<HidEnabledGate
|
|
4
|
+
:site="siteId"
|
|
5
|
+
:org="orgId"
|
|
6
|
+
message="Enable HID as a service for this site before generating a QR code."
|
|
7
|
+
>
|
|
8
|
+
<HidProfileQrCode :site="siteId" />
|
|
9
|
+
</HidEnabledGate>
|
|
10
|
+
</v-container>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
definePageMeta({
|
|
15
|
+
layout: "default",
|
|
16
|
+
middleware: ["01-auth", "02-org"],
|
|
17
|
+
memberOnly: true,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const route = useRoute();
|
|
21
|
+
const siteId = computed(() => String(route.params.site ?? ""));
|
|
22
|
+
const orgId = computed(() => String(route.params.org ?? ""));
|
|
23
|
+
</script>
|
package/types/comment.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ declare type TCommentChat = {
|
|
|
9
9
|
updatedAt?: string;
|
|
10
10
|
createdByName?: string;
|
|
11
11
|
createdByType?: string;
|
|
12
|
+
/** The sender's avatar file id. The API has always returned it. */
|
|
13
|
+
createdByProfile?: string;
|
|
12
14
|
justify?: string;
|
|
13
15
|
feedback?: string;
|
|
14
16
|
seenByNames: Person;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a message's sender is described under their name in a chat thread.
|
|
3
|
+
*
|
|
4
|
+
* `createdByType` is the raw `user.type` from the API - lowercase, sometimes
|
|
5
|
+
* hyphenated, sometimes empty. The mobile chat used to print it as-is for
|
|
6
|
+
* everything except "site", so a resident read "provider" while a technician on
|
|
7
|
+
* the same thread read "Site Personnel". The web read nothing at all, because
|
|
8
|
+
* the whole panel was a mockup. Nothing here invents a job title: the one name
|
|
9
|
+
* the product already uses is kept, and anything else is simply made readable.
|
|
10
|
+
*
|
|
11
|
+
* Kept in step with `src/utils/chat-sender.ts` in the six mobile apps.
|
|
12
|
+
*/
|
|
13
|
+
export function formatSenderRole(
|
|
14
|
+
type: string | undefined | null,
|
|
15
|
+
sitePersonnelLabel = "Site Personnel"
|
|
16
|
+
): string {
|
|
17
|
+
const raw = (type ?? "").trim();
|
|
18
|
+
if (!raw) return "";
|
|
19
|
+
if (raw.toLowerCase() === "site") return sitePersonnelLabel;
|
|
20
|
+
|
|
21
|
+
return raw
|
|
22
|
+
.split(/[-_\s]+/)
|
|
23
|
+
.filter(Boolean)
|
|
24
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
25
|
+
.join(" ");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A thread already in reading order (oldest first, as `useComment.setComments`
|
|
30
|
+
* sorts it), split into one group per day so the panel can draw a single day
|
|
31
|
+
* heading above each day's messages instead of a date on every bubble.
|
|
32
|
+
*/
|
|
33
|
+
export function groupChatByDay<T extends { createdAt?: string | Date }>(
|
|
34
|
+
comments: T[],
|
|
35
|
+
formatDay: (value: string | Date) => string
|
|
36
|
+
): { day: string; messages: T[] }[] {
|
|
37
|
+
const days: { day: string; messages: T[] }[] = [];
|
|
38
|
+
|
|
39
|
+
for (const message of comments) {
|
|
40
|
+
const day = message.createdAt ? formatDay(message.createdAt) : "";
|
|
41
|
+
const current = days[days.length - 1];
|
|
42
|
+
if (current && current.day === day) current.messages.push(message);
|
|
43
|
+
else days.push({ day, messages: [message] });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return days;
|
|
47
|
+
}
|