@7365admin1/layer-common 4.32.0 → 4.32.1-staging.365
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 +4 -4
- package/assets/css/robot-hero.css +26 -0
- package/components/AccessCardAddForm.vue +5 -4
- package/components/AccessCardAssignToUnitForm.vue +3 -2
- package/components/AccessCardPreviewDialog.vue +4 -3
- package/components/Dialog/DeleteConfirmation.vue +17 -2
- package/components/Dialog/ReusablePrompt.vue +26 -3
- package/components/Dialog/UpdateMoreAction.vue +11 -1
- package/components/DocumentForm.vue +407 -112
- package/components/DocumentManagement.vue +213 -12
- package/components/EntryPass/QrTemplatePreview.vue +21 -25
- package/components/EntryPassInformation.vue +119 -24
- package/components/Facility/BookingSetup.vue +63 -0
- package/components/HidAccessLogDashboard.vue +41 -8
- package/components/HidAccessPermissions.vue +424 -0
- package/components/HidIntercomManagement.vue +148 -14
- package/components/HidProfileQrCode.vue +332 -0
- package/components/HidReaderManagement.vue +26 -0
- package/components/HidReaderUserRoster.vue +44 -3
- package/components/HidUserEnrollment.vue +845 -155
- package/components/InvitationClientForm.vue +19 -1
- package/components/NotificationBell.vue +39 -3
- package/components/Robot/ActivityLog.vue +113 -0
- package/components/Robot/AlertsTable.vue +1 -0
- package/components/Robot/Detail.vue +8 -5
- package/components/Robot/Form.vue +170 -214
- package/components/Robot/MiniMap.vue +7 -1
- package/components/Robot/SiteAlerts.vue +117 -0
- package/components/Robot/SiteScreen.vue +69 -5
- package/components/VehicleForm.vue +45 -2
- package/components/VehicleManagement.vue +95 -10
- package/components/VisitorManagement.vue +267 -5
- package/composables/useAccessManagement.ts +5 -0
- package/composables/useCleaningPermission.ts +4 -4
- package/composables/useCommonPermission.ts +16 -0
- package/composables/useDocument.ts +7 -0
- package/composables/useFacility.ts +11 -0
- package/composables/useHidAmico.ts +117 -0
- package/composables/useHidNavigation.ts +25 -1
- package/composables/useHidReaderSelection.ts +50 -0
- package/composables/useLandscapingPermission.ts +4 -4
- package/composables/useMechanicalElectricalPermission.ts +4 -4
- package/composables/usePeople.ts +19 -0
- package/composables/usePestControlPermission.ts +4 -4
- package/composables/usePoolMaintenancePermission.ts +4 -4
- package/composables/useRobotBuilding.ts +9 -12
- package/composables/useRobots.ts +53 -4
- package/composables/useSecurityPermission.ts +4 -10
- package/composables/useSiteCategory.ts +45 -0
- package/composables/useSiteEntryPassSettings.ts +26 -0
- package/composables/useWebUsb.ts +14 -11
- package/package.json +1 -1
- package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +23 -0
- package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
- package/types/document.d.ts +14 -0
- package/types/facility.d.ts +4 -0
- package/types/people.d.ts +28 -1
- package/utils/hid-permission-assignments.ts +190 -0
- package/utils/hid-reader-selection.ts +52 -0
- package/utils/notification-target.ts +75 -0
- package/utils/occupancy-role.ts +109 -0
- package/utils/robot-display.ts +146 -0
- package/utils/vehicle-actions.ts +12 -4
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
:types="types"
|
|
17
17
|
:type="type"
|
|
18
18
|
:connected="connected"
|
|
19
|
-
:faults="
|
|
19
|
+
:faults="alertCount"
|
|
20
20
|
:role="role"
|
|
21
21
|
@update:site="(id) => emit('update:site', id)"
|
|
22
22
|
@update:type="setType"
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
:can-edit="canEdit"
|
|
32
32
|
:can-command="canCommand"
|
|
33
33
|
:can-delete="canDelete"
|
|
34
|
+
:types="types"
|
|
34
35
|
@back="emit('back')"
|
|
35
36
|
@removed="onRemoved"
|
|
36
37
|
@status="(s) => (connected = s.connected)"
|
|
@@ -64,6 +65,26 @@
|
|
|
64
65
|
@network="emit('network')"
|
|
65
66
|
@status="onFleetStatus"
|
|
66
67
|
/>
|
|
68
|
+
<RobotSiteAlerts
|
|
69
|
+
v-else-if="view === 'alerts'"
|
|
70
|
+
:key="`alerts:${site}`"
|
|
71
|
+
:site="site"
|
|
72
|
+
:site-name="siteName || names.siteName"
|
|
73
|
+
:client-name="clientName || names.clientName"
|
|
74
|
+
:back-to-network="backToNetwork"
|
|
75
|
+
@open="(id) => emit('open', id)"
|
|
76
|
+
@network="emit('network')"
|
|
77
|
+
@status="onFleetStatus"
|
|
78
|
+
/>
|
|
79
|
+
<RobotActivityLog
|
|
80
|
+
v-else-if="view === 'log'"
|
|
81
|
+
:key="`log:${site}`"
|
|
82
|
+
:site="site"
|
|
83
|
+
:site-name="siteName || names.siteName"
|
|
84
|
+
:client-name="clientName || names.clientName"
|
|
85
|
+
:back-to-network="backToNetwork"
|
|
86
|
+
@network="emit('network')"
|
|
87
|
+
/>
|
|
67
88
|
<RobotSiteFleet
|
|
68
89
|
v-else
|
|
69
90
|
:organization="organization"
|
|
@@ -81,12 +102,15 @@
|
|
|
81
102
|
/>
|
|
82
103
|
</main>
|
|
83
104
|
|
|
84
|
-
<v-dialog v-model="addOpen" width="
|
|
105
|
+
<v-dialog v-model="addOpen" width="520" persistent>
|
|
85
106
|
<RobotForm
|
|
86
107
|
v-if="addOpen"
|
|
87
108
|
:organization="organization"
|
|
88
109
|
:site="site"
|
|
110
|
+
:site-name="siteName || names.siteName"
|
|
111
|
+
:sites="sites"
|
|
89
112
|
:type="type"
|
|
113
|
+
:types="types"
|
|
90
114
|
@cancel="addOpen = false"
|
|
91
115
|
@created="onCreated"
|
|
92
116
|
/>
|
|
@@ -96,13 +120,15 @@
|
|
|
96
120
|
</template>
|
|
97
121
|
|
|
98
122
|
<script setup lang="ts">
|
|
99
|
-
import { computed, ref, watch } from "vue";
|
|
123
|
+
import { computed, onBeforeUnmount, ref, watch } from "vue";
|
|
100
124
|
import RobotHero from "./Hero.vue";
|
|
101
125
|
import RobotSiteHeader from "./SiteHeader.vue";
|
|
102
126
|
import RobotSiteFleet from "./SiteFleet.vue";
|
|
103
127
|
import RobotDetail from "./Detail.vue";
|
|
104
128
|
import RobotBuildingMap from "./BuildingMap.vue";
|
|
105
129
|
import RobotLiftQueue from "./LiftQueue.vue";
|
|
130
|
+
import RobotSiteAlerts from "./SiteAlerts.vue";
|
|
131
|
+
import RobotActivityLog from "./ActivityLog.vue";
|
|
106
132
|
import RobotForm from "./Form.vue";
|
|
107
133
|
import RobotToast from "./Toast.vue";
|
|
108
134
|
import { roleLabel, type TRobotType } from "../../utils/robot-display";
|
|
@@ -123,8 +149,8 @@ const props = withDefaults(
|
|
|
123
149
|
type?: TRobotType;
|
|
124
150
|
/** One robot open, or none (the fleet). */
|
|
125
151
|
robotId?: string;
|
|
126
|
-
/** Which screen: the fleet (default), the 3D building map, or the
|
|
127
|
-
view?: "fleet" | "map" | "lifts";
|
|
152
|
+
/** Which screen: the fleet (default), the 3D building map, the lift queue, alerts or the activity log. A robot open wins. */
|
|
153
|
+
view?: "fleet" | "map" | "lifts" | "alerts" | "log";
|
|
128
154
|
canSetup?: boolean;
|
|
129
155
|
canEdit?: boolean;
|
|
130
156
|
canCommand?: boolean;
|
|
@@ -179,6 +205,44 @@ function onFleetStatus(s: { connected: boolean; faults: number; siteName: string
|
|
|
179
205
|
}
|
|
180
206
|
watch([connected, faults], ([c, f]) => emit("status", { connected: c, faults: f }));
|
|
181
207
|
|
|
208
|
+
/*
|
|
209
|
+
* The bell: the site's open faults (not robots merely offline - they are on
|
|
210
|
+
* Alerts too) for every robot type this app presents, the same count on every
|
|
211
|
+
* view. Read every 30 s while visible; clicking it opens Alerts (`bell`).
|
|
212
|
+
*/
|
|
213
|
+
const { getSiteFaults, getSiteSummary } = useRobots();
|
|
214
|
+
|
|
215
|
+
// The client and site names for the Alerts / Activity log kickers, known even
|
|
216
|
+
// before a fleet view has reported them.
|
|
217
|
+
watch(
|
|
218
|
+
() => [props.organization, props.site],
|
|
219
|
+
async ([org, site]) => {
|
|
220
|
+
if (!org || !site || (props.siteName && props.clientName)) return;
|
|
221
|
+
try {
|
|
222
|
+
const s = await getSiteSummary(org, site);
|
|
223
|
+
if (s?.site?.name) names.value = { siteName: s.site.name, clientName: s.client?.name ?? "" };
|
|
224
|
+
} catch {
|
|
225
|
+
// Names stay blank; the views still work.
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
{ immediate: true },
|
|
229
|
+
);
|
|
230
|
+
const alertCount = ref(0);
|
|
231
|
+
async function loadAlertCount() {
|
|
232
|
+
if (!props.site) return;
|
|
233
|
+
try {
|
|
234
|
+
alertCount.value = Number((await getSiteFaults(props.site, { limit: 1 }))?.faults ?? 0);
|
|
235
|
+
} catch {
|
|
236
|
+
// Keep the last count; the views say what failed.
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
watch(() => props.site, loadAlertCount, { immediate: true });
|
|
240
|
+
const bellTimer = setInterval(() => {
|
|
241
|
+
if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
|
|
242
|
+
loadAlertCount();
|
|
243
|
+
}, 30000);
|
|
244
|
+
onBeforeUnmount(() => clearInterval(bellTimer));
|
|
245
|
+
|
|
182
246
|
const addOpen = ref(false);
|
|
183
247
|
const toast = ref("");
|
|
184
248
|
const reloadKey = ref(0);
|
|
@@ -396,7 +396,10 @@
|
|
|
396
396
|
to find out why. The click now runs the validation, which paints every
|
|
397
397
|
offending field and writes the reason above.
|
|
398
398
|
-->
|
|
399
|
-
|
|
399
|
+
<!-- Refused by the server for want of the right: drawn disabled, and a
|
|
400
|
+
press only repeats the reason - nothing is sent again. -->
|
|
401
|
+
<AppButton :disabled="processing" :class="{ 'no-permission': !!refusedMessage }"
|
|
402
|
+
:aria-disabled="!!refusedMessage || undefined" @click="submit">
|
|
400
403
|
{{ prop.mode == "add" ? "Submit" : "Update" }}
|
|
401
404
|
</AppButton>
|
|
402
405
|
</div>
|
|
@@ -440,7 +443,8 @@
|
|
|
440
443
|
</div>
|
|
441
444
|
<div class="vehicle-form__footer">
|
|
442
445
|
<AppButton variant="ghost" :disabled="processing" @click="cancelExistingUpdate">Cancel</AppButton>
|
|
443
|
-
<AppButton :disabled="processing"
|
|
446
|
+
<AppButton :disabled="processing" :class="{ 'no-permission': !!refusedMessage }"
|
|
447
|
+
:aria-disabled="!!refusedMessage || undefined" @click="confirmExistingUpdate">Update</AppButton>
|
|
444
448
|
</div>
|
|
445
449
|
</v-card>
|
|
446
450
|
</v-dialog>
|
|
@@ -517,6 +521,7 @@
|
|
|
517
521
|
|
|
518
522
|
<script setup lang="ts">
|
|
519
523
|
import { errorConverter } from "../utils/data";
|
|
524
|
+
import { isPermissionRefusalError } from "../utils/permission-refusal";
|
|
520
525
|
const prop = defineProps({
|
|
521
526
|
type: {
|
|
522
527
|
type: String as PropType<TVehicleType | "seasonpass">,
|
|
@@ -597,8 +602,28 @@ const emit = defineEmits([
|
|
|
597
602
|
"error",
|
|
598
603
|
"close",
|
|
599
604
|
"close:all",
|
|
605
|
+
// The server refused for want of the right: "create" or "update".
|
|
606
|
+
"refused",
|
|
600
607
|
]);
|
|
601
608
|
|
|
609
|
+
/**
|
|
610
|
+
* The server's "You do not have permission to ..." once it has refused this
|
|
611
|
+
* form. From then on the confirm is drawn disabled and a press only shows the
|
|
612
|
+
* sentence again - no second request. The host is told (`refused`) so it can
|
|
613
|
+
* take the matching action off its menus.
|
|
614
|
+
*/
|
|
615
|
+
const refusedMessage = ref("");
|
|
616
|
+
function noteRefusal(error: unknown) {
|
|
617
|
+
if (!isPermissionRefusalError(error)) return;
|
|
618
|
+
refusedMessage.value = errorMessage.value;
|
|
619
|
+
emit("refused", prop.mode === "add" ? "create" : "update");
|
|
620
|
+
}
|
|
621
|
+
function refusedAlready() {
|
|
622
|
+
if (!refusedMessage.value) return false;
|
|
623
|
+
errorMessage.value = refusedMessage.value;
|
|
624
|
+
return true;
|
|
625
|
+
}
|
|
626
|
+
|
|
602
627
|
const vehicle = reactive<
|
|
603
628
|
Omit<ExceptPartial<TVehicle>, "type"> & { type: TVehicleType | "seasonpass" }
|
|
604
629
|
>({
|
|
@@ -1142,6 +1167,10 @@ function cancelExistingUpdate() {
|
|
|
1142
1167
|
async function confirmExistingUpdate() {
|
|
1143
1168
|
const payload = pendingPayload.value;
|
|
1144
1169
|
if (!payload) return;
|
|
1170
|
+
if (refusedAlready()) {
|
|
1171
|
+
showExistingDialog.value = false;
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1145
1174
|
|
|
1146
1175
|
errorMessage.value = "";
|
|
1147
1176
|
processing.value = true;
|
|
@@ -1168,12 +1197,14 @@ async function confirmExistingUpdate() {
|
|
|
1168
1197
|
// Shown under the form. A record moved before the failure stays moved.
|
|
1169
1198
|
showExistingDialog.value = false;
|
|
1170
1199
|
errorMessage.value = errorConverter(error);
|
|
1200
|
+
noteRefusal(error);
|
|
1171
1201
|
} finally {
|
|
1172
1202
|
processing.value = false;
|
|
1173
1203
|
}
|
|
1174
1204
|
}
|
|
1175
1205
|
|
|
1176
1206
|
async function submit() {
|
|
1207
|
+
if (refusedAlready()) return;
|
|
1177
1208
|
errorMessage.value = "";
|
|
1178
1209
|
|
|
1179
1210
|
// Ask the form first. `validate()` marks each failing field, so the person
|
|
@@ -1326,6 +1357,7 @@ async function submit() {
|
|
|
1326
1357
|
// with nothing), returns a plain sentence instead of ofetch's
|
|
1327
1358
|
// `[POST] "/api/vehicles": 502`.
|
|
1328
1359
|
errorMessage.value = errorConverter(error);
|
|
1360
|
+
noteRefusal(error);
|
|
1329
1361
|
} finally {
|
|
1330
1362
|
processing.value = false;
|
|
1331
1363
|
}
|
|
@@ -1508,6 +1540,12 @@ function handleCloseMatchDialog() {
|
|
|
1508
1540
|
// The panel's own close button never did that; the two now agree. Backing out
|
|
1509
1541
|
// of a picker is not a decision to discard what you already had.
|
|
1510
1542
|
showMatchingPeopleDialog.value = false;
|
|
1543
|
+
// Closed WITHOUT picking a record: the person is someone new at this unit,
|
|
1544
|
+
// so NRIC and Full Name are typed in by hand. They were left locked by the
|
|
1545
|
+
// lookup (`disablePrefilledInputs`), with no way to unlock them short of
|
|
1546
|
+
// choosing a different unit. A picked record still locks them
|
|
1547
|
+
// (`selectPeopleRecord`).
|
|
1548
|
+
if (!vehicle.peopleId) disablePrefilledInputs.value = false;
|
|
1511
1549
|
}
|
|
1512
1550
|
|
|
1513
1551
|
onMounted(() => {
|
|
@@ -1547,6 +1585,11 @@ onMounted(() => {
|
|
|
1547
1585
|
});
|
|
1548
1586
|
</script>
|
|
1549
1587
|
<style scoped>
|
|
1588
|
+
/* Refused: faded, but still takes the click so it can say why. */
|
|
1589
|
+
.no-permission {
|
|
1590
|
+
opacity: 0.45;
|
|
1591
|
+
cursor: not-allowed;
|
|
1592
|
+
}
|
|
1550
1593
|
.button-outline-class {
|
|
1551
1594
|
border: 1px solid rgba(var(--v-theme-primary));
|
|
1552
1595
|
}
|
|
@@ -20,6 +20,16 @@
|
|
|
20
20
|
show-header @row-click="handleRowClick"
|
|
21
21
|
@update:page="handleUpdatePage">
|
|
22
22
|
|
|
23
|
+
<!-- Empty table: say WHY when the server refused the list ("You do not
|
|
24
|
+
have permission to view vehicles."), rather than "No data
|
|
25
|
+
available", which reads as an empty site. -->
|
|
26
|
+
<template #no-data>
|
|
27
|
+
<div class="table-card__empty" :class="{ 'text-error': !!listError }">
|
|
28
|
+
<v-icon :icon="listError ? 'mdi-lock-outline' : 'mdi-magnify-close'" size="32" />
|
|
29
|
+
<span>{{ listError || "No data available" }}</span>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
23
33
|
<!-- Residents / Season Passes / Block Listed, on the toolbar row the way
|
|
24
34
|
the other screens draw their tabs. Each tab shows every status. -->
|
|
25
35
|
<template #tabs>
|
|
@@ -115,19 +125,19 @@
|
|
|
115
125
|
<v-dialog v-model="dialog.createVehicle" v-if="vehicleType" width="450" persistent>
|
|
116
126
|
<VehicleForm :type="vehicleType" :mode="mode" :vehicle-data="selectedVehicleObject"
|
|
117
127
|
:plate-number-id="selectedPlateNumberId" :name-hints="nameHints" @back="handleBackToSelection" @done="handleAddVehicleComplete"
|
|
118
|
-
:org="org" :site="props.site" @close:all="handleCloseAll" />
|
|
128
|
+
:org="org" :site="props.site" @close:all="handleCloseAll" @refused="handleFormRefused" />
|
|
119
129
|
</v-dialog>
|
|
120
130
|
|
|
121
131
|
<v-dialog v-model="dialog.updateVehicle" v-if="vehicleType" width="450" persistent>
|
|
122
132
|
<VehicleForm :type="vehicleType" :mode="mode" :vehicle-data="selectedPlateNumberObject"
|
|
123
133
|
:plate-number-id="selectedPlateNumberId" :name-hints="nameHints" @back="handleBackToSelection" @done="handleAddVehicleComplete"
|
|
124
|
-
:org="org" :site="props.site" @close:all="handleCloseAll" @close="handleCloseAll" />
|
|
134
|
+
:org="org" :site="props.site" @close:all="handleCloseAll" @refused="handleFormRefused" @close="handleCloseAll" />
|
|
125
135
|
</v-dialog>
|
|
126
136
|
|
|
127
137
|
<!-- <v-dialog v-model="dialog.updateVehicle" v-if="vehicleType" width="450" persistent>
|
|
128
138
|
<VehicleForm :type="vehicleType" mode="edit" :vehicle-data="selectedVehicleObject"
|
|
129
139
|
@back="dialog.updateVehicle = false" @close="dialog.updateVehicle = false" @done="handleUpdateVehicleComplete"
|
|
130
|
-
:org="org" :site="site" @close:all="handleCloseAll" />
|
|
140
|
+
:org="org" :site="site" @close:all="handleCloseAll" @refused="handleFormRefused" />
|
|
131
141
|
</v-dialog> -->
|
|
132
142
|
|
|
133
143
|
<v-dialog v-if="canViewVehicleDetails" v-model="dialog.showMoreActions" width="800" persistent>
|
|
@@ -244,7 +254,7 @@
|
|
|
244
254
|
when the ANPR revoke could not be confirmed - the dialog stays open on
|
|
245
255
|
that path so the operator can read it and retry.
|
|
246
256
|
-->
|
|
247
|
-
<DialogDeleteConfirmation :loading="deletingVehicle" :message="deleteError"
|
|
257
|
+
<DialogDeleteConfirmation :loading="deletingVehicle" :message="deleteError" :no-permission="revoked.delete"
|
|
248
258
|
:prompt-title="`Remove vehicle number ${selectedPlateNumberObject?.plateNumber} from this record? This revokes its ANPR access - it will no longer open the barrier. The resident and any other vehicle numbers on this record are not affected.`"
|
|
249
259
|
@delete="submitDelete" @close="closeDeleteDialog" />
|
|
250
260
|
</v-dialog>
|
|
@@ -255,24 +265,26 @@
|
|
|
255
265
|
operator has to read and act on - it was going to a five-second
|
|
256
266
|
snackbar, along with the device's raw `{"ErrorCode":...}` reply.
|
|
257
267
|
-->
|
|
258
|
-
<DialogReusablePrompt :loading="approvingVehicle" :message="actionError"
|
|
268
|
+
<DialogReusablePrompt :loading="approvingVehicle" :message="actionError" message-error :no-permission="revoked.approve"
|
|
259
269
|
:prompt-title="`Are you sure want to approve this vehicle - ${selectedPlateNumberObject?.plateNumber}?`"
|
|
260
270
|
@proceed="submitApprove" @close="closeActionDialog('approveVehicle')" />
|
|
261
271
|
</v-dialog>
|
|
272
|
+
<!-- Like Delete, Restore says what it does at the barrier: a whitelist
|
|
273
|
+
plate goes back on the allowed list and opens it again. -->
|
|
262
274
|
<v-dialog v-model="dialog.restoreVehicle" persistent width="540">
|
|
263
|
-
<DialogReusablePrompt :loading="restoringVehicle" :message="actionError"
|
|
264
|
-
:prompt-title="
|
|
275
|
+
<DialogReusablePrompt :loading="restoringVehicle" :message="actionError" message-error :no-permission="revoked.approve"
|
|
276
|
+
:prompt-title="restorePrompt"
|
|
265
277
|
@proceed="submitRestore" @close="closeActionDialog('restoreVehicle')" />
|
|
266
278
|
</v-dialog>
|
|
267
279
|
<!-- Block / Unblock say what happens on the cameras, because that is the
|
|
268
280
|
part the operator cannot see from here. -->
|
|
269
281
|
<v-dialog v-model="dialog.blockVehicle" persistent width="540">
|
|
270
|
-
<DialogReusablePrompt :loading="blockingVehicle" :message="actionError"
|
|
282
|
+
<DialogReusablePrompt :loading="blockingVehicle" :message="actionError" message-error :no-permission="revoked.update"
|
|
271
283
|
:prompt-title="`Block vehicle ${selectedPlateNumberObject?.plateNumber}? It is added to every ANPR camera's blocklist and taken off the allowed list. Its status becomes Blocked and its category Block Listed.`"
|
|
272
284
|
@proceed="submitBlock" @close="closeActionDialog('blockVehicle')" />
|
|
273
285
|
</v-dialog>
|
|
274
286
|
<v-dialog v-model="dialog.unblockVehicle" persistent width="540">
|
|
275
|
-
<DialogReusablePrompt :loading="unblockingVehicle" :message="actionError"
|
|
287
|
+
<DialogReusablePrompt :loading="unblockingVehicle" :message="actionError" message-error :no-permission="revoked.update"
|
|
276
288
|
:prompt-title="`Unblock vehicle ${selectedPlateNumberObject?.plateNumber}? It is taken off every ANPR camera's blocklist. It is NOT whitelisted - the record stays with status Unblocked.`"
|
|
277
289
|
@proceed="submitUnblock" @close="closeActionDialog('unblockVehicle')" />
|
|
278
290
|
</v-dialog>
|
|
@@ -629,7 +641,7 @@ const nameHints = computed<Record<string, string>>(() => {
|
|
|
629
641
|
return hints;
|
|
630
642
|
})
|
|
631
643
|
|
|
632
|
-
const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesPending } =
|
|
644
|
+
const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesPending, error: getVehiclesError } =
|
|
633
645
|
await useLazyAsyncData(
|
|
634
646
|
`get-all-vehicles-${props.site}`,
|
|
635
647
|
() =>
|
|
@@ -645,6 +657,18 @@ const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesP
|
|
|
645
657
|
);
|
|
646
658
|
|
|
647
659
|
|
|
660
|
+
/** The server's reason when the list itself was refused or failed. */
|
|
661
|
+
const listError = computed(() =>
|
|
662
|
+
getVehiclesError.value ? errorConverter(getVehiclesError.value) : "",
|
|
663
|
+
);
|
|
664
|
+
watch(getVehiclesError, (error) => {
|
|
665
|
+
// A refused list must not keep showing the rows from before the refusal.
|
|
666
|
+
if (!error) return;
|
|
667
|
+
items.value = [];
|
|
668
|
+
pages.value = 0;
|
|
669
|
+
pageRange.value = "-- - -- of --";
|
|
670
|
+
});
|
|
671
|
+
|
|
648
672
|
watch(getVehiclesReq, (newData: any) => {
|
|
649
673
|
loadActiveCameraCounts();
|
|
650
674
|
items.value = newData?.items || [];
|
|
@@ -653,6 +677,12 @@ watch(getVehiclesReq, (newData: any) => {
|
|
|
653
677
|
})
|
|
654
678
|
|
|
655
679
|
function handleRowClick(data: any) {
|
|
680
|
+
// Without "See Vehicle Details" the Preview dialog is not rendered at all,
|
|
681
|
+
// so a click used to do nothing and gave no reason. Say why instead.
|
|
682
|
+
if (!props.canViewVehicleDetails) {
|
|
683
|
+
showMessage("You do not have permission to view vehicle details.", "error");
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
656
686
|
selectedVehicleId.value = data?.item?._id;
|
|
657
687
|
dialog.showMoreActions = true;
|
|
658
688
|
message.value = "";
|
|
@@ -829,6 +859,29 @@ function revokeOnRefusal(error: unknown, right: keyof typeof revoked) {
|
|
|
829
859
|
if (isPermissionRefusalError(error)) revoked[right] = true;
|
|
830
860
|
}
|
|
831
861
|
|
|
862
|
+
/** The server's own sentences, reused so a repeat press sends nothing. */
|
|
863
|
+
const NO_PERMISSION: Record<keyof typeof revoked, string> = {
|
|
864
|
+
update: "You do not have permission to edit vehicles.",
|
|
865
|
+
delete: "You do not have permission to delete vehicles.",
|
|
866
|
+
approve: "You do not have permission to approve vehicles.",
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* True (and the reason shown in the dialog) when this right was already
|
|
871
|
+
* refused: the confirm is drawn disabled, and pressing it again only repeats
|
|
872
|
+
* the message - no request goes to the server.
|
|
873
|
+
*/
|
|
874
|
+
/** The add/edit form was refused: an edit refusal takes Edit/Block/Unblock off. */
|
|
875
|
+
function handleFormRefused(kind: "create" | "update") {
|
|
876
|
+
if (kind === "update") revoked.update = true;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
function refusedAlready(right: keyof typeof revoked, target: typeof actionError) {
|
|
880
|
+
if (!revoked[right]) return false;
|
|
881
|
+
target.value = NO_PERMISSION[right];
|
|
882
|
+
return true;
|
|
883
|
+
}
|
|
884
|
+
|
|
832
885
|
/**
|
|
833
886
|
* One entry point for every menu item, in both menus, so a new action can only
|
|
834
887
|
* be added in one place and cannot be forgotten in the other.
|
|
@@ -910,6 +963,7 @@ const formatPlateNumbers = (value: any) => {
|
|
|
910
963
|
};
|
|
911
964
|
|
|
912
965
|
async function submitDelete() {
|
|
966
|
+
if (refusedAlready("delete", deleteError)) return;
|
|
913
967
|
|
|
914
968
|
const plateNumberId = selectedPlateNumberObject.value?._id;
|
|
915
969
|
const type = selectedPlateNumberObject.value?.type as TVehicleType;
|
|
@@ -945,7 +999,33 @@ async function submitDelete() {
|
|
|
945
999
|
|
|
946
1000
|
|
|
947
1001
|
|
|
1002
|
+
/**
|
|
1003
|
+
* What Restore will do on the cameras, from the site's live camera counts:
|
|
1004
|
+
* a whitelist plate (or season pass) goes back on the allowed list and opens
|
|
1005
|
+
* the barrier again; a blocklist plate goes back on the blocklist.
|
|
1006
|
+
*/
|
|
1007
|
+
const restorePrompt = computed(() => {
|
|
1008
|
+
const plate = selectedPlateNumberObject.value;
|
|
1009
|
+
const number = plate?.plateNumber ?? "";
|
|
1010
|
+
const blocklist = String(plate?.type ?? "").toLowerCase() === "blocklist";
|
|
1011
|
+
const counts = activeCameraCounts.value;
|
|
1012
|
+
const cameras = counts ? (blocklist ? counts.blocked : counts.allowed) : null;
|
|
1013
|
+
const onCameras =
|
|
1014
|
+
cameras === null
|
|
1015
|
+
? "every ANPR camera"
|
|
1016
|
+
: `${cameras} ANPR camera${cameras === 1 ? "" : "s"}`;
|
|
1017
|
+
|
|
1018
|
+
if (cameras === 0) {
|
|
1019
|
+
return `Restore vehicle ${number}? There is no active ANPR camera for it at this site, so barrier access does not change until one is added.`;
|
|
1020
|
+
}
|
|
1021
|
+
if (blocklist) {
|
|
1022
|
+
return `Restore vehicle ${number}? It is added back to the blocklist on ${onCameras} - the barrier will stay closed for it. Its status becomes Blocked.`;
|
|
1023
|
+
}
|
|
1024
|
+
return `Restore vehicle ${number}? This gives back its ANPR access on ${onCameras} - it will open the barrier again. Only this vehicle number is affected.`;
|
|
1025
|
+
});
|
|
1026
|
+
|
|
948
1027
|
async function submitRestore() {
|
|
1028
|
+
if (refusedAlready("approve", actionError)) return;
|
|
949
1029
|
|
|
950
1030
|
const vehicleId = selectedPlateNumberObject.value?._id;
|
|
951
1031
|
|
|
@@ -965,6 +1045,8 @@ async function submitRestore() {
|
|
|
965
1045
|
await getVehiclesRefresh();
|
|
966
1046
|
} catch (error: any) {
|
|
967
1047
|
actionError.value = errorConverter(error);
|
|
1048
|
+
// Restore is the approve endpoint: a refusal is the Approve right gone.
|
|
1049
|
+
revokeOnRefusal(error, "approve");
|
|
968
1050
|
} finally {
|
|
969
1051
|
restoringVehicle.value = false;
|
|
970
1052
|
}
|
|
@@ -972,6 +1054,7 @@ async function submitRestore() {
|
|
|
972
1054
|
|
|
973
1055
|
|
|
974
1056
|
async function submitBlock() {
|
|
1057
|
+
if (refusedAlready("update", actionError)) return;
|
|
975
1058
|
const vehicleId = selectedPlateNumberObject.value?._id;
|
|
976
1059
|
if (!vehicleId) {
|
|
977
1060
|
showMessage("Invalid vehicle selected for blocking.", "error");
|
|
@@ -995,6 +1078,7 @@ async function submitBlock() {
|
|
|
995
1078
|
|
|
996
1079
|
|
|
997
1080
|
async function submitUnblock() {
|
|
1081
|
+
if (refusedAlready("update", actionError)) return;
|
|
998
1082
|
const vehicleId = selectedPlateNumberObject.value?._id;
|
|
999
1083
|
if (!vehicleId) {
|
|
1000
1084
|
showMessage("Invalid vehicle selected for unblocking.", "error");
|
|
@@ -1018,6 +1102,7 @@ async function submitUnblock() {
|
|
|
1018
1102
|
|
|
1019
1103
|
|
|
1020
1104
|
async function submitApprove() {
|
|
1105
|
+
if (refusedAlready("approve", actionError)) return;
|
|
1021
1106
|
|
|
1022
1107
|
const plateNumberId = selectedPlateNumberObject.value?._id;
|
|
1023
1108
|
if (!plateNumberId) {
|