Skip to content

Commit

Permalink
feat(audit): render UNLOCK_GATE and PARKING_ACCESS events
Browse files Browse the repository at this point in the history
  • Loading branch information
mtthp committed Dec 6, 2024
1 parent 9051a78 commit b57cba6
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 17 deletions.
12 changes: 9 additions & 3 deletions src/components/audit/AuditEntryInline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@
tag="p">
<template #author>
<RouterLink
v-if="event.author && $route.params.id !== event.author._id"
v-if="event.author?._id && $route.params.id !== event.author._id"
class="font-medium text-indigo-600 hover:underline"
:to="{
name: ROUTE_NAMES.MEMBERS.DETAIL.INDEX,
params: { id: event.author._id || event.author.wpUserId },
params: { id: event.author._id },
}">
{{ event.author.name }}
</RouterLink>
<span v-else class="font-medium text-gray-900">
<span v-else class="font-medium text-gray-900" :title="event.author?.email">
{{ event.author?.name || $t('audit.author.unknown') }}
</span>
</template>
Expand Down Expand Up @@ -147,6 +147,8 @@ import {
mdiChevronDown,
mdiChevronUp,
mdiDevices,
mdiDoorbell,
mdiGateOpen,
mdiHeadCogOutline,
mdiHelp,
mdiKeyChainVariant,
Expand Down Expand Up @@ -187,6 +189,10 @@ const icon = computed(() => {
return mdiKeyChainVariant;
case AuditAction.UNLOCK_DECK_DOOR:
return mdiLockOpenOutline;
case AuditAction.UNLOCK_GATE:
return mdiDoorbell;
case AuditAction.PARKING_ACCESS:
return mdiGateOpen;
case AuditAction.MEMBER_DEVICE_UPDATE:
return mdiDevices;
case AuditAction.MEMBER_CAPABILITIES_UPDATE:
Expand Down
6 changes: 3 additions & 3 deletions src/components/audit/AuditEntryMemberSubscription.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
tag="p">
<template #author>
<RouterLink
v-if="event.author && $route.params.id !== event.author._id"
v-if="event.author?._id && $route.params.id !== event.author._id"
class="font-medium text-indigo-600 hover:underline"
:to="{
name: ROUTE_NAMES.MEMBERS.DETAIL.INDEX,
params: { id: event.author._id || event.author.wpUserId },
params: { id: event.author._id },
}">
{{ event.author.name }}
</RouterLink>
<span v-else class="font-medium text-gray-900">
<span v-else class="font-medium text-gray-900" :title="event.author?.email">
{{ event.author?.name || $t('audit.author.unknown') }}
</span>
</template>
Expand Down
6 changes: 3 additions & 3 deletions src/components/audit/AuditEntryMemberTicket.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
tag="p">
<template #author>
<RouterLink
v-if="event.author && $route.params.id !== event.author._id"
v-if="event.author?._id && $route.params.id !== event.author._id"
class="font-medium text-indigo-600 hover:underline"
:to="{
name: ROUTE_NAMES.MEMBERS.DETAIL.INDEX,
params: { id: event.author._id || event.author.wpUserId },
params: { id: event.author._id },
}">
{{ event.author.name }}
</RouterLink>
<span v-else class="font-medium text-gray-900">
<span v-else class="font-medium text-gray-900" :title="event.author?.email">
{{ event.author?.name || $t('audit.author.unknown') }}
</span>
</template>
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/en-GB/audit.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@
"message": "{author} modified the number of tickets in an order, from previously {previousCount} to now {count} for {member}",
"self": "{author} modified the number of tickets in one of their orders, from previously {previousCount} to now {count}"
},
"PARKING_ACCESS": {
"message": "{author} has opened the parking barrier"
},
"UNLOCK_DECK_DOOR": {
"message": "{author} unlocked the deck door"
},
"UNLOCK_GATE": {
"message": "{author} unlock pedestrian gate"
}
},
"author": {
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/fr-FR/audit.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@
"message": "{author} a modifié le nombre de tickets d'une commande, de précédemment {previousCount} à désormais {count} pour {member}",
"self": "{author} a modifié le nombre de tickets d'une de ses commandes, de précédemment {previousCount} à désormais {count}"
},
"PARKING_ACCESS": {
"message": "{author} a ouvert la barrière pour accéder au parking"
},
"UNLOCK_DECK_DOOR": {
"message": "{author} a déverrouillé la porte de la terrasse"
},
"UNLOCK_GATE": {
"message": "{author} a déverrouillé le portail piéton"
}
},
"author": {
Expand Down
2 changes: 2 additions & 0 deletions src/services/api/audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export enum AuditAction {
MEMBER_CAPABILITIES_UPDATE = 'MEMBER_CAPABILITIES_UPDATE',
KEYS_ACCESS = 'KEYS_ACCESS',
UNLOCK_DECK_DOOR = 'UNLOCK_DECK_DOOR',
UNLOCK_GATE = 'UNLOCK_GATE',
PARKING_ACCESS = 'PARKING_ACCESS',
}

export interface AuditEvent {
Expand Down
12 changes: 11 additions & 1 deletion src/views/Private/History/HistoryEventsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,17 @@ const filteredList = computed(() => {
.filter((event) =>
dayjs(event.occurred).isBetween(state.period.start, state.period.end, 'day', '[]'),
)
.filter((event) => !state.search || searchIn(state.search, JSON.stringify(event)))
.filter(
(event) =>
!state.search ||
searchIn(
state.search,
event.author?._id === event.context?.member._id
? i18n.t(`audit.action.${event.action}.self`)
: i18n.t(`audit.action.${event.action}.message`),
JSON.stringify(event),
),
)
.sort(ALL_LIST_SORTERS.value.find((s) => s.key === props.sort)?.sort);
});
Expand Down
10 changes: 5 additions & 5 deletions src/views/Private/Members/MembersDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ watch(
error,
i18n.t('members.detail.attendance.onFetch.fail'),
);
// TODO: should report to Sentry
}
},
);
Expand All @@ -551,8 +550,10 @@ watch(
() => ticketsError.value,
(error) => {
if (error && !isSilentError(error)) {
notificationsStore.addErrorNotification(error, i18n.t('members.detail.tickets.onFetch.fail'));
// TODO: should report to Sentry
notificationsStore.addErrorNotification(
error,
i18n.t('members.detail.orders.tickets.onFetch.fail'),
);
}
},
);
Expand All @@ -575,9 +576,8 @@ watch(
if (error && !isSilentError(error)) {
notificationsStore.addErrorNotification(
error,
i18n.t('members.detail.subscriptions.onFetch.fail'),
i18n.t('members.detail.orders.subscriptions.onFetch.fail'),
);
// TODO: should report to Sentry
}
},
);
Expand Down
2 changes: 0 additions & 2 deletions src/views/Private/Members/MembersList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ watch(
(error) => {
if (error && !isSilentError(error)) {
notificationsStore.addErrorNotification(error, i18n.t('members.list.onFetch.fail'));
// TODO: should report to Sentry
}
},
);
Expand All @@ -477,7 +476,6 @@ watch(
error,
i18n.t('members.list.onFetchVotingMembers.fail'),
);
// TODO: should report to Sentry
}
},
);
Expand Down

0 comments on commit b57cba6

Please sign in to comment.