@conduction/nextcloud-vue 0.1.0-beta.1 → 0.1.0-beta.11

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.
Files changed (208) hide show
  1. package/README.md +226 -0
  2. package/css/index.css +5 -0
  3. package/dist/nextcloud-vue.cjs.js +79416 -7715
  4. package/dist/nextcloud-vue.cjs.js.map +1 -1
  5. package/dist/nextcloud-vue.css +3583 -504
  6. package/dist/nextcloud-vue.esm.js +79343 -7692
  7. package/dist/nextcloud-vue.esm.js.map +1 -1
  8. package/l10n/en.json +164 -0
  9. package/l10n/nl.json +164 -0
  10. package/package.json +104 -63
  11. package/src/components/CnActionsBar/CnActionsBar.vue +254 -0
  12. package/src/components/CnActionsBar/index.js +1 -0
  13. package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +570 -0
  14. package/src/components/CnAdvancedFormDialog/CnDataTab.vue +217 -0
  15. package/src/components/CnAdvancedFormDialog/CnMetadataTab.vue +121 -0
  16. package/src/components/CnAdvancedFormDialog/CnPropertiesTab.vue +422 -0
  17. package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -0
  18. package/src/components/CnAdvancedFormDialog/index.js +1 -0
  19. package/src/components/CnCard/CnCard.vue +415 -0
  20. package/src/components/CnCard/index.js +1 -0
  21. package/src/components/CnCardGrid/CnCardGrid.vue +156 -152
  22. package/src/components/CnCardGrid/index.js +1 -1
  23. package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -132
  24. package/src/components/CnCellRenderer/index.js +1 -1
  25. package/src/components/CnChartWidget/CnChartWidget.vue +346 -0
  26. package/src/components/CnChartWidget/index.js +1 -0
  27. package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -77
  28. package/src/components/CnConfigurationCard/index.js +1 -1
  29. package/src/components/CnContextMenu/CnContextMenu.vue +142 -0
  30. package/src/components/CnContextMenu/index.js +1 -0
  31. package/src/components/CnCopyDialog/CnCopyDialog.vue +266 -0
  32. package/src/components/CnCopyDialog/index.js +1 -0
  33. package/src/components/CnDashboardGrid/CnDashboardGrid.vue +229 -0
  34. package/src/components/CnDashboardGrid/index.js +1 -0
  35. package/src/components/CnDashboardPage/CnDashboardPage.vue +397 -0
  36. package/src/components/CnDashboardPage/index.js +1 -0
  37. package/src/components/CnDataTable/CnDataTable.vue +362 -354
  38. package/src/components/CnDataTable/index.js +1 -1
  39. package/src/components/CnDeleteDialog/CnDeleteDialog.vue +177 -0
  40. package/src/components/CnDeleteDialog/index.js +1 -0
  41. package/src/components/CnDetailCard/CnDetailCard.vue +225 -0
  42. package/src/components/CnDetailCard/index.js +1 -0
  43. package/src/components/CnDetailGrid/CnDetailGrid.vue +256 -0
  44. package/src/components/CnDetailGrid/index.js +1 -0
  45. package/src/components/CnDetailPage/CnDetailPage.vue +432 -0
  46. package/src/components/CnDetailPage/index.js +1 -0
  47. package/src/components/CnFacetSidebar/CnFacetSidebar.vue +234 -223
  48. package/src/components/CnFacetSidebar/index.js +1 -1
  49. package/src/components/CnFilterBar/CnFilterBar.vue +153 -152
  50. package/src/components/CnFilterBar/index.js +1 -1
  51. package/src/components/CnFormDialog/CnFormDialog.vue +1047 -0
  52. package/src/components/CnFormDialog/index.js +1 -0
  53. package/src/components/CnIcon/CnIcon.vue +89 -0
  54. package/src/components/CnIcon/index.js +1 -0
  55. package/src/components/CnIndexPage/CnIndexPage.vue +980 -682
  56. package/src/components/CnIndexPage/index.js +1 -1
  57. package/src/components/CnIndexSidebar/CnIndexSidebar.vue +536 -0
  58. package/src/components/CnIndexSidebar/index.js +1 -0
  59. package/src/components/CnInfoWidget/CnInfoWidget.vue +219 -0
  60. package/src/components/CnInfoWidget/index.js +1 -0
  61. package/src/components/CnItemCard/CnItemCard.vue +134 -0
  62. package/src/components/CnItemCard/index.js +1 -0
  63. package/src/components/CnJsonViewer/CnJsonViewer.vue +312 -0
  64. package/src/components/CnJsonViewer/index.js +1 -0
  65. package/src/components/CnKpiGrid/CnKpiGrid.vue +93 -89
  66. package/src/components/CnKpiGrid/index.js +1 -1
  67. package/src/components/CnMassActionBar/CnMassActionBar.vue +161 -160
  68. package/src/components/CnMassActionBar/index.js +1 -1
  69. package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +327 -320
  70. package/src/components/CnMassCopyDialog/index.js +1 -1
  71. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +245 -238
  72. package/src/components/CnMassDeleteDialog/index.js +1 -1
  73. package/src/components/CnMassExportDialog/CnMassExportDialog.vue +191 -190
  74. package/src/components/CnMassExportDialog/index.js +1 -1
  75. package/src/components/CnMassImportDialog/CnMassImportDialog.vue +494 -491
  76. package/src/components/CnMassImportDialog/index.js +1 -1
  77. package/src/components/CnNoteCard/CnNoteCard.vue +149 -0
  78. package/src/components/CnNoteCard/index.js +1 -0
  79. package/src/components/CnNotesCard/CnNotesCard.vue +416 -0
  80. package/src/components/CnNotesCard/index.js +1 -0
  81. package/src/components/CnObjectCard/CnObjectCard.vue +294 -292
  82. package/src/components/CnObjectCard/index.js +1 -1
  83. package/src/components/CnObjectDataWidget/CnObjectDataWidget.vue +854 -0
  84. package/src/components/CnObjectDataWidget/index.js +1 -0
  85. package/src/components/CnObjectMetadataWidget/CnObjectMetadataWidget.vue +289 -0
  86. package/src/components/CnObjectMetadataWidget/index.js +1 -0
  87. package/src/components/CnObjectSidebar/CnAuditTrailTab.vue +369 -0
  88. package/src/components/CnObjectSidebar/CnFilesTab.vue +287 -0
  89. package/src/components/CnObjectSidebar/CnNotesTab.vue +250 -0
  90. package/src/components/CnObjectSidebar/CnObjectSidebar.vue +255 -0
  91. package/src/components/CnObjectSidebar/CnTagsTab.vue +259 -0
  92. package/src/components/CnObjectSidebar/CnTasksTab.vue +483 -0
  93. package/src/components/CnObjectSidebar/index.js +6 -0
  94. package/src/components/CnPageHeader/CnPageHeader.vue +61 -0
  95. package/src/components/CnPageHeader/index.js +1 -0
  96. package/src/components/CnPagination/CnPagination.vue +253 -252
  97. package/src/components/CnPagination/index.js +1 -1
  98. package/src/components/CnProgressBar/CnProgressBar.vue +262 -0
  99. package/src/components/CnProgressBar/index.js +1 -0
  100. package/src/components/CnRegisterMapping/CnRegisterMapping.vue +793 -0
  101. package/src/components/CnRegisterMapping/index.js +1 -0
  102. package/src/components/CnRowActions/CnRowActions.vue +95 -73
  103. package/src/components/CnRowActions/index.js +1 -1
  104. package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -0
  105. package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +788 -0
  106. package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -0
  107. package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -0
  108. package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -0
  109. package/src/components/CnSchemaFormDialog/index.js +1 -0
  110. package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -92
  111. package/src/components/CnSettingsCard/index.js +1 -1
  112. package/src/components/CnSettingsSection/CnSettingsSection.vue +267 -266
  113. package/src/components/CnSettingsSection/index.js +1 -1
  114. package/src/components/CnStatsBlock/CnStatsBlock.vue +437 -366
  115. package/src/components/CnStatsBlock/index.js +1 -1
  116. package/src/components/CnStatsPanel/CnStatsPanel.vue +321 -0
  117. package/src/components/CnStatsPanel/index.js +1 -0
  118. package/src/components/CnStatusBadge/CnStatusBadge.vue +90 -77
  119. package/src/components/CnStatusBadge/index.js +1 -1
  120. package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +545 -0
  121. package/src/components/CnTabbedFormDialog/index.js +1 -0
  122. package/src/components/CnTableWidget/CnTableWidget.vue +333 -0
  123. package/src/components/CnTableWidget/index.js +1 -0
  124. package/src/components/CnTasksCard/CnTasksCard.vue +374 -0
  125. package/src/components/CnTasksCard/index.js +1 -0
  126. package/src/components/CnTileWidget/CnTileWidget.vue +159 -0
  127. package/src/components/CnTileWidget/index.js +1 -0
  128. package/src/components/CnTimelineStages/CnTimelineStages.vue +294 -0
  129. package/src/components/CnTimelineStages/index.js +1 -0
  130. package/src/components/CnUserActionMenu/CnUserActionMenu.vue +436 -0
  131. package/src/components/CnUserActionMenu/index.js +1 -0
  132. package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +313 -312
  133. package/src/components/CnVersionInfoCard/index.js +1 -1
  134. package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -0
  135. package/src/components/CnWidgetRenderer/index.js +1 -0
  136. package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +248 -0
  137. package/src/components/CnWidgetWrapper/index.js +1 -0
  138. package/src/components/index.js +57 -25
  139. package/src/composables/index.js +5 -3
  140. package/src/composables/useContextMenu.js +126 -0
  141. package/src/composables/useDashboardView.js +286 -0
  142. package/src/composables/useDetailView.js +290 -132
  143. package/src/composables/useListView.js +364 -153
  144. package/src/composables/useSubResource.js +142 -142
  145. package/src/constants/metadata.js +30 -0
  146. package/src/css/CnSchemaFormDialog.css +546 -0
  147. package/src/css/__sample_nextcloud_tokens.css +110 -0
  148. package/src/css/actions-bar.css +54 -0
  149. package/src/css/badge.css +83 -51
  150. package/src/css/card.css +129 -128
  151. package/src/css/context-menu.css +20 -0
  152. package/src/css/dashboard.css +70 -0
  153. package/src/css/detail-page.css +235 -0
  154. package/src/css/detail.css +68 -68
  155. package/src/css/index-page.css +44 -0
  156. package/src/css/index-sidebar.css +193 -0
  157. package/src/css/index.css +17 -8
  158. package/src/css/layout.css +90 -90
  159. package/src/css/page-header.css +35 -0
  160. package/src/css/pagination.css +72 -72
  161. package/src/css/table.css +142 -143
  162. package/src/css/timeline-stages.css +220 -0
  163. package/src/css/utilities.css +46 -46
  164. package/src/index.js +95 -50
  165. package/src/l10n/index.js +12 -0
  166. package/src/mixins/gridLayout.js +118 -0
  167. package/src/store/createCrudStore.d.ts +350 -0
  168. package/src/store/createCrudStore.js +413 -0
  169. package/src/store/createSubResourcePlugin.js +125 -135
  170. package/src/store/index.js +4 -3
  171. package/src/store/pluginMerge.js +55 -0
  172. package/src/store/plugins/auditTrails.js +357 -17
  173. package/src/store/plugins/files.js +250 -186
  174. package/src/store/plugins/index.js +8 -4
  175. package/src/store/plugins/lifecycle.js +180 -180
  176. package/src/store/plugins/logs.d.ts +22 -0
  177. package/src/store/plugins/logs.js +172 -0
  178. package/src/store/plugins/registerMapping.js +195 -0
  179. package/src/store/plugins/relations.js +68 -68
  180. package/src/store/plugins/search.js +385 -0
  181. package/src/store/plugins/selection.js +104 -0
  182. package/src/store/useObjectStore.js +793 -625
  183. package/src/types/auditTrail.d.ts +32 -32
  184. package/src/types/file.d.ts +23 -23
  185. package/src/types/index.d.ts +67 -35
  186. package/src/types/notification.d.ts +36 -36
  187. package/src/types/object.d.ts +40 -40
  188. package/src/types/organisation.d.ts +41 -41
  189. package/src/types/register.d.ts +25 -25
  190. package/src/types/schema.d.ts +39 -39
  191. package/src/types/shared.d.ts +79 -79
  192. package/src/types/source.d.ts +14 -14
  193. package/src/types/task.d.ts +31 -31
  194. package/src/utils/errors.js +96 -96
  195. package/src/utils/getTheme.js +9 -0
  196. package/src/utils/headers.js +80 -44
  197. package/src/utils/id.js +13 -0
  198. package/src/utils/index.js +4 -3
  199. package/src/utils/schema.js +423 -287
  200. package/src/utils/widgetVisibility.js +162 -0
  201. package/src/components/CnDetailViewLayout/CnDetailViewLayout.vue +0 -88
  202. package/src/components/CnDetailViewLayout/index.js +0 -1
  203. package/src/components/CnEmptyState/CnEmptyState.vue +0 -78
  204. package/src/components/CnEmptyState/index.js +0 -1
  205. package/src/components/CnListViewLayout/CnListViewLayout.vue +0 -80
  206. package/src/components/CnListViewLayout/index.js +0 -1
  207. package/src/components/CnViewModeToggle/CnViewModeToggle.vue +0 -77
  208. package/src/components/CnViewModeToggle/index.js +0 -1
@@ -0,0 +1 @@
1
+ export { default as CnObjectDataWidget } from './CnObjectDataWidget.vue'
@@ -0,0 +1,289 @@
1
+ <!--
2
+ CnObjectMetadataWidget — Read-only metadata display widget.
3
+
4
+ Shows system/internal metadata for an OpenRegister object in a horizontal
5
+ label-value grid. Automatically extracts known metadata fields from the object
6
+ (id, uuid, uri, register, schema, created, updated, owner, etc.).
7
+
8
+ Not editable — purely informational. Wraps CnDetailCard + CnDetailGrid.
9
+ -->
10
+ <template>
11
+ <CnDetailCard :title="title"
12
+ :icon="iconComponent"
13
+ :collapsible="collapsible"
14
+ :collapsed="collapsed">
15
+ <template #actions>
16
+ <slot name="actions" />
17
+ </template>
18
+
19
+ <CnDetailGrid
20
+ :items="metadataItems"
21
+ :layout="layout"
22
+ :columns="columns"
23
+ :label-width="labelWidth"
24
+ :accent="false"
25
+ :empty-label="emptyLabel" />
26
+ </CnDetailCard>
27
+ </template>
28
+
29
+ <script>
30
+ import { translate as t } from '@nextcloud/l10n'
31
+ import { CnDetailCard } from '../CnDetailCard/index.js'
32
+ import { CnDetailGrid } from '../CnDetailGrid/index.js'
33
+
34
+ /**
35
+ * Known metadata fields and their labels.
36
+ * These are the standard fields from OpenRegister's @self / system fields.
37
+ */
38
+ const METADATA_FIELDS = [
39
+ { key: 'id', label: 'ID' },
40
+ { key: 'uuid', label: 'UUID' },
41
+ { key: 'uri', label: 'URI' },
42
+ { key: 'register', label: 'Register' },
43
+ { key: 'schema', label: 'Schema' },
44
+ { key: 'status', label: 'Status' },
45
+ { key: 'owner', label: 'Owner' },
46
+ { key: 'organization', label: 'Organization' },
47
+ { key: 'created', label: 'Created', format: 'date-time' },
48
+ { key: 'updated', label: 'Updated', format: 'date-time' },
49
+ { key: 'folder', label: 'Folder' },
50
+ { key: 'textRepresentation', label: 'Text Representation' },
51
+ { key: 'locked', label: 'Locked' },
52
+ { key: 'version', label: 'Version' },
53
+ ]
54
+
55
+ /**
56
+ * CnObjectMetadataWidget — Read-only metadata display widget.
57
+ *
58
+ * Automatically extracts and formats metadata from an OpenRegister object.
59
+ * Understands both flat objects (where metadata is at the top level) and
60
+ * objects with a `@self` metadata block.
61
+ *
62
+ * @example Basic usage
63
+ * <CnObjectMetadataWidget :object-data="publication" />
64
+ *
65
+ * @example With extra items
66
+ * <CnObjectMetadataWidget
67
+ * title="System Info"
68
+ * :object-data="entity"
69
+ * :extra-items="[
70
+ * { label: 'Source', value: entity.source },
71
+ * { label: 'Catalog', value: entity.catalog },
72
+ * ]" />
73
+ *
74
+ * @example Selective display
75
+ * <CnObjectMetadataWidget
76
+ * :object-data="entity"
77
+ * :include="['id', 'uuid', 'created', 'updated', 'owner']" />
78
+ */
79
+ export default {
80
+ name: 'CnObjectMetadataWidget',
81
+
82
+ components: {
83
+ CnDetailCard,
84
+ CnDetailGrid,
85
+ },
86
+
87
+ props: {
88
+ /** Widget title shown in the card header */
89
+ title: {
90
+ type: String,
91
+ default: () => t('nextcloud-vue', 'Metadata'),
92
+ },
93
+ /** Optional MDI icon component for the header */
94
+ icon: {
95
+ type: [Object, Function],
96
+ default: null,
97
+ },
98
+ /**
99
+ * The object data containing metadata.
100
+ * Supports flat objects and objects with `@self` metadata block.
101
+ */
102
+ objectData: {
103
+ type: Object,
104
+ required: true,
105
+ },
106
+ /**
107
+ * Layout mode for the grid: 'grid' or 'horizontal'.
108
+ */
109
+ layout: {
110
+ type: String,
111
+ default: 'horizontal',
112
+ },
113
+ /**
114
+ * Number of grid columns (only for layout='grid').
115
+ */
116
+ columns: {
117
+ type: Number,
118
+ default: 0,
119
+ },
120
+ /**
121
+ * Min width for labels in horizontal layout.
122
+ */
123
+ labelWidth: {
124
+ type: Number,
125
+ default: 150,
126
+ },
127
+ /**
128
+ * Additional metadata items to display.
129
+ * @type {Array<{ label: string, value: string|number }>}
130
+ */
131
+ extraItems: {
132
+ type: Array,
133
+ default: () => [],
134
+ },
135
+ /**
136
+ * Metadata fields to include (whitelist). If null, all available are shown.
137
+ * @type {string[]|null}
138
+ */
139
+ include: {
140
+ type: Array,
141
+ default: null,
142
+ },
143
+ /**
144
+ * Metadata fields to exclude.
145
+ * @type {string[]}
146
+ */
147
+ exclude: {
148
+ type: Array,
149
+ default: () => [],
150
+ },
151
+ /** Whether the card can be collapsed */
152
+ collapsible: {
153
+ type: Boolean,
154
+ default: false,
155
+ },
156
+ /** Initial collapsed state */
157
+ collapsed: {
158
+ type: Boolean,
159
+ default: false,
160
+ },
161
+ /** Label shown when no metadata available */
162
+ emptyLabel: {
163
+ type: String,
164
+ default: () => t('nextcloud-vue', 'No metadata available'),
165
+ },
166
+ },
167
+
168
+ computed: {
169
+ iconComponent() {
170
+ return this.icon
171
+ },
172
+
173
+ /**
174
+ * Merged metadata source: combines @self block with top-level fields.
175
+ * @self fields take priority over top-level for shared keys.
176
+ */
177
+ metadataSource() {
178
+ const selfBlock = this.objectData['@self'] || {}
179
+ return { ...this.objectData, ...selfBlock }
180
+ },
181
+
182
+ /**
183
+ * Build the items array for CnDetailGrid from known metadata fields.
184
+ */
185
+ metadataItems() {
186
+ const source = this.metadataSource
187
+ const items = []
188
+
189
+ for (const def of METADATA_FIELDS) {
190
+ // Filter by include/exclude
191
+ if (this.include && !this.include.includes(def.key)) continue
192
+ if (this.exclude.includes(def.key)) continue
193
+
194
+ const raw = source[def.key]
195
+ if (raw === undefined || raw === null) continue
196
+
197
+ items.push({
198
+ label: def.label,
199
+ value: this.formatMetadataValue(raw, def),
200
+ })
201
+ }
202
+
203
+ // Append extra items
204
+ for (const item of this.extraItems) {
205
+ items.push(item)
206
+ }
207
+
208
+ return items
209
+ },
210
+ },
211
+
212
+ methods: {
213
+ /**
214
+ * Format a metadata value for display.
215
+ * @param value
216
+ * @param def
217
+ */
218
+ formatMetadataValue(value, def) {
219
+ if (value === null || value === undefined) return '-'
220
+
221
+ // Date-time formatting
222
+ if (def.format === 'date-time') {
223
+ try {
224
+ const date = new Date(value)
225
+ if (Number.isNaN(date.getTime())) return String(value)
226
+ return date.toLocaleDateString(undefined, {
227
+ day: '2-digit',
228
+ month: '2-digit',
229
+ year: 'numeric',
230
+ }) + ', ' + date.toLocaleTimeString(undefined, {
231
+ hour: '2-digit',
232
+ minute: '2-digit',
233
+ second: '2-digit',
234
+ })
235
+ } catch {
236
+ return String(value)
237
+ }
238
+ }
239
+
240
+ // Booleans
241
+ if (typeof value === 'boolean') {
242
+ return value ? 'Yes' : 'No'
243
+ }
244
+
245
+ // Arrays
246
+ if (Array.isArray(value)) {
247
+ return value.length > 0 ? value.join(', ') : '-'
248
+ }
249
+
250
+ // Objects — show as JSON snippet
251
+ if (typeof value === 'object') {
252
+ return JSON.stringify(value)
253
+ }
254
+
255
+ return String(value)
256
+ },
257
+ },
258
+ }
259
+ </script>
260
+
261
+ <style scoped>
262
+ /* Override CnDetailGrid item styling for a compact table-like appearance */
263
+ :deep(.cn-detail-grid__item) {
264
+ background: none;
265
+ border-radius: 0;
266
+ border-bottom: 1px solid var(--color-border);
267
+ padding: calc(1.5 * var(--default-grid-baseline, 4px)) 0;
268
+ }
269
+
270
+ :deep(.cn-detail-grid__item:last-child) {
271
+ border-bottom: none;
272
+ }
273
+
274
+ :deep(.cn-detail-grid--horizontal) {
275
+ gap: 0;
276
+ }
277
+
278
+ :deep(.cn-detail-grid__label) {
279
+ font-size: 0.8em;
280
+ text-transform: uppercase;
281
+ letter-spacing: 0.02em;
282
+ }
283
+
284
+ :deep(.cn-detail-grid__value) {
285
+ font-size: 0.9em;
286
+ word-break: break-all;
287
+ margin: 0;
288
+ }
289
+ </style>
@@ -0,0 +1 @@
1
+ export { default as CnObjectMetadataWidget } from './CnObjectMetadataWidget.vue'
@@ -0,0 +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>