@conduction/nextcloud-vue 0.1.0-beta.11 → 0.1.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nextcloud-vue.cjs +67614 -0
- package/dist/nextcloud-vue.cjs.js +13518 -13617
- package/dist/nextcloud-vue.cjs.js.map +1 -1
- package/dist/nextcloud-vue.cjs.map +1 -0
- package/dist/nextcloud-vue.css +1796 -1800
- package/dist/nextcloud-vue.esm.js +13518 -13617
- package/dist/nextcloud-vue.esm.js.map +1 -1
- package/package.json +3 -2
- package/src/components/CnActionsBar/CnActionsBar.vue +254 -254
- package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +570 -570
- package/src/components/CnAdvancedFormDialog/CnDataTab.vue +217 -217
- package/src/components/CnAdvancedFormDialog/CnMetadataTab.vue +121 -121
- package/src/components/CnAdvancedFormDialog/CnPropertiesTab.vue +422 -422
- package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -247
- package/src/components/CnCard/CnCard.vue +415 -415
- package/src/components/CnCardGrid/CnCardGrid.vue +156 -156
- package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -132
- package/src/components/CnChartWidget/CnChartWidget.vue +346 -346
- package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -77
- package/src/components/CnContextMenu/CnContextMenu.vue +142 -142
- package/src/components/CnCopyDialog/CnCopyDialog.vue +266 -266
- package/src/components/CnDashboardGrid/CnDashboardGrid.vue +229 -229
- package/src/components/CnDashboardPage/CnDashboardPage.vue +397 -397
- package/src/components/CnDataTable/CnDataTable.vue +362 -362
- package/src/components/CnDeleteDialog/CnDeleteDialog.vue +177 -177
- package/src/components/CnDetailCard/CnDetailCard.vue +225 -225
- package/src/components/CnDetailGrid/CnDetailGrid.vue +256 -256
- package/src/components/CnDetailPage/CnDetailPage.vue +432 -432
- package/src/components/CnFacetSidebar/CnFacetSidebar.vue +234 -234
- package/src/components/CnFilterBar/CnFilterBar.vue +153 -153
- package/src/components/CnFormDialog/CnFormDialog.vue +1047 -1047
- package/src/components/CnIcon/CnIcon.vue +89 -89
- package/src/components/CnIndexPage/CnIndexPage.vue +981 -980
- package/src/components/CnIndexSidebar/CnIndexSidebar.vue +536 -536
- package/src/components/CnInfoWidget/CnInfoWidget.vue +219 -219
- package/src/components/CnItemCard/CnItemCard.vue +134 -134
- package/src/components/CnJsonViewer/CnJsonViewer.vue +312 -312
- package/src/components/CnKpiGrid/CnKpiGrid.vue +93 -93
- package/src/components/CnMassActionBar/CnMassActionBar.vue +161 -161
- package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +327 -327
- package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +245 -245
- package/src/components/CnMassExportDialog/CnMassExportDialog.vue +191 -191
- package/src/components/CnMassImportDialog/CnMassImportDialog.vue +494 -494
- package/src/components/CnNoteCard/CnNoteCard.vue +149 -149
- package/src/components/CnNotesCard/CnNotesCard.vue +416 -416
- package/src/components/CnObjectCard/CnObjectCard.vue +294 -294
- package/src/components/CnObjectDataWidget/CnObjectDataWidget.vue +854 -854
- package/src/components/CnObjectMetadataWidget/CnObjectMetadataWidget.vue +289 -289
- package/src/components/CnObjectSidebar/CnAuditTrailTab.vue +369 -369
- package/src/components/CnObjectSidebar/CnFilesTab.vue +287 -287
- package/src/components/CnObjectSidebar/CnNotesTab.vue +250 -250
- package/src/components/CnObjectSidebar/CnObjectSidebar.vue +255 -255
- package/src/components/CnObjectSidebar/CnTagsTab.vue +259 -259
- package/src/components/CnObjectSidebar/CnTasksTab.vue +483 -483
- package/src/components/CnPageHeader/CnPageHeader.vue +61 -61
- package/src/components/CnPagination/CnPagination.vue +253 -253
- package/src/components/CnProgressBar/CnProgressBar.vue +262 -262
- package/src/components/CnRegisterMapping/CnRegisterMapping.vue +793 -793
- package/src/components/CnRowActions/CnRowActions.vue +95 -95
- package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -226
- package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +788 -788
- package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -305
- package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -1398
- package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -236
- package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -92
- package/src/components/CnSettingsSection/CnSettingsSection.vue +267 -267
- package/src/components/CnStatsBlock/CnStatsBlock.vue +437 -437
- package/src/components/CnStatsPanel/CnStatsPanel.vue +321 -321
- package/src/components/CnStatusBadge/CnStatusBadge.vue +90 -90
- package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +545 -545
- package/src/components/CnTableWidget/CnTableWidget.vue +333 -333
- package/src/components/CnTasksCard/CnTasksCard.vue +374 -374
- package/src/components/CnTileWidget/CnTileWidget.vue +159 -159
- package/src/components/CnTimelineStages/CnTimelineStages.vue +294 -294
- package/src/components/CnUserActionMenu/CnUserActionMenu.vue +436 -436
- package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +313 -313
- package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -180
- package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +248 -248
|
@@ -1,369 +1,369 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="cn-sidebar-tab">
|
|
3
|
-
<NcLoadingIcon v-if="loading" />
|
|
4
|
-
<template v-else-if="entries.length > 0">
|
|
5
|
-
<!-- Filters -->
|
|
6
|
-
<div class="cn-audit-filters">
|
|
7
|
-
<NcSelect
|
|
8
|
-
v-model="filterAction"
|
|
9
|
-
:options="actionOptions"
|
|
10
|
-
:placeholder="actionFilterLabel"
|
|
11
|
-
:multiple="true"
|
|
12
|
-
:close-on-select="false"
|
|
13
|
-
class="cn-audit-filters__select" />
|
|
14
|
-
<NcSelect
|
|
15
|
-
v-model="filterUser"
|
|
16
|
-
:options="userOptions"
|
|
17
|
-
:placeholder="userFilterLabel"
|
|
18
|
-
:multiple="true"
|
|
19
|
-
:close-on-select="false"
|
|
20
|
-
class="cn-audit-filters__select" />
|
|
21
|
-
<NcDateTimePickerNative
|
|
22
|
-
id="audit-date-from"
|
|
23
|
-
v-model="filterDateFrom"
|
|
24
|
-
:label="fromLabel"
|
|
25
|
-
type="date"
|
|
26
|
-
class="cn-audit-filters__date" />
|
|
27
|
-
<NcDateTimePickerNative
|
|
28
|
-
id="audit-date-to"
|
|
29
|
-
v-model="filterDateTo"
|
|
30
|
-
:label="toLabel"
|
|
31
|
-
type="date"
|
|
32
|
-
class="cn-audit-filters__date" />
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
<div v-if="entries.length === 0 && !loading" class="cn-sidebar-tab__empty">
|
|
36
|
-
{{ noMatchLabel }}
|
|
37
|
-
</div>
|
|
38
|
-
<div v-else class="cn-sidebar-tab__list">
|
|
39
|
-
<div v-for="entry in entries" :key="entry.id" class="cn-audit-entry">
|
|
40
|
-
<NcListItem
|
|
41
|
-
:name="formatDate(entry.created)"
|
|
42
|
-
:bold="false"
|
|
43
|
-
:details="entry.action"
|
|
44
|
-
:counter-number="changedCount(entry)"
|
|
45
|
-
@click="toggleExpand(entry.id)">
|
|
46
|
-
<template #icon>
|
|
47
|
-
<History :size="32" />
|
|
48
|
-
</template>
|
|
49
|
-
<template #subname>
|
|
50
|
-
{{ entry.userName || entry.user || 'System' }}
|
|
51
|
-
</template>
|
|
52
|
-
</NcListItem>
|
|
53
|
-
<!-- Expandable details -->
|
|
54
|
-
<div v-if="expandedId === entry.id" class="cn-audit-details">
|
|
55
|
-
<div class="cn-audit-details__row">
|
|
56
|
-
<span class="cn-audit-details__label">Action</span>
|
|
57
|
-
<span>{{ entry.action }}</span>
|
|
58
|
-
</div>
|
|
59
|
-
<div class="cn-audit-details__row">
|
|
60
|
-
<span class="cn-audit-details__label">User</span>
|
|
61
|
-
<span>{{ entry.userName || entry.user || 'System' }}</span>
|
|
62
|
-
</div>
|
|
63
|
-
<div class="cn-audit-details__row">
|
|
64
|
-
<span class="cn-audit-details__label">Date</span>
|
|
65
|
-
<span>{{ formatDate(entry.created) }}</span>
|
|
66
|
-
</div>
|
|
67
|
-
<div v-if="entry.ipAddress" class="cn-audit-details__row">
|
|
68
|
-
<span class="cn-audit-details__label">IP</span>
|
|
69
|
-
<span>{{ entry.ipAddress }}</span>
|
|
70
|
-
</div>
|
|
71
|
-
<div v-if="entry.session" class="cn-audit-details__row">
|
|
72
|
-
<span class="cn-audit-details__label">Session</span>
|
|
73
|
-
<span class="cn-audit-details__mono">{{ entry.session }}</span>
|
|
74
|
-
</div>
|
|
75
|
-
<!-- Changed fields -->
|
|
76
|
-
<div v-if="entry.changed && Object.keys(entry.changed).length > 0" class="cn-audit-details__changes">
|
|
77
|
-
<span class="cn-audit-details__label">Changes</span>
|
|
78
|
-
<div
|
|
79
|
-
v-for="(change, field) in entry.changed"
|
|
80
|
-
:key="field"
|
|
81
|
-
class="cn-audit-details__change">
|
|
82
|
-
<span class="cn-audit-details__field">{{ field }}</span>
|
|
83
|
-
<div v-if="isSimpleValue(change)" class="cn-audit-details__values">
|
|
84
|
-
<span v-if="change.old !== null && change.old !== undefined" class="cn-audit-details__old">{{ formatValue(change.old) }}</span>
|
|
85
|
-
<span v-if="change.old !== null && change.new !== null" class="cn-audit-details__arrow">→</span>
|
|
86
|
-
<span v-if="change.new !== null && change.new !== undefined" class="cn-audit-details__new">{{ formatValue(change.new) }}</span>
|
|
87
|
-
<span v-if="change.old === null && change.new === null" class="cn-audit-details__null">null</span>
|
|
88
|
-
</div>
|
|
89
|
-
<div v-else class="cn-audit-details__values">
|
|
90
|
-
<span class="cn-audit-details__mono">{{ formatValue(change) }}</span>
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
93
|
-
</div>
|
|
94
|
-
</div>
|
|
95
|
-
</div>
|
|
96
|
-
<!-- Load more -->
|
|
97
|
-
<NcButton
|
|
98
|
-
v-if="hasMore"
|
|
99
|
-
type="tertiary"
|
|
100
|
-
:wide="true"
|
|
101
|
-
:disabled="loadingMore"
|
|
102
|
-
class="cn-sidebar-tab__load-more"
|
|
103
|
-
@click="loadMore">
|
|
104
|
-
<template v-if="loadingMore" #icon>
|
|
105
|
-
<NcLoadingIcon :size="20" />
|
|
106
|
-
</template>
|
|
107
|
-
{{ loadingMore ? '' : loadMoreLabel }}
|
|
108
|
-
</NcButton>
|
|
109
|
-
</div>
|
|
110
|
-
</template>
|
|
111
|
-
<div v-else class="cn-sidebar-tab__empty">
|
|
112
|
-
{{ noAuditTrailLabel }}
|
|
113
|
-
</div>
|
|
114
|
-
</div>
|
|
115
|
-
</template>
|
|
116
|
-
|
|
117
|
-
<script>
|
|
118
|
-
import { translate as t } from '@nextcloud/l10n'
|
|
119
|
-
import { NcButton, NcListItem, NcLoadingIcon, NcSelect, NcDateTimePickerNative } from '@nextcloud/vue'
|
|
120
|
-
import History from 'vue-material-design-icons/History.vue'
|
|
121
|
-
import { buildHeaders } from '../../utils/index.js'
|
|
122
|
-
|
|
123
|
-
export default {
|
|
124
|
-
name: 'CnAuditTrailTab',
|
|
125
|
-
|
|
126
|
-
components: { NcButton, NcListItem, NcLoadingIcon, NcSelect, NcDateTimePickerNative, History },
|
|
127
|
-
|
|
128
|
-
props: {
|
|
129
|
-
objectId: { type: String, required: true },
|
|
130
|
-
register: { type: String, default: '' },
|
|
131
|
-
schema: { type: String, default: '' },
|
|
132
|
-
apiBase: { type: String, default: '/apps/openregister/api' },
|
|
133
|
-
noAuditTrailLabel: { type: String, default: () => t('nextcloud-vue', 'No audit trail entries') },
|
|
134
|
-
noMatchLabel: { type: String, default: () => t('nextcloud-vue', 'No matching entries') },
|
|
135
|
-
actionFilterLabel: { type: String, default: () => t('nextcloud-vue', 'Action') },
|
|
136
|
-
userFilterLabel: { type: String, default: () => t('nextcloud-vue', 'User') },
|
|
137
|
-
fromLabel: { type: String, default: () => t('nextcloud-vue', 'From') },
|
|
138
|
-
toLabel: { type: String, default: () => t('nextcloud-vue', 'To') },
|
|
139
|
-
loadMoreLabel: { type: String, default: () => t('nextcloud-vue', 'Load more') },
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
data() {
|
|
143
|
-
return {
|
|
144
|
-
entries: [],
|
|
145
|
-
loading: false,
|
|
146
|
-
loadingMore: false,
|
|
147
|
-
expandedId: null,
|
|
148
|
-
filterAction: [],
|
|
149
|
-
filterUser: [],
|
|
150
|
-
filterDateFrom: null,
|
|
151
|
-
filterDateTo: null,
|
|
152
|
-
page: 1,
|
|
153
|
-
total: 0,
|
|
154
|
-
limit: 20,
|
|
155
|
-
actionOptions: ['create', 'read', 'update', 'delete'],
|
|
156
|
-
userOptions: [],
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
computed: {
|
|
161
|
-
hasMore() {
|
|
162
|
-
return this.entries.length < this.total
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
|
|
166
|
-
watch: {
|
|
167
|
-
objectId: {
|
|
168
|
-
immediate: true,
|
|
169
|
-
handler(id) { if (id) this.fetchAuditTrails() },
|
|
170
|
-
},
|
|
171
|
-
filterAction() { this.resetAndFetch() },
|
|
172
|
-
filterUser() { this.resetAndFetch() },
|
|
173
|
-
filterDateFrom() { this.resetAndFetch() },
|
|
174
|
-
filterDateTo() { this.resetAndFetch() },
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
methods: {
|
|
178
|
-
resetAndFetch() {
|
|
179
|
-
this.page = 1
|
|
180
|
-
this.entries = []
|
|
181
|
-
this.fetchAuditTrails()
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
buildQueryParams() {
|
|
185
|
-
const params = new URLSearchParams()
|
|
186
|
-
params.set('limit', this.limit)
|
|
187
|
-
params.set('_page', this.page)
|
|
188
|
-
params.set('_sort[created]', 'DESC')
|
|
189
|
-
if (this.filterAction?.length) params.set('action', this.filterAction.join(','))
|
|
190
|
-
if (this.filterUser?.length) params.set('user_name', this.filterUser.join(','))
|
|
191
|
-
if (this.filterDateFrom) {
|
|
192
|
-
params.set('_dateFrom', new Date(this.filterDateFrom).toISOString().split('T')[0])
|
|
193
|
-
}
|
|
194
|
-
if (this.filterDateTo) {
|
|
195
|
-
params.set('_dateTo', new Date(this.filterDateTo).toISOString().split('T')[0])
|
|
196
|
-
}
|
|
197
|
-
return params.toString()
|
|
198
|
-
},
|
|
199
|
-
|
|
200
|
-
async fetchAuditTrails() {
|
|
201
|
-
if (!this.register || !this.schema) return
|
|
202
|
-
this.loading = this.page === 1
|
|
203
|
-
this.loadingMore = this.page > 1
|
|
204
|
-
try {
|
|
205
|
-
const query = this.buildQueryParams()
|
|
206
|
-
const response = await fetch(
|
|
207
|
-
`${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/audit-trails?${query}`,
|
|
208
|
-
{ headers: buildHeaders() },
|
|
209
|
-
)
|
|
210
|
-
if (response.ok) {
|
|
211
|
-
const data = await response.json()
|
|
212
|
-
const results = data.results || data || []
|
|
213
|
-
if (this.page === 1) {
|
|
214
|
-
this.entries = results
|
|
215
|
-
} else {
|
|
216
|
-
this.entries = [...this.entries, ...results]
|
|
217
|
-
}
|
|
218
|
-
this.total = data.total || this.entries.length
|
|
219
|
-
// Build user options from all seen entries
|
|
220
|
-
const users = new Set(this.entries.map(e => e.userName || e.user).filter(Boolean))
|
|
221
|
-
this.userOptions = [...users].sort()
|
|
222
|
-
}
|
|
223
|
-
} catch (err) {
|
|
224
|
-
console.error('CnAuditTrailTab: Failed to fetch audit trails', err)
|
|
225
|
-
} finally {
|
|
226
|
-
this.loading = false
|
|
227
|
-
this.loadingMore = false
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
|
|
231
|
-
loadMore() {
|
|
232
|
-
this.page++
|
|
233
|
-
this.fetchAuditTrails()
|
|
234
|
-
},
|
|
235
|
-
|
|
236
|
-
toggleExpand(id) {
|
|
237
|
-
this.expandedId = this.expandedId === id ? null : id
|
|
238
|
-
},
|
|
239
|
-
|
|
240
|
-
changedCount(entry) {
|
|
241
|
-
if (!entry.changed || typeof entry.changed !== 'object') return 0
|
|
242
|
-
return Object.keys(entry.changed).length
|
|
243
|
-
},
|
|
244
|
-
|
|
245
|
-
isSimpleValue(change) {
|
|
246
|
-
return change && typeof change === 'object' && ('old' in change || 'new' in change)
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
formatValue(val) {
|
|
250
|
-
if (val === null || val === undefined) return 'null'
|
|
251
|
-
if (typeof val === 'object') return JSON.stringify(val)
|
|
252
|
-
return String(val)
|
|
253
|
-
},
|
|
254
|
-
|
|
255
|
-
formatDate(dateStr) {
|
|
256
|
-
if (!dateStr) return ''
|
|
257
|
-
try {
|
|
258
|
-
return new Date(dateStr).toLocaleString(undefined, {
|
|
259
|
-
year: 'numeric',
|
|
260
|
-
month: 'short',
|
|
261
|
-
day: 'numeric',
|
|
262
|
-
hour: '2-digit',
|
|
263
|
-
minute: '2-digit',
|
|
264
|
-
})
|
|
265
|
-
} catch { return dateStr }
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
}
|
|
269
|
-
</script>
|
|
270
|
-
|
|
271
|
-
<style scoped>
|
|
272
|
-
.cn-sidebar-tab { padding: 12px; }
|
|
273
|
-
|
|
274
|
-
.cn-sidebar-tab__empty {
|
|
275
|
-
text-align: center;
|
|
276
|
-
padding: 24px 12px;
|
|
277
|
-
color: var(--color-text-maxcontrast);
|
|
278
|
-
font-size: 13px;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
.cn-sidebar-tab__list { display: flex; flex-direction: column; gap: 2px; }
|
|
282
|
-
|
|
283
|
-
.cn-audit-filters {
|
|
284
|
-
display: grid;
|
|
285
|
-
grid-template-columns: 1fr 1fr;
|
|
286
|
-
gap: 8px;
|
|
287
|
-
margin-bottom: 12px;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
.cn-audit-filters__select { min-width: 0; }
|
|
291
|
-
.cn-audit-filters__date { min-width: 0; }
|
|
292
|
-
|
|
293
|
-
.cn-sidebar-tab__load-more { margin-top: 8px; }
|
|
294
|
-
|
|
295
|
-
.cn-audit-entry { cursor: pointer; }
|
|
296
|
-
|
|
297
|
-
.cn-audit-details {
|
|
298
|
-
padding: 8px 12px 12px 52px;
|
|
299
|
-
font-size: 12px;
|
|
300
|
-
border-bottom: 1px solid var(--color-border);
|
|
301
|
-
animation: cn-slide-down 0.15s ease;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
@keyframes cn-slide-down {
|
|
305
|
-
from { opacity: 0; max-height: 0; }
|
|
306
|
-
to { opacity: 1; max-height: 600px; }
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
.cn-audit-details__row {
|
|
310
|
-
display: flex;
|
|
311
|
-
gap: 8px;
|
|
312
|
-
padding: 2px 0;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
.cn-audit-details__label {
|
|
316
|
-
color: var(--color-text-maxcontrast);
|
|
317
|
-
min-width: 56px;
|
|
318
|
-
font-weight: 500;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
.cn-audit-details__mono {
|
|
322
|
-
font-family: monospace;
|
|
323
|
-
font-size: 11px;
|
|
324
|
-
word-break: break-all;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
.cn-audit-details__changes {
|
|
328
|
-
margin-top: 8px;
|
|
329
|
-
padding-top: 8px;
|
|
330
|
-
border-top: 1px solid var(--color-border);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
.cn-audit-details__change {
|
|
334
|
-
padding: 4px 0 4px 8px;
|
|
335
|
-
border-left: 2px solid var(--color-border);
|
|
336
|
-
margin: 4px 0;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
.cn-audit-details__field {
|
|
340
|
-
font-weight: 500;
|
|
341
|
-
display: block;
|
|
342
|
-
margin-bottom: 2px;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
.cn-audit-details__values {
|
|
346
|
-
display: flex;
|
|
347
|
-
gap: 6px;
|
|
348
|
-
align-items: baseline;
|
|
349
|
-
flex-wrap: wrap;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
.cn-audit-details__old {
|
|
353
|
-
color: var(--color-error, #e53935);
|
|
354
|
-
text-decoration: line-through;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
.cn-audit-details__arrow {
|
|
358
|
-
color: var(--color-text-maxcontrast);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
.cn-audit-details__new {
|
|
362
|
-
color: var(--color-success, #43a047);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
.cn-audit-details__null {
|
|
366
|
-
color: var(--color-text-maxcontrast);
|
|
367
|
-
font-style: italic;
|
|
368
|
-
}
|
|
369
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="cn-sidebar-tab">
|
|
3
|
+
<NcLoadingIcon v-if="loading" />
|
|
4
|
+
<template v-else-if="entries.length > 0">
|
|
5
|
+
<!-- Filters -->
|
|
6
|
+
<div class="cn-audit-filters">
|
|
7
|
+
<NcSelect
|
|
8
|
+
v-model="filterAction"
|
|
9
|
+
:options="actionOptions"
|
|
10
|
+
:placeholder="actionFilterLabel"
|
|
11
|
+
:multiple="true"
|
|
12
|
+
:close-on-select="false"
|
|
13
|
+
class="cn-audit-filters__select" />
|
|
14
|
+
<NcSelect
|
|
15
|
+
v-model="filterUser"
|
|
16
|
+
:options="userOptions"
|
|
17
|
+
:placeholder="userFilterLabel"
|
|
18
|
+
:multiple="true"
|
|
19
|
+
:close-on-select="false"
|
|
20
|
+
class="cn-audit-filters__select" />
|
|
21
|
+
<NcDateTimePickerNative
|
|
22
|
+
id="audit-date-from"
|
|
23
|
+
v-model="filterDateFrom"
|
|
24
|
+
:label="fromLabel"
|
|
25
|
+
type="date"
|
|
26
|
+
class="cn-audit-filters__date" />
|
|
27
|
+
<NcDateTimePickerNative
|
|
28
|
+
id="audit-date-to"
|
|
29
|
+
v-model="filterDateTo"
|
|
30
|
+
:label="toLabel"
|
|
31
|
+
type="date"
|
|
32
|
+
class="cn-audit-filters__date" />
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div v-if="entries.length === 0 && !loading" class="cn-sidebar-tab__empty">
|
|
36
|
+
{{ noMatchLabel }}
|
|
37
|
+
</div>
|
|
38
|
+
<div v-else class="cn-sidebar-tab__list">
|
|
39
|
+
<div v-for="entry in entries" :key="entry.id" class="cn-audit-entry">
|
|
40
|
+
<NcListItem
|
|
41
|
+
:name="formatDate(entry.created)"
|
|
42
|
+
:bold="false"
|
|
43
|
+
:details="entry.action"
|
|
44
|
+
:counter-number="changedCount(entry)"
|
|
45
|
+
@click="toggleExpand(entry.id)">
|
|
46
|
+
<template #icon>
|
|
47
|
+
<History :size="32" />
|
|
48
|
+
</template>
|
|
49
|
+
<template #subname>
|
|
50
|
+
{{ entry.userName || entry.user || 'System' }}
|
|
51
|
+
</template>
|
|
52
|
+
</NcListItem>
|
|
53
|
+
<!-- Expandable details -->
|
|
54
|
+
<div v-if="expandedId === entry.id" class="cn-audit-details">
|
|
55
|
+
<div class="cn-audit-details__row">
|
|
56
|
+
<span class="cn-audit-details__label">Action</span>
|
|
57
|
+
<span>{{ entry.action }}</span>
|
|
58
|
+
</div>
|
|
59
|
+
<div class="cn-audit-details__row">
|
|
60
|
+
<span class="cn-audit-details__label">User</span>
|
|
61
|
+
<span>{{ entry.userName || entry.user || 'System' }}</span>
|
|
62
|
+
</div>
|
|
63
|
+
<div class="cn-audit-details__row">
|
|
64
|
+
<span class="cn-audit-details__label">Date</span>
|
|
65
|
+
<span>{{ formatDate(entry.created) }}</span>
|
|
66
|
+
</div>
|
|
67
|
+
<div v-if="entry.ipAddress" class="cn-audit-details__row">
|
|
68
|
+
<span class="cn-audit-details__label">IP</span>
|
|
69
|
+
<span>{{ entry.ipAddress }}</span>
|
|
70
|
+
</div>
|
|
71
|
+
<div v-if="entry.session" class="cn-audit-details__row">
|
|
72
|
+
<span class="cn-audit-details__label">Session</span>
|
|
73
|
+
<span class="cn-audit-details__mono">{{ entry.session }}</span>
|
|
74
|
+
</div>
|
|
75
|
+
<!-- Changed fields -->
|
|
76
|
+
<div v-if="entry.changed && Object.keys(entry.changed).length > 0" class="cn-audit-details__changes">
|
|
77
|
+
<span class="cn-audit-details__label">Changes</span>
|
|
78
|
+
<div
|
|
79
|
+
v-for="(change, field) in entry.changed"
|
|
80
|
+
:key="field"
|
|
81
|
+
class="cn-audit-details__change">
|
|
82
|
+
<span class="cn-audit-details__field">{{ field }}</span>
|
|
83
|
+
<div v-if="isSimpleValue(change)" class="cn-audit-details__values">
|
|
84
|
+
<span v-if="change.old !== null && change.old !== undefined" class="cn-audit-details__old">{{ formatValue(change.old) }}</span>
|
|
85
|
+
<span v-if="change.old !== null && change.new !== null" class="cn-audit-details__arrow">→</span>
|
|
86
|
+
<span v-if="change.new !== null && change.new !== undefined" class="cn-audit-details__new">{{ formatValue(change.new) }}</span>
|
|
87
|
+
<span v-if="change.old === null && change.new === null" class="cn-audit-details__null">null</span>
|
|
88
|
+
</div>
|
|
89
|
+
<div v-else class="cn-audit-details__values">
|
|
90
|
+
<span class="cn-audit-details__mono">{{ formatValue(change) }}</span>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
<!-- Load more -->
|
|
97
|
+
<NcButton
|
|
98
|
+
v-if="hasMore"
|
|
99
|
+
type="tertiary"
|
|
100
|
+
:wide="true"
|
|
101
|
+
:disabled="loadingMore"
|
|
102
|
+
class="cn-sidebar-tab__load-more"
|
|
103
|
+
@click="loadMore">
|
|
104
|
+
<template v-if="loadingMore" #icon>
|
|
105
|
+
<NcLoadingIcon :size="20" />
|
|
106
|
+
</template>
|
|
107
|
+
{{ loadingMore ? '' : loadMoreLabel }}
|
|
108
|
+
</NcButton>
|
|
109
|
+
</div>
|
|
110
|
+
</template>
|
|
111
|
+
<div v-else class="cn-sidebar-tab__empty">
|
|
112
|
+
{{ noAuditTrailLabel }}
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
</template>
|
|
116
|
+
|
|
117
|
+
<script>
|
|
118
|
+
import { translate as t } from '@nextcloud/l10n'
|
|
119
|
+
import { NcButton, NcListItem, NcLoadingIcon, NcSelect, NcDateTimePickerNative } from '@nextcloud/vue'
|
|
120
|
+
import History from 'vue-material-design-icons/History.vue'
|
|
121
|
+
import { buildHeaders } from '../../utils/index.js'
|
|
122
|
+
|
|
123
|
+
export default {
|
|
124
|
+
name: 'CnAuditTrailTab',
|
|
125
|
+
|
|
126
|
+
components: { NcButton, NcListItem, NcLoadingIcon, NcSelect, NcDateTimePickerNative, History },
|
|
127
|
+
|
|
128
|
+
props: {
|
|
129
|
+
objectId: { type: String, required: true },
|
|
130
|
+
register: { type: String, default: '' },
|
|
131
|
+
schema: { type: String, default: '' },
|
|
132
|
+
apiBase: { type: String, default: '/apps/openregister/api' },
|
|
133
|
+
noAuditTrailLabel: { type: String, default: () => t('nextcloud-vue', 'No audit trail entries') },
|
|
134
|
+
noMatchLabel: { type: String, default: () => t('nextcloud-vue', 'No matching entries') },
|
|
135
|
+
actionFilterLabel: { type: String, default: () => t('nextcloud-vue', 'Action') },
|
|
136
|
+
userFilterLabel: { type: String, default: () => t('nextcloud-vue', 'User') },
|
|
137
|
+
fromLabel: { type: String, default: () => t('nextcloud-vue', 'From') },
|
|
138
|
+
toLabel: { type: String, default: () => t('nextcloud-vue', 'To') },
|
|
139
|
+
loadMoreLabel: { type: String, default: () => t('nextcloud-vue', 'Load more') },
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
data() {
|
|
143
|
+
return {
|
|
144
|
+
entries: [],
|
|
145
|
+
loading: false,
|
|
146
|
+
loadingMore: false,
|
|
147
|
+
expandedId: null,
|
|
148
|
+
filterAction: [],
|
|
149
|
+
filterUser: [],
|
|
150
|
+
filterDateFrom: null,
|
|
151
|
+
filterDateTo: null,
|
|
152
|
+
page: 1,
|
|
153
|
+
total: 0,
|
|
154
|
+
limit: 20,
|
|
155
|
+
actionOptions: ['create', 'read', 'update', 'delete'],
|
|
156
|
+
userOptions: [],
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
computed: {
|
|
161
|
+
hasMore() {
|
|
162
|
+
return this.entries.length < this.total
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
watch: {
|
|
167
|
+
objectId: {
|
|
168
|
+
immediate: true,
|
|
169
|
+
handler(id) { if (id) this.fetchAuditTrails() },
|
|
170
|
+
},
|
|
171
|
+
filterAction() { this.resetAndFetch() },
|
|
172
|
+
filterUser() { this.resetAndFetch() },
|
|
173
|
+
filterDateFrom() { this.resetAndFetch() },
|
|
174
|
+
filterDateTo() { this.resetAndFetch() },
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
methods: {
|
|
178
|
+
resetAndFetch() {
|
|
179
|
+
this.page = 1
|
|
180
|
+
this.entries = []
|
|
181
|
+
this.fetchAuditTrails()
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
buildQueryParams() {
|
|
185
|
+
const params = new URLSearchParams()
|
|
186
|
+
params.set('limit', this.limit)
|
|
187
|
+
params.set('_page', this.page)
|
|
188
|
+
params.set('_sort[created]', 'DESC')
|
|
189
|
+
if (this.filterAction?.length) params.set('action', this.filterAction.join(','))
|
|
190
|
+
if (this.filterUser?.length) params.set('user_name', this.filterUser.join(','))
|
|
191
|
+
if (this.filterDateFrom) {
|
|
192
|
+
params.set('_dateFrom', new Date(this.filterDateFrom).toISOString().split('T')[0])
|
|
193
|
+
}
|
|
194
|
+
if (this.filterDateTo) {
|
|
195
|
+
params.set('_dateTo', new Date(this.filterDateTo).toISOString().split('T')[0])
|
|
196
|
+
}
|
|
197
|
+
return params.toString()
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
async fetchAuditTrails() {
|
|
201
|
+
if (!this.register || !this.schema) return
|
|
202
|
+
this.loading = this.page === 1
|
|
203
|
+
this.loadingMore = this.page > 1
|
|
204
|
+
try {
|
|
205
|
+
const query = this.buildQueryParams()
|
|
206
|
+
const response = await fetch(
|
|
207
|
+
`${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/audit-trails?${query}`,
|
|
208
|
+
{ headers: buildHeaders() },
|
|
209
|
+
)
|
|
210
|
+
if (response.ok) {
|
|
211
|
+
const data = await response.json()
|
|
212
|
+
const results = data.results || data || []
|
|
213
|
+
if (this.page === 1) {
|
|
214
|
+
this.entries = results
|
|
215
|
+
} else {
|
|
216
|
+
this.entries = [...this.entries, ...results]
|
|
217
|
+
}
|
|
218
|
+
this.total = data.total || this.entries.length
|
|
219
|
+
// Build user options from all seen entries
|
|
220
|
+
const users = new Set(this.entries.map(e => e.userName || e.user).filter(Boolean))
|
|
221
|
+
this.userOptions = [...users].sort()
|
|
222
|
+
}
|
|
223
|
+
} catch (err) {
|
|
224
|
+
console.error('CnAuditTrailTab: Failed to fetch audit trails', err)
|
|
225
|
+
} finally {
|
|
226
|
+
this.loading = false
|
|
227
|
+
this.loadingMore = false
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
loadMore() {
|
|
232
|
+
this.page++
|
|
233
|
+
this.fetchAuditTrails()
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
toggleExpand(id) {
|
|
237
|
+
this.expandedId = this.expandedId === id ? null : id
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
changedCount(entry) {
|
|
241
|
+
if (!entry.changed || typeof entry.changed !== 'object') return 0
|
|
242
|
+
return Object.keys(entry.changed).length
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
isSimpleValue(change) {
|
|
246
|
+
return change && typeof change === 'object' && ('old' in change || 'new' in change)
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
formatValue(val) {
|
|
250
|
+
if (val === null || val === undefined) return 'null'
|
|
251
|
+
if (typeof val === 'object') return JSON.stringify(val)
|
|
252
|
+
return String(val)
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
formatDate(dateStr) {
|
|
256
|
+
if (!dateStr) return ''
|
|
257
|
+
try {
|
|
258
|
+
return new Date(dateStr).toLocaleString(undefined, {
|
|
259
|
+
year: 'numeric',
|
|
260
|
+
month: 'short',
|
|
261
|
+
day: 'numeric',
|
|
262
|
+
hour: '2-digit',
|
|
263
|
+
minute: '2-digit',
|
|
264
|
+
})
|
|
265
|
+
} catch { return dateStr }
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
}
|
|
269
|
+
</script>
|
|
270
|
+
|
|
271
|
+
<style scoped>
|
|
272
|
+
.cn-sidebar-tab { padding: 12px; }
|
|
273
|
+
|
|
274
|
+
.cn-sidebar-tab__empty {
|
|
275
|
+
text-align: center;
|
|
276
|
+
padding: 24px 12px;
|
|
277
|
+
color: var(--color-text-maxcontrast);
|
|
278
|
+
font-size: 13px;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.cn-sidebar-tab__list { display: flex; flex-direction: column; gap: 2px; }
|
|
282
|
+
|
|
283
|
+
.cn-audit-filters {
|
|
284
|
+
display: grid;
|
|
285
|
+
grid-template-columns: 1fr 1fr;
|
|
286
|
+
gap: 8px;
|
|
287
|
+
margin-bottom: 12px;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.cn-audit-filters__select { min-width: 0; }
|
|
291
|
+
.cn-audit-filters__date { min-width: 0; }
|
|
292
|
+
|
|
293
|
+
.cn-sidebar-tab__load-more { margin-top: 8px; }
|
|
294
|
+
|
|
295
|
+
.cn-audit-entry { cursor: pointer; }
|
|
296
|
+
|
|
297
|
+
.cn-audit-details {
|
|
298
|
+
padding: 8px 12px 12px 52px;
|
|
299
|
+
font-size: 12px;
|
|
300
|
+
border-bottom: 1px solid var(--color-border);
|
|
301
|
+
animation: cn-slide-down 0.15s ease;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
@keyframes cn-slide-down {
|
|
305
|
+
from { opacity: 0; max-height: 0; }
|
|
306
|
+
to { opacity: 1; max-height: 600px; }
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.cn-audit-details__row {
|
|
310
|
+
display: flex;
|
|
311
|
+
gap: 8px;
|
|
312
|
+
padding: 2px 0;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.cn-audit-details__label {
|
|
316
|
+
color: var(--color-text-maxcontrast);
|
|
317
|
+
min-width: 56px;
|
|
318
|
+
font-weight: 500;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.cn-audit-details__mono {
|
|
322
|
+
font-family: monospace;
|
|
323
|
+
font-size: 11px;
|
|
324
|
+
word-break: break-all;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.cn-audit-details__changes {
|
|
328
|
+
margin-top: 8px;
|
|
329
|
+
padding-top: 8px;
|
|
330
|
+
border-top: 1px solid var(--color-border);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.cn-audit-details__change {
|
|
334
|
+
padding: 4px 0 4px 8px;
|
|
335
|
+
border-left: 2px solid var(--color-border);
|
|
336
|
+
margin: 4px 0;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.cn-audit-details__field {
|
|
340
|
+
font-weight: 500;
|
|
341
|
+
display: block;
|
|
342
|
+
margin-bottom: 2px;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.cn-audit-details__values {
|
|
346
|
+
display: flex;
|
|
347
|
+
gap: 6px;
|
|
348
|
+
align-items: baseline;
|
|
349
|
+
flex-wrap: wrap;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.cn-audit-details__old {
|
|
353
|
+
color: var(--color-error, #e53935);
|
|
354
|
+
text-decoration: line-through;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.cn-audit-details__arrow {
|
|
358
|
+
color: var(--color-text-maxcontrast);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.cn-audit-details__new {
|
|
362
|
+
color: var(--color-success, #43a047);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.cn-audit-details__null {
|
|
366
|
+
color: var(--color-text-maxcontrast);
|
|
367
|
+
font-style: italic;
|
|
368
|
+
}
|
|
369
|
+
</style>
|