lesli_guard 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +38 -0
- data/app/assets/config/lesli_guard_manifest.js +38 -0
- data/app/assets/images/lesli_guard/guard-logo.svg +160 -0
- data/app/assets/javascripts/lesli_guard/application.js +4787 -0
- data/app/assets/stylesheets/lesli_guard/application.scss +33 -0
- data/app/assets/stylesheets/lesli_guard/dashboards.scss +32 -0
- data/app/assets/stylesheets/lesli_guard/descriptors.scss +32 -0
- data/app/assets/stylesheets/lesli_guard/roles.scss +32 -0
- data/app/assets/stylesheets/lesli_guard/system_controller.scss +32 -0
- data/app/assets/stylesheets/lesli_guard/users.scss +67 -0
- data/app/controllers/lesli_guard/accounts_controller.rb +60 -0
- data/app/controllers/lesli_guard/application_controller.rb +37 -0
- data/app/controllers/lesli_guard/dashboard/components_controller.rb +60 -0
- data/app/controllers/lesli_guard/dashboards_controller.rb +36 -0
- data/app/controllers/lesli_guard/descriptor/activities_controller.rb +122 -0
- data/app/controllers/lesli_guard/descriptor/privileges_controller.rb +112 -0
- data/app/controllers/lesli_guard/descriptors_controller.rb +129 -0
- data/app/controllers/lesli_guard/role/activities_controller.rb +76 -0
- data/app/controllers/lesli_guard/role/descriptors_controller.rb +97 -0
- data/app/controllers/lesli_guard/role/privileges_controller.rb +47 -0
- data/app/controllers/lesli_guard/roles_controller.rb +185 -0
- data/app/controllers/lesli_guard/user/roles_controller.rb +98 -0
- data/app/controllers/lesli_guard/user/sessions_controller.rb +71 -0
- data/app/controllers/lesli_guard/users_controller.rb +206 -0
- data/app/helpers/lesli_guard/accounts_helper.rb +4 -0
- data/app/helpers/lesli_guard/application_helper.rb +4 -0
- data/app/helpers/lesli_guard/dashboards_helper.rb +4 -0
- data/app/helpers/lesli_guard/descriptor/activities_helper.rb +4 -0
- data/app/helpers/lesli_guard/descriptor/privileges_helper.rb +4 -0
- data/app/helpers/lesli_guard/descriptors_helper.rb +4 -0
- data/app/helpers/lesli_guard/role/activities_helper.rb +4 -0
- data/app/helpers/lesli_guard/role/descriptors_helper.rb +4 -0
- data/app/helpers/lesli_guard/role/privileges_helper.rb +4 -0
- data/app/helpers/lesli_guard/roles_helper.rb +4 -0
- data/app/jobs/lesli_guard/application_job.rb +37 -0
- data/app/mailers/lesli_guard/application_mailer.rb +39 -0
- data/app/models/lesli_guard/account.rb +43 -0
- data/app/models/lesli_guard/application_record.rb +37 -0
- data/app/models/lesli_guard/dashboard/component.rb +42 -0
- data/app/models/lesli_guard/dashboard.rb +58 -0
- data/app/models/lesli_guard/descriptor/activity.rb +40 -0
- data/app/models/lesli_guard/descriptor/privilege.rb +40 -0
- data/app/models/lesli_guard/descriptor.rb +41 -0
- data/app/models/lesli_guard/role/activity.rb +40 -0
- data/app/services/lesli_guard/descriptor_privilege_service.rb +74 -0
- data/app/services/lesli_guard/descriptor_service.rb +152 -0
- data/app/services/lesli_guard/role_descriptor_service.rb +61 -0
- data/app/services/lesli_guard/role_service.rb +215 -0
- data/app/services/lesli_guard/user_service.rb +305 -0
- data/app/views/lesli_guard/accounts/_account.html.erb +2 -0
- data/app/views/lesli_guard/accounts/_form.html.erb +17 -0
- data/app/views/lesli_guard/accounts/edit.html.erb +10 -0
- data/app/views/lesli_guard/accounts/index.html.erb +14 -0
- data/app/views/lesli_guard/accounts/new.html.erb +9 -0
- data/app/views/lesli_guard/accounts/show.html.erb +10 -0
- data/app/views/lesli_guard/dashboards/show.html.erb +1 -0
- data/app/views/lesli_guard/descriptor/activities/_form.html.erb +32 -0
- data/app/views/lesli_guard/descriptor/activities/edit.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/activities/index.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/activities/new.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/activities/show.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/privileges/_form.html.erb +32 -0
- data/app/views/lesli_guard/descriptor/privileges/edit.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/privileges/index.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/privileges/new.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/privileges/show.html.erb +34 -0
- data/app/views/lesli_guard/descriptors/_form.html.erb +32 -0
- data/app/views/lesli_guard/descriptors/edit.html.erb +34 -0
- data/app/views/lesli_guard/descriptors/index.html.erb +34 -0
- data/app/views/lesli_guard/descriptors/new.html.erb +34 -0
- data/app/views/lesli_guard/descriptors/show.html.erb +34 -0
- data/app/views/lesli_guard/partials/_engine-navigation.html.erb +38 -0
- data/app/views/lesli_guard/role/activities/_form.html.erb +32 -0
- data/app/views/lesli_guard/role/activities/edit.html.erb +34 -0
- data/app/views/lesli_guard/role/activities/index.html.erb +34 -0
- data/app/views/lesli_guard/role/activities/new.html.erb +34 -0
- data/app/views/lesli_guard/role/activities/show.html.erb +34 -0
- data/app/views/lesli_guard/role/descriptors/_form.html.erb +32 -0
- data/app/views/lesli_guard/role/descriptors/edit.html.erb +34 -0
- data/app/views/lesli_guard/role/descriptors/index.html.erb +34 -0
- data/app/views/lesli_guard/role/descriptors/new.html.erb +34 -0
- data/app/views/lesli_guard/role/descriptors/show.html.erb +34 -0
- data/app/views/lesli_guard/role/privileges/_form.html.erb +32 -0
- data/app/views/lesli_guard/role/privileges/edit.html.erb +34 -0
- data/app/views/lesli_guard/role/privileges/index.html.erb +34 -0
- data/app/views/lesli_guard/role/privileges/new.html.erb +34 -0
- data/app/views/lesli_guard/role/privileges/show.html.erb +34 -0
- data/app/views/lesli_guard/roles/edit.html.erb +34 -0
- data/app/views/lesli_guard/roles/index.html.erb +34 -0
- data/app/views/lesli_guard/roles/new.html.erb +34 -0
- data/app/views/lesli_guard/roles/show.html.erb +34 -0
- data/app/views/lesli_guard/users/edit.html.erb +10 -0
- data/app/views/lesli_guard/users/index.html.erb +34 -0
- data/app/views/lesli_guard/users/new.html.erb +34 -0
- data/app/views/lesli_guard/users/show.html.erb +1 -0
- data/config/locales/translations.en.yml +43 -0
- data/config/locales/translations.es.yml +43 -0
- data/config/routes.rb +90 -0
- data/db/migrate/v1/0801000110_create_lesli_guard_accounts.rb +42 -0
- data/db/migrate/v1/0801050110_create_lesli_guard_dashboards.rb +51 -0
- data/db/migrate/v1/0801050210_create_lesli_guard_dashboard_components.rb +53 -0
- data/lib/lesli_guard/engine.rb +18 -0
- data/lib/lesli_guard/version.rb +4 -0
- data/lib/lesli_guard.rb +6 -0
- data/lib/tasks/lesli_guard_tasks.rake +50 -0
- data/lib/vue/application.js +112 -0
- data/lib/vue/apps/descriptors/components/form.vue +136 -0
- data/lib/vue/apps/descriptors/edit.vue +83 -0
- data/lib/vue/apps/descriptors/index.vue +113 -0
- data/lib/vue/apps/descriptors/new.vue +69 -0
- data/lib/vue/apps/descriptors/show.vue +233 -0
- data/lib/vue/apps/roles/components/descriptors.vue +81 -0
- data/lib/vue/apps/roles/components/form.vue +253 -0
- data/lib/vue/apps/roles/components/privilegeCustom.vue +86 -0
- data/lib/vue/apps/roles/components/privilegeStandard.vue +196 -0
- data/lib/vue/apps/roles/edit.vue +118 -0
- data/lib/vue/apps/roles/index.vue +168 -0
- data/lib/vue/apps/roles/logs.vue +110 -0
- data/lib/vue/apps/roles/new.vue +86 -0
- data/lib/vue/apps/roles/show.vue +109 -0
- data/lib/vue/apps/users/components/information-card.vue +107 -0
- data/lib/vue/apps/users/components/information-form.vue +176 -0
- data/lib/vue/apps/users/components/integrations-information.vue +61 -0
- data/lib/vue/apps/users/components/management-roles.vue +107 -0
- data/lib/vue/apps/users/components/management-security.vue +113 -0
- data/lib/vue/apps/users/components/management-sessions.vue +101 -0
- data/lib/vue/apps/users/components/management-settings.vue +93 -0
- data/lib/vue/apps/users/index.vue +207 -0
- data/lib/vue/apps/users/new.vue +181 -0
- data/lib/vue/apps/users/show.vue +131 -0
- data/lib/vue/stores/descriptor.js +117 -0
- data/lib/vue/stores/descriptors.js +156 -0
- data/lib/vue/stores/role.js +203 -0
- data/lib/vue/stores/roles.js +58 -0
- data/lib/vue/stores/translations.json +98 -0
- data/lib/vue/stores/user.js +331 -0
- data/lib/vue/stores/users.js +176 -0
- data/license +674 -0
- data/readme.md +76 -0
- metadata +199 -0
@@ -0,0 +1,98 @@
|
|
1
|
+
{
|
2
|
+
"en": {
|
3
|
+
"lesli": {
|
4
|
+
"application": {
|
5
|
+
"navigation_logout": "Logout",
|
6
|
+
"navigation_my_profile": "My profile"
|
7
|
+
},
|
8
|
+
"shared": {
|
9
|
+
"button_add_new": "Add new",
|
10
|
+
"button_delete": "Delete",
|
11
|
+
"button_edit": "Edit",
|
12
|
+
"button_list": "List",
|
13
|
+
"button_reload": "Reload",
|
14
|
+
"button_save": "Save",
|
15
|
+
"button_settings": "Settings",
|
16
|
+
"button_show": "Show",
|
17
|
+
"view_discussions": "Discussions",
|
18
|
+
"view_files": "Files",
|
19
|
+
"view_quick_actions": "Quick actions",
|
20
|
+
"view_status_active": "Active",
|
21
|
+
"view_status_inactive": "Inactive"
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"lesli_guard": {
|
25
|
+
"users": {
|
26
|
+
"column_active": "Active",
|
27
|
+
"column_address": "Address",
|
28
|
+
"column_alias": "Alias",
|
29
|
+
"column_email": "Email",
|
30
|
+
"column_first_name": "First name",
|
31
|
+
"column_last_name": "Last name",
|
32
|
+
"column_salutation": "Salutation",
|
33
|
+
"column_telephone": "Telephone",
|
34
|
+
"column_title": "Title",
|
35
|
+
"tab_information": "Information",
|
36
|
+
"tab_roles_and_privileges": "Roles and privileges",
|
37
|
+
"tab_security": "Security",
|
38
|
+
"tab_sessions": "Sessions",
|
39
|
+
"tab_settings": "Settings",
|
40
|
+
"table_header_email": "Email",
|
41
|
+
"table_header_last_activity": "Last activity",
|
42
|
+
"table_header_last_sign_in": "Last sign in",
|
43
|
+
"table_header_name": "Name",
|
44
|
+
"table_header_roles": "Roles",
|
45
|
+
"table_header_status": "Status",
|
46
|
+
"view_title": "Users"
|
47
|
+
}
|
48
|
+
}
|
49
|
+
},
|
50
|
+
"es": {
|
51
|
+
"lesli": {
|
52
|
+
"application": {
|
53
|
+
"navigation_logout": "Cerrar sesión",
|
54
|
+
"navigation_my_profile": "Mi perfil"
|
55
|
+
},
|
56
|
+
"shared": {
|
57
|
+
"button_add_new": "Agregar nuevo",
|
58
|
+
"button_delete": "Eliminar",
|
59
|
+
"button_edit": "Editar",
|
60
|
+
"button_list": "Lista",
|
61
|
+
"button_reload": "Recargar",
|
62
|
+
"button_save": "Guardar",
|
63
|
+
"button_settings": "Configuración",
|
64
|
+
"button_show": "Ver",
|
65
|
+
"view_discussions": "Discusiones",
|
66
|
+
"view_files": "Archivos",
|
67
|
+
"view_quick_actions": "Acciones rapidas",
|
68
|
+
"view_status_active": "Activo",
|
69
|
+
"view_status_inactive": "Inactivo"
|
70
|
+
}
|
71
|
+
},
|
72
|
+
"lesli_guard": {
|
73
|
+
"users": {
|
74
|
+
"column_active": "Activo",
|
75
|
+
"column_address": "Dirección",
|
76
|
+
"column_alias": "Alias",
|
77
|
+
"column_email": "Email",
|
78
|
+
"column_first_name": "Nombre",
|
79
|
+
"column_last_name": "Apellido",
|
80
|
+
"column_salutation": "Saludo",
|
81
|
+
"column_telephone": "Teléfono",
|
82
|
+
"column_title": "Titulo",
|
83
|
+
"tab_information": "Información",
|
84
|
+
"tab_roles_and_privileges": "Roles y privilegios",
|
85
|
+
"tab_security": "Seguridad",
|
86
|
+
"tab_sessions": "Sesiones",
|
87
|
+
"tab_settings": "Configuración",
|
88
|
+
"table_header_email": "Email",
|
89
|
+
"table_header_last_activity": "Ultima actividad",
|
90
|
+
"table_header_last_sign_in": "Ultimo login",
|
91
|
+
"table_header_name": "Nombre",
|
92
|
+
"table_header_roles": "Roles",
|
93
|
+
"table_header_status": "Estado",
|
94
|
+
"view_title": "Usuarios"
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
@@ -0,0 +1,331 @@
|
|
1
|
+
/*
|
2
|
+
Lesli
|
3
|
+
|
4
|
+
Copyright (c) 2023, Lesli Technologies, S. A.
|
5
|
+
|
6
|
+
This program is free software: you can redistribute it and/or modify
|
7
|
+
it under the terms of the GNU General Public License as published by
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
9
|
+
(at your option) any later version.
|
10
|
+
|
11
|
+
This program is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with this program. If not, see http://www.gnu.org/licenses/.
|
18
|
+
|
19
|
+
Lesli · Ruby on Rails SaaS Development Framework.
|
20
|
+
|
21
|
+
Made with ♥ by https://www.lesli.tech
|
22
|
+
Building a better future, one line of code at a time.
|
23
|
+
|
24
|
+
@contact hello@lesli.tech
|
25
|
+
@website https://www.lesli.tech
|
26
|
+
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
27
|
+
|
28
|
+
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
29
|
+
// ·
|
30
|
+
*/
|
31
|
+
|
32
|
+
|
33
|
+
// ·
|
34
|
+
import { defineStore } from "pinia"
|
35
|
+
|
36
|
+
|
37
|
+
// ·
|
38
|
+
export const useUser = defineStore("lesli.user", {
|
39
|
+
state: () => {
|
40
|
+
return {
|
41
|
+
options: {
|
42
|
+
regions: [],
|
43
|
+
locales: [],
|
44
|
+
salutations: [],
|
45
|
+
mfa_methods: []
|
46
|
+
},
|
47
|
+
user: {
|
48
|
+
roles_id: null,
|
49
|
+
email: null,
|
50
|
+
alias: null,
|
51
|
+
first_name: null,
|
52
|
+
last_name: null,
|
53
|
+
telephone: null,
|
54
|
+
detail_attributes: {
|
55
|
+
salutation: null,
|
56
|
+
title: null,
|
57
|
+
}
|
58
|
+
},
|
59
|
+
roles: [],
|
60
|
+
sessions: {
|
61
|
+
pagination: {},
|
62
|
+
records: []
|
63
|
+
},
|
64
|
+
options: {
|
65
|
+
salutations: [],
|
66
|
+
locales: []
|
67
|
+
}
|
68
|
+
}
|
69
|
+
},
|
70
|
+
getters: {
|
71
|
+
initials() {
|
72
|
+
let initials = ""
|
73
|
+
if (this.user?.first_name) initials += this.user?.first_name[0];
|
74
|
+
if (this.user?.last_name) initials += this.user?.last_name[0];
|
75
|
+
return initials.toUpperCase()
|
76
|
+
}
|
77
|
+
},
|
78
|
+
actions: {
|
79
|
+
|
80
|
+
getOptions() {
|
81
|
+
this.http.get(this.url.lesli("users/options")).then(result => {
|
82
|
+
this.options = result
|
83
|
+
})
|
84
|
+
},
|
85
|
+
|
86
|
+
getUser(id=null) {
|
87
|
+
|
88
|
+
let url = this.url.guard("profile")
|
89
|
+
|
90
|
+
if (id !== null) {
|
91
|
+
url = this.url.guard("users/:id", id)
|
92
|
+
}
|
93
|
+
|
94
|
+
// get an specifick user if id is provided
|
95
|
+
this.http.get(url).then(result => {
|
96
|
+
this.user = result
|
97
|
+
this.user.password = ""
|
98
|
+
this.user.password_confirmation = ""
|
99
|
+
|
100
|
+
this.language = result.locale ? result.locale.value : this.language
|
101
|
+
|
102
|
+
// Backend should return the list of roles ordered by object level permission
|
103
|
+
this.role_names = result.roles[0].name
|
104
|
+
|
105
|
+
}).catch(error => {
|
106
|
+
console.log(error)
|
107
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
108
|
+
}).finally(() => {
|
109
|
+
this.loading = false
|
110
|
+
})
|
111
|
+
},
|
112
|
+
|
113
|
+
putUser() {
|
114
|
+
this.http.put(this.url.guard("users/:id", this.user.id), {
|
115
|
+
user: {
|
116
|
+
active: this.user.active,
|
117
|
+
alias: this.user.alias,
|
118
|
+
first_name: this.user.first_name,
|
119
|
+
last_name: this.user.last_name,
|
120
|
+
telephone: this.user.telephone,
|
121
|
+
detail_attributes: {
|
122
|
+
title: this.user.detail_attributes.title,
|
123
|
+
salutation: this.user.detail_attributes.salutation
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}).then(result => {
|
127
|
+
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
128
|
+
}).catch(error => {
|
129
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
130
|
+
})
|
131
|
+
},
|
132
|
+
|
133
|
+
deleteUser() {
|
134
|
+
this.dialog.confirmation({
|
135
|
+
title: "Delete user",
|
136
|
+
text: "Are you sure you want to delete user?",
|
137
|
+
confirmText: "Yes",
|
138
|
+
cancelText: "No"
|
139
|
+
})
|
140
|
+
.then(({ isConfirmed }) => {
|
141
|
+
if (isConfirmed) {
|
142
|
+
this.http.delete(this.url.lesli("/users/:id", this.user.id)).then(result => {
|
143
|
+
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
144
|
+
//this.url.go("/administration/users")
|
145
|
+
}).catch(error => {
|
146
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
147
|
+
})
|
148
|
+
}
|
149
|
+
})
|
150
|
+
},
|
151
|
+
|
152
|
+
getRoles() {
|
153
|
+
this.http.get(this.url.guard("users/:id/roles", this.user.id)).then(result => {
|
154
|
+
this.roles = result
|
155
|
+
}).catch(error => {
|
156
|
+
console.log(error)
|
157
|
+
})
|
158
|
+
},
|
159
|
+
|
160
|
+
postRole(role) {
|
161
|
+
this.http.post(this.url.guard('users/:id/roles', this.user.id), {
|
162
|
+
user_role: {
|
163
|
+
id: role.id
|
164
|
+
}
|
165
|
+
}).then(result => {
|
166
|
+
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
167
|
+
}).catch(error => {
|
168
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
169
|
+
})
|
170
|
+
},
|
171
|
+
|
172
|
+
deleteRole(role) {
|
173
|
+
this.http.delete(this.url.guard('users/:user_id/roles/:role_id', {
|
174
|
+
user_id: this.user.id,
|
175
|
+
role_id: role.id
|
176
|
+
})).then(result => {
|
177
|
+
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
178
|
+
}).catch(error => {
|
179
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
180
|
+
})
|
181
|
+
},
|
182
|
+
|
183
|
+
doRequestPassword() {
|
184
|
+
this.http.post(this.url.lesli("users/:id/requestpassword", this.user.id)).then(result => {
|
185
|
+
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
186
|
+
}).catch(error => {
|
187
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
188
|
+
})
|
189
|
+
},
|
190
|
+
|
191
|
+
doPasswordReset() {
|
192
|
+
this.http.post(this.url.lesli("users/:id/passwordreset", this.user.id)).then(result => {
|
193
|
+
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
194
|
+
}).catch(error => {
|
195
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
196
|
+
})
|
197
|
+
},
|
198
|
+
|
199
|
+
doLogout() {
|
200
|
+
this.http.post(this.url.lesli("users/:id/logout", this.user.id)).then(result => {
|
201
|
+
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
202
|
+
}).catch(error => {
|
203
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
204
|
+
})
|
205
|
+
},
|
206
|
+
|
207
|
+
doRevokeAccess() {
|
208
|
+
this.http.post(this.url.lesli("users/:id/revokeaccess", this.user.id)).then(result => {
|
209
|
+
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
210
|
+
}).catch(error => {
|
211
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
212
|
+
})
|
213
|
+
},
|
214
|
+
|
215
|
+
fetchSessions() {
|
216
|
+
if (!this.sessions.length > 0) {
|
217
|
+
this.getSessions()
|
218
|
+
}
|
219
|
+
},
|
220
|
+
|
221
|
+
getSessions() {
|
222
|
+
this.http.get(this.url.guard("users/:id/sessions", this.user.id )).then(result => {
|
223
|
+
this.sessions.pagination = result.pagination
|
224
|
+
this.sessions.records = result.records
|
225
|
+
}).catch(error => {
|
226
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
227
|
+
}).finally(() => {
|
228
|
+
this.loading = false
|
229
|
+
})
|
230
|
+
},
|
231
|
+
|
232
|
+
deleteSession(user_session_id){
|
233
|
+
this.dialog.confirmation({
|
234
|
+
title: "Close session",
|
235
|
+
text: 'Are you sure you want to close this session',
|
236
|
+
confirmText: "Yes",
|
237
|
+
cancelText: "No"
|
238
|
+
})
|
239
|
+
.then(({ isConfirmed }) => {
|
240
|
+
if (isConfirmed) {
|
241
|
+
this.http.delete(this.url.lesli("users/:id/sessions/:session_id", {
|
242
|
+
id: this.user.id,
|
243
|
+
session_id: user_session_id
|
244
|
+
})).then(result => {
|
245
|
+
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
246
|
+
}).catch(error => {
|
247
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
248
|
+
})
|
249
|
+
this.fetchSessions()
|
250
|
+
}
|
251
|
+
})
|
252
|
+
},
|
253
|
+
|
254
|
+
postLanguage() {
|
255
|
+
this.http.post(this.url.lesli('users/:id/settings', this.user.id), {
|
256
|
+
user_setting: {
|
257
|
+
name: 'locale',
|
258
|
+
value: this.user.locale.value
|
259
|
+
}
|
260
|
+
}).then(result => {
|
261
|
+
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
262
|
+
// TODO: Only if current_user changed his own language
|
263
|
+
// reload the page so the user can work with the new language
|
264
|
+
// setTimeout(() => window.location.reload(), 1000)
|
265
|
+
}).catch(error => {
|
266
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
267
|
+
})
|
268
|
+
},
|
269
|
+
|
270
|
+
getOptions() {
|
271
|
+
this.http.get(this.url.lesli("users/options")).then(result => {
|
272
|
+
this.options.salutations = result.salutations
|
273
|
+
|
274
|
+
this.options.locales = Object.keys(result.locales).map(key => {
|
275
|
+
return {label: result.locales[key], value: key}
|
276
|
+
})
|
277
|
+
}).catch(error => {
|
278
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
279
|
+
})
|
280
|
+
},
|
281
|
+
}
|
282
|
+
})
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
/*
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
updatePassword() {
|
292
|
+
this.http.put("/", {
|
293
|
+
user: {
|
294
|
+
password: this.user.password,
|
295
|
+
password_confirmation: this.user.password_confirmation
|
296
|
+
}
|
297
|
+
}).then(result => {
|
298
|
+
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
299
|
+
this.user.password = ""
|
300
|
+
this.user.password_confirmation = ""
|
301
|
+
}).catch(error => {
|
302
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
303
|
+
})
|
304
|
+
},
|
305
|
+
|
306
|
+
// This action is used to change the user status active or inactive
|
307
|
+
putUserStatus(){
|
308
|
+
this.dialog.confirmation({
|
309
|
+
title: "Change status",
|
310
|
+
text: "Are you sure you want to change the status of this user?",
|
311
|
+
confirmText: "Yes",
|
312
|
+
cancelText: "No"
|
313
|
+
})
|
314
|
+
.then(({ isConfirmed }) => {
|
315
|
+
if (isConfirmed) {
|
316
|
+
this.http.patch(this.url.lesli('users/:id', this.user.id), {
|
317
|
+
user: {
|
318
|
+
active: this.user.active
|
319
|
+
}
|
320
|
+
}).then(result => {
|
321
|
+
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
322
|
+
}) .catch(error => {
|
323
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
324
|
+
})
|
325
|
+
} else {
|
326
|
+
this.user.active = !this.user.active
|
327
|
+
}
|
328
|
+
})
|
329
|
+
},
|
330
|
+
|
331
|
+
*/
|
@@ -0,0 +1,176 @@
|
|
1
|
+
/*
|
2
|
+
Lesli
|
3
|
+
|
4
|
+
Copyright (c) 2023, Lesli Technologies, S. A.
|
5
|
+
|
6
|
+
This program is free software: you can redistribute it and/or modify
|
7
|
+
it under the terms of the GNU General Public License as published by
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
9
|
+
(at your option) any later version.
|
10
|
+
|
11
|
+
This program is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with this program. If not, see http://www.gnu.org/licenses/.
|
18
|
+
|
19
|
+
Lesli · Ruby on Rails SaaS Development Framework.
|
20
|
+
|
21
|
+
Made with ♥ by https://www.lesli.tech
|
22
|
+
Building a better future, one line of code at a time.
|
23
|
+
|
24
|
+
@contact hello@lesli.tech
|
25
|
+
@website https://www.lesli.tech
|
26
|
+
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
27
|
+
|
28
|
+
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
29
|
+
// ·
|
30
|
+
*/
|
31
|
+
|
32
|
+
|
33
|
+
// ·
|
34
|
+
import { defineStore } from "pinia"
|
35
|
+
|
36
|
+
|
37
|
+
// · translations
|
38
|
+
const translations = {
|
39
|
+
core: {
|
40
|
+
roles: I18n.t("core.roles"),
|
41
|
+
users: I18n.t("core.users"),
|
42
|
+
shared: I18n.t("core.shared")
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
|
47
|
+
// ·
|
48
|
+
export const useUsers = defineStore("guard.users", {
|
49
|
+
state: () => {
|
50
|
+
return {
|
51
|
+
loading: false,
|
52
|
+
search: "",
|
53
|
+
order: {
|
54
|
+
column: "id",
|
55
|
+
direction: "desc"
|
56
|
+
},
|
57
|
+
index: {
|
58
|
+
pagination: {},
|
59
|
+
records: []
|
60
|
+
},
|
61
|
+
filters :{
|
62
|
+
per_page: 15,
|
63
|
+
role: null,
|
64
|
+
status: 'active'
|
65
|
+
},
|
66
|
+
roles_options: [],
|
67
|
+
|
68
|
+
user: {
|
69
|
+
roles_id: null,
|
70
|
+
email: null,
|
71
|
+
first_name: null,
|
72
|
+
last_name: null,
|
73
|
+
telephone: null,
|
74
|
+
}
|
75
|
+
}
|
76
|
+
},
|
77
|
+
actions: {
|
78
|
+
|
79
|
+
search(search_string) {
|
80
|
+
this.index.pagination.page = 1
|
81
|
+
this.search_string = search_string
|
82
|
+
this.loading = true
|
83
|
+
this.getUsers()
|
84
|
+
},
|
85
|
+
|
86
|
+
paginateIndex(page) {
|
87
|
+
this.index.pagination.page = page
|
88
|
+
this.getUsers()
|
89
|
+
},
|
90
|
+
|
91
|
+
sortIndex(column, direction) {
|
92
|
+
this.order.column = column
|
93
|
+
this.order.direction = direction
|
94
|
+
this.getUsers()
|
95
|
+
},
|
96
|
+
|
97
|
+
fetchUsers() {
|
98
|
+
|
99
|
+
if (!this.index.pagination?.results > 0) {
|
100
|
+
this.loading = true
|
101
|
+
this.getUsers()
|
102
|
+
}
|
103
|
+
|
104
|
+
},
|
105
|
+
|
106
|
+
getUsers() {
|
107
|
+
|
108
|
+
const query_filters = {}
|
109
|
+
|
110
|
+
//Format filters to send them in the query string
|
111
|
+
for (const [key, value] of Object.entries(this.filters)) {
|
112
|
+
//query_filters[key] = [value]
|
113
|
+
}
|
114
|
+
|
115
|
+
this.http.get(
|
116
|
+
this.url
|
117
|
+
.guard("users")
|
118
|
+
.search(this.search_string)
|
119
|
+
.paginate(this.index.pagination.page, this.filters.per_page)
|
120
|
+
.filter(query_filters)
|
121
|
+
.order(this.order.column, this.order.direction)
|
122
|
+
).then(result => {
|
123
|
+
this.index = result
|
124
|
+
this.search_string=""
|
125
|
+
}).catch(error => {
|
126
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
127
|
+
}).finally(() => {
|
128
|
+
this.loading = false
|
129
|
+
})
|
130
|
+
},
|
131
|
+
|
132
|
+
getUser(id=null) {
|
133
|
+
|
134
|
+
// get the profile by default
|
135
|
+
let url = this.url.lesli("profile")
|
136
|
+
|
137
|
+
// get an specifick user if id is provided
|
138
|
+
if (id) { url = this.url.lesli("users/:id", id) }
|
139
|
+
|
140
|
+
this.http.get(url).then(result => {
|
141
|
+
this.user = result
|
142
|
+
this.user.password = ""
|
143
|
+
this.user.password_confirmation = ""
|
144
|
+
|
145
|
+
this.language = result.locale ? result.locale.value : this.language
|
146
|
+
|
147
|
+
// Backend should return the list of roles ordered by object level permission
|
148
|
+
this.role_names = result.roles[0].name
|
149
|
+
|
150
|
+
}).catch(error => {
|
151
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
152
|
+
}).finally(() => {
|
153
|
+
this.loading = false
|
154
|
+
})
|
155
|
+
},
|
156
|
+
|
157
|
+
postUsers() {
|
158
|
+
return this.http.post(this.url.admin("users"), {
|
159
|
+
user: this.user
|
160
|
+
})
|
161
|
+
},
|
162
|
+
|
163
|
+
fetchList() {
|
164
|
+
this.loading = true
|
165
|
+
return this.http.get(this.url.admin("users/list")).then(response => {
|
166
|
+
//this.records = response
|
167
|
+
this.list = response
|
168
|
+
}).catch(error => {
|
169
|
+
|
170
|
+
}).finally(() => {
|
171
|
+
this.loading = false
|
172
|
+
})
|
173
|
+
}
|
174
|
+
|
175
|
+
}
|
176
|
+
})
|