@dracul/audit-frontend 1.35.5 → 1.35.7

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.5",
3
+ "version": "1.35.7",
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": "f593ab2b43687a9e8c3545c164e30494a868bf59"
41
+ "gitHead": "b9c5be39959452b94d59742d37b0a391ccef62b5"
42
42
  }
@@ -28,23 +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: 'A resource with ID "{resourceID}" was restarted',
41
+ restart: 'Se ha reiniciado un recurso con ID "{resourceID}',
42
42
  },
43
43
 
44
44
  changes: {
45
- field: 'Campo',
46
- oldValue: 'Valor anterior',
47
- newValue: 'Valor nuevo',
45
+ field: 'Field',
46
+ oldValue: 'Old value',
47
+ newValue: 'New value',
48
48
  },
49
49
  },
50
50
 
@@ -99,13 +99,13 @@ const i18nMessages = {
99
99
  read: 'Visualizar',
100
100
  update: 'Modificar',
101
101
  delete: 'Eliminar',
102
-
102
+ restart: 'Reiniciar',
103
103
  detailMessages: {
104
104
  create: 'Se ha creado un recurso con ID "{resourceID}"',
105
105
  read: 'Se ha visualizado un recurso con ID "{resourceID}"',
106
106
  update: 'Se ha modificado un recurso con ID "{resourceID}"',
107
107
  delete: 'Se ha eliminado un recurso con ID "{resourceID}"',
108
- restart: 'Se ha reiniciado un recurso con ID "{resourceID}"',
108
+ restart: 'Se ha reiniciado un recurso con ID "{resourceID}',
109
109
  },
110
110
 
111
111
  changes: {
@@ -162,23 +162,23 @@ const i18nMessages = {
162
162
  action: 'Ação',
163
163
 
164
164
  actions: {
165
- create: 'Criar',
166
- read: 'Exibir',
165
+ create: 'Crear',
166
+ read: 'Visualizar',
167
167
  update: 'Modificar',
168
- delete: 'Excluir',
169
-
168
+ delete: 'Eliminar',
169
+ restart: 'Reiniciar',
170
170
  detailMessages: {
171
- create: 'Um recurso com a ID “{resourceID}” foi criado',
172
- read: 'Um recurso com ID “{resourceID}” foi exibido',
173
- update: 'Um recurso com a ID “{resourceID}” foi modificado',
174
- delete: 'Um recurso com a ID “{resourceID}” foi excluído',
175
- restart: 'Um recurso com a ID “{resourceID}” foi reiniciado',
171
+ create: 'Se ha creado un recurso con ID "{resourceID}"',
172
+ read: 'Se ha visualizado un recurso con ID "{resourceID}"',
173
+ update: 'Se ha modificado un recurso con ID "{resourceID}"',
174
+ delete: 'Se ha eliminado un recurso con ID "{resourceID}"',
175
+ restart: 'Se ha reiniciado un recurso con ID "{resourceID}',
176
176
  },
177
177
 
178
178
  changes: {
179
179
  field: 'Campo',
180
- oldValue: 'Valor antigo',
181
- newValue: 'Novo valor',
180
+ oldValue: 'Valor anterior',
181
+ newValue: 'Valor nuevo',
182
182
  },
183
183
  },
184
184
 
@@ -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,104 @@
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
+ <div class="sticky-header">
91
+
92
+ <v-toolbar
93
+ dense
94
+ >
95
+ Cambios de auditoria
96
+ <v-spacer />
97
+
98
+ <v-btn
99
+ icon
100
+ small
101
+ @click="item.dialogVisible = false"
102
+ >
103
+ <v-icon>mdi-close</v-icon>
104
+ </v-btn>
105
+ </v-toolbar>
106
+
107
+ <v-card
108
+ class="d-flex pl-5 rounded-0 text-h2"
109
+ >
110
+ <v-card-text>
111
+ <b>{{$t('audit.labels.createdAt')}}</b>: {{ getDateTimeFormat(item.createdAt) }}
112
+ </v-card-text>
113
+
114
+ <v-card-text>
115
+ <b>{{$t('audit.labels.role')}}</b>: {{ item.user.role.name }}
116
+ </v-card-text>
117
+
118
+ <v-card-text>
119
+ <b>{{$t('audit.labels.user')}}</b>: {{ item.user.username }}
120
+ </v-card-text>
121
+
122
+ <v-card-text>
123
+ <b>{{$t('audit.labels.entity')}}</b>: {{ item.entity }}
124
+ </v-card-text>
94
125
 
126
+ <v-card-text>
127
+ <b>{{$t('audit.labels.action')}}</b>: {{ $t(`audit.actions.${item.action.toLowerCase()}`) }}
128
+ </v-card-text>
129
+
130
+ <v-card-text>
131
+ <b>{{$t('audit.labels.details')}}</b>: {{ item.details }}
132
+ </v-card-text>
133
+ </v-card>
134
+ </div>
135
+
136
+ <v-spacer></v-spacer>
137
+
138
+ <div class="scrollable-content">
139
+ <v-card
140
+ outlined
141
+ class="rounded-0"
142
+ elevation="0"
143
+ >
144
+ <v-card-text
145
+ class="px-8"
146
+ >
147
+ <v-data-table v-if="item.action == 'UPDATE'"
148
+ :headers="changeHeaders"
149
+ :items="item.changes"
150
+ :hide-default-footer="true"
151
+ class="rounded-0"
152
+ >
153
+ <template v-slot:[`item.oldValue`]="{ item }">
154
+ {{ item.oldValue }}
155
+ </template>
156
+ <template v-slot:[`item.newValue`]="{ item }">
157
+ {{ item.newValue }}
158
+ </template>
159
+ </v-data-table>
160
+
161
+ <v-treeview v-if="item.dialogVisible"
162
+ :items="getAuditDataChanges(item)"
163
+ item-text="name"
164
+ item-children="children"
165
+ open-on-click
166
+ class="rounded-0"
167
+ />
168
+ </v-card-text>
169
+ </v-card>
170
+ </div>
171
+ </v-card>
172
+ </v-dialog>
95
173
  </template>
96
174
 
97
175
 
176
+
98
177
  <template v-slot:[`item.details`]="{ item }">
99
178
  {{ $t(`audit.actions.detailMessages.${item.action.toLowerCase()}`, {resourceID: item.details}) }}
100
179
  </template>
@@ -133,8 +212,8 @@ export default {
133
212
  items: [],
134
213
  totalItems: null,
135
214
  loading: false,
136
- orderBy: null,
137
- orderDesc: false,
215
+ orderBy: 'createdAt',
216
+ orderDesc: true,
138
217
  itemsPerPage: 5,
139
218
  pageNumber: 1,
140
219
  search: '',
@@ -154,7 +233,8 @@ export default {
154
233
  operator: '$regex',
155
234
  value: null
156
235
  }
157
- ]
236
+ ],
237
+ dialogVisible: false,
158
238
  }
159
239
  },
160
240
  computed: {
@@ -204,25 +284,30 @@ export default {
204
284
  this.fetch()
205
285
  },
206
286
  async fetch() {
207
-
208
- const fetchAll = await AuditProvider.fetchAudit()
209
- console.log(fetchAll)
210
287
  this.loading = true
211
- AuditProvider.paginateAudit(
212
- this.pageNumber,
213
- this.itemsPerPage,
214
- this.search,
215
- this.filters,
216
- this.getOrderBy,
217
- this.getOrderDesc
218
- ).then(r => {
219
- console.log('paginate audit', r)
220
- r.data.paginateAudit.items.forEach((item) => item.changes.length == 0 ? item.changes.length = 1 : null)
221
- this.items = r.data.paginateAudit.items
222
- this.totalItems = r.data.paginateAudit.totalItems
223
- }).catch(err => {
288
+
289
+ try {
290
+ const response = await AuditProvider.paginateAudit(
291
+ this.pageNumber,
292
+ this.itemsPerPage,
293
+ this.search,
294
+ this.filters,
295
+ this.getOrderBy,
296
+ this.getOrderDesc
297
+ )
298
+
299
+ this.items = response.data.paginateAudit.items.map(item => ({
300
+ ...item,
301
+ changes: item.changes.length === 0 ? [{ length: 1 }] : item.changes,
302
+ dialogVisible: false,
303
+ }))
304
+
305
+ this.totalItems = response.data.paginateAudit.totalItems
306
+ } catch (err) {
224
307
  console.error(err)
225
- }).finally(() => this.loading = false)
308
+ } finally {
309
+ this.loading = false
310
+ }
226
311
  },
227
312
  setFilters(auditFilters) {
228
313
  console.log('auditFilters', auditFilters)
@@ -235,8 +320,33 @@ export default {
235
320
  })
236
321
  this.fetch()
237
322
  },
238
- visualizeAuditChanges(audit){
239
- console.log(audit)
323
+ getAuditDataChanges(audit) {
324
+ if (audit && typeof audit.resourceData === 'string') {
325
+ try {
326
+ audit.resourceData = JSON.parse(audit.resourceData)
327
+ } catch {
328
+ console.error('Invalid JSON format in resourceData')
329
+ return []
330
+ }
331
+ }
332
+
333
+ if (!audit || typeof audit.resourceData !== 'object') return []
334
+
335
+ const buildTree = (data) => {
336
+ return Object.entries(data).map(([key, value]) => {
337
+ if (typeof value === 'object' && value !== null) {
338
+ return {
339
+ name: key,
340
+ children: buildTree(value) // Recursión para niveles anidados
341
+ }
342
+ }
343
+ return {
344
+ name: `${key}: ${String(value)}`
345
+ }
346
+ })
347
+ }
348
+
349
+ return buildTree(audit.resourceData)
240
350
  }
241
351
  }
242
352
 
@@ -248,4 +358,18 @@ export default {
248
358
  white-space: nowrap !important;
249
359
  align-self: center
250
360
  }
361
+
362
+ .sticky-header {
363
+ position: sticky;
364
+ top: 0;
365
+ z-index: 10;
366
+ background-color: white; /* Ajusta según el diseño */
367
+ box-shadow: 0 rgba(0, 0, 0, 0.1); /* Opcional */
368
+ }
369
+
370
+ .scrollable-content {
371
+ max-height: 60vh; /* Ajusta según el tamaño del v-dialog */
372
+ overflow-y: auto;
373
+ padding: 16px; /* Opcional, para espaciar el contenido */
374
+ }
251
375
  </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
  }
@@ -13,6 +13,7 @@ query fetchAudit{
13
13
  oldValue
14
14
  newValue
15
15
  }
16
+ resourceData
16
17
  }
17
18
  }
18
19
 
@@ -13,5 +13,6 @@ query findAudit($id:ID!){
13
13
  oldValue
14
14
  newValue
15
15
  }
16
+ resourceData
16
17
  }
17
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
  }