@7365admin1/layer-common 4.2.23 → 4.2.25
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/CHANGELOG.md +34 -4
- package/assets/css/screens.css +132 -0
- package/assets/css/shell.css +4 -0
- package/components/VisitorSocketPopUp.vue +71 -36
- package/composables/useLocalAuth.ts +34 -16
- package/composables/useVisitorSocket.ts +31 -0
- package/package.json +1 -1
- package/plugins/secure-member.client.ts +30 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 4.2.25
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 332119d: Redraw the ANPR "New plate detected" toast on the product's own card surface
|
|
8
|
+
|
|
9
|
+
The realtime plate toast was Vuetify's default: a flat `color="info"` slab with
|
|
10
|
+
the plate concatenated onto the label at the same weight, an underlined
|
|
11
|
+
uppercase text link for the action and a bare 24px cross. It matched nothing
|
|
12
|
+
else in the product.
|
|
13
|
+
|
|
14
|
+
It is now the design's card - `--card` on a `--border` rule at `--r-card` with
|
|
15
|
+
the menu shadow - with the plate set at 21px above a 13.5px label, a
|
|
16
|
+
`directions_car` glyph, `AppButton`'s ghost variant for the action and a 44px
|
|
17
|
+
close button with an accessible name. The message sits in a polite live region
|
|
18
|
+
and Escape dismisses it.
|
|
19
|
+
|
|
20
|
+
Presentation only: when the toast fires, where it links and how long it stays
|
|
21
|
+
are unchanged.
|
|
22
|
+
|
|
23
|
+
## 4.2.24
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- ce5231a: Stop the app root waiting on two API round trips before it can paint, and start the third one alongside them.
|
|
28
|
+
|
|
29
|
+
`secure-member.client.ts` awaited the member lookup and then, serially, the role document inside `router.beforeEach`, so nothing painted on any route -- not even the neutral "signing you in" hold -- until both had come back. The app root renders no permission-gated surface, so it paid for a gate it does not have. On the root only (`to.name === "index"` and no `memberOnly`) the resolve is now started rather than awaited; every other route, and a root that does carry `memberOnly`, awaits exactly as before, and a route reached while the resolve is still in flight awaits that same promise.
|
|
30
|
+
|
|
31
|
+
`useLocalAuth.getCurrentUser` was the third round trip and it started last, because page setup only runs after the guard returns. The guard now primes it once per page load in parallel with the member lookup, and `getCurrentUser` collapses concurrent callers onto one request so the page asking again costs nothing. `authenticate()` goes through the same request instead of its own `useLazyAsyncData` copy; with no `user` cookie it takes the redirect-to-index branch directly rather than after a request that could only fail.
|
|
32
|
+
|
|
3
33
|
## 4.2.23
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
|
@@ -755,11 +785,11 @@
|
|
|
755
785
|
`utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
|
|
756
786
|
own rule from two endpoints the console already calls, unprojected:
|
|
757
787
|
|
|
758
|
-
|
|
759
|
-
|
|
788
|
+
GET /api/members/user/:user/app/admin the Seven365 staff membership
|
|
789
|
+
GET /api/roles/id/:role that membership's role document
|
|
760
790
|
|
|
761
|
-
|
|
762
|
-
|
|
791
|
+
owner = member.type === "admin" && role.type === "admin" && role.default === true
|
|
792
|
+
staff = member.type === "admin" && role.type === "admin"
|
|
763
793
|
|
|
764
794
|
`role.default` is the marker because it is the only property of a platform
|
|
765
795
|
staff role no API caller can set - `role.controller.ts` validates create and
|
package/assets/css/screens.css
CHANGED
|
@@ -896,6 +896,138 @@
|
|
|
896
896
|
text-transform: none;
|
|
897
897
|
}
|
|
898
898
|
|
|
899
|
+
/* ------------------------------------------------------------------ */
|
|
900
|
+
/* The ANPR plate toast (`components/VisitorSocketPopUp.vue`). */
|
|
901
|
+
/* */
|
|
902
|
+
/* The generic toast above is a coloured slab with a sentence on it, */
|
|
903
|
+
/* which is the wrong shape for this one: it carries a PAYLOAD - the */
|
|
904
|
+
/* plate the camera read - and the operator reads the number, not the */
|
|
905
|
+
/* sentence. So it is the design's own CARD instead: `--card` on a */
|
|
906
|
+
/* `--border` rule at `--r-card`, the menu shadow, and the plate set */
|
|
907
|
+
/* two steps above the label. */
|
|
908
|
+
/* */
|
|
909
|
+
/* No colour is written down here. The tint is `--info` over */
|
|
910
|
+
/* `--info-bg`, the same pair `.tone-info` paints a chip with, so the */
|
|
911
|
+
/* toast follows the theme instead of Vuetify's flat `color="info"` */
|
|
912
|
+
/* fill - which is what the owner was shown and what this replaces. */
|
|
913
|
+
/* ------------------------------------------------------------------ */
|
|
914
|
+
.anpr-toast .v-snackbar__wrapper {
|
|
915
|
+
background: var(--card);
|
|
916
|
+
color: var(--text);
|
|
917
|
+
border: 1px solid var(--border);
|
|
918
|
+
border-radius: var(--r-card);
|
|
919
|
+
box-shadow: var(--shadow-menu);
|
|
920
|
+
/* One width for every read, so the toast does not resize between plates.
|
|
921
|
+
Vuetify's own 344px minimum is left behind deliberately: a plate set at
|
|
922
|
+
21px needs the room, and a long read wraps inside this box. Vuetify's own
|
|
923
|
+
344px minimum is zeroed first, or a narrow phone gets a toast wider than
|
|
924
|
+
the screen. */
|
|
925
|
+
min-width: 0;
|
|
926
|
+
width: min(92vw, 400px);
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
.anpr-toast .v-snackbar__content {
|
|
930
|
+
width: 100%;
|
|
931
|
+
padding: 14px 14px 16px 16px;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
.anpr-toast__row {
|
|
935
|
+
display: flex;
|
|
936
|
+
align-items: flex-start;
|
|
937
|
+
gap: 12px;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
/* The leading glyph says WHAT was detected - a vehicle, not "information".
|
|
941
|
+
`mdi-car` resolves to `directions_car` through `utils/materialSymbols.ts`. */
|
|
942
|
+
.anpr-toast__icon {
|
|
943
|
+
flex: 0 0 auto;
|
|
944
|
+
display: inline-flex;
|
|
945
|
+
align-items: center;
|
|
946
|
+
justify-content: center;
|
|
947
|
+
width: 34px;
|
|
948
|
+
height: 34px;
|
|
949
|
+
border-radius: var(--r-pill);
|
|
950
|
+
background: var(--info-bg);
|
|
951
|
+
color: var(--info);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
.anpr-toast__text {
|
|
955
|
+
flex: 1 1 auto;
|
|
956
|
+
/* Without this a long read stretches the flex item instead of wrapping. */
|
|
957
|
+
min-width: 0;
|
|
958
|
+
display: flex;
|
|
959
|
+
flex-direction: column;
|
|
960
|
+
gap: 2px;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
/* The label is the SMALL half. `--fs-btn` is the size the generic toast
|
|
964
|
+
already uses, so nothing here is set smaller than the product's own toast
|
|
965
|
+
text - the plate is what got bigger. */
|
|
966
|
+
/* `--text2`, not `--muted`. `utils/theme.ts` measures `--muted` at 3.24:1 on a
|
|
967
|
+
card - below AA - and this is real text, not a graphical mark. */
|
|
968
|
+
.anpr-toast__label {
|
|
969
|
+
font-size: var(--fs-btn);
|
|
970
|
+
font-weight: var(--fw-btn);
|
|
971
|
+
line-height: 1.3;
|
|
972
|
+
color: var(--text2);
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
/* The payload. Tabular figures so `0`/`8` and `1`/`7` cannot be mistaken for
|
|
976
|
+
one another at a barrier, and `anywhere` so a malformed read wraps inside
|
|
977
|
+
the card rather than widening it. */
|
|
978
|
+
.anpr-toast__plate {
|
|
979
|
+
font-size: 21px;
|
|
980
|
+
font-weight: var(--fw-h1);
|
|
981
|
+
letter-spacing: 0.05em;
|
|
982
|
+
line-height: 1.25;
|
|
983
|
+
color: var(--text);
|
|
984
|
+
font-variant-numeric: tabular-nums;
|
|
985
|
+
overflow-wrap: anywhere;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/* 44px, the touch minimum - the bare 24px Vuetify cross this replaces was
|
|
989
|
+
under half that. Pulled out by its own padding so the glyph still sits on
|
|
990
|
+
the card's optical edge. */
|
|
991
|
+
.anpr-toast__close {
|
|
992
|
+
flex: 0 0 auto;
|
|
993
|
+
display: inline-flex;
|
|
994
|
+
align-items: center;
|
|
995
|
+
justify-content: center;
|
|
996
|
+
width: 44px;
|
|
997
|
+
height: 44px;
|
|
998
|
+
margin: -10px -10px 0 0;
|
|
999
|
+
padding: 0;
|
|
1000
|
+
border: 0;
|
|
1001
|
+
border-radius: var(--r-inner-sm);
|
|
1002
|
+
background: transparent;
|
|
1003
|
+
color: var(--muted);
|
|
1004
|
+
cursor: pointer;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
.anpr-toast__close:hover {
|
|
1008
|
+
background: var(--hover);
|
|
1009
|
+
color: var(--text);
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
.anpr-toast__close:focus-visible {
|
|
1013
|
+
outline: 2px solid var(--accent);
|
|
1014
|
+
outline-offset: 2px;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
/* Indented to the text column, so the button reads as belonging to the plate
|
|
1018
|
+
above it rather than to the card's edge. */
|
|
1019
|
+
.anpr-toast__actions {
|
|
1020
|
+
display: flex;
|
|
1021
|
+
margin: 12px 0 0 46px;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
/* `AppButton`'s ghost is 40px everywhere else in the product; in a toast the
|
|
1025
|
+
operator is often on a tablet at a gate, so it is raised to the touch
|
|
1026
|
+
minimum here rather than changed for every screen. */
|
|
1027
|
+
.anpr-toast__actions .app-btn {
|
|
1028
|
+
min-height: 44px;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
899
1031
|
/* ------------------------------------------------------------------ */
|
|
900
1032
|
/* The "Back" link that sits above a page title. */
|
|
901
1033
|
/* `SpecificAttr.vue` (17 caller files) and `Container/Standard.vue`. */
|
package/assets/css/shell.css
CHANGED
|
@@ -284,8 +284,12 @@
|
|
|
284
284
|
pointer-events: none;
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
+
/* `button` is on the list because the design's own controls - `AppButton` and
|
|
288
|
+
the plate toast's close - are plain `<button>` elements, not `v-btn`. Left
|
|
289
|
+
off, a redesigned toast draws a button that cannot be clicked. */
|
|
287
290
|
.v-snackbar .v-snackbar__wrapper .v-btn,
|
|
288
291
|
.v-snackbar .v-snackbar__wrapper a,
|
|
292
|
+
.v-snackbar .v-snackbar__wrapper button,
|
|
289
293
|
.v-snackbar .v-snackbar__wrapper [role="button"] {
|
|
290
294
|
pointer-events: auto;
|
|
291
295
|
}
|
|
@@ -31,38 +31,54 @@
|
|
|
31
31
|
</ul>
|
|
32
32
|
</section> -->
|
|
33
33
|
|
|
34
|
+
<!--
|
|
35
|
+
THE PLATE TOAST.
|
|
36
|
+
|
|
37
|
+
The estate's own toast surface (`.app-toast`, `assets/css/screens.css`)
|
|
38
|
+
rather than Vuetify's flat `color="info"` slab, and the plate is set
|
|
39
|
+
apart from the label because the plate IS the payload - a guard reads the
|
|
40
|
+
number, not the sentence around it. Nothing here changes when the toast
|
|
41
|
+
fires, what it links to, or how long it stays; only how it is drawn.
|
|
42
|
+
-->
|
|
34
43
|
<v-snackbar
|
|
35
44
|
v-if="!isUnregisteredVisitorRoute && enableUnregisteredSnackbar && canViewVisitor"
|
|
36
45
|
v-model="snackBarMessage.modal"
|
|
37
|
-
:color="snackBarMessage.color"
|
|
38
46
|
:timeout="snackBarMessage.timeout"
|
|
39
47
|
location="bottom center"
|
|
40
|
-
class="
|
|
48
|
+
class="app-toast anpr-toast"
|
|
41
49
|
multi-line
|
|
42
50
|
:z-index="100000000"
|
|
43
51
|
>
|
|
44
|
-
<div class="
|
|
45
|
-
<
|
|
46
|
-
<
|
|
52
|
+
<div class="anpr-toast__row">
|
|
53
|
+
<span class="anpr-toast__icon" aria-hidden="true">
|
|
54
|
+
<v-icon icon="mdi-car" :size="20" />
|
|
55
|
+
</span>
|
|
56
|
+
|
|
57
|
+
<!--
|
|
58
|
+
One live region for both halves, so a screen reader announces
|
|
59
|
+
"New plate detected SLD7537A" as a single message. `polite`: a plate
|
|
60
|
+
read must not interrupt whatever the operator is being told.
|
|
61
|
+
-->
|
|
62
|
+
<div class="anpr-toast__text" role="status" aria-live="polite">
|
|
63
|
+
<span class="anpr-toast__label">{{ plateCopy.label }}</span>
|
|
64
|
+
<span class="anpr-toast__plate">{{ plateCopy.plate }}</span>
|
|
47
65
|
</div>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
@click="
|
|
66
|
+
|
|
67
|
+
<button
|
|
68
|
+
type="button"
|
|
69
|
+
class="anpr-toast__close"
|
|
70
|
+
aria-label="Dismiss plate notification"
|
|
71
|
+
@click="handleCloseSnackbar"
|
|
54
72
|
>
|
|
55
|
-
|
|
56
|
-
</
|
|
73
|
+
<v-icon icon="mdi-close" :size="18" />
|
|
74
|
+
</button>
|
|
57
75
|
</div>
|
|
58
76
|
|
|
59
|
-
<
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
/>
|
|
65
|
-
</template>
|
|
77
|
+
<div class="anpr-toast__actions">
|
|
78
|
+
<AppButton variant="ghost" @click="goToUnregistered">
|
|
79
|
+
Go to Unregistered
|
|
80
|
+
</AppButton>
|
|
81
|
+
</div>
|
|
66
82
|
</v-snackbar>
|
|
67
83
|
|
|
68
84
|
<!--
|
|
@@ -138,12 +154,13 @@ const lastPlateNumber = ref("");
|
|
|
138
154
|
|
|
139
155
|
const snackBarMessage = reactive({
|
|
140
156
|
timeout: 3000,
|
|
141
|
-
|
|
142
|
-
|
|
157
|
+
/** The camera's raw read. `plateToast` decides what is drawn for it. */
|
|
158
|
+
plateNumber: "",
|
|
143
159
|
modal: false,
|
|
144
|
-
isUnregistered: false,
|
|
145
160
|
});
|
|
146
161
|
|
|
162
|
+
const plateCopy = computed(() => plateToast(snackBarMessage.plateNumber));
|
|
163
|
+
|
|
147
164
|
const permanentMessageDialog = reactive({
|
|
148
165
|
modal: false,
|
|
149
166
|
text: "",
|
|
@@ -226,20 +243,21 @@ const handleCloseSnackbar = () => {
|
|
|
226
243
|
|
|
227
244
|
};
|
|
228
245
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
246
|
+
/*
|
|
247
|
+
* Several reads in quick succession REPLACE each other in this one toast -
|
|
248
|
+
* they have never stacked, and they still do not. At a busy gate a queue of
|
|
249
|
+
* toasts would put the operator several plates behind the barrier; the newest
|
|
250
|
+
* read is the one that matters, and the ones before it are on the Unregistered
|
|
251
|
+
* tab the toast links to.
|
|
252
|
+
*/
|
|
253
|
+
const showPlate = (plateNumber: string) => {
|
|
234
254
|
if (!enableUnregisteredSnackbar.value) {
|
|
235
255
|
return;
|
|
236
256
|
}
|
|
237
257
|
|
|
238
|
-
snackBarMessage.
|
|
239
|
-
snackBarMessage.color = color;
|
|
258
|
+
snackBarMessage.plateNumber = plateNumber;
|
|
240
259
|
snackBarMessage.modal = true;
|
|
241
260
|
snackBarMessage.timeout = 20000;
|
|
242
|
-
snackBarMessage.isUnregistered = isUnregistered;
|
|
243
261
|
};
|
|
244
262
|
|
|
245
263
|
const connectSocket = () => {
|
|
@@ -270,11 +288,7 @@ const connectSocket = () => {
|
|
|
270
288
|
newVisitor.value = data;
|
|
271
289
|
|
|
272
290
|
if (isCheckIn) {
|
|
273
|
-
|
|
274
|
-
`New plate detected: ${plateNumber}`,
|
|
275
|
-
"info",
|
|
276
|
-
true
|
|
277
|
-
);
|
|
291
|
+
showPlate(plateNumber);
|
|
278
292
|
lastPlateNumber.value = plateNumber;
|
|
279
293
|
return;
|
|
280
294
|
}
|
|
@@ -359,7 +373,28 @@ watch(enableUnregisteredSnackbar, (enabled) => {
|
|
|
359
373
|
}
|
|
360
374
|
});
|
|
361
375
|
|
|
376
|
+
/*
|
|
377
|
+
* Escape closes it. The close button is a real `<button>` and is reachable by
|
|
378
|
+
* tab, so the toast was already dismissible from the keyboard; Escape is what
|
|
379
|
+
* anyone actually reaches for, and it is bound only while the toast is up.
|
|
380
|
+
*/
|
|
381
|
+
const onEscape = (event: KeyboardEvent) => {
|
|
382
|
+
if (event.key === "Escape") handleCloseSnackbar();
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
watch(
|
|
386
|
+
() => snackBarMessage.modal,
|
|
387
|
+
(open) => {
|
|
388
|
+
if (typeof document === "undefined") return;
|
|
389
|
+
if (open) document.addEventListener("keydown", onEscape);
|
|
390
|
+
else document.removeEventListener("keydown", onEscape);
|
|
391
|
+
}
|
|
392
|
+
);
|
|
393
|
+
|
|
362
394
|
onUnmounted(() => {
|
|
395
|
+
if (typeof document !== "undefined") {
|
|
396
|
+
document.removeEventListener("keydown", onEscape);
|
|
397
|
+
}
|
|
363
398
|
disconnectSocket();
|
|
364
399
|
});
|
|
365
400
|
|
|
@@ -1,25 +1,36 @@
|
|
|
1
|
+
// One in-flight `GET /api/users/id/:id` per page load, shared by every caller.
|
|
2
|
+
// These apps are `ssr: false`, so module scope is exactly one browser session.
|
|
3
|
+
// The route guard starts this request in parallel with the member lookup and
|
|
4
|
+
// the first screen asks for it again on setup; without this that is two
|
|
5
|
+
// identical requests instead of one.
|
|
6
|
+
let currentUserRequest: Promise<any> | null = null;
|
|
7
|
+
|
|
1
8
|
export default function useLocalAuth() {
|
|
2
9
|
const { cookieConfig } = useRuntimeConfig().public;
|
|
3
10
|
|
|
4
11
|
const currentUser = useState<TUser | null>("currentUser", () => null);
|
|
5
12
|
|
|
13
|
+
// Goes through the same request `getCurrentUser` makes, so it joins the one
|
|
14
|
+
// the route guard already started instead of issuing a second.
|
|
15
|
+
//
|
|
16
|
+
// DELIBERATELY NOT AWAITED INSIDE. 19 pages call this with a top-level
|
|
17
|
+
// `await`, and the `useLazyAsyncData` it replaces returned before its request
|
|
18
|
+
// did; awaiting the request here would newly suspend every one of them.
|
|
6
19
|
async function authenticate() {
|
|
7
20
|
const user = useCookie("user", cookieConfig).value;
|
|
8
21
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
22
|
+
// No cookie used to mean a request for `/api/users/id/undefined` that could
|
|
23
|
+
// only fail. Same destination, one round trip earlier.
|
|
24
|
+
if (!user) {
|
|
25
|
+
currentUser.value = null;
|
|
26
|
+
navigateTo({ name: "index" });
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
17
29
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
30
|
+
getCurrentUser().catch(() => {
|
|
31
|
+
currentUser.value = null;
|
|
32
|
+
// Redirect to login page if user authentication fails
|
|
33
|
+
navigateTo({ name: "index" });
|
|
23
34
|
});
|
|
24
35
|
}
|
|
25
36
|
|
|
@@ -63,9 +74,16 @@ export default function useLocalAuth() {
|
|
|
63
74
|
currentUser.value = null;
|
|
64
75
|
return null;
|
|
65
76
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
if (!currentUserRequest) {
|
|
78
|
+
currentUserRequest = useNuxtApp()
|
|
79
|
+
.$api<TUser>(`/api/users/id/${user}`, { method: "GET" })
|
|
80
|
+
.finally(() => {
|
|
81
|
+
// Cleared on success AND on failure: this collapses callers that
|
|
82
|
+
// overlap, it does not cache the answer.
|
|
83
|
+
currentUserRequest = null;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const _user = (await currentUserRequest) as TUser;
|
|
69
87
|
currentUser.value = _user;
|
|
70
88
|
return _user;
|
|
71
89
|
}
|
|
@@ -33,6 +33,37 @@ export const cameraAlertMessage = (messages: string[]): string => {
|
|
|
33
33
|
);
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* The two halves of the plate toast.
|
|
38
|
+
*
|
|
39
|
+
* The camera's read is the payload, so it is returned SEPARATELY from the
|
|
40
|
+
* label rather than concatenated into one sentence - the toast sets it at its
|
|
41
|
+
* own size and weight, and a run-on `"New plate detected: SLD7537A"` cannot be
|
|
42
|
+
* typeset that way.
|
|
43
|
+
*
|
|
44
|
+
* `plate` is never empty: the socket only raises this toast when a plate was
|
|
45
|
+
* read, but a build that ever calls it without one gets a word rather than a
|
|
46
|
+
* dangling label. A read is a handful of characters - anything past
|
|
47
|
+
* `MAX_PLATE_CHARS` is a malformed payload, not a number plate, and is cut so
|
|
48
|
+
* it cannot stretch the toast off the screen.
|
|
49
|
+
*/
|
|
50
|
+
export const MAX_PLATE_CHARS = 24;
|
|
51
|
+
|
|
52
|
+
export const plateToast = (
|
|
53
|
+
plateNumber?: string | null,
|
|
54
|
+
): { label: string; plate: string } => {
|
|
55
|
+
const plate = (plateNumber ?? "").trim();
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
label: "New plate detected",
|
|
59
|
+
plate: plate
|
|
60
|
+
? plate.length > MAX_PLATE_CHARS
|
|
61
|
+
? `${plate.slice(0, MAX_PLATE_CHARS)}…`
|
|
62
|
+
: plate
|
|
63
|
+
: "Unknown",
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
36
67
|
export const useVisitorSocket = () => {
|
|
37
68
|
const socketUnregisteredVisitorTrigger = useState(
|
|
38
69
|
"socketUnregisteredVisitorTrigger",
|
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.2.
|
|
5
|
+
"version": "4.2.25",
|
|
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.",
|
|
@@ -13,6 +13,7 @@ export default defineNuxtPlugin(() => {
|
|
|
13
13
|
const { getByUserType } = useMember();
|
|
14
14
|
const { getRoleById } = useRole();
|
|
15
15
|
const { getById } = useOrg();
|
|
16
|
+
const { getCurrentUser } = useLocalAuth();
|
|
16
17
|
|
|
17
18
|
const { userAppRole, userAppRoleStatus, id, orgNature } = useLocalSetup();
|
|
18
19
|
|
|
@@ -21,6 +22,7 @@ export default defineNuxtPlugin(() => {
|
|
|
21
22
|
let resolvedFor: string | null = null;
|
|
22
23
|
let inFlight: Promise<void> | null = null;
|
|
23
24
|
let hasMemberDocument = false;
|
|
25
|
+
let primedUser = false;
|
|
24
26
|
|
|
25
27
|
// Deliberately never redirects and never throws.
|
|
26
28
|
//
|
|
@@ -68,13 +70,40 @@ export default defineNuxtPlugin(() => {
|
|
|
68
70
|
router.beforeEach(async (to) => {
|
|
69
71
|
const userId = useCookie("user").value ?? "";
|
|
70
72
|
|
|
73
|
+
// The signed-in user's own record is a THIRD round trip and almost every
|
|
74
|
+
// first screen wants it, but page setup only runs once the guard below has
|
|
75
|
+
// returned -- so it used to start after both lookups had finished. Started
|
|
76
|
+
// here it runs alongside them. `getCurrentUser` collapses concurrent
|
|
77
|
+
// callers onto one request, so the page asking for it again costs nothing.
|
|
78
|
+
if (userId && !primedUser) {
|
|
79
|
+
primedUser = true;
|
|
80
|
+
void getCurrentUser().catch(() => {
|
|
81
|
+
// A failed prime is not this guard's business: every caller that needs
|
|
82
|
+
// the user asks again and handles its own failure.
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
71
86
|
// Resolve for EVERY authenticated route, not only `memberOnly` ones. Gates
|
|
72
87
|
// are read on pages that carry no such flag -- the staff console cannot
|
|
73
88
|
// carry it at all, it has no organisation in the route -- and until this
|
|
74
89
|
// ran there the role stayed null for the life of the page: gates that
|
|
75
90
|
// default open granted everything, gates that fail closed denied everything.
|
|
76
91
|
// Awaited, so no gate is ever evaluated against an unresolved role.
|
|
77
|
-
|
|
92
|
+
//
|
|
93
|
+
// The ONE exception is the app root. It renders no permission-gated
|
|
94
|
+
// surface -- it reads the signed-in email, and leaves -- so waiting two
|
|
95
|
+
// serial round trips there delays the first paint of every app by the
|
|
96
|
+
// length of both and buys nothing. Started, not awaited. Every other
|
|
97
|
+
// route, root-or-not, still awaits, and a route reached while this is
|
|
98
|
+
// still in flight awaits THIS promise: `resolveAppRole` returns the
|
|
99
|
+
// in-flight one rather than starting a second.
|
|
100
|
+
if (userId) {
|
|
101
|
+
if (to.name === "index" && !to.meta?.memberOnly) {
|
|
102
|
+
void resolveAppRole(userId);
|
|
103
|
+
} else {
|
|
104
|
+
await resolveAppRole(userId);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
78
107
|
|
|
79
108
|
const isMember = to.meta?.memberOnly;
|
|
80
109
|
|