@dracul/audit-frontend 1.35.5 → 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.5",
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": "f593ab2b43687a9e8c3545c164e30494a868bf59"
41
+ "gitHead": "b866b70b275902cba82da8e6b7f490a3543b82bc"
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
 
@@ -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: '',
@@ -154,7 +237,8 @@ export default {
154
237
  operator: '$regex',
155
238
  value: null
156
239
  }
157
- ]
240
+ ],
241
+ dialogVisible: false,
158
242
  }
159
243
  },
160
244
  computed: {
@@ -204,26 +288,28 @@ export default {
204
288
  this.fetch()
205
289
  },
206
290
  async fetch() {
207
-
208
- const fetchAll = await AuditProvider.fetchAudit()
209
- console.log(fetchAll)
210
- this.loading = true
211
- AuditProvider.paginateAudit(
291
+ this.loading = true;
292
+ try {
293
+ const response = await AuditProvider.paginateAudit(
212
294
  this.pageNumber,
213
295
  this.itemsPerPage,
214
296
  this.search,
215
297
  this.filters,
216
298
  this.getOrderBy,
217
299
  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 => {
224
- console.error(err)
225
- }).finally(() => this.loading = false)
226
- },
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
+ },
227
313
  setFilters(auditFilters) {
228
314
  console.log('auditFilters', auditFilters)
229
315
  this.filters = auditFilters
@@ -235,8 +321,15 @@ export default {
235
321
  })
236
322
  this.fetch()
237
323
  },
238
- visualizeAuditChanges(audit){
239
- 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
+ }))
240
333
  }
241
334
  }
242
335
 
@@ -248,4 +341,18 @@ export default {
248
341
  white-space: nowrap !important;
249
342
  align-self: center
250
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
+ }
251
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
  }
@@ -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
  }