@dracul/audit-frontend 1.35.4 → 1.35.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dracul/audit-frontend",
3
- "version": "1.35.4",
3
+ "version": "1.35.6",
4
4
  "description": "Audit frontend",
5
5
  "author": "Cristian Incarnato <cristian.cdi@gmail.com>",
6
6
  "publishConfig": {
@@ -38,5 +38,5 @@
38
38
  "type": "git",
39
39
  "url": "git+https://github.com/draculjs/modular-framework.git"
40
40
  },
41
- "gitHead": "e1efb726822b8011ead5ff2701c20e5e35c76182"
41
+ "gitHead": "b866b70b275902cba82da8e6b7f490a3543b82bc"
42
42
  }
@@ -28,22 +28,23 @@ const i18nMessages = {
28
28
  action: 'Action',
29
29
 
30
30
  actions: {
31
- create: 'Crear',
32
- read: 'Visualizar',
33
- update: 'Modificar',
34
- delete: 'Eliminar',
35
-
31
+ create: 'Create',
32
+ read: 'Visualize',
33
+ update: 'Modify',
34
+ delete: 'Delete',
35
+ restart: 'Reiniciar',
36
36
  detailMessages: {
37
37
  create: 'A resource with ID "{resourceID}" was created',
38
38
  read: 'A resource with ID "{resourceID}" was visualized',
39
39
  update: 'A resource with ID "{resourceID}" was updated',
40
40
  delete: 'A resource with ID "{resourceID}" was deleted',
41
+ restart: 'Se ha reiniciado un recurso con ID "{resourceID}',
41
42
  },
42
43
 
43
44
  changes: {
44
- field: 'Campo',
45
- oldValue: 'Valor anterior',
46
- newValue: 'Valor nuevo',
45
+ field: 'Field',
46
+ oldValue: 'Old value',
47
+ newValue: 'New value',
47
48
  },
48
49
  },
49
50
 
@@ -98,12 +99,13 @@ const i18nMessages = {
98
99
  read: 'Visualizar',
99
100
  update: 'Modificar',
100
101
  delete: 'Eliminar',
101
-
102
+ restart: 'Reiniciar',
102
103
  detailMessages: {
103
104
  create: 'Se ha creado un recurso con ID "{resourceID}"',
104
105
  read: 'Se ha visualizado un recurso con ID "{resourceID}"',
105
106
  update: 'Se ha modificado un recurso con ID "{resourceID}"',
106
107
  delete: 'Se ha eliminado un recurso con ID "{resourceID}"',
108
+ restart: 'Se ha reiniciado un recurso con ID "{resourceID}',
107
109
  },
108
110
 
109
111
  changes: {
@@ -164,12 +166,13 @@ const i18nMessages = {
164
166
  read: 'Visualizar',
165
167
  update: 'Modificar',
166
168
  delete: 'Eliminar',
167
-
169
+ restart: 'Reiniciar',
168
170
  detailMessages: {
169
171
  create: 'Se ha creado un recurso con ID "{resourceID}"',
170
172
  read: 'Se ha visualizado un recurso con ID "{resourceID}"',
171
173
  update: 'Se ha modificado un recurso con ID "{resourceID}"',
172
174
  delete: 'Se ha eliminado un recurso con ID "{resourceID}"',
175
+ restart: 'Se ha reiniciado un recurso con ID "{resourceID}',
173
176
  },
174
177
 
175
178
  changes: {
@@ -0,0 +1,83 @@
1
+ <template>
2
+ <v-dialog
3
+ :content-class=" audit.action == 'UPDATE' ? 'rounded-sm' : 'rounded-0'"
4
+ >
5
+ <template v-slot:activator="{ on, attrs }">
6
+ <v-btn
7
+ text
8
+ color="secondary"
9
+ outlined
10
+ tile
11
+
12
+ v-bind="attrs"
13
+ v-on="on"
14
+ >
15
+ {{ audit.changes.length }}
16
+ </v-btn>
17
+ </template>
18
+
19
+ <v-data-table v-if="audit.action == 'UPDATE'"
20
+ :headers=changeHeaders
21
+ :items="audit.changes"
22
+ :hide-default-footer="true"
23
+
24
+ class="rounded-0"
25
+ >
26
+ <template v-slot:[`item.oldValue`]="{ item }">
27
+ {{ item.oldValue }}
28
+ </template>
29
+
30
+ <template v-slot:[`item.newValue`]="{ item }">
31
+ {{ item.newValue }}
32
+ </template>
33
+ </v-data-table>
34
+
35
+ <v-card>
36
+ <v-treeview
37
+ :items="getAuditDataChanges(item)"
38
+ item-text="name"
39
+ item-children="children"
40
+ open-on-click
41
+ class="rounded-0"
42
+ >
43
+ </v-treeview>
44
+ </v-card>
45
+
46
+ </v-dialog>
47
+ </template>
48
+
49
+
50
+
51
+ <script>
52
+ export default {
53
+ name:"AuditChanges",
54
+ props:{
55
+ audit: {type: Object, required: true}
56
+ },
57
+ methods: {
58
+ getAuditDataChanges(audit) {
59
+ if (!audit || typeof audit.resourceData !== 'object' || !audit.resourceData) return [];
60
+
61
+ return Object.entries(audit.resourceData).map(([key, value]) => ({
62
+ name: key,
63
+ children: Array.isArray(value) || typeof value === 'object'
64
+ ? Object.entries(value).map(([subKey, subValue]) => ({ name: `${subKey}: ${subValue}` }))
65
+ : [{ name: `${value}` }]
66
+ }))
67
+ }
68
+ },
69
+ computed: {
70
+ changeHeaders() {
71
+ return [
72
+ { text: this.$t('audit.actions.changes.field'), value: 'field' },
73
+ { text: this.$t('audit.actions.changes.oldValue'), value: 'oldValue' },
74
+ { text: this.$t('audit.actions.changes.newValue'), value: 'newValue' },
75
+ ]
76
+ },
77
+ }
78
+ }
79
+ </script>
80
+
81
+ <style lang="scss" scoped>
82
+
83
+ </style>
@@ -64,11 +64,11 @@
64
64
  <template v-slot:[`item.createdAt`]="{ item }">
65
65
  {{ getDateTimeFormat(item.createdAt) }}
66
66
  </template>
67
-
68
67
  <template v-slot:[`item.changes`]="{ item }">
69
- <v-menu
70
- bottom
71
- left
68
+ <v-dialog
69
+ v-model="item.dialogVisible"
70
+ content-class='rounded-0'
71
+ scrollable
72
72
  >
73
73
  <template v-slot:activator="{ on, attrs }">
74
74
  <v-btn
@@ -76,25 +76,108 @@
76
76
  color="secondary"
77
77
  outlined
78
78
  tile
79
-
80
79
  v-bind="attrs"
81
80
  v-on="on"
82
- :disabled="item.action !== 'UPDATE'"
83
81
  >
84
82
  {{ item.changes.length }}
85
83
  </v-btn>
86
84
  </template>
87
85
 
88
- <v-data-table
89
- :headers=changeHeaders
90
- :items="item.changes"
91
- :hide-default-footer="true"
92
- ></v-data-table>
93
- </v-menu>
86
+ <v-card
87
+ class="rounded-0"
88
+ >
89
+
90
+ <!-- MAKE THIS STICKY -->
91
+ <div class="sticky-header">
92
+
93
+ <v-toolbar
94
+ dense
95
+ >
96
+ Cambios de auditoria
97
+ <v-spacer />
98
+
99
+ <v-btn
100
+ icon
101
+ small
102
+ @click="item.dialogVisible = false"
103
+ >
104
+ <v-icon>mdi-close</v-icon>
105
+ </v-btn>
106
+ </v-toolbar>
107
+
108
+ <v-card
109
+ class="d-flex pl-5 rounded-0 text-h2"
110
+ >
111
+ <v-card-text>
112
+ <b>{{$t('audit.labels.createdAt')}}</b>: {{ getDateTimeFormat(item.createdAt) }}
113
+ </v-card-text>
114
+
115
+ <v-card-text>
116
+ <b>{{$t('audit.labels.role')}}</b>: {{ item.user.role.name }}
117
+ </v-card-text>
118
+
119
+ <v-card-text>
120
+ <b>{{$t('audit.labels.user')}}</b>: {{ item.user.username }}
121
+ </v-card-text>
122
+
123
+ <v-card-text>
124
+ <b>{{$t('audit.labels.entity')}}</b>: {{ item.entity }}
125
+ </v-card-text>
126
+
127
+ <v-card-text>
128
+ <b>{{$t('audit.labels.action')}}</b>: {{ $t(`audit.actions.${item.action.toLowerCase()}`) }}
129
+ </v-card-text>
130
+
131
+ <v-card-text>
132
+ <b>{{$t('audit.labels.details')}}</b>: {{ item.details }}
133
+ </v-card-text>
134
+ </v-card>
135
+ </div>
136
+
137
+ <!-- MAKE THIS STICKY -->
138
+
139
+
140
+ <v-spacer></v-spacer>
94
141
 
142
+ <div class="scrollable-content">
143
+ <v-card
144
+ outlined
145
+ class="rounded-0"
146
+ elevation="0"
147
+ >
148
+ <v-card-text
149
+ class="px-8"
150
+ >
151
+ <v-data-table v-if="item.action == 'UPDATE'"
152
+ :headers="changeHeaders"
153
+ :items="item.changes"
154
+ :hide-default-footer="true"
155
+ class="rounded-0"
156
+ >
157
+ <template v-slot:[`item.oldValue`]="{ item }">
158
+ {{ item.oldValue }}
159
+ </template>
160
+ <template v-slot:[`item.newValue`]="{ item }">
161
+ {{ item.newValue }}
162
+ </template>
163
+ </v-data-table>
164
+
165
+ <v-treeview
166
+ :items="getAuditDataChanges(item)"
167
+ item-text="name"
168
+ item-children="children"
169
+ open-on-click
170
+ class="rounded-0"
171
+ />
172
+ </v-card-text>
173
+ </v-card>
174
+ </div>
175
+ </v-card>
176
+ </v-dialog>
95
177
  </template>
96
178
 
97
179
 
180
+
98
181
  <template v-slot:[`item.details`]="{ item }">
99
182
  {{ $t(`audit.actions.detailMessages.${item.action.toLowerCase()}`, {resourceID: item.details}) }}
100
183
  </template>
@@ -133,8 +216,8 @@ export default {
133
216
  items: [],
134
217
  totalItems: null,
135
218
  loading: false,
136
- orderBy: null,
137
- orderDesc: false,
219
+ orderBy: 'createdAt',
220
+ orderDesc: true,
138
221
  itemsPerPage: 5,
139
222
  pageNumber: 1,
140
223
  search: '',
@@ -150,11 +233,12 @@ export default {
150
233
  value: null
151
234
  },
152
235
  {
153
- field: 'resource',
236
+ field: 'entity',
154
237
  operator: '$regex',
155
238
  value: null
156
239
  }
157
- ]
240
+ ],
241
+ dialogVisible: false,
158
242
  }
159
243
  },
160
244
  computed: {
@@ -203,24 +287,29 @@ export default {
203
287
  this.pageNumber = 1
204
288
  this.fetch()
205
289
  },
206
- fetch() {
207
- this.loading = true
208
- AuditProvider.paginateAudit(
290
+ async fetch() {
291
+ this.loading = true;
292
+ try {
293
+ const response = await AuditProvider.paginateAudit(
209
294
  this.pageNumber,
210
295
  this.itemsPerPage,
211
296
  this.search,
212
297
  this.filters,
213
298
  this.getOrderBy,
214
299
  this.getOrderDesc
215
- ).then(r => {
216
- console.log('paginate audit', r)
217
- r.data.paginateAudit.items.forEach((item) => item.changes.length == 0 ? item.changes.length = 1 : null)
218
- this.items = r.data.paginateAudit.items
219
- this.totalItems = r.data.paginateAudit.totalItems
220
- }).catch(err => {
221
- console.error(err)
222
- }).finally(() => this.loading = false)
223
- },
300
+ );
301
+ this.items = response.data.paginateAudit.items.map(item => ({
302
+ ...item,
303
+ changes: item.changes.length === 0 ? [{ length: 1 }] : item.changes,
304
+ dialogVisible: false,
305
+ }));
306
+ this.totalItems = response.data.paginateAudit.totalItems;
307
+ } catch (err) {
308
+ console.error(err);
309
+ } finally {
310
+ this.loading = false;
311
+ }
312
+ },
224
313
  setFilters(auditFilters) {
225
314
  console.log('auditFilters', auditFilters)
226
315
  this.filters = auditFilters
@@ -232,8 +321,15 @@ export default {
232
321
  })
233
322
  this.fetch()
234
323
  },
235
- visualizeAuditChanges(audit){
236
- console.log(audit)
324
+ getAuditDataChanges(audit) {
325
+ if (!audit || typeof audit.resourceData !== 'object' || !audit.resourceData) return [];
326
+
327
+ return Object.entries(audit.resourceData).map(([key, value]) => ({
328
+ name: key,
329
+ children: Array.isArray(value) || typeof value === 'object'
330
+ ? Object.entries(value).map(([subKey, subValue]) => ({ name: `${subKey}: ${subValue}` }))
331
+ : [{ name: `${value}` }]
332
+ }))
237
333
  }
238
334
  }
239
335
 
@@ -245,4 +341,18 @@ export default {
245
341
  white-space: nowrap !important;
246
342
  align-self: center
247
343
  }
344
+
345
+ .sticky-header {
346
+ position: sticky;
347
+ top: 0;
348
+ z-index: 10;
349
+ background-color: white; /* Ajusta según el diseño */
350
+ box-shadow: 0 rgba(0, 0, 0, 0.1); /* Opcional */
351
+ }
352
+
353
+ .scrollable-content {
354
+ max-height: 60vh; /* Ajusta según el tamaño del v-dialog */
355
+ overflow-y: auto;
356
+ padding: 16px; /* Opcional, para espaciar el contenido */
357
+ }
248
358
  </style>
@@ -21,11 +21,44 @@ export default {
21
21
  name: "AuditTest",
22
22
  methods: {
23
23
  createNewAudit() {
24
- AuditProvider.createAudit('CREATE', 'AUDIT', 'ksdf63ksdf923.123123')
24
+ AuditProvider.createAudit('CREATE', 'Servicio', 'kdsf8rg9c48v', [], {
25
+ "id": "7a6irev0so3iuiobiw1fpf08z",
26
+ "name": "nuevoservicioTesting",
27
+ "stack": "testing",
28
+ "image": {
29
+ "id": "",
30
+ "fullname": "sndregistry.sondeosglobal.com/docs/snd-docs:latest",
31
+ "domain": "sndregistry.sondeosglobal.com",
32
+ "namespace": "docs",
33
+ "name": "snd-docs",
34
+ "tag": "latest",
35
+ "nameWithTag": "snd-docs:latest"
36
+ },
37
+ "createdAt": "2024-12-09T14:38:53.389502821Z",
38
+ "updatedAt": "2024-12-17T11:31:41.591560506Z",
39
+ "labels": [
40
+ {
41
+ "name": "com.docker.stack.namespace",
42
+ "value": "testing"
43
+ }
44
+ ],
45
+ "envs": [
46
+ {
47
+ "name": "CONTROL_VERSION",
48
+ "value": "41873"
49
+ }
50
+ ],
51
+ "limits": {},
52
+ "mode": "replic",
53
+ "extraHosts": [],
54
+ "dns": []
55
+ })
25
56
  },
26
57
  updateAudit() {
27
- AuditProvider.createAudit('UPDATE', 'AUDIT', 'ksdf63ksdf923.123123', [
28
- { field: 'status', oldValue: 'inactive', newValue: 'active' }
58
+ AuditProvider.createAudit('UPDATE', 'Servicio', 'kdsf8rg9c48v', [
59
+ { field: 'name', oldValue: 'debops', newValue: 'devops' },
60
+ { field: 'image', oldValue: 'sndregistry.sondeosglobal.com/docs/snd-docs', newValue: 'sndregistry.sondeosglobal.com/dockerway/docker-devops:2.13.0' },
61
+ { field: 'stack', oldValue: 'docker', newValue: 'dockerway'}
29
62
  ])
30
63
  },
31
64
  deleteAudit() {
@@ -41,10 +41,10 @@ class AuditProvider {
41
41
  })
42
42
  }
43
43
 
44
- createAudit(action, entity, details, changes){
44
+ createAudit(action, entity, details, changes, resourceData){
45
45
  return this.getGraphqlClient().mutate({
46
46
  mutation: require('./gql/Audit/createAudit.graphql'),
47
- variables: {action, entity, details, changes},
47
+ variables: {action, entity, details, changes, resourceData},
48
48
  fetchPolicy: "no-cache"
49
49
  })
50
50
  }
@@ -2,9 +2,10 @@ mutation createAudit(
2
2
  $action: String!,
3
3
  $entity: String!,
4
4
  $details: String,
5
- $changes: [ChangesInput]
5
+ $changes: [ChangesInput],
6
+ $resourceData: JSON
6
7
  ) {
7
- createAudit(action: $action, entity: $entity, details: $details, changes: $changes) {
8
+ createAudit(action: $action, entity: $entity, details: $details, changes: $changes, resourceData: $resourceData) {
8
9
  id
9
10
  user {
10
11
  username
@@ -17,5 +18,6 @@ mutation createAudit(
17
18
  oldValue
18
19
  newValue
19
20
  }
21
+ resourceData
20
22
  }
21
23
  }
@@ -2,11 +2,18 @@ query fetchAudit{
2
2
  fetchAudit{
3
3
  id
4
4
  user{
5
- id
6
- username
7
- }
5
+ id
6
+ username
7
+ }
8
8
  action
9
- resource
9
+ entity
10
+ details
11
+ changes {
12
+ field
13
+ oldValue
14
+ newValue
15
+ }
16
+ resourceData
10
17
  }
11
18
  }
12
19
 
@@ -6,6 +6,13 @@ query findAudit($id:ID!){
6
6
  username
7
7
  }
8
8
  action
9
- resource
9
+ entity
10
+ details
11
+ changes {
12
+ field
13
+ oldValue
14
+ newValue
15
+ }
16
+ resourceData
10
17
  }
11
18
  }
@@ -21,6 +21,7 @@ query paginateAudit( $pageNumber: Int, $itemsPerPage:Int, $search: String, $filt
21
21
  oldValue
22
22
  newValue
23
23
  }
24
+ resourceData
24
25
  }
25
26
  }
26
27
  }