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 <scm.mymail@gmail.com>
This commit is contained in:
@@ -80,6 +80,12 @@ export default {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
beforeRouteEnter(to, from, next) {
|
||||||
|
// Fetch Audit Logs on page load without manual refresh
|
||||||
|
next(vm => {
|
||||||
|
vm.fetchAuditLogs();
|
||||||
|
});
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
records: 'auditlogs/getAuditLogs',
|
records: 'auditlogs/getAuditLogs',
|
||||||
@@ -90,10 +96,17 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
// Fetch API Call
|
// Fetch API Call
|
||||||
this.$store.dispatch('auditlogs/fetch', { page: 1 });
|
|
||||||
this.$store.dispatch('agents/get');
|
this.$store.dispatch('agents/get');
|
||||||
},
|
},
|
||||||
methods: {
|
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) {
|
getAgentName(email) {
|
||||||
if (email === null) {
|
if (email === null) {
|
||||||
return this.$t('AUDIT_LOGS.DEFAULT_USER');
|
return this.$t('AUDIT_LOGS.DEFAULT_USER');
|
||||||
|
|||||||
Reference in New Issue
Block a user