@conduction/nextcloud-vue 0.1.0-beta.1 → 0.1.0-beta.10
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/README.md +226 -0
- package/css/index.css +5 -0
- package/dist/nextcloud-vue.cjs +67614 -0
- package/dist/nextcloud-vue.cjs.js +76311 -5905
- package/dist/nextcloud-vue.cjs.js.map +1 -1
- package/dist/nextcloud-vue.cjs.map +1 -0
- package/dist/nextcloud-vue.css +3279 -203
- package/dist/nextcloud-vue.esm.js +76240 -5882
- package/dist/nextcloud-vue.esm.js.map +1 -1
- package/package.json +89 -63
- package/src/components/CnActionsBar/CnActionsBar.vue +254 -0
- package/src/components/CnActionsBar/index.js +1 -0
- package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +569 -0
- package/src/components/CnAdvancedFormDialog/CnDataTab.vue +217 -0
- package/src/components/CnAdvancedFormDialog/CnMetadataTab.vue +121 -0
- package/src/components/CnAdvancedFormDialog/CnPropertiesTab.vue +422 -0
- package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -0
- package/src/components/CnAdvancedFormDialog/index.js +1 -0
- package/src/components/CnCard/CnCard.vue +415 -0
- package/src/components/CnCard/index.js +1 -0
- package/src/components/CnCardGrid/CnCardGrid.vue +23 -20
- package/src/components/CnCardGrid/index.js +1 -1
- package/src/components/CnCellRenderer/index.js +1 -1
- package/src/components/CnChartWidget/CnChartWidget.vue +318 -0
- package/src/components/CnChartWidget/index.js +1 -0
- package/src/components/CnConfigurationCard/index.js +1 -1
- package/src/components/CnContextMenu/CnContextMenu.vue +142 -0
- package/src/components/CnContextMenu/index.js +1 -0
- package/src/components/CnCopyDialog/CnCopyDialog.vue +257 -0
- package/src/components/CnCopyDialog/index.js +1 -0
- package/src/components/CnDashboardGrid/CnDashboardGrid.vue +229 -0
- package/src/components/CnDashboardGrid/index.js +1 -0
- package/src/components/CnDashboardPage/CnDashboardPage.vue +396 -0
- package/src/components/CnDashboardPage/index.js +1 -0
- package/src/components/CnDataTable/CnDataTable.vue +24 -16
- package/src/components/CnDataTable/index.js +1 -1
- package/src/components/CnDeleteDialog/CnDeleteDialog.vue +177 -0
- package/src/components/CnDeleteDialog/index.js +1 -0
- package/src/components/CnDetailCard/CnDetailCard.vue +225 -0
- package/src/components/CnDetailCard/index.js +1 -0
- package/src/components/CnDetailGrid/CnDetailGrid.vue +254 -0
- package/src/components/CnDetailGrid/index.js +1 -0
- package/src/components/CnDetailPage/CnDetailPage.vue +431 -0
- package/src/components/CnDetailPage/index.js +1 -0
- package/src/components/CnFacetSidebar/CnFacetSidebar.vue +12 -2
- package/src/components/CnFacetSidebar/index.js +1 -1
- package/src/components/CnFilterBar/index.js +1 -1
- package/src/components/CnFormDialog/CnFormDialog.vue +934 -0
- package/src/components/CnFormDialog/index.js +1 -0
- package/src/components/CnIcon/CnIcon.vue +89 -0
- package/src/components/CnIcon/index.js +1 -0
- package/src/components/CnIndexPage/CnIndexPage.vue +589 -291
- package/src/components/CnIndexPage/index.js +1 -1
- package/src/components/CnIndexSidebar/CnIndexSidebar.vue +535 -0
- package/src/components/CnIndexSidebar/index.js +1 -0
- package/src/components/CnInfoWidget/CnInfoWidget.vue +219 -0
- package/src/components/CnInfoWidget/index.js +1 -0
- package/src/components/CnItemCard/CnItemCard.vue +134 -0
- package/src/components/CnItemCard/index.js +1 -0
- package/src/components/CnJsonViewer/CnJsonViewer.vue +283 -0
- package/src/components/CnJsonViewer/index.js +1 -0
- package/src/components/CnKpiGrid/CnKpiGrid.vue +5 -1
- package/src/components/CnKpiGrid/index.js +1 -1
- package/src/components/CnMassActionBar/CnMassActionBar.vue +6 -5
- package/src/components/CnMassActionBar/index.js +1 -1
- package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +16 -9
- package/src/components/CnMassCopyDialog/index.js +1 -1
- package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +16 -9
- package/src/components/CnMassDeleteDialog/index.js +1 -1
- package/src/components/CnMassExportDialog/CnMassExportDialog.vue +8 -7
- package/src/components/CnMassExportDialog/index.js +1 -1
- package/src/components/CnMassImportDialog/CnMassImportDialog.vue +20 -17
- package/src/components/CnMassImportDialog/index.js +1 -1
- package/src/components/CnNoteCard/CnNoteCard.vue +149 -0
- package/src/components/CnNoteCard/index.js +1 -0
- package/src/components/CnNotesCard/CnNotesCard.vue +415 -0
- package/src/components/CnNotesCard/index.js +1 -0
- package/src/components/CnObjectCard/CnObjectCard.vue +3 -1
- package/src/components/CnObjectCard/index.js +1 -1
- package/src/components/CnObjectDataWidget/CnObjectDataWidget.vue +853 -0
- package/src/components/CnObjectDataWidget/index.js +1 -0
- package/src/components/CnObjectMetadataWidget/CnObjectMetadataWidget.vue +288 -0
- package/src/components/CnObjectMetadataWidget/index.js +1 -0
- package/src/components/CnObjectSidebar/CnAuditTrailTab.vue +368 -0
- package/src/components/CnObjectSidebar/CnFilesTab.vue +286 -0
- package/src/components/CnObjectSidebar/CnNotesTab.vue +249 -0
- package/src/components/CnObjectSidebar/CnObjectSidebar.vue +254 -0
- package/src/components/CnObjectSidebar/CnTagsTab.vue +258 -0
- package/src/components/CnObjectSidebar/CnTasksTab.vue +482 -0
- package/src/components/CnObjectSidebar/index.js +6 -0
- package/src/components/CnPageHeader/CnPageHeader.vue +61 -0
- package/src/components/CnPageHeader/index.js +1 -0
- package/src/components/CnPagination/CnPagination.vue +7 -6
- package/src/components/CnPagination/index.js +1 -1
- package/src/components/CnProgressBar/CnProgressBar.vue +262 -0
- package/src/components/CnProgressBar/index.js +1 -0
- package/src/components/CnRegisterMapping/CnRegisterMapping.vue +792 -0
- package/src/components/CnRegisterMapping/index.js +1 -0
- package/src/components/CnRowActions/CnRowActions.vue +25 -3
- package/src/components/CnRowActions/index.js +1 -1
- package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -0
- package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +787 -0
- package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -0
- package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -0
- package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -0
- package/src/components/CnSchemaFormDialog/index.js +1 -0
- package/src/components/CnSettingsCard/index.js +1 -1
- package/src/components/CnSettingsSection/index.js +1 -1
- package/src/components/CnStatsBlock/CnStatsBlock.vue +89 -19
- package/src/components/CnStatsBlock/index.js +1 -1
- package/src/components/CnStatsPanel/CnStatsPanel.vue +320 -0
- package/src/components/CnStatsPanel/index.js +1 -0
- package/src/components/CnStatusBadge/CnStatusBadge.vue +15 -2
- package/src/components/CnStatusBadge/index.js +1 -1
- package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +544 -0
- package/src/components/CnTabbedFormDialog/index.js +1 -0
- package/src/components/CnTableWidget/CnTableWidget.vue +332 -0
- package/src/components/CnTableWidget/index.js +1 -0
- package/src/components/CnTasksCard/CnTasksCard.vue +373 -0
- package/src/components/CnTasksCard/index.js +1 -0
- package/src/components/CnTileWidget/CnTileWidget.vue +159 -0
- package/src/components/CnTileWidget/index.js +1 -0
- package/src/components/CnTimelineStages/CnTimelineStages.vue +292 -0
- package/src/components/CnTimelineStages/index.js +1 -0
- package/src/components/CnUserActionMenu/CnUserActionMenu.vue +435 -0
- package/src/components/CnUserActionMenu/index.js +1 -0
- package/src/components/CnVersionInfoCard/index.js +1 -1
- package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -0
- package/src/components/CnWidgetRenderer/index.js +1 -0
- package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +246 -0
- package/src/components/CnWidgetWrapper/index.js +1 -0
- package/src/components/index.js +57 -25
- package/src/composables/index.js +5 -3
- package/src/composables/useContextMenu.js +126 -0
- package/src/composables/useDashboardView.js +286 -0
- package/src/composables/useDetailView.js +290 -132
- package/src/composables/useListView.js +364 -153
- package/src/composables/useSubResource.js +142 -142
- package/src/constants/metadata.js +30 -0
- package/src/css/CnSchemaFormDialog.css +546 -0
- package/src/css/__sample_nextcloud_tokens.css +110 -0
- package/src/css/actions-bar.css +54 -0
- package/src/css/badge.css +83 -51
- package/src/css/card.css +129 -128
- package/src/css/context-menu.css +20 -0
- package/src/css/dashboard.css +70 -0
- package/src/css/detail-page.css +235 -0
- package/src/css/detail.css +68 -68
- package/src/css/index-page.css +44 -0
- package/src/css/index-sidebar.css +193 -0
- package/src/css/index.css +17 -8
- package/src/css/layout.css +90 -90
- package/src/css/page-header.css +35 -0
- package/src/css/pagination.css +72 -72
- package/src/css/table.css +142 -143
- package/src/css/timeline-stages.css +220 -0
- package/src/css/utilities.css +46 -46
- package/src/index.js +91 -50
- package/src/mixins/gridLayout.js +118 -0
- package/src/store/createCrudStore.js +360 -0
- package/src/store/createSubResourcePlugin.js +125 -135
- package/src/store/index.js +4 -3
- package/src/store/plugins/auditTrails.js +357 -17
- package/src/store/plugins/files.js +250 -186
- package/src/store/plugins/index.js +7 -4
- package/src/store/plugins/lifecycle.js +180 -180
- package/src/store/plugins/registerMapping.js +195 -0
- package/src/store/plugins/relations.js +68 -68
- package/src/store/plugins/search.js +385 -0
- package/src/store/plugins/selection.js +104 -0
- package/src/store/useObjectStore.js +823 -625
- package/src/types/auditTrail.d.ts +32 -32
- package/src/types/file.d.ts +23 -23
- package/src/types/index.d.ts +35 -35
- package/src/types/notification.d.ts +36 -36
- package/src/types/object.d.ts +40 -40
- package/src/types/organisation.d.ts +41 -41
- package/src/types/register.d.ts +25 -25
- package/src/types/schema.d.ts +39 -39
- package/src/types/shared.d.ts +79 -79
- package/src/types/source.d.ts +14 -14
- package/src/types/task.d.ts +31 -31
- package/src/utils/errors.js +96 -96
- package/src/utils/getTheme.js +9 -0
- package/src/utils/headers.js +80 -44
- package/src/utils/id.js +13 -0
- package/src/utils/index.js +4 -3
- package/src/utils/schema.js +422 -287
- package/src/utils/widgetVisibility.js +162 -0
- package/src/components/CnDetailViewLayout/CnDetailViewLayout.vue +0 -88
- package/src/components/CnDetailViewLayout/index.js +0 -1
- package/src/components/CnEmptyState/CnEmptyState.vue +0 -78
- package/src/components/CnEmptyState/index.js +0 -1
- package/src/components/CnListViewLayout/CnListViewLayout.vue +0 -80
- package/src/components/CnListViewLayout/index.js +0 -1
- package/src/components/CnViewModeToggle/CnViewModeToggle.vue +0 -77
- package/src/components/CnViewModeToggle/index.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CnObjectDataWidget } from './CnObjectDataWidget.vue'
|
|
@@ -0,0 +1,288 @@
|
|
|
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 { CnDetailCard } from '../CnDetailCard/index.js'
|
|
31
|
+
import { CnDetailGrid } from '../CnDetailGrid/index.js'
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Known metadata fields and their labels.
|
|
35
|
+
* These are the standard fields from OpenRegister's @self / system fields.
|
|
36
|
+
*/
|
|
37
|
+
const METADATA_FIELDS = [
|
|
38
|
+
{ key: 'id', label: 'ID' },
|
|
39
|
+
{ key: 'uuid', label: 'UUID' },
|
|
40
|
+
{ key: 'uri', label: 'URI' },
|
|
41
|
+
{ key: 'register', label: 'Register' },
|
|
42
|
+
{ key: 'schema', label: 'Schema' },
|
|
43
|
+
{ key: 'status', label: 'Status' },
|
|
44
|
+
{ key: 'owner', label: 'Owner' },
|
|
45
|
+
{ key: 'organization', label: 'Organization' },
|
|
46
|
+
{ key: 'created', label: 'Created', format: 'date-time' },
|
|
47
|
+
{ key: 'updated', label: 'Updated', format: 'date-time' },
|
|
48
|
+
{ key: 'folder', label: 'Folder' },
|
|
49
|
+
{ key: 'textRepresentation', label: 'Text Representation' },
|
|
50
|
+
{ key: 'locked', label: 'Locked' },
|
|
51
|
+
{ key: 'version', label: 'Version' },
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* CnObjectMetadataWidget — Read-only metadata display widget.
|
|
56
|
+
*
|
|
57
|
+
* Automatically extracts and formats metadata from an OpenRegister object.
|
|
58
|
+
* Understands both flat objects (where metadata is at the top level) and
|
|
59
|
+
* objects with a `@self` metadata block.
|
|
60
|
+
*
|
|
61
|
+
* @example Basic usage
|
|
62
|
+
* <CnObjectMetadataWidget :object-data="publication" />
|
|
63
|
+
*
|
|
64
|
+
* @example With extra items
|
|
65
|
+
* <CnObjectMetadataWidget
|
|
66
|
+
* title="System Info"
|
|
67
|
+
* :object-data="entity"
|
|
68
|
+
* :extra-items="[
|
|
69
|
+
* { label: 'Source', value: entity.source },
|
|
70
|
+
* { label: 'Catalog', value: entity.catalog },
|
|
71
|
+
* ]" />
|
|
72
|
+
*
|
|
73
|
+
* @example Selective display
|
|
74
|
+
* <CnObjectMetadataWidget
|
|
75
|
+
* :object-data="entity"
|
|
76
|
+
* :include="['id', 'uuid', 'created', 'updated', 'owner']" />
|
|
77
|
+
*/
|
|
78
|
+
export default {
|
|
79
|
+
name: 'CnObjectMetadataWidget',
|
|
80
|
+
|
|
81
|
+
components: {
|
|
82
|
+
CnDetailCard,
|
|
83
|
+
CnDetailGrid,
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
props: {
|
|
87
|
+
/** Widget title shown in the card header */
|
|
88
|
+
title: {
|
|
89
|
+
type: String,
|
|
90
|
+
default: 'Metadata',
|
|
91
|
+
},
|
|
92
|
+
/** Optional MDI icon component for the header */
|
|
93
|
+
icon: {
|
|
94
|
+
type: [Object, Function],
|
|
95
|
+
default: null,
|
|
96
|
+
},
|
|
97
|
+
/**
|
|
98
|
+
* The object data containing metadata.
|
|
99
|
+
* Supports flat objects and objects with `@self` metadata block.
|
|
100
|
+
*/
|
|
101
|
+
objectData: {
|
|
102
|
+
type: Object,
|
|
103
|
+
required: true,
|
|
104
|
+
},
|
|
105
|
+
/**
|
|
106
|
+
* Layout mode for the grid: 'grid' or 'horizontal'.
|
|
107
|
+
*/
|
|
108
|
+
layout: {
|
|
109
|
+
type: String,
|
|
110
|
+
default: 'horizontal',
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* Number of grid columns (only for layout='grid').
|
|
114
|
+
*/
|
|
115
|
+
columns: {
|
|
116
|
+
type: Number,
|
|
117
|
+
default: 0,
|
|
118
|
+
},
|
|
119
|
+
/**
|
|
120
|
+
* Min width for labels in horizontal layout.
|
|
121
|
+
*/
|
|
122
|
+
labelWidth: {
|
|
123
|
+
type: Number,
|
|
124
|
+
default: 150,
|
|
125
|
+
},
|
|
126
|
+
/**
|
|
127
|
+
* Additional metadata items to display.
|
|
128
|
+
* @type {Array<{ label: string, value: string|number }>}
|
|
129
|
+
*/
|
|
130
|
+
extraItems: {
|
|
131
|
+
type: Array,
|
|
132
|
+
default: () => [],
|
|
133
|
+
},
|
|
134
|
+
/**
|
|
135
|
+
* Metadata fields to include (whitelist). If null, all available are shown.
|
|
136
|
+
* @type {string[]|null}
|
|
137
|
+
*/
|
|
138
|
+
include: {
|
|
139
|
+
type: Array,
|
|
140
|
+
default: null,
|
|
141
|
+
},
|
|
142
|
+
/**
|
|
143
|
+
* Metadata fields to exclude.
|
|
144
|
+
* @type {string[]}
|
|
145
|
+
*/
|
|
146
|
+
exclude: {
|
|
147
|
+
type: Array,
|
|
148
|
+
default: () => [],
|
|
149
|
+
},
|
|
150
|
+
/** Whether the card can be collapsed */
|
|
151
|
+
collapsible: {
|
|
152
|
+
type: Boolean,
|
|
153
|
+
default: false,
|
|
154
|
+
},
|
|
155
|
+
/** Initial collapsed state */
|
|
156
|
+
collapsed: {
|
|
157
|
+
type: Boolean,
|
|
158
|
+
default: false,
|
|
159
|
+
},
|
|
160
|
+
/** Label shown when no metadata available */
|
|
161
|
+
emptyLabel: {
|
|
162
|
+
type: String,
|
|
163
|
+
default: 'No metadata available',
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
computed: {
|
|
168
|
+
iconComponent() {
|
|
169
|
+
return this.icon
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Merged metadata source: combines @self block with top-level fields.
|
|
174
|
+
* @self fields take priority over top-level for shared keys.
|
|
175
|
+
*/
|
|
176
|
+
metadataSource() {
|
|
177
|
+
const selfBlock = this.objectData['@self'] || {}
|
|
178
|
+
return { ...this.objectData, ...selfBlock }
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Build the items array for CnDetailGrid from known metadata fields.
|
|
183
|
+
*/
|
|
184
|
+
metadataItems() {
|
|
185
|
+
const source = this.metadataSource
|
|
186
|
+
const items = []
|
|
187
|
+
|
|
188
|
+
for (const def of METADATA_FIELDS) {
|
|
189
|
+
// Filter by include/exclude
|
|
190
|
+
if (this.include && !this.include.includes(def.key)) continue
|
|
191
|
+
if (this.exclude.includes(def.key)) continue
|
|
192
|
+
|
|
193
|
+
const raw = source[def.key]
|
|
194
|
+
if (raw === undefined || raw === null) continue
|
|
195
|
+
|
|
196
|
+
items.push({
|
|
197
|
+
label: def.label,
|
|
198
|
+
value: this.formatMetadataValue(raw, def),
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Append extra items
|
|
203
|
+
for (const item of this.extraItems) {
|
|
204
|
+
items.push(item)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return items
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
methods: {
|
|
212
|
+
/**
|
|
213
|
+
* Format a metadata value for display.
|
|
214
|
+
* @param value
|
|
215
|
+
* @param def
|
|
216
|
+
*/
|
|
217
|
+
formatMetadataValue(value, def) {
|
|
218
|
+
if (value === null || value === undefined) return '-'
|
|
219
|
+
|
|
220
|
+
// Date-time formatting
|
|
221
|
+
if (def.format === 'date-time') {
|
|
222
|
+
try {
|
|
223
|
+
const date = new Date(value)
|
|
224
|
+
if (Number.isNaN(date.getTime())) return String(value)
|
|
225
|
+
return date.toLocaleDateString(undefined, {
|
|
226
|
+
day: '2-digit',
|
|
227
|
+
month: '2-digit',
|
|
228
|
+
year: 'numeric',
|
|
229
|
+
}) + ', ' + date.toLocaleTimeString(undefined, {
|
|
230
|
+
hour: '2-digit',
|
|
231
|
+
minute: '2-digit',
|
|
232
|
+
second: '2-digit',
|
|
233
|
+
})
|
|
234
|
+
} catch {
|
|
235
|
+
return String(value)
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Booleans
|
|
240
|
+
if (typeof value === 'boolean') {
|
|
241
|
+
return value ? 'Yes' : 'No'
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Arrays
|
|
245
|
+
if (Array.isArray(value)) {
|
|
246
|
+
return value.length > 0 ? value.join(', ') : '-'
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Objects — show as JSON snippet
|
|
250
|
+
if (typeof value === 'object') {
|
|
251
|
+
return JSON.stringify(value)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return String(value)
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
}
|
|
258
|
+
</script>
|
|
259
|
+
|
|
260
|
+
<style scoped>
|
|
261
|
+
/* Override CnDetailGrid item styling for a compact table-like appearance */
|
|
262
|
+
:deep(.cn-detail-grid__item) {
|
|
263
|
+
background: none;
|
|
264
|
+
border-radius: 0;
|
|
265
|
+
border-bottom: 1px solid var(--color-border);
|
|
266
|
+
padding: calc(1.5 * var(--default-grid-baseline, 4px)) 0;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
:deep(.cn-detail-grid__item:last-child) {
|
|
270
|
+
border-bottom: none;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
:deep(.cn-detail-grid--horizontal) {
|
|
274
|
+
gap: 0;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
:deep(.cn-detail-grid__label) {
|
|
278
|
+
font-size: 0.8em;
|
|
279
|
+
text-transform: uppercase;
|
|
280
|
+
letter-spacing: 0.02em;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
:deep(.cn-detail-grid__value) {
|
|
284
|
+
font-size: 0.9em;
|
|
285
|
+
word-break: break-all;
|
|
286
|
+
margin: 0;
|
|
287
|
+
}
|
|
288
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CnObjectMetadataWidget } from './CnObjectMetadataWidget.vue'
|
|
@@ -0,0 +1,368 @@
|
|
|
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 { NcButton, NcListItem, NcLoadingIcon, NcSelect, NcDateTimePickerNative } from '@nextcloud/vue'
|
|
119
|
+
import History from 'vue-material-design-icons/History.vue'
|
|
120
|
+
import { buildHeaders } from '../../utils/index.js'
|
|
121
|
+
|
|
122
|
+
export default {
|
|
123
|
+
name: 'CnAuditTrailTab',
|
|
124
|
+
|
|
125
|
+
components: { NcButton, NcListItem, NcLoadingIcon, NcSelect, NcDateTimePickerNative, History },
|
|
126
|
+
|
|
127
|
+
props: {
|
|
128
|
+
objectId: { type: String, required: true },
|
|
129
|
+
register: { type: String, default: '' },
|
|
130
|
+
schema: { type: String, default: '' },
|
|
131
|
+
apiBase: { type: String, default: '/apps/openregister/api' },
|
|
132
|
+
noAuditTrailLabel: { type: String, default: 'No audit trail entries' },
|
|
133
|
+
noMatchLabel: { type: String, default: 'No matching entries' },
|
|
134
|
+
actionFilterLabel: { type: String, default: 'Action' },
|
|
135
|
+
userFilterLabel: { type: String, default: 'User' },
|
|
136
|
+
fromLabel: { type: String, default: 'From' },
|
|
137
|
+
toLabel: { type: String, default: 'To' },
|
|
138
|
+
loadMoreLabel: { type: String, default: 'Load more' },
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
data() {
|
|
142
|
+
return {
|
|
143
|
+
entries: [],
|
|
144
|
+
loading: false,
|
|
145
|
+
loadingMore: false,
|
|
146
|
+
expandedId: null,
|
|
147
|
+
filterAction: [],
|
|
148
|
+
filterUser: [],
|
|
149
|
+
filterDateFrom: null,
|
|
150
|
+
filterDateTo: null,
|
|
151
|
+
page: 1,
|
|
152
|
+
total: 0,
|
|
153
|
+
limit: 20,
|
|
154
|
+
actionOptions: ['create', 'read', 'update', 'delete'],
|
|
155
|
+
userOptions: [],
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
computed: {
|
|
160
|
+
hasMore() {
|
|
161
|
+
return this.entries.length < this.total
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
watch: {
|
|
166
|
+
objectId: {
|
|
167
|
+
immediate: true,
|
|
168
|
+
handler(id) { if (id) this.fetchAuditTrails() },
|
|
169
|
+
},
|
|
170
|
+
filterAction() { this.resetAndFetch() },
|
|
171
|
+
filterUser() { this.resetAndFetch() },
|
|
172
|
+
filterDateFrom() { this.resetAndFetch() },
|
|
173
|
+
filterDateTo() { this.resetAndFetch() },
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
methods: {
|
|
177
|
+
resetAndFetch() {
|
|
178
|
+
this.page = 1
|
|
179
|
+
this.entries = []
|
|
180
|
+
this.fetchAuditTrails()
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
buildQueryParams() {
|
|
184
|
+
const params = new URLSearchParams()
|
|
185
|
+
params.set('limit', this.limit)
|
|
186
|
+
params.set('_page', this.page)
|
|
187
|
+
params.set('_sort[created]', 'DESC')
|
|
188
|
+
if (this.filterAction?.length) params.set('action', this.filterAction.join(','))
|
|
189
|
+
if (this.filterUser?.length) params.set('user_name', this.filterUser.join(','))
|
|
190
|
+
if (this.filterDateFrom) {
|
|
191
|
+
params.set('_dateFrom', new Date(this.filterDateFrom).toISOString().split('T')[0])
|
|
192
|
+
}
|
|
193
|
+
if (this.filterDateTo) {
|
|
194
|
+
params.set('_dateTo', new Date(this.filterDateTo).toISOString().split('T')[0])
|
|
195
|
+
}
|
|
196
|
+
return params.toString()
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
async fetchAuditTrails() {
|
|
200
|
+
if (!this.register || !this.schema) return
|
|
201
|
+
this.loading = this.page === 1
|
|
202
|
+
this.loadingMore = this.page > 1
|
|
203
|
+
try {
|
|
204
|
+
const query = this.buildQueryParams()
|
|
205
|
+
const response = await fetch(
|
|
206
|
+
`${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/audit-trails?${query}`,
|
|
207
|
+
{ headers: buildHeaders() },
|
|
208
|
+
)
|
|
209
|
+
if (response.ok) {
|
|
210
|
+
const data = await response.json()
|
|
211
|
+
const results = data.results || data || []
|
|
212
|
+
if (this.page === 1) {
|
|
213
|
+
this.entries = results
|
|
214
|
+
} else {
|
|
215
|
+
this.entries = [...this.entries, ...results]
|
|
216
|
+
}
|
|
217
|
+
this.total = data.total || this.entries.length
|
|
218
|
+
// Build user options from all seen entries
|
|
219
|
+
const users = new Set(this.entries.map(e => e.userName || e.user).filter(Boolean))
|
|
220
|
+
this.userOptions = [...users].sort()
|
|
221
|
+
}
|
|
222
|
+
} catch (err) {
|
|
223
|
+
console.error('CnAuditTrailTab: Failed to fetch audit trails', err)
|
|
224
|
+
} finally {
|
|
225
|
+
this.loading = false
|
|
226
|
+
this.loadingMore = false
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
loadMore() {
|
|
231
|
+
this.page++
|
|
232
|
+
this.fetchAuditTrails()
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
toggleExpand(id) {
|
|
236
|
+
this.expandedId = this.expandedId === id ? null : id
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
changedCount(entry) {
|
|
240
|
+
if (!entry.changed || typeof entry.changed !== 'object') return 0
|
|
241
|
+
return Object.keys(entry.changed).length
|
|
242
|
+
},
|
|
243
|
+
|
|
244
|
+
isSimpleValue(change) {
|
|
245
|
+
return change && typeof change === 'object' && ('old' in change || 'new' in change)
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
formatValue(val) {
|
|
249
|
+
if (val === null || val === undefined) return 'null'
|
|
250
|
+
if (typeof val === 'object') return JSON.stringify(val)
|
|
251
|
+
return String(val)
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
formatDate(dateStr) {
|
|
255
|
+
if (!dateStr) return ''
|
|
256
|
+
try {
|
|
257
|
+
return new Date(dateStr).toLocaleString(undefined, {
|
|
258
|
+
year: 'numeric',
|
|
259
|
+
month: 'short',
|
|
260
|
+
day: 'numeric',
|
|
261
|
+
hour: '2-digit',
|
|
262
|
+
minute: '2-digit',
|
|
263
|
+
})
|
|
264
|
+
} catch { return dateStr }
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
}
|
|
268
|
+
</script>
|
|
269
|
+
|
|
270
|
+
<style scoped>
|
|
271
|
+
.cn-sidebar-tab { padding: 12px; }
|
|
272
|
+
|
|
273
|
+
.cn-sidebar-tab__empty {
|
|
274
|
+
text-align: center;
|
|
275
|
+
padding: 24px 12px;
|
|
276
|
+
color: var(--color-text-maxcontrast);
|
|
277
|
+
font-size: 13px;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.cn-sidebar-tab__list { display: flex; flex-direction: column; gap: 2px; }
|
|
281
|
+
|
|
282
|
+
.cn-audit-filters {
|
|
283
|
+
display: grid;
|
|
284
|
+
grid-template-columns: 1fr 1fr;
|
|
285
|
+
gap: 8px;
|
|
286
|
+
margin-bottom: 12px;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.cn-audit-filters__select { min-width: 0; }
|
|
290
|
+
.cn-audit-filters__date { min-width: 0; }
|
|
291
|
+
|
|
292
|
+
.cn-sidebar-tab__load-more { margin-top: 8px; }
|
|
293
|
+
|
|
294
|
+
.cn-audit-entry { cursor: pointer; }
|
|
295
|
+
|
|
296
|
+
.cn-audit-details {
|
|
297
|
+
padding: 8px 12px 12px 52px;
|
|
298
|
+
font-size: 12px;
|
|
299
|
+
border-bottom: 1px solid var(--color-border);
|
|
300
|
+
animation: cn-slide-down 0.15s ease;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
@keyframes cn-slide-down {
|
|
304
|
+
from { opacity: 0; max-height: 0; }
|
|
305
|
+
to { opacity: 1; max-height: 600px; }
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.cn-audit-details__row {
|
|
309
|
+
display: flex;
|
|
310
|
+
gap: 8px;
|
|
311
|
+
padding: 2px 0;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.cn-audit-details__label {
|
|
315
|
+
color: var(--color-text-maxcontrast);
|
|
316
|
+
min-width: 56px;
|
|
317
|
+
font-weight: 500;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.cn-audit-details__mono {
|
|
321
|
+
font-family: monospace;
|
|
322
|
+
font-size: 11px;
|
|
323
|
+
word-break: break-all;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.cn-audit-details__changes {
|
|
327
|
+
margin-top: 8px;
|
|
328
|
+
padding-top: 8px;
|
|
329
|
+
border-top: 1px solid var(--color-border);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.cn-audit-details__change {
|
|
333
|
+
padding: 4px 0 4px 8px;
|
|
334
|
+
border-left: 2px solid var(--color-border);
|
|
335
|
+
margin: 4px 0;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.cn-audit-details__field {
|
|
339
|
+
font-weight: 500;
|
|
340
|
+
display: block;
|
|
341
|
+
margin-bottom: 2px;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.cn-audit-details__values {
|
|
345
|
+
display: flex;
|
|
346
|
+
gap: 6px;
|
|
347
|
+
align-items: baseline;
|
|
348
|
+
flex-wrap: wrap;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.cn-audit-details__old {
|
|
352
|
+
color: var(--color-error, #e53935);
|
|
353
|
+
text-decoration: line-through;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.cn-audit-details__arrow {
|
|
357
|
+
color: var(--color-text-maxcontrast);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.cn-audit-details__new {
|
|
361
|
+
color: var(--color-success, #43a047);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.cn-audit-details__null {
|
|
365
|
+
color: var(--color-text-maxcontrast);
|
|
366
|
+
font-style: italic;
|
|
367
|
+
}
|
|
368
|
+
</style>
|