@dracul/audit-frontend 1.13.0 → 1.13.1

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/.env ADDED
@@ -0,0 +1,2 @@
1
+ VUE_APP_APIHOST=http://localhost:5000
2
+ VUE_APP_KEY=audits
package/.eslintrc.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "root": true,
3
+ "env": {
4
+ "node": true
5
+ },
6
+ "extends": [
7
+ "plugin:vue/essential",
8
+ "eslint:recommended"
9
+ ],
10
+ "parserOptions": {
11
+ "parser": "babel-eslint"
12
+ },
13
+ "rules": {},
14
+ "overrides": [
15
+ {
16
+ "files": [
17
+ "**/__tests__/*.{j,t}s?(x)",
18
+ "**/tests/unit/**/*.spec.{j,t}s?(x)"
19
+ ],
20
+ "env": {
21
+ "jest": true
22
+ }
23
+ }
24
+ ]
25
+ }
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const auditFrontend = require('../lib/audit-frontend');
4
+
5
+ describe('audit-frontend', () => {
6
+ it('needs tests');
7
+ });
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ presets: [
3
+ '@vue/cli-plugin-babel/preset'
4
+ ]
5
+ }
6
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dracul/audit-frontend",
3
- "version": "1.13.0",
3
+ "version": "1.13.1",
4
4
  "description": "Audit frontend",
5
5
  "author": "Cristian Incarnato <cristian.cdi@gmail.com>",
6
6
  "homepage": "https://github.com/draculjs/modular-framework#readme",
@@ -11,9 +11,6 @@
11
11
  "storybook": "start-storybook -p 6006 --no-dll",
12
12
  "test": "echo \"Error: run tests from root\" && exit 1"
13
13
  },
14
- "files": [
15
- "lib"
16
- ],
17
14
  "repository": {
18
15
  "type": "git",
19
16
  "url": "git+https://github.com/draculjs/modular-framework.git"
@@ -64,5 +61,5 @@
64
61
  "vue-template-compiler": "^2.7.4",
65
62
  "vuetify": "2.6.7"
66
63
  },
67
- "gitHead": "9738c340cc32c1a3de1bed55e2d744704e60c842"
64
+ "gitHead": "ff4f595fc286a72c0f29f19823ebc7788092aafe"
68
65
  }
@@ -0,0 +1,133 @@
1
+ const i18nMessages = {
2
+ en: {
3
+ audit: {
4
+ name: 'Audit',
5
+ title: 'Audit management',
6
+ subtitle: 'View, search, create, edit and delete Audit',
7
+ creating: 'Creating Audit',
8
+ editing: 'Editing Audit',
9
+ deleting: 'Deleting Audit',
10
+ showing: 'Showing Audit',
11
+ menu: 'Audit',
12
+ labels: {
13
+ user: 'User',
14
+ action: 'Action',
15
+ targetResource: 'Resource',
16
+ createdAt: 'Date',
17
+ description: 'Description'
18
+ },
19
+
20
+ userAudit: 'User audit',
21
+
22
+ when: 'When',
23
+ actionBy: 'Action By',
24
+ actionFor: 'Action For',
25
+ action: 'Action',
26
+
27
+ today: 'Today',
28
+ yesterday: 'Yesterday',
29
+ userRecoveryPasswordChange: 'user {username} has recovered his password',
30
+ userPasswordChange: 'user {username} has modified his password',
31
+ adminPasswordChange: 'user {username}\'s password was changed by administrator',
32
+ userCreated: 'user {username} has been created',
33
+ userModified: 'user {username} has been modified',
34
+ userDeleted: 'user {username} has been deleted',
35
+ userRestored: 'user {username} has been restored',
36
+ passwordRecovery: 'user {username} has requested to recover password',
37
+ userRegistered: 'user {username} has registered',
38
+ userActivated: 'user {username} has activated his account',
39
+ avatarChange: 'user {username} has modified his avatar',
40
+
41
+ failedLogins: 'Failed logins',
42
+ nofailedLogins: 'No failed logins '
43
+ }
44
+ },
45
+ es: {
46
+ audit: {
47
+ name: 'Auditorias',
48
+ title: 'Administración de Auditorias',
49
+ subtitle: 'Ver, buscar, crear, editar, y borrar Auditorias',
50
+ creating: 'Creando Auditoria',
51
+ editing: 'Modificando Auditoria',
52
+ deleting: 'Eliminando Auditoria',
53
+ showing: 'Detalles de Auditoria',
54
+ menu: 'Auditoria',
55
+ labels: {
56
+ user: 'Usuario',
57
+ action: 'Acción',
58
+ targetResource: 'Recurso',
59
+ createdAt: 'Fecha',
60
+ description: 'Descripcion'
61
+ },
62
+
63
+ userAudit: 'Auditoria de usuario',
64
+ when: 'Cuando',
65
+ actionBy: 'Acción Por',
66
+ actionFor: 'Acción Para',
67
+ action: 'Acción',
68
+
69
+ today: 'Hoy',
70
+ yesterday: 'ayer',
71
+ userRecoveryPasswordChange: 'usuario {username} ha recuperado su contraseña',
72
+ userPasswordChange: 'usuario {username} ha modificado su contraseña',
73
+ adminPasswordChange: 'la contraseña de {username} fue modificada por administrator',
74
+ userCreated: 'usuario {username} ha sido creado',
75
+ userModified: 'usuario {username} ha sido modificado',
76
+ userDeleted: 'usuario {username} ha sido borrado',
77
+ userRestored: 'usuario {username} ha sido restaurado',
78
+ passwordRecovery: 'usuario {username} ha solicitado recuperar su contraseña',
79
+ userRegistered: 'usuario {username} se ha registrado',
80
+ userActivated: 'usuario {username} ha activado su cuenta',
81
+ avatarChange: 'usuario {username} ha modificado su avatar',
82
+
83
+ failedLogins: 'Inicios de sesión fallidos',
84
+ nofailedLogins: 'Sin inicios de sesión fallidos'
85
+ }
86
+ },
87
+ pt: {
88
+ audit: {
89
+ name: 'Audit',
90
+ title: 'Administração de Audit',
91
+ subtitle: 'Ver, buscar, criar, editar e usar Audit',
92
+ creating: 'Criando Audit',
93
+ editing: 'Edição Audit',
94
+ deleting: 'Apagando Audit',
95
+ showing: 'Detalhes do Audit',
96
+ menu: 'Audit',
97
+ labels: {
98
+ user: 'Nome do usuário',
99
+ action: 'Açao',
100
+ targetResource: 'Alvo',
101
+ createdAt: 'Data',
102
+ description: 'Description'
103
+ },
104
+
105
+ userAudit: 'Auditoria de Usuário',
106
+ when: 'Quando',
107
+ actionBy: 'Ação por',
108
+ actionFor: 'Ação Para',
109
+ action: 'Ação',
110
+
111
+ today: 'hoje',
112
+ yesterday: 'ontem',
113
+ userRecoveryPasswordChange: 'O usuário {username} recuperou sua senha',
114
+ userPasswordChange: 'Usuário {username} mudou sua senha',
115
+ adminPasswordChange: 'a senha de {username} foi alterada pelo administrador',
116
+ userCreated: 'Usuário {username} foi criado',
117
+ userModified: 'Usuário {username} foi modificado',
118
+ userDeleted: 'Usuário {username} foi excluído',
119
+ userRestored: 'Usuário {username} foi restaurado',
120
+ passwordRecovery: 'Usuário {username} solicitou recuperar sua senha',
121
+ userRegistered: 'Usuário {username} se cadastrou',
122
+ userActivated: 'Usuário {username} ativou sua conta',
123
+ avatarChange: 'Usuário {username} mudou sua avatar',
124
+ failedLogins: 'Logins com falha',
125
+ nofailedLogins: 'Sem logins com falha'
126
+ }
127
+ }
128
+
129
+ }
130
+
131
+ module.exports = {
132
+ i18nMessages
133
+ }
package/src/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import AuditPage from "./pages/AuditPage/index.vue"
2
+ import routes from "./routes/index.js"
3
+ import AuditProvider from "./providers/AuditProvider"
4
+ import { i18nMessages } from "./i18n/messages/audit-messages.js"
5
+
6
+ export {
7
+ AuditPage,
8
+ routes,
9
+ i18nMessages,
10
+ AuditProvider
11
+ }
@@ -0,0 +1,139 @@
1
+ <template>
2
+ <v-row row wrap>
3
+
4
+ <v-col cols="12" >
5
+ <v-row justify="space-between">
6
+ <v-col cols="12" sm="6" md="8">
7
+ <!-- FILTERS HERE -->
8
+ </v-col>
9
+ <v-col cols="12" sm="6" md="4">
10
+ <search-input @search="performSearch" v-model="search" />
11
+ </v-col>
12
+ </v-row>
13
+ </v-col>
14
+
15
+ <v-col cols="12">
16
+
17
+ <v-data-table
18
+ class="mt-3"
19
+ :headers="headers"
20
+ :items="items"
21
+ :search="search"
22
+ :single-expand="false"
23
+ :server-items-length="totalItems"
24
+ :loading="loading"
25
+ :page.sync="pageNumber"
26
+ :items-per-page.sync="itemsPerPage"
27
+ :sort-by.sync="orderBy"
28
+ :sort-desc.sync="orderDesc"
29
+ :footer-props="{ itemsPerPageOptions: [5, 10, 25, 50] }"
30
+ @update:page="fetch"
31
+ @update:sort-by="fetch"
32
+ @update:sort-desc="fetch"
33
+ @update:items-per-page="fetch"
34
+ >
35
+
36
+
37
+ <template v-slot:item.user="{ item }">
38
+ {{ item.user ? item.user.username : '' }}
39
+ </template>
40
+
41
+ <template v-slot:item.createdAt="{ item }">
42
+ {{ getDateTimeFormat(item.createdAt) }}
43
+ </template>
44
+
45
+
46
+ <template slot="no-data">
47
+ <div class="text-xs-center" v-t="'common.noData'"></div>
48
+ </template>
49
+
50
+ <template slot="loading">
51
+ <div class="text-xs-center" v-t="'common.loading'"></div>
52
+ </template>
53
+
54
+
55
+ </v-data-table>
56
+ </v-col>
57
+ </v-row>
58
+ </template>
59
+
60
+ <script>
61
+ import AuditProvider from "../../providers/AuditProvider";
62
+
63
+ import { SearchInput} from "@dracul/common-frontend"
64
+ import { DayjsMixin} from "@dracul/dayjs-frontend"
65
+
66
+
67
+ export default {
68
+ name: "AuditList",
69
+ components: {SearchInput},
70
+ mixins: [DayjsMixin],
71
+ data() {
72
+ return {
73
+ items: [],
74
+ totalItems: null,
75
+ loading: false,
76
+ orderBy: null,
77
+ orderDesc: false,
78
+ itemsPerPage: 5,
79
+ pageNumber: 1,
80
+ search: '',
81
+ filters: [
82
+ /*{
83
+ field: '',
84
+ operator: 'eq', //(eq|contain|regex|gt|lt|lte|gte)
85
+ value: ''
86
+ }*/
87
+ ]
88
+ }
89
+ },
90
+ computed: {
91
+ headers () {
92
+ return [
93
+ //Entity Headers
94
+ {text: this.$t('audit.labels.createdAt'), value: 'createdAt'},
95
+ {text: this.$t('audit.labels.user'), value: 'user'},
96
+ {text: this.$t('audit.labels.action'), value: 'action'},
97
+ {text: this.$t('audit.labels.targetResource'), value: 'resource'},
98
+ {text: this.$t('audit.labels.description'), value: 'description'},
99
+ //Actions
100
+ ]
101
+ },
102
+ getOrderBy(){
103
+ return (Array.isArray(this.orderBy)) ? this.orderBy[0]: this.orderBy
104
+ },
105
+ getOrderDesc(){
106
+ return (Array.isArray(this.orderDesc)) ? this.orderDesc[0]: this.orderDesc
107
+ }
108
+ },
109
+ created() {
110
+ this.fetch()
111
+ },
112
+ methods:{
113
+ performSearch(){
114
+ this.pageNumber = 1
115
+ this.fetch()
116
+ },
117
+ fetch() {
118
+ this.loading = true
119
+ AuditProvider.paginateAudit(
120
+ this.pageNumber,
121
+ this.itemsPerPage,
122
+ this.search,
123
+ this.filters,
124
+ this.getOrderBy,
125
+ this.getOrderDesc
126
+ ).then(r => {
127
+ this.items = r.data.paginateAudit.items
128
+ this.totalItems = r.data.paginateAudit.totalItems
129
+ }).catch(err => {
130
+ console.error(err)
131
+ }).finally(() => this.loading = false)
132
+ }
133
+ }
134
+
135
+ }
136
+ </script>
137
+
138
+
139
+
@@ -0,0 +1,46 @@
1
+ import {ApolloClient} from 'apollo-client'
2
+
3
+ class AuditProvider {
4
+
5
+ constructor(){
6
+ this.graphqlClient = null
7
+ }
8
+
9
+ setGqlc(graphqlClient){
10
+ if(graphqlClient instanceof ApolloClient){
11
+ this.graphqlClient = graphqlClient
12
+ }else{
13
+ throw new Error('graphqlClient must be an ApolloClient instance')
14
+ }
15
+ }
16
+
17
+ getGraphqlClient(){
18
+ if (this.graphqlClient === null) {
19
+ throw new Error('graphqlClient must be initialized')
20
+ } else {
21
+ return this.graphqlClient
22
+ }
23
+ }
24
+
25
+ findAudit(id) {
26
+ return this.getGraphqlClient().query({
27
+ query: require('./gql/Audit/findAudit.graphql'),
28
+ variables: {id}
29
+ })
30
+ }
31
+
32
+ fetchAudit() {
33
+ return this.getGraphqlClient().query({query: require('./gql/Audit/fetchAudit.graphql')})
34
+ }
35
+
36
+ paginateAudit(pageNumber, itemsPerPage, search = null, filters = null, orderBy = null, orderDesc = false) {
37
+ return this.getGraphqlClient().query({
38
+ query: require('./gql/Audit/paginateAudit.graphql'),
39
+ variables: {pageNumber, itemsPerPage, search, filters, orderBy, orderDesc},
40
+ fetchPolicy: "network-only"
41
+ })
42
+ }
43
+
44
+ }
45
+
46
+ export default new AuditProvider()
@@ -0,0 +1,12 @@
1
+ query fetchAudit{
2
+ fetchAudit{
3
+ id
4
+ user{
5
+ id
6
+ username
7
+ }
8
+ action
9
+ resource
10
+ }
11
+ }
12
+
@@ -0,0 +1,11 @@
1
+ query findAudit($id:ID!){
2
+ findAudit(id:$id){
3
+ id
4
+ user{
5
+ id
6
+ username
7
+ }
8
+ action
9
+ resource
10
+ }
11
+ }
@@ -0,0 +1,17 @@
1
+ query paginateAudit( $pageNumber: Int, $itemsPerPage:Int, $search: String, $filters: [FilterInput], $orderBy: String, $orderDesc: Boolean){
2
+ paginateAudit( pageNumber: $pageNumber, itemsPerPage: $itemsPerPage, search: $search, filters: $filters, orderBy: $orderBy, orderDesc: $orderDesc){
3
+ totalItems
4
+ page
5
+ items{
6
+ id
7
+ createdAt
8
+ user{
9
+ id
10
+ username
11
+ }
12
+ action
13
+ resource
14
+ description
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,16 @@
1
+ import AuditPage from '../pages/AuditPage/index.vue'
2
+
3
+ const routes = [
4
+
5
+ {
6
+ name: 'AuditPage',
7
+ path: '/audit',
8
+ component: AuditPage,
9
+ meta: {
10
+ requiresAuth: true,
11
+ permission: "AUDIT_SHOW"
12
+ }
13
+ }
14
+ ]
15
+
16
+ export default routes;
@@ -0,0 +1,5 @@
1
+ import merge from 'deepmerge'
2
+ import crudRoutes from './auditRoutes'
3
+
4
+ const routes = merge.all([crudRoutes])
5
+ export default routes;