lesli_admin 0.1.0

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.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +5 -0
  3. data/app/assets/config/lesli_admin_manifest.js +38 -0
  4. data/app/assets/javascripts/lesli_admin/application.js +3713 -0
  5. data/app/assets/stylesheets/lesli_admin/application.css +15 -0
  6. data/app/controllers/lesli_admin/accounts_controller.rb +125 -0
  7. data/app/controllers/lesli_admin/application_controller.rb +4 -0
  8. data/app/controllers/lesli_admin/dashboards_controller.rb +60 -0
  9. data/app/controllers/lesli_admin/users_controller.rb +244 -0
  10. data/app/helpers/lesli_admin/application_helper.rb +4 -0
  11. data/app/helpers/lesli_admin/dashboards_helper.rb +4 -0
  12. data/app/jobs/lesli_admin/application_job.rb +4 -0
  13. data/app/mailers/lesli_admin/application_mailer.rb +6 -0
  14. data/app/models/lesli_admin/account.rb +66 -0
  15. data/app/models/lesli_admin/application_record.rb +5 -0
  16. data/app/models/lesli_admin/dashboard.rb +4 -0
  17. data/app/models/lesli_admin/user.rb +4 -0
  18. data/app/services/lesli_admin/user_service.rb +300 -0
  19. data/app/views/layouts/lesli_admin/application.html.erb +15 -0
  20. data/app/views/lesli_admin/accounts/_account.html.erb +2 -0
  21. data/app/views/lesli_admin/accounts/_form.html.erb +17 -0
  22. data/app/views/lesli_admin/accounts/edit.html.erb +10 -0
  23. data/app/views/lesli_admin/accounts/index.html.erb +34 -0
  24. data/app/views/lesli_admin/accounts/new.html.erb +9 -0
  25. data/app/views/lesli_admin/accounts/show.html.erb +34 -0
  26. data/app/views/lesli_admin/dashboards/_dashboard.html.erb +2 -0
  27. data/app/views/lesli_admin/dashboards/_form.html.erb +17 -0
  28. data/app/views/lesli_admin/dashboards/edit.html.erb +10 -0
  29. data/app/views/lesli_admin/dashboards/index.html.erb +14 -0
  30. data/app/views/lesli_admin/dashboards/new.html.erb +9 -0
  31. data/app/views/lesli_admin/dashboards/show.html.erb +1 -0
  32. data/app/views/lesli_admin/partials/_engine-navigation.html.erb +52 -0
  33. data/app/views/lesli_admin/users/edit.html.erb +10 -0
  34. data/app/views/lesli_admin/users/index.html.erb +34 -0
  35. data/app/views/lesli_admin/users/new.html.erb +34 -0
  36. data/app/views/lesli_admin/users/show.html.erb +10 -0
  37. data/config/routes.rb +13 -0
  38. data/lib/lesli_admin/engine.rb +18 -0
  39. data/lib/lesli_admin/version.rb +3 -0
  40. data/lib/lesli_admin.rb +6 -0
  41. data/lib/tasks/lesli_admin_tasks.rake +4 -0
  42. data/lib/vue/application.js +153 -0
  43. data/lib/vue/apps/account/components/address-form.vue +134 -0
  44. data/lib/vue/apps/account/components/contact-form.vue +162 -0
  45. data/lib/vue/apps/account/components/form-information.vue +107 -0
  46. data/lib/vue/apps/account/show.vue +89 -0
  47. data/lib/vue/apps/dashboard/show.vue +33 -0
  48. data/lib/vue/apps/profile/components/change-email.vue +38 -0
  49. data/lib/vue/apps/profile/components/subscriptions.vue +94 -0
  50. data/lib/vue/apps/profile/show.vue +141 -0
  51. data/lib/vue/apps/users/components/information-card.vue +119 -0
  52. data/lib/vue/apps/users/components/information-form.vue +180 -0
  53. data/lib/vue/apps/users/components/integrations-information.vue +61 -0
  54. data/lib/vue/apps/users/components/management-roles.vue +109 -0
  55. data/lib/vue/apps/users/components/management-security.vue +113 -0
  56. data/lib/vue/apps/users/components/management-sessions.vue +106 -0
  57. data/lib/vue/apps/users/components/management-settings.vue +94 -0
  58. data/lib/vue/apps/users/index.vue +201 -0
  59. data/lib/vue/apps/users/new.vue +181 -0
  60. data/lib/vue/apps/users/show.vue +101 -0
  61. data/lib/vue/stores/account.js +113 -0
  62. data/lib/vue/stores/accountSettings.js +342 -0
  63. data/lib/vue/stores/descriptor.js +116 -0
  64. data/lib/vue/stores/descriptors.js +167 -0
  65. data/lib/vue/stores/integration.js +103 -0
  66. data/lib/vue/stores/role.js +243 -0
  67. data/lib/vue/stores/roles.js +89 -0
  68. data/lib/vue/stores/systemController.js +67 -0
  69. data/lib/vue/stores/user.js +319 -0
  70. data/lib/vue/stores/users.js +150 -0
  71. data/readme.md +28 -0
  72. metadata +130 -0
@@ -0,0 +1,103 @@
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 useIntegration = defineStore("administration.integration", {
39
+ state: () => {
40
+ return {
41
+ token: "",
42
+ records: [],
43
+ pagination: {},
44
+ integration: {
45
+ name: ""
46
+ }
47
+ }
48
+ },
49
+ actions: {
50
+
51
+ fetch() {
52
+ this.http.get(this.url.admin("account/integrations")).then(result => {
53
+ this.pagination = result.pagination
54
+ this.records = result.records.map(integrations => {
55
+ integrations.created_at = this.date.dateTime(integrations.created_at)
56
+ return integrations
57
+ })
58
+ })
59
+ },
60
+
61
+ post() {
62
+
63
+ if (this.integration.name == "") {
64
+ return
65
+ }
66
+
67
+ this.http.post(this.url.admin("account/integrations"), {
68
+ account_integration: this.integration
69
+ }).then(result => {
70
+ this.integration.name = ""
71
+ this.token = result
72
+ })
73
+ },
74
+ /**
75
+ * @description This action is used to delete an integration
76
+ */
77
+ deleteIntegration(integration_id){
78
+ this.dialog.confirmation({
79
+ title: "Delete integration",
80
+ text: 'Are you sure you want to delete this integration?',
81
+ confirmText: "Yes",
82
+ cancelText: "No"
83
+ })
84
+ .then(({ isConfirmed }) => {
85
+ if (isConfirmed) {
86
+ this.http.delete(this.url.admin("account/integrations/:id", { id: integration_id})).then(result => {
87
+ // delete user associated with integration
88
+ this.http.delete(this.url.admin("/users/:user_id", {
89
+ user_id: result.users_id
90
+ })).then(result => {
91
+ this.msg.success(I18n.t("core.users.messages_success_operation"))
92
+ }).catch(error => {
93
+ this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
94
+ })
95
+ }).catch(error => {
96
+ this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
97
+ })
98
+ this.fetch()
99
+ }
100
+ })
101
+ }
102
+ }
103
+ })
@@ -0,0 +1,243 @@
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 useRole = defineStore("administration.role", {
39
+ state: () => {
40
+ return {
41
+ options: {},
42
+ records: [],
43
+ descriptors: [],
44
+ descriptorsCustom: [],
45
+ descriptorSearchString: '',
46
+ role: {
47
+ name: "",
48
+ descriptors: []
49
+ },
50
+ pagination: {
51
+ page: 1
52
+ },
53
+ index: {
54
+ pagination: {},
55
+ records: []
56
+ },
57
+ loading: false,
58
+ order: {
59
+ column: "id",
60
+ direction: "desc"
61
+ },
62
+ search_string: "",
63
+ role_activities: {}
64
+ }
65
+ },
66
+ actions: {
67
+
68
+ fetch() {
69
+ this.loading = true
70
+ this.http.get(this.url.admin("roles")
71
+ .paginate(this.pagination.page)
72
+ .order(this.order.column, this.order.direction)
73
+ .search(this.search_string))
74
+ .then(result => {
75
+ this.index = result
76
+ this.records = result.records.map(integrations => {
77
+ integrations.created_at = this.date.dateTime(integrations.created_at)
78
+ return integrations
79
+ })
80
+ this.loading = false
81
+ })
82
+ },
83
+
84
+ paginateIndex(page) {
85
+ this.pagination.page = page
86
+ this.fetch()
87
+ },
88
+
89
+ fetchRole(id) {
90
+ this.loading = true
91
+ this.http.get(this.url.admin("roles/:id", id)).then(result => {
92
+ this.role = result
93
+ this.getDescriptors()
94
+ this.loading = false
95
+ })
96
+ },
97
+
98
+ postRole() {
99
+ return this.http.post(this.url.admin("roles"), this.role)
100
+ },
101
+
102
+ putRole() {
103
+ this.http.put(this.url.admin("roles/:id", this.role.id), this.role).then(result => {
104
+ this.msg.success(I18n.t('core.roles.messages_success_role_successfully_updated'))
105
+ })
106
+ },
107
+
108
+ searchDescriptors(string) {
109
+ this.descriptorSearchString = string
110
+ this.getDescriptors()
111
+ },
112
+
113
+ getDescriptors() {
114
+
115
+ let url = this.url.admin("roles/:id/descriptors", this.role.id)
116
+
117
+ if (this.descriptorSearchString != '') {
118
+ url = url.search(this.descriptorSearchString)
119
+ }
120
+
121
+ this.http.get(url).then(descriptors => {
122
+
123
+ // reset the list of descriptors
124
+ this.descriptors = []
125
+ this.descriptorsCustom = []
126
+
127
+ // temporary container for the descriptor matrix
128
+ let descriptorgrid = {}
129
+
130
+ // convert list of descriptors from: controller/action to controller/actions (like a matrix)
131
+ descriptors.forEach(descriptor => {
132
+
133
+ if (["list", "index", "show", "create", "update", "destroy"].includes(descriptor.action)) {
134
+
135
+ if (!descriptorgrid[descriptor.reference]) {
136
+ descriptorgrid[descriptor.reference] = {
137
+ id: descriptor.id,
138
+ name: descriptor.name,
139
+ reference: descriptor.reference,
140
+ controller: descriptor.controller,
141
+ index: null,
142
+ show: null,
143
+ create: null,
144
+ update: null,
145
+ destroy: null
146
+ }
147
+ }
148
+
149
+ // add the id of the descriptor that the action belongs to
150
+ descriptorgrid[descriptor.reference][descriptor.action] = {
151
+ id: descriptor.id,
152
+ active: descriptor.active
153
+ }
154
+
155
+ return;
156
+
157
+ }
158
+
159
+ this.descriptorsCustom.push(descriptor)
160
+
161
+ })
162
+
163
+ // return the arrys only
164
+ this.descriptors = Object.values(descriptorgrid)
165
+
166
+ })
167
+ },
168
+
169
+ updateDescriptor(descriptor) {
170
+
171
+ // enable descriptor
172
+ if (descriptor.active) {
173
+ return this.postDescriptor(descriptor)
174
+ }
175
+
176
+ // disable descriptor
177
+ this.deleteDescriptor(descriptor)
178
+
179
+ },
180
+
181
+ postDescriptor(descriptor) {
182
+ this.http.post(this.url.admin("roles/:id/descriptors", this.role.id), {
183
+ role_descriptor: {
184
+ id: descriptor.id
185
+ }
186
+ })
187
+ },
188
+
189
+ deleteDescriptor(descriptor) {
190
+ this.http.delete(this.url.admin("roles/:id/descriptors/:descriptor_id", {
191
+ id: this.role.id,
192
+ descriptor_id: descriptor.id
193
+ }))
194
+ },
195
+
196
+ getOptions() {
197
+ this.http.get(this.url.admin("roles/options")).then(result => {
198
+
199
+ this.options = result
200
+ })
201
+ },
202
+ /**
203
+ * @description This action is used to sort the results
204
+ */
205
+ sortIndex(column, direction) {
206
+ this.order.column = column
207
+ this.order.direction = direction
208
+ this.fetch()
209
+ },
210
+ /**
211
+ * @description This action is used to search
212
+ * @param {string} search_string
213
+ */
214
+ search(search_string) {
215
+ this.search_string = search_string
216
+ this.fetch()
217
+ },
218
+ /**
219
+ * @description This action is used to delete a role
220
+ * @param {Integer} role_id id of the role to be deleted
221
+ */
222
+ deleteRole(role_id){
223
+ this.http.delete(this.url.admin('roles/:id', {id: role_id})).then(result => {
224
+ this.msg.success(I18n.t("core.users.messages_success_operation"))
225
+ this.fetch()
226
+ }).catch(error => {
227
+ this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
228
+ })
229
+ },
230
+ /**
231
+ * @description This action is used to fetch activity logs from a role
232
+ */
233
+ fetchLogs(){
234
+ this.loading = true
235
+ this.http.get(this.url.admin('roles/:id/activities', {id: this.role.id})).then(result => {
236
+ this.role_activities = result.activities
237
+ this.loading = false
238
+ }).catch(error => {
239
+ this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
240
+ })
241
+ }
242
+ }
243
+ })
@@ -0,0 +1,89 @@
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 useRoles = defineStore("administration.roles", {
39
+ state: () => {
40
+ return {
41
+ list: [],
42
+ index: {
43
+ pagination: {},
44
+ records: []
45
+ }
46
+ }
47
+ },
48
+ actions: {
49
+
50
+ fetchList() {
51
+ if (!this.list.length > 0) {
52
+ this.getList()
53
+ }
54
+ },
55
+
56
+ // Get the list of role user is able to work with
57
+ // according to object level permissions
58
+ getList() {
59
+ this.http.get(this.url.admin("roles/list")).then(result => {
60
+ this.list = result
61
+
62
+ // parse the list of roles to be used in select control
63
+ /*
64
+ this.listOptions = []
65
+ this.listOptions = result.map(role => {
66
+ return {
67
+ label: role.name,
68
+ value: role.id
69
+ }
70
+ })
71
+ */
72
+ })
73
+ },
74
+
75
+ fetchRoles() {
76
+ if (!this.list.length > 0) {
77
+ this.getRoles()
78
+ }
79
+ },
80
+
81
+ // Get the list of role user is able to work with
82
+ // according to object level permissions
83
+ getRoles() {
84
+ this.http.get(this.url.admin("roles")).then(result => {
85
+ this.index = result
86
+ })
87
+ },
88
+ }
89
+ })
@@ -0,0 +1,67 @@
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 useSystemController = defineStore("administration.systemController", {
39
+ state: () => {
40
+ return {
41
+ options: { categories: []},
42
+ controllerActions: {},
43
+ }
44
+ },
45
+ actions: {
46
+
47
+ fetchControllers() {
48
+ this.http.get(this.url.admin("system_controllers")).then(result => {
49
+ result.forEach(controllerAction => {
50
+ if (!this.controllerActions[controllerAction.action]) {
51
+ this.controllerActions[controllerAction.action] = []
52
+ }
53
+ controllerAction['active'] = false
54
+ this.controllerActions[controllerAction.action].push(controllerAction)
55
+ })
56
+ }).catch(error => {
57
+ console.log(error)
58
+ })
59
+ },
60
+
61
+ fetchOptions() {
62
+ this.http.get(this.url.admin("system_controllers/options")).then(result => {
63
+ this.options = result
64
+ })
65
+ }
66
+ }
67
+ })