From bc813b71dde57e0d56c8092b2e16deec2db05eab Mon Sep 17 00:00:00 2001 From: Vishnu Narayanan Date: Tue, 20 Jun 2023 09:36:16 +0530 Subject: [PATCH] feat: refresh the audit page on navigation without manual reload (#7292) Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: Shivam Mishra --- .../routes/dashboard/settings/auditlogs/Index.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/javascript/dashboard/routes/dashboard/settings/auditlogs/Index.vue b/app/javascript/dashboard/routes/dashboard/settings/auditlogs/Index.vue index 97e5830e0..c20431ad9 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/auditlogs/Index.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/auditlogs/Index.vue @@ -80,6 +80,12 @@ export default { }, }; }, + beforeRouteEnter(to, from, next) { + // Fetch Audit Logs on page load without manual refresh + next(vm => { + vm.fetchAuditLogs(); + }); + }, computed: { ...mapGetters({ records: 'auditlogs/getAuditLogs', @@ -90,10 +96,17 @@ export default { }, mounted() { // Fetch API Call - this.$store.dispatch('auditlogs/fetch', { page: 1 }); this.$store.dispatch('agents/get'); }, methods: { + fetchAuditLogs() { + const page = this.$route.query.page ?? 1; + this.$store.dispatch('auditlogs/fetch', { page }).catch(error => { + const errorMessage = + error?.message || this.$t('AUDIT_LOGS.API.ERROR_MESSAGE'); + this.showAlert(errorMessage); + }); + }, getAgentName(email) { if (email === null) { return this.$t('AUDIT_LOGS.DEFAULT_USER');