lesli_admin 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/config/lesli_admin_manifest.js +1 -0
- data/app/assets/images/lesli_admin/admin-logo.svg +1 -0
- data/app/assets/javascripts/lesli_admin/application.js +2635 -244
- data/app/assets/javascripts/lesli_admin/translations.js +2291 -0
- data/app/assets/stylesheets/lesli_admin/application.scss +32 -0
- data/app/assets/stylesheets/lesli_admin/users.scss +67 -0
- data/app/controllers/lesli_admin/profiles_controller.rb +56 -0
- data/app/controllers/lesli_admin/users_controller.rb +5 -196
- data/app/helpers/lesli_admin/profiles_helper.rb +4 -0
- data/app/views/lesli_admin/profiles/edit.html.erb +10 -0
- data/app/views/lesli_admin/profiles/index.html.erb +14 -0
- data/app/views/lesli_admin/profiles/new.html.erb +9 -0
- data/app/views/lesli_admin/profiles/show.html.erb +1 -0
- data/app/views/lesli_admin/users/show.html.erb +1 -10
- data/config/locales/translations.en.yml +6 -0
- data/config/locales/translations.es.yml +6 -0
- data/config/routes.rb +4 -7
- data/lib/lesli_admin/engine.rb +31 -0
- data/lib/lesli_admin/version.rb +2 -1
- data/lib/vue/application.js +15 -98
- data/lib/vue/apps/account/show.vue +2 -2
- data/lib/vue/apps/dashboard/show.vue +6 -8
- data/lib/vue/apps/profile/show.vue +22 -15
- data/lib/vue/apps/users/components/information-card.vue +4 -7
- data/lib/vue/apps/users/components/information-form.vue +4 -7
- data/lib/vue/apps/users/index.vue +10 -4
- data/lib/vue/apps/users/show.vue +25 -10
- data/lib/vue/stores/translations.json +20 -0
- data/lib/vue/stores/users.js +1 -1
- data/readme.md +61 -18
- metadata +16 -14
- data/app/assets/stylesheets/lesli_admin/application.css +0 -15
- data/app/models/lesli_admin/dashboard.rb +0 -4
- data/app/models/lesli_admin/user.rb +0 -4
- data/app/services/lesli_admin/user_service.rb +0 -300
- data/lib/vue/stores/account.js +0 -113
- data/lib/vue/stores/descriptor.js +0 -116
- data/lib/vue/stores/descriptors.js +0 -167
- data/lib/vue/stores/integration.js +0 -103
- data/lib/vue/stores/role.js +0 -243
- data/lib/vue/stores/systemController.js +0 -67
- data/lib/vue/stores/user.js +0 -319
- /data/lib/vue/stores/{accountSettings.js → account_settings.js} +0 -0
data/lib/vue/stores/user.js
DELETED
@@ -1,319 +0,0 @@
|
|
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 Development Platform.
|
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
|
-
// get the profile by default
|
89
|
-
let url = this.url.lesli("profile")
|
90
|
-
|
91
|
-
// get an specifick user if id is provided
|
92
|
-
if (id) { url = this.url.lesli("users/:id", id) }
|
93
|
-
|
94
|
-
this.http.get(url).then(result => {
|
95
|
-
this.user = result
|
96
|
-
this.user.password = ""
|
97
|
-
this.user.password_confirmation = ""
|
98
|
-
|
99
|
-
this.language = result.locale ? result.locale.value : this.language
|
100
|
-
|
101
|
-
// Backend should return the list of roles ordered by object level permission
|
102
|
-
this.role_names = result.roles[0].name
|
103
|
-
|
104
|
-
}).catch(error => {
|
105
|
-
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
106
|
-
}).finally(() => {
|
107
|
-
this.loading = false
|
108
|
-
})
|
109
|
-
},
|
110
|
-
|
111
|
-
putUser() {
|
112
|
-
this.http.put(this.url.lesli("users/:id", this.user.id), {
|
113
|
-
user: this.user
|
114
|
-
}).then(result => {
|
115
|
-
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
116
|
-
}).catch(error => {
|
117
|
-
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
118
|
-
})
|
119
|
-
},
|
120
|
-
|
121
|
-
deleteUser() {
|
122
|
-
this.dialog.confirmation({
|
123
|
-
title: "Delete user",
|
124
|
-
text: "Are you sure you want to delete user?",
|
125
|
-
confirmText: "Yes",
|
126
|
-
cancelText: "No"
|
127
|
-
})
|
128
|
-
.then(({ isConfirmed }) => {
|
129
|
-
if (isConfirmed) {
|
130
|
-
this.http.delete(this.url.lesli("/users/:id", this.user.id)).then(result => {
|
131
|
-
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
132
|
-
//this.url.go("/administration/users")
|
133
|
-
}).catch(error => {
|
134
|
-
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
135
|
-
})
|
136
|
-
}
|
137
|
-
})
|
138
|
-
},
|
139
|
-
|
140
|
-
getRoles() {
|
141
|
-
this.http.get(this.url.lesli("users/:id/roles", this.user.id)).then(result => {
|
142
|
-
this.roles = result
|
143
|
-
}).catch(error => {
|
144
|
-
console.log(error)
|
145
|
-
})
|
146
|
-
},
|
147
|
-
|
148
|
-
postRole(role) {
|
149
|
-
this.http.post(this.url.lesli('users/:id/roles', this.user.id), {
|
150
|
-
user_role: {
|
151
|
-
id: role.id
|
152
|
-
}
|
153
|
-
}).then(result => {
|
154
|
-
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
155
|
-
}).catch(error => {
|
156
|
-
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
157
|
-
})
|
158
|
-
},
|
159
|
-
|
160
|
-
deleteRole(role) {
|
161
|
-
this.http.delete(this.url.lesli('users/:user_id/roles/:role_id', {
|
162
|
-
user_id: this.user.id,
|
163
|
-
role_id: role.id
|
164
|
-
})).then(result => {
|
165
|
-
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
166
|
-
}).catch(error => {
|
167
|
-
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
168
|
-
})
|
169
|
-
},
|
170
|
-
|
171
|
-
doRequestPassword() {
|
172
|
-
this.http.post(this.url.lesli("users/:id/requestpassword", this.user.id)).then(result => {
|
173
|
-
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
174
|
-
}).catch(error => {
|
175
|
-
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
176
|
-
})
|
177
|
-
},
|
178
|
-
|
179
|
-
doPasswordReset() {
|
180
|
-
this.http.post(this.url.lesli("users/:id/passwordreset", this.user.id)).then(result => {
|
181
|
-
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
182
|
-
}).catch(error => {
|
183
|
-
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
184
|
-
})
|
185
|
-
},
|
186
|
-
|
187
|
-
doLogout() {
|
188
|
-
this.http.post(this.url.lesli("users/:id/logout", this.user.id)).then(result => {
|
189
|
-
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
190
|
-
}).catch(error => {
|
191
|
-
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
192
|
-
})
|
193
|
-
},
|
194
|
-
|
195
|
-
doRevokeAccess() {
|
196
|
-
this.http.post(this.url.lesli("users/:id/revokeaccess", this.user.id)).then(result => {
|
197
|
-
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
198
|
-
}).catch(error => {
|
199
|
-
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
200
|
-
})
|
201
|
-
},
|
202
|
-
|
203
|
-
fetchSessions() {
|
204
|
-
if (!this.sessions.length > 0) {
|
205
|
-
this.getSessions()
|
206
|
-
}
|
207
|
-
},
|
208
|
-
|
209
|
-
getSessions() {
|
210
|
-
this.http.get(this.url.lesli("users/:id/sessions", this.user.id )).then(result => {
|
211
|
-
this.sessions.pagination = result.pagination
|
212
|
-
this.sessions.records = result.records
|
213
|
-
}).catch(error => {
|
214
|
-
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
215
|
-
}).finally(() => {
|
216
|
-
this.loading = false
|
217
|
-
})
|
218
|
-
},
|
219
|
-
|
220
|
-
deleteSession(user_session_id){
|
221
|
-
this.dialog.confirmation({
|
222
|
-
title: "Close session",
|
223
|
-
text: 'Are you sure you want to close this session',
|
224
|
-
confirmText: "Yes",
|
225
|
-
cancelText: "No"
|
226
|
-
})
|
227
|
-
.then(({ isConfirmed }) => {
|
228
|
-
if (isConfirmed) {
|
229
|
-
this.http.delete(this.url.lesli("users/:id/sessions/:session_id", {
|
230
|
-
id: this.user.id,
|
231
|
-
session_id: user_session_id
|
232
|
-
})).then(result => {
|
233
|
-
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
234
|
-
}).catch(error => {
|
235
|
-
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
236
|
-
})
|
237
|
-
this.fetchSessions()
|
238
|
-
}
|
239
|
-
})
|
240
|
-
},
|
241
|
-
|
242
|
-
postLanguage() {
|
243
|
-
this.http.post(this.url.lesli('users/:id/settings', this.user.id), {
|
244
|
-
user_setting: {
|
245
|
-
name: 'locale',
|
246
|
-
value: this.user.locale.value
|
247
|
-
}
|
248
|
-
}).then(result => {
|
249
|
-
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
250
|
-
// TODO: Only if current_user changed his own language
|
251
|
-
// reload the page so the user can work with the new language
|
252
|
-
// setTimeout(() => window.location.reload(), 1000)
|
253
|
-
}).catch(error => {
|
254
|
-
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
255
|
-
})
|
256
|
-
},
|
257
|
-
|
258
|
-
getOptions() {
|
259
|
-
this.http.get(this.url.lesli("users/options")).then(result => {
|
260
|
-
this.options.salutations = result.salutations
|
261
|
-
|
262
|
-
this.options.locales = Object.keys(result.locales).map(key => {
|
263
|
-
return {label: result.locales[key], value: key}
|
264
|
-
})
|
265
|
-
}).catch(error => {
|
266
|
-
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
267
|
-
})
|
268
|
-
},
|
269
|
-
}
|
270
|
-
})
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
/*
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
updatePassword() {
|
280
|
-
this.http.put("/", {
|
281
|
-
user: {
|
282
|
-
password: this.user.password,
|
283
|
-
password_confirmation: this.user.password_confirmation
|
284
|
-
}
|
285
|
-
}).then(result => {
|
286
|
-
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
287
|
-
this.user.password = ""
|
288
|
-
this.user.password_confirmation = ""
|
289
|
-
}).catch(error => {
|
290
|
-
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
291
|
-
})
|
292
|
-
},
|
293
|
-
|
294
|
-
// This action is used to change the user status active or inactive
|
295
|
-
putUserStatus(){
|
296
|
-
this.dialog.confirmation({
|
297
|
-
title: "Change status",
|
298
|
-
text: "Are you sure you want to change the status of this user?",
|
299
|
-
confirmText: "Yes",
|
300
|
-
cancelText: "No"
|
301
|
-
})
|
302
|
-
.then(({ isConfirmed }) => {
|
303
|
-
if (isConfirmed) {
|
304
|
-
this.http.patch(this.url.lesli('users/:id', this.user.id), {
|
305
|
-
user: {
|
306
|
-
active: this.user.active
|
307
|
-
}
|
308
|
-
}).then(result => {
|
309
|
-
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
310
|
-
}) .catch(error => {
|
311
|
-
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
312
|
-
})
|
313
|
-
} else {
|
314
|
-
this.user.active = !this.user.active
|
315
|
-
}
|
316
|
-
})
|
317
|
-
},
|
318
|
-
|
319
|
-
*/
|
File without changes
|