Skip to content

Commit 0b9549b

Browse files
chore: add missing loading state in AuditLog
1 parent f22c5ee commit 0b9549b

5 files changed

Lines changed: 46 additions & 28 deletions

File tree

frontend/src/pages/admin/AuditLog.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</template>
88
</ff-page-header>
99
</template>
10-
<AuditLogBrowser ref="AuditLog" :users="users" :logEntries="logEntries" logType="platform" @load-entries="loadEntries" />
10+
<AuditLogBrowser ref="AuditLog" :users="users" :logEntries="logEntries" logType="platform" :loading="loading" @load-entries="loadEntries" />
1111
</ff-page>
1212
</template>
1313

@@ -26,7 +26,8 @@ export default {
2626
data () {
2727
return {
2828
logEntries: [],
29-
users: []
29+
users: [],
30+
loading: true
3031
}
3132
},
3233
computed: {
@@ -46,6 +47,8 @@ export default {
4647
if (err.response?.status === 403) {
4748
this.$router.push('/')
4849
}
50+
} finally {
51+
this.loading = false
4952
}
5053
}
5154
}

frontend/src/pages/application/Activity.vue

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<AuditLogBrowser ref="AuditLog" :users="users" :logEntries="logEntries" :associations="associations" :logType="logScope" @load-entries="loadEntries">
2+
<AuditLogBrowser ref="AuditLog" :users="users" :logEntries="logEntries" :associations="associations" :logType="logScope" :loading="loading" @load-entries="loadEntries">
33
<template #title>
44
<SectionTopMenu hero="Audit Log" info="Recorded events that have taken place in within this application." />
55
</template>
@@ -61,6 +61,7 @@ export default {
6161
data () {
6262
return {
6363
logEntries: [],
64+
loading: true,
6465
associations: {}, // applications, instances, devices
6566
users: [],
6667
auditFilters: {
@@ -122,16 +123,22 @@ export default {
122123
}
123124
params.set('includeChildren', includeChildren)
124125
params.set('scope', paramScope)
125-
if (this.applicationId) {
126-
let log
127-
if (paramScope === 'application') {
128-
log = (await ApplicationApi.getApplicationAuditLog(this.applicationId, params, cursor, 200))
129-
} else {
130-
const instanceId = this.auditFilters.selectedEventScope
131-
log = (await InstanceApi.getInstanceAuditLog(instanceId, params, cursor, 200))
126+
try {
127+
if (this.applicationId) {
128+
let log
129+
if (paramScope === 'application') {
130+
log = (await ApplicationApi.getApplicationAuditLog(this.applicationId, params, cursor, 200))
131+
} else {
132+
const instanceId = this.auditFilters.selectedEventScope
133+
log = (await InstanceApi.getInstanceAuditLog(instanceId, params, cursor, 200))
134+
}
135+
this.logEntries = log.log
136+
this.associations = includeChildren ? log.associations : null
132137
}
133-
this.logEntries = log.log
134-
this.associations = includeChildren ? log.associations : null
138+
} catch (error) {
139+
console.error('Failed to load audit logs:', error)
140+
} finally {
141+
this.loading = false
135142
}
136143
}
137144
},

frontend/src/pages/device/AuditLog.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="mb-3">
33
<SectionTopMenu hero="Audit Log" info="" />
44
</div>
5-
<AuditLogBrowser ref="AuditLog" :users="users" :logEntries="logEntries" logType="device" @load-entries="loadEntries" />
5+
<AuditLogBrowser ref="AuditLog" :users="users" :logEntries="logEntries" logType="device" :loading="loading" @load-entries="loadEntries" />
66
</template>
77

88
<script>
@@ -29,7 +29,8 @@ export default {
2929
data () {
3030
return {
3131
logEntries: [],
32-
users: []
32+
users: [],
33+
loading: true
3334
}
3435
},
3536
computed: {
@@ -52,7 +53,13 @@ export default {
5253
},
5354
async loadEntries (params = new URLSearchParams(), cursor = undefined) {
5455
const deviceId = this.device.id
55-
this.logEntries = (await DeviceApi.getDeviceAuditLog(deviceId, params, cursor, 200)).log
56+
try {
57+
this.logEntries = (await DeviceApi.getDeviceAuditLog(deviceId, params, cursor, 200)).log
58+
} catch (error) {
59+
console.error('Failed to load audit logs:', error)
60+
} finally {
61+
this.loading = false
62+
}
5663
}
5764
}
5865
}

frontend/src/pages/instance/AuditLog.vue

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,15 @@ export default {
109109
}
110110
} catch (error) {
111111
console.error('Failed to load audit logs:', error)
112-
this.auditLog = []
113112
} finally {
114113
this.loading = false
115114
}
116115
},
117116
triggerLoad ({ users = false, events = true } = {}) {
118117
// if `events` is true, call AuditLogBrowser.loadEntries - this will emit 'load-entries' event which calls this.loadEntries with appropriate params
119-
if (events) {
120-
const eventTypes = this.auditFilters.selectedEventScope || 'instance'
121-
this.loading = true
122-
this.$refs.AuditLog?.loadEntries(this.auditFilters.selectedEventScope, this.auditFilters.includeChildren, eventTypes)
123-
}
124-
if (users) {
125-
this.loadUsers()
126-
}
118+
const eventTypes = this.auditFilters.selectedEventScope || 'instance'
119+
events && this.$refs.AuditLog?.loadEntries(this.auditFilters.selectedEventScope, this.auditFilters.includeChildren, eventTypes)
120+
users && this.loadUsers()
127121
}
128122
129123
}

frontend/src/pages/team/AuditLog.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</template>
88
</ff-page-header>
99
</template>
10-
<AuditLogBrowser ref="AuditLog" :users="users" :logEntries="logEntries" :associations="associations" logType="team" @load-entries="loadEntries">
10+
<AuditLogBrowser ref="AuditLog" :users="users" :logEntries="logEntries" :associations="associations" logType="team" :loading="loading" @load-entries="loadEntries">
1111
<template #title>
1212
<SectionTopMenu hero="Audit Log" info="Recorded events that have taken place in this Team." />
1313
</template>
@@ -64,6 +64,7 @@ export default {
6464
data () {
6565
return {
6666
logEntries: [],
67+
loading: true,
6768
associations: {}, // applications, instances, devices
6869
users: [],
6970
auditFilters: {
@@ -118,9 +119,15 @@ export default {
118119
}
119120
params.set('includeChildren', includeChildren)
120121
params.set('scope', paramScope)
121-
const auditLog = (await TeamAPI.getTeamAuditLog(teamId, params, cursor, 200))
122-
this.logEntries = auditLog.log
123-
this.associations = auditLog.associations
122+
try {
123+
const auditLog = (await TeamAPI.getTeamAuditLog(teamId, params, cursor, 200))
124+
this.logEntries = auditLog.log
125+
this.associations = auditLog.associations
126+
} catch (error) {
127+
console.error('Failed to load audit logs:', error)
128+
} finally {
129+
this.loading = false
130+
}
124131
}
125132
},
126133
triggerLoad ({ users = false, events = true } = {}) {

0 commit comments

Comments
 (0)