lesli_vault 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 (124) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +38 -0
  3. data/app/assets/config/lesli_vault_manifest.js +38 -0
  4. data/app/assets/images/lesli_vault/vault-logo.svg +160 -0
  5. data/app/assets/javascripts/lesli_vault/application.js +2848 -0
  6. data/app/assets/stylesheets/lesli_vault/application.scss +15 -0
  7. data/app/assets/stylesheets/lesli_vault/dashboards.scss +32 -0
  8. data/app/assets/stylesheets/lesli_vault/descriptors.scss +32 -0
  9. data/app/assets/stylesheets/lesli_vault/roles.scss +32 -0
  10. data/app/assets/stylesheets/lesli_vault/system_controller.scss +32 -0
  11. data/app/controllers/lesli_vault/application_controller.rb +37 -0
  12. data/app/controllers/lesli_vault/dashboards_controller.rb +6 -0
  13. data/app/controllers/lesli_vault/descriptor/activities_controller.rb +122 -0
  14. data/app/controllers/lesli_vault/descriptor/privileges_controller.rb +104 -0
  15. data/app/controllers/lesli_vault/descriptors_controller.rb +130 -0
  16. data/app/controllers/lesli_vault/role/activities_controller.rb +76 -0
  17. data/app/controllers/lesli_vault/role/descriptors_controller.rb +95 -0
  18. data/app/controllers/lesli_vault/role/privileges_controller.rb +48 -0
  19. data/app/controllers/lesli_vault/roles_controller.rb +226 -0
  20. data/app/controllers/lesli_vault/system_controller/actions_controller.rb +112 -0
  21. data/app/controllers/lesli_vault/system_controllers_controller.rb +64 -0
  22. data/app/helpers/lesli_vault/application_helper.rb +4 -0
  23. data/app/helpers/lesli_vault/dashboards_helper.rb +4 -0
  24. data/app/helpers/lesli_vault/descriptor/activities_helper.rb +4 -0
  25. data/app/helpers/lesli_vault/descriptor/privileges_helper.rb +4 -0
  26. data/app/helpers/lesli_vault/descriptors_helper.rb +4 -0
  27. data/app/helpers/lesli_vault/role/activities_helper.rb +4 -0
  28. data/app/helpers/lesli_vault/role/descriptors_helper.rb +4 -0
  29. data/app/helpers/lesli_vault/role/privileges_helper.rb +4 -0
  30. data/app/helpers/lesli_vault/roles_helper.rb +4 -0
  31. data/app/helpers/lesli_vault/system_controller/actions_helper.rb +4 -0
  32. data/app/helpers/lesli_vault/system_controllers_helper.rb +4 -0
  33. data/app/jobs/lesli_vault/application_job.rb +37 -0
  34. data/app/mailers/lesli_vault/application_mailer.rb +39 -0
  35. data/app/models/lesli_vault/application_record.rb +39 -0
  36. data/app/models/lesli_vault/descriptor/activity.rb +40 -0
  37. data/app/models/lesli_vault/descriptor/privilege.rb +40 -0
  38. data/app/models/lesli_vault/descriptor.rb +41 -0
  39. data/app/models/lesli_vault/role/activity.rb +40 -0
  40. data/app/models/lesli_vault/role/descriptor.rb +40 -0
  41. data/app/models/lesli_vault/role/privilege.rb +40 -0
  42. data/app/models/lesli_vault/role.rb +39 -0
  43. data/app/models/lesli_vault/system_controller/action.rb +39 -0
  44. data/app/models/lesli_vault/system_controller.rb +40 -0
  45. data/app/services/application_lesli_services.rb +168 -0
  46. data/app/services/descriptor_services.rb +197 -0
  47. data/app/services/role_services.rb +218 -0
  48. data/app/services/system_controller_services.rb +99 -0
  49. data/app/views/layouts/lesli_vault/application.html.erb +15 -0
  50. data/app/views/lesli_vault/dashboards/show.html.erb +1 -0
  51. data/app/views/lesli_vault/descriptor/activities/_form.html.erb +32 -0
  52. data/app/views/lesli_vault/descriptor/activities/edit.html.erb +34 -0
  53. data/app/views/lesli_vault/descriptor/activities/index.html.erb +34 -0
  54. data/app/views/lesli_vault/descriptor/activities/new.html.erb +34 -0
  55. data/app/views/lesli_vault/descriptor/activities/show.html.erb +34 -0
  56. data/app/views/lesli_vault/descriptor/privileges/_form.html.erb +32 -0
  57. data/app/views/lesli_vault/descriptor/privileges/edit.html.erb +34 -0
  58. data/app/views/lesli_vault/descriptor/privileges/index.html.erb +34 -0
  59. data/app/views/lesli_vault/descriptor/privileges/new.html.erb +34 -0
  60. data/app/views/lesli_vault/descriptor/privileges/show.html.erb +34 -0
  61. data/app/views/lesli_vault/descriptors/_form.html.erb +32 -0
  62. data/app/views/lesli_vault/descriptors/edit.html.erb +34 -0
  63. data/app/views/lesli_vault/descriptors/index.html.erb +34 -0
  64. data/app/views/lesli_vault/descriptors/new.html.erb +34 -0
  65. data/app/views/lesli_vault/descriptors/show.html.erb +34 -0
  66. data/app/views/lesli_vault/role/activities/_form.html.erb +32 -0
  67. data/app/views/lesli_vault/role/activities/edit.html.erb +34 -0
  68. data/app/views/lesli_vault/role/activities/index.html.erb +34 -0
  69. data/app/views/lesli_vault/role/activities/new.html.erb +34 -0
  70. data/app/views/lesli_vault/role/activities/show.html.erb +34 -0
  71. data/app/views/lesli_vault/role/descriptors/_form.html.erb +32 -0
  72. data/app/views/lesli_vault/role/descriptors/edit.html.erb +34 -0
  73. data/app/views/lesli_vault/role/descriptors/index.html.erb +34 -0
  74. data/app/views/lesli_vault/role/descriptors/new.html.erb +34 -0
  75. data/app/views/lesli_vault/role/descriptors/show.html.erb +34 -0
  76. data/app/views/lesli_vault/role/privileges/_form.html.erb +32 -0
  77. data/app/views/lesli_vault/role/privileges/edit.html.erb +34 -0
  78. data/app/views/lesli_vault/role/privileges/index.html.erb +34 -0
  79. data/app/views/lesli_vault/role/privileges/new.html.erb +34 -0
  80. data/app/views/lesli_vault/role/privileges/show.html.erb +34 -0
  81. data/app/views/lesli_vault/roles/edit.html.erb +34 -0
  82. data/app/views/lesli_vault/roles/index.html.erb +34 -0
  83. data/app/views/lesli_vault/roles/new.html.erb +34 -0
  84. data/app/views/lesli_vault/roles/show.html.erb +34 -0
  85. data/app/views/lesli_vault/system_controller/actions/_form.html.erb +32 -0
  86. data/app/views/lesli_vault/system_controller/actions/edit.html.erb +34 -0
  87. data/app/views/lesli_vault/system_controller/actions/index.html.erb +34 -0
  88. data/app/views/lesli_vault/system_controller/actions/new.html.erb +34 -0
  89. data/app/views/lesli_vault/system_controller/actions/show.html.erb +34 -0
  90. data/app/views/lesli_vault/system_controllers/_form.html.erb +32 -0
  91. data/app/views/lesli_vault/system_controllers/edit.html.erb +34 -0
  92. data/app/views/lesli_vault/system_controllers/index.html.erb +34 -0
  93. data/app/views/lesli_vault/system_controllers/new.html.erb +34 -0
  94. data/app/views/lesli_vault/system_controllers/show.html.erb +34 -0
  95. data/app/vue/lesli_vault/application.js +38 -0
  96. data/app/vue/lesli_vault/apps/descriptors/components/form.vue +147 -0
  97. data/app/vue/lesli_vault/apps/descriptors/edit.vue +83 -0
  98. data/app/vue/lesli_vault/apps/descriptors/index.vue +116 -0
  99. data/app/vue/lesli_vault/apps/descriptors/new.vue +76 -0
  100. data/app/vue/lesli_vault/apps/descriptors/privileges.vue +179 -0
  101. data/app/vue/lesli_vault/apps/descriptors/show.vue +240 -0
  102. data/app/vue/lesli_vault/apps/roles/componentForm.vue +231 -0
  103. data/app/vue/lesli_vault/apps/roles/componentPrivilegeCustom.vue +86 -0
  104. data/app/vue/lesli_vault/apps/roles/componentPrivilegeStandard.vue +173 -0
  105. data/app/vue/lesli_vault/apps/roles/edit.vue +93 -0
  106. data/app/vue/lesli_vault/apps/roles/index.vue +169 -0
  107. data/app/vue/lesli_vault/apps/roles/logs.vue +110 -0
  108. data/app/vue/lesli_vault/apps/roles/new.vue +89 -0
  109. data/app/vue/lesli_vault/apps/roles/show.vue +111 -0
  110. data/app/vue/lesli_vault/apps/security/index.vue +208 -0
  111. data/app/vue/lesli_vault/stores/descriptor.js +116 -0
  112. data/app/vue/lesli_vault/stores/descriptors.js +167 -0
  113. data/app/vue/lesli_vault/stores/role.js +243 -0
  114. data/app/vue/lesli_vault/stores/roles.js +89 -0
  115. data/app/vue/lesli_vault/stores/systemController.js +67 -0
  116. data/config/routes.rb +52 -0
  117. data/lib/lesli_vault/engine.rb +18 -0
  118. data/lib/lesli_vault/version.rb +3 -0
  119. data/lib/lesli_vault.rb +6 -0
  120. data/lib/tasks/lesli_vault_tasks.rake +4 -0
  121. data/lib/tasks/system/controllers.rake +112 -0
  122. data/lib/vue/application.js +7 -0
  123. data/readme.md +19 -0
  124. metadata +181 -0
@@ -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
+ })
data/config/routes.rb ADDED
@@ -0,0 +1,52 @@
1
+ =begin
2
+
3
+ Lesli
4
+
5
+ Copyright (c) 2023, Lesli Technologies, S. A.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
19
+
20
+ Lesli · Ruby on Rails SaaS development platform.
21
+
22
+ Made with ♥ by https://www.lesli.tech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+
32
+ =end
33
+
34
+ LesliVault::Engine.routes.draw do
35
+ root to: "dashboards#show"
36
+
37
+ resources :roles do
38
+ scope module: :role do
39
+ resources :privileges
40
+ resources :descriptors
41
+ resources :activities
42
+ end
43
+ end
44
+
45
+ resources :descriptors do
46
+ scope module: :descriptor do
47
+ resources :privileges
48
+ resources :activities
49
+ end
50
+ end
51
+
52
+ end
@@ -0,0 +1,18 @@
1
+ module LesliVault
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace LesliVault
4
+
5
+ initializer :lesli_vault do |app|
6
+
7
+ # register assets manifest
8
+ config.assets.precompile += %w[lesli_vault_manifest.js]
9
+
10
+ # register engine migrations path
11
+ unless app.root.to_s.match root.to_s
12
+ config.paths["db/migrate"].expanded.each do |expanded_path|
13
+ app.config.paths["db/migrate"] << expanded_path
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module LesliVault
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "lesli_vault/version"
2
+ require "lesli_vault/engine"
3
+
4
+ module LesliVault
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :lesli_vault do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,112 @@
1
+ namespace :lesli_vault do
2
+ namespace :system do
3
+
4
+ desc "Testing"
5
+ task test: :environment do
6
+ puts "Testing environment"
7
+ end
8
+
9
+ namespace :controllers do
10
+
11
+ desc "Scan new routes added and create role privileges"
12
+ task build: :environment do
13
+
14
+ L2.msg("Registering engines, controllers and actions")
15
+
16
+ # get all the engines, controllers and actions
17
+ engines = scan_for_engine_controllers
18
+
19
+ # Register descriptors and privileges for all the accounts
20
+ engines.each do |engine, controllers|
21
+
22
+ controllers.each do |controller_route, controller_actions|
23
+
24
+ # Build a strig with the standard name of a Rails controller from the standard routes
25
+ # Examples:
26
+ # users converts to Users
27
+ # cloud_bell/notifications converts to CloudBell::Notifications
28
+ # sometimes we need a second split to deal with third level deep of controllers
29
+ # Example: "Account::Currency::ExchangeRatesController" from "account/currency/exchange_rates"
30
+ reference = controller_route
31
+ .split('/') # split the controller path by namespace
32
+ .collect(&:capitalize) # uppercase the first letter to match the class name convention of Rails
33
+ .join("::") # join by ruby class separator for namespaces
34
+ .split('_') # work with compound words like "exchange_rates"
35
+ .collect { |x| x[0] = x[0].upcase; x } # convert ['exchange', 'rates'] to ['Exchange', 'Rates']
36
+ .join('')
37
+
38
+ name = reference.sub('::',' ')
39
+
40
+ controller = SystemController.create_with({
41
+ name: name,
42
+ :engine => engine,
43
+ :reference => reference
44
+ }).find_or_create_by!(route: controller_route)
45
+
46
+ controller_actions.each do |action_name|
47
+ controller.actions.find_or_create_by!(name: action_name)
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ def scan_for_engine_controllers
54
+
55
+ # Global container
56
+ controller_list = {
57
+ "core" => {}
58
+ }
59
+
60
+ # Get the name of the instance (builder engine)
61
+ instance = Rails.configuration.lesli.dig(:instance, :name)
62
+
63
+ # Get the list of controllers and actions of the core
64
+ Rails.application.routes.routes.each do |route|
65
+ route = route.defaults
66
+
67
+ # filter the non-used core routes
68
+ next if route[:controller].blank?
69
+ next if route[:controller].include? "rails"
70
+ next if route[:controller].include? "action_mailbox"
71
+ next if route[:controller].include? "active_storage"
72
+
73
+ # create a container for the actions related to a controller
74
+ controller_list["core"][route[:controller]] = [] unless controller_list["core"][route[:controller]]
75
+
76
+ # assign and group all the actions related to the controller
77
+ controller_list["core"][route[:controller]].push(route[:action])
78
+
79
+ end
80
+
81
+ # Get the list of controllers and actions from engines
82
+ Rails.configuration.lesli.dig(:engines).each do |engine|
83
+
84
+ # load and retrieve the list of controllers and actions from an engine
85
+ routes = "#{engine[:name]}::Engine".constantize.routes.routes.each do |route|
86
+ route = route.defaults
87
+
88
+ # validate if route has information, some special routes like redirects
89
+ # can generate an empty entry in the route hash
90
+ next if route.empty?
91
+
92
+ # get the engine code
93
+ engine_code = engine[:name].underscore
94
+
95
+ # create a container for the controllers related to the engine
96
+ controller_list[engine_code] = {} if controller_list[engine_code].blank?
97
+
98
+ # assign and group all the actions related to the controller
99
+ controller_list[engine_code][route[:controller]] = [] if controller_list[engine_code][route[:controller]].blank?
100
+
101
+ # assign and group all the actions related to the controller
102
+ controller_list[engine_code][route[:controller]].push(route[:action])
103
+
104
+ end
105
+ end
106
+
107
+ return controller_list
108
+ end
109
+ end
110
+ end
111
+
112
+ end
@@ -0,0 +1,7 @@
1
+
2
+ // ·
3
+ import application from "Lesli/application"
4
+
5
+
6
+ // ·
7
+ application("LesliVault", [])
data/readme.md ADDED
@@ -0,0 +1,19 @@
1
+ <p align="center">
2
+ <img width="100" alt="LesliBabel logo" src="app/assets/images/lesli_vault/vault-logo.svg" />
3
+ </p>
4
+
5
+ <h3 align="center">LesliVault</h3>
6
+
7
+ <hr/>
8
+
9
+ Version 1
10
+
11
+ ### License
12
+ ------
13
+ Software developed in [Guatemala](http://visitguatemala.com/) by [LesliTech](https://www.lesli.tech) distributed under the *General Public License v 3.0* you can read the full license [here](http://www.gnu.org/licenses/gpl-3.0.html)
14
+
15
+ <br>
16
+
17
+ <p align="center">
18
+ <img alt="Lesli logo" width="100" src="./app/assets/images/lesli/brand/app-icon.svg" />
19
+ </p>