@7365admin1/layer-common 4.16.0 → 4.17.0
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 +25 -4
- package/components/CameraWallTile.vue +13 -4
- package/components/VehicleAddSelection.vue +7 -2
- package/components/VehicleBulkAddForm.vue +1417 -0
- package/components/VehicleManagement.vue +31 -3
- package/composables/useVehicle.ts +35 -0
- package/package.json +1 -1
- package/utils/camera-wall.ts +30 -0
- package/utils/vehicle-bulk-rows.ts +584 -0
- package/utils/vehicle-bulk-sheet.ts +387 -0
|
@@ -83,6 +83,19 @@
|
|
|
83
83
|
<VehicleAddSelection @cancel="dialog.showSelection = false" @select="handleSelectVehicleStatus" />
|
|
84
84
|
</v-dialog>
|
|
85
85
|
|
|
86
|
+
<!-- Many whitelist vehicles at once. Wider than the one-vehicle form: it
|
|
87
|
+
is a sheet, and it stays open until the person closes it. -->
|
|
88
|
+
<v-dialog v-model="dialog.bulkVehicle" width="1200" persistent scrollable>
|
|
89
|
+
<VehicleBulkAddForm
|
|
90
|
+
v-if="dialog.bulkVehicle"
|
|
91
|
+
:site="props.site"
|
|
92
|
+
:org="org"
|
|
93
|
+
@back="handleBackToSelection"
|
|
94
|
+
@added="getVehiclesRefresh"
|
|
95
|
+
@close="handleBulkClose"
|
|
96
|
+
/>
|
|
97
|
+
</v-dialog>
|
|
98
|
+
|
|
86
99
|
<v-dialog v-model="dialog.createVehicle" v-if="vehicleType" width="450" persistent>
|
|
87
100
|
<VehicleForm :type="vehicleType" :mode="mode" :vehicle-data="selectedVehicleObject"
|
|
88
101
|
:plate-number-id="selectedPlateNumberId" :name-hints="nameHints" @back="handleBackToSelection" @done="handleAddVehicleComplete"
|
|
@@ -308,7 +321,8 @@ const dialog = reactive({
|
|
|
308
321
|
showMoreActions: false,
|
|
309
322
|
approveVehicle: false,
|
|
310
323
|
restoreVehicle: false,
|
|
311
|
-
updateVehicleType: false
|
|
324
|
+
updateVehicleType: false,
|
|
325
|
+
bulkVehicle: false
|
|
312
326
|
});
|
|
313
327
|
|
|
314
328
|
|
|
@@ -515,15 +529,29 @@ function runVehicleAction(key: VehicleActionKey, plate: TPlateNumber) {
|
|
|
515
529
|
}
|
|
516
530
|
}
|
|
517
531
|
|
|
518
|
-
function handleSelectVehicleStatus(value: TVehicleType) {
|
|
519
|
-
vehicleType.value = value;
|
|
532
|
+
function handleSelectVehicleStatus(value: TVehicleType | "whitelist-bulk") {
|
|
520
533
|
dialog.showSelection = false;
|
|
534
|
+
|
|
535
|
+
// The bulk sheet is its own screen - it adds many whitelist vehicles and
|
|
536
|
+
// reports on each row - so it does not go through VehicleForm.
|
|
537
|
+
if (value === "whitelist-bulk") {
|
|
538
|
+
dialog.bulkVehicle = true;
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
vehicleType.value = value;
|
|
521
543
|
dialog.createVehicle = true;
|
|
522
544
|
}
|
|
523
545
|
|
|
546
|
+
function handleBulkClose() {
|
|
547
|
+
dialog.bulkVehicle = false;
|
|
548
|
+
getVehiclesRefresh();
|
|
549
|
+
}
|
|
550
|
+
|
|
524
551
|
function handleBackToSelection() {
|
|
525
552
|
dialog.showSelection = true;
|
|
526
553
|
dialog.createVehicle = false;
|
|
554
|
+
dialog.bulkVehicle = false;
|
|
527
555
|
vehicleType.value = null;
|
|
528
556
|
}
|
|
529
557
|
|
|
@@ -27,6 +27,40 @@ export default function useVehicle() {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* The Whitelist (Bulk) sheet: many vehicles in one request.
|
|
32
|
+
*
|
|
33
|
+
* Every row carries its own `id`, and the answer hands that id back with
|
|
34
|
+
* `ok` and a sentence, so the sheet can mark each row and send only the ones
|
|
35
|
+
* that did not go on. The server adds each row exactly as `addVehicle` adds
|
|
36
|
+
* one - same status rule, same ANPR cameras.
|
|
37
|
+
*/
|
|
38
|
+
async function addVehiclesBulk(payload: {
|
|
39
|
+
site: string;
|
|
40
|
+
org: string;
|
|
41
|
+
category?: string;
|
|
42
|
+
rows: Array<{
|
|
43
|
+
id: string;
|
|
44
|
+
block: string;
|
|
45
|
+
level: string;
|
|
46
|
+
unit: string;
|
|
47
|
+
name: string;
|
|
48
|
+
plateNumber: string;
|
|
49
|
+
nric?: string;
|
|
50
|
+
phoneNumber?: string;
|
|
51
|
+
}>;
|
|
52
|
+
}) {
|
|
53
|
+
return await useNuxtApp().$api<{
|
|
54
|
+
message: string;
|
|
55
|
+
added: number;
|
|
56
|
+
failed: number;
|
|
57
|
+
results: Array<{ id: string; ok: boolean; message: string }>;
|
|
58
|
+
}>("/api/vehicles/bulk", {
|
|
59
|
+
method: "POST",
|
|
60
|
+
body: payload,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
30
64
|
async function updateVehicle(id: string, payload: Partial<TVehiclePayload>) {
|
|
31
65
|
return await useNuxtApp().$api<Record<string, any>>(`/api/vehicles/id/${id}`, {
|
|
32
66
|
method: "PUT",
|
|
@@ -147,6 +181,7 @@ function getSpecificVehicleById(id: string){
|
|
|
147
181
|
return {
|
|
148
182
|
getVehicles,
|
|
149
183
|
addVehicle,
|
|
184
|
+
addVehiclesBulk,
|
|
150
185
|
getCustomSeasonPassTypes,
|
|
151
186
|
getVehicleById,
|
|
152
187
|
updateVehicle,
|
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
|
+
"version": "4.17.0",
|
|
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.",
|
package/utils/camera-wall.ts
CHANGED
|
@@ -59,6 +59,20 @@ export type TWallCamera = {
|
|
|
59
59
|
* renderable live-video page — it is the picture, not a fragment to resolve.
|
|
60
60
|
*/
|
|
61
61
|
host?: string;
|
|
62
|
+
/**
|
|
63
|
+
* The SIGNED live address, when the server has one for this camera.
|
|
64
|
+
*
|
|
65
|
+
* The relay's live routes are being closed behind a signature the server
|
|
66
|
+
* mints per request (`exp` + `sig`, covering the channel). That signature
|
|
67
|
+
* cannot live on `host`: `host` is the stored record, copied into patrol
|
|
68
|
+
* routes and re-read by the server's own `isRelayPlayerUrl`, which rejects an
|
|
69
|
+
* address carrying a query. So the server hands the signed address over
|
|
70
|
+
* beside it, and leaves `host` exactly as it always was.
|
|
71
|
+
*
|
|
72
|
+
* Absent for a camera whose relay is not configured — and then the wall falls
|
|
73
|
+
* back to `host` and behaves precisely as it does today.
|
|
74
|
+
*/
|
|
75
|
+
liveUrl?: string | null;
|
|
62
76
|
type?: string;
|
|
63
77
|
status?: string;
|
|
64
78
|
capabilities?: Record<string, TWallCapability>;
|
|
@@ -714,6 +728,22 @@ export function playerSignal(data: unknown): TPlayerSignal {
|
|
|
714
728
|
* that is not a URL at all. Kept here so the rule is tested rather than
|
|
715
729
|
* inlined in a component.
|
|
716
730
|
*/
|
|
731
|
+
/**
|
|
732
|
+
* The address the player is actually pointed at.
|
|
733
|
+
*
|
|
734
|
+
* `liveUrl` is the server's signed address and wins whenever it is there;
|
|
735
|
+
* `host` is the unsigned stored one and is what every camera used before
|
|
736
|
+
* signing existed. Never rebuilt, never re-encoded, never stripped of its
|
|
737
|
+
* query — a signature dropped here is a camera that goes black the day the
|
|
738
|
+
* relay starts enforcing, with nothing on screen to say why.
|
|
739
|
+
*/
|
|
740
|
+
export function liveSource(
|
|
741
|
+
camera: Pick<TWallCamera, "host" | "liveUrl"> | null | undefined
|
|
742
|
+
): string {
|
|
743
|
+
const signed = typeof camera?.liveUrl === "string" ? camera.liveUrl.trim() : "";
|
|
744
|
+
return signed || camera?.host || "";
|
|
745
|
+
}
|
|
746
|
+
|
|
717
747
|
export function playerOrigin(host: string | null | undefined): string {
|
|
718
748
|
if (!host) return "";
|
|
719
749
|
try {
|