|
1 | 1 | <template> |
2 | | - <AuditLogBrowser ref="AuditLog" :users="users" :logEntries="logEntries" :associations="associations" logType="project" @load-entries="loadEntries"> |
| 2 | + <AuditLogBrowser ref="AuditLog" :users="users" :logEntries="logEntries" :associations="associations" logType="project" :loading="loading" @load-entries="loadEntries"> |
3 | 3 | <template #title> |
4 | 4 | <SectionTopMenu hero="Audit Log" info="Recorded events that have taken place in within this instance." /> |
5 | 5 | </template> |
@@ -49,6 +49,7 @@ export default { |
49 | 49 | data () { |
50 | 50 | return { |
51 | 51 | logEntries: [], |
| 52 | + loading: true, |
52 | 53 | associations: {}, // devices |
53 | 54 | users: [], |
54 | 55 | auditFilters: { |
@@ -92,25 +93,37 @@ export default { |
92 | 93 | * @param cursor - cursor to use for pagination |
93 | 94 | */ |
94 | 95 | async loadEntries (params = new URLSearchParams(), cursor = undefined) { |
95 | | - if (this.instance.id) { |
96 | | - const auditLog = (await InstanceApi.getInstanceAuditLog(this.instance.id, params, cursor, 200)) |
97 | | - this.logEntries = auditLog.log |
98 | | - // dont show associations if we are looking at "this" scope (project)" |
99 | | - let showAssociations = false |
100 | | - if (this.auditFilters.selectedEventScope === 'device') { |
101 | | - showAssociations = true |
| 96 | + try { |
| 97 | + if (this.instance.id) { |
| 98 | + const auditLog = (await InstanceApi.getInstanceAuditLog(this.instance.id, params, cursor, 200)) |
| 99 | + this.logEntries = auditLog.log |
| 100 | + // dont show associations if we are looking at "this" scope (project)" |
| 101 | + let showAssociations = false |
| 102 | + if (this.auditFilters.selectedEventScope === 'device') { |
| 103 | + showAssociations = true |
| 104 | + } |
| 105 | + if (this.auditFilters.selectedEventScope === 'project' && this.auditFilters.includeChildren) { |
| 106 | + showAssociations = true |
| 107 | + } |
| 108 | + this.associations = showAssociations ? auditLog.associations : null |
102 | 109 | } |
103 | | - if (this.auditFilters.selectedEventScope === 'project' && this.auditFilters.includeChildren) { |
104 | | - showAssociations = true |
105 | | - } |
106 | | - this.associations = showAssociations ? auditLog.associations : null |
| 110 | + } catch (error) { |
| 111 | + console.error('Failed to load audit logs:', error) |
| 112 | + this.auditLog = [] |
| 113 | + } finally { |
| 114 | + this.loading = false |
107 | 115 | } |
108 | 116 | }, |
109 | 117 | triggerLoad ({ users = false, events = true } = {}) { |
110 | 118 | // if `events` is true, call AuditLogBrowser.loadEntries - this will emit 'load-entries' event which calls this.loadEntries with appropriate params |
111 | | - const eventTypes = this.auditFilters.selectedEventScope || 'instance' |
112 | | - events && this.$refs.AuditLog?.loadEntries(this.auditFilters.selectedEventScope, this.auditFilters.includeChildren, eventTypes) |
113 | | - users && this.loadUsers() |
| 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 | + } |
114 | 127 | } |
115 | 128 |
|
116 | 129 | } |
|
0 commit comments