lesli_vault 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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,197 @@
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
+ module LesliVault
35
+ class DescriptorServices < LesliVault::ApplicationLesliServices
36
+
37
+ # @overwrite
38
+ # @return {Object}
39
+ # @description Finds a descriptor according the ID given
40
+ def find id
41
+ self.resource = self.current_user.account.descriptors.find_by_id(id)
42
+ self
43
+ end
44
+
45
+ # @overwrite
46
+ # @return [Array] Paginated index of users.
47
+ # @description Return a paginated array of users, used mostly in frontend views
48
+ def index
49
+ descriptors = current_user.account.descriptors.where.not(
50
+ :name => ["owner"]
51
+ ).select(
52
+ :id,
53
+ :name,
54
+ :category,
55
+ "coalesce(actions.total, 0) as privileges_count",
56
+ Date2.new.date_time.db_timestamps("descriptors")
57
+ )
58
+
59
+ # Count the amount of privileges assigned to every descriptor
60
+ descriptors = descriptors.joins(%(
61
+ left join (
62
+ select
63
+ count(1) as total,
64
+ descriptor_id
65
+ from descriptor_privileges
66
+ --where apga.status = TRUE
67
+ group by descriptor_id
68
+ ) as actions
69
+ on actions.descriptor_id = descriptors.id
70
+ ))
71
+
72
+ # skip native descriptors
73
+ #descriptors = descriptors.where.not("descriptors.name in (?)", ["owner", "sysadmin", "profile"])
74
+
75
+ # Filter results by search string
76
+ # unless search_string.blank?
77
+ # descriptors = descriptors.where("(LOWER(descriptors.name) SIMILAR TO ?)", search_string)
78
+ # end
79
+
80
+ descriptors.page(
81
+ query[:pagination][:page]
82
+ ).per(query[:pagination][:perPage]
83
+ ).order("#{query[:order][:by]} #{query[:order][:dir]} NULLS LAST")
84
+ end
85
+
86
+ # @overwrite
87
+ # @return {Hash}
88
+ # @description Retrives the descriptor with specific keys/attributes
89
+ def show
90
+ {
91
+ :id => resource.id,
92
+ :name => resource.name,
93
+ :category => resource.category,
94
+ :privileges => resource.privileges.joins(system_controller_action: :system_controller).select(
95
+ "descriptor_privileges.id",
96
+ "system_controllers.name as controlle_name",
97
+ "system_controller_actions.name as action_name",
98
+ "descriptor_privileges.created_at"
99
+ )
100
+ }
101
+ end
102
+
103
+ # @overwrite
104
+ # @return {Object}
105
+ # @param {params} Hash of the permitted attributes for a descriptor
106
+ # @description Creates a new descriptor
107
+ def create params
108
+ descriptor = current_user.account.descriptors.new(params)
109
+
110
+ if descriptor.save
111
+ self.resource = descriptor
112
+ # TODO: keep track of the activities
113
+ else
114
+ self.error(descriptor.errors.full_messages.to_sentence)
115
+ end
116
+
117
+ self
118
+ end
119
+
120
+ # @overwrite
121
+ # @return {Object}
122
+ # @param {params} Hash of the permitted attributes for a descriptor
123
+ # @description Updates descriptor's attributes and saves logs if it went without problem
124
+ def update params
125
+
126
+ # TODO: keep track of the activities
127
+
128
+ unless self.resource.update(params)
129
+ self.error(self.resource.errors.full_messages.to_sentence)
130
+ end
131
+
132
+ self
133
+ end
134
+
135
+ # @overwrite
136
+ # @return {Object}
137
+ # @description Deletes the descriptor
138
+ def destroy
139
+
140
+ # TODO: keep track of the activities
141
+
142
+ unless self.resource.destroy
143
+ self.error(self.resource.errors.full_messages.to_sentence)
144
+ end
145
+
146
+ self
147
+ end
148
+
149
+ # @return [void]
150
+ # @param role_descriptor [RoleDescriptor] The role_descriptor on wich we want to add the system actions
151
+ # @description Return the list of privilege actions defined for
152
+ # profile descriptor
153
+ # Example
154
+ # RoleDescriptor::DefaultPrivilegeActionsService.add_profile_actions(RoleDescriptor.last)
155
+ def self.add_profile_privileges(descriptor)
156
+
157
+ # Adding default system actions for profile descriptor
158
+ [
159
+ { controller: "Profiles", actions: ["show"] }, # enable profile view
160
+ #{ controller: "profile/subscriptions", actions: ["options", "index"] }, # enable profile subscriptions
161
+ #{ controller: "user/sessions", actions: ["index"] }, # seession management
162
+ { controller: "Users", actions: ["options", "update"] } # enable user edition
163
+ ].each do |controller_action|
164
+
165
+ controller_action[:actions].each do |action_name|
166
+
167
+ system_controller_action = SystemController::Action.joins(:system_controller)
168
+ .where("system_controllers.reference = ?", controller_action[:controller])
169
+ .where("system_controller_actions.name = ?", action_name).first
170
+
171
+ descriptor.privileges.find_or_create_by(
172
+ system_controller_action: system_controller_action
173
+ )
174
+ end
175
+ end
176
+ end
177
+
178
+ # @return [void]
179
+ # @param role_descriptor [RoleDescriptor] The role_descriptor on wich we want to add the system actions
180
+ # @description Return the list of privilege actions defined for
181
+ # profile descriptor
182
+ # Example
183
+ # RoleDescriptor::DefaultPrivilegeActionsService.add_profile_actions(RoleDescriptor.last)
184
+ def self.add_owner_privileges(descriptor)
185
+
186
+ # Adding default system actions for profile descriptor
187
+ actions = SystemController::Action.all
188
+
189
+ actions.each do |action|
190
+ descriptor.privileges.find_or_create_by(
191
+ system_controller_action: action
192
+ )
193
+ end
194
+ end
195
+
196
+ end
197
+ end
@@ -0,0 +1,218 @@
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
+ module LesliVault
35
+ class RoleServices < ApplicationLesliServices
36
+
37
+ # @overwrite
38
+ # @return {Object}
39
+ # @description Finds a role according the ID given
40
+ def find id
41
+ self.resource = current_user.account.roles.find_by_id(id)
42
+ self
43
+ end
44
+
45
+ # @overwrite
46
+ # @return {Object}
47
+ # @description Retrives the role
48
+ def show
49
+ self.resource
50
+ end
51
+
52
+ # @overwrite
53
+ # @return [Array] Paginated index of roles.
54
+ # @description Return a paginated array of roles, used mostly in frontend views
55
+ def index
56
+
57
+ current_user.account.roles
58
+ .joins("
59
+ left join (
60
+ select
61
+ count(1) users,
62
+ role_id
63
+ from user_roles
64
+ inner join users as u
65
+ on u.id = user_roles.user_id
66
+ and u.deleted_at is null
67
+ where user_roles.deleted_at is null
68
+ group by (role_id)
69
+ )
70
+ users on users.role_id = roles.id
71
+ ")
72
+ .where("roles.object_level_permission < ?", current_user.max_object_level_permission)
73
+ .select(
74
+ :id,
75
+ :name,
76
+ :active,
77
+ :isolated,
78
+ :description,
79
+ :path_default,
80
+ :object_level_permission,
81
+ "users.users"
82
+ )
83
+ .page(query[:pagination][:page])
84
+ .per(query[:pagination][:perPage])
85
+ .order(object_level_permission: :desc, name: :asc)
86
+ end
87
+
88
+ # Return a list of roles that the user is able to work with
89
+ # according to object level permission
90
+ def list
91
+ current_user.account.roles.where(
92
+ "object_level_permission <= ?", current_user.max_object_level_permission
93
+ ).order(
94
+ object_level_permission: :desc,
95
+ name: :asc
96
+ ).select(:id, :name, :object_level_permission)
97
+ end
98
+
99
+ # @overwrite
100
+ # @return {Object}
101
+ # @param {params} Hash of the permitted attributes for a role
102
+ # @description Creates a new role
103
+ def create params
104
+ role = current_user.account.roles.new(params)
105
+
106
+ unless current_user.can_work_with_role?(role)
107
+ self.error(I18n.t("core.roles.messages_danger_creating_role_object_level_permission_too_high"))
108
+ end
109
+
110
+ # check if user can work with that object level permission
111
+ if role.object_level_permission.to_f >= current_user.roles.map(&:object_level_permission).max()
112
+ self.error(I18n.t("core.roles.messages_danger_creating_role_object_level_permission_too_high"))
113
+ end
114
+
115
+ # Try to save role and logs if it went OK
116
+ if role.save
117
+ self.resource = role
118
+ Role::Activity.log_create(current_user, self.resource)
119
+ else
120
+ self.error(role.errors.full_messages.to_sentence)
121
+ end
122
+
123
+ self
124
+ end
125
+
126
+ # @overwrite
127
+ # @return {Object}
128
+ # @param {params} Hash of the permitted attributes for a role
129
+ # @description Updates role's attributes and saves logs if it went without problem
130
+ def update params
131
+ old_attributes = self.resource.attributes
132
+
133
+ unless self.resource.update(params)
134
+ self.error(self.resource.errors.full_messages.to_sentence)
135
+ end
136
+
137
+ if self.successful?
138
+ new_attributes = self.resource.attributes
139
+
140
+ LesliVault::Role::Activity.log_update(current_user, role, old_attributes, new_attributes)
141
+ end
142
+
143
+ self
144
+ end
145
+
146
+ # @overwrite
147
+ # @return {Object}
148
+ # @description Deletes the role
149
+ def destroy
150
+ unless self.resource.destroy
151
+ self.error(self.resource.errors.full_messages.to_sentence)
152
+ end
153
+
154
+ if self.successful?
155
+ LesliVault::Role::Activity.log_destroy(current_user, self.resource)
156
+ end
157
+
158
+ self
159
+ end
160
+
161
+ def options
162
+ levels = {}
163
+
164
+ # get all the different object level permission registered in the roles
165
+ existing_levels = current_user.account.roles
166
+ .select(:object_level_permission)
167
+ .order(object_level_permission: :desc)
168
+ .distinct
169
+ .map { |level| level.object_level_permission }
170
+
171
+ # Build the next available object levels
172
+ # basically we need to add the possibles object level permissions between the
173
+ # existing ones
174
+ existing_levels.each_with_index do |level_current, i|
175
+
176
+ level_next = 0
177
+
178
+ # get the next OLP in the list of the existing roles
179
+ level_next = existing_levels.to_a[i+1] unless existing_levels.to_a[i+1].nil?
180
+
181
+ # calculate the new next level, basically we get the level right in the middle
182
+ # between the existing levels, example:
183
+ # 1000 existing level
184
+ # 750 new projected level
185
+ # 500 existing level
186
+ level_new = (level_current + level_next) / 2
187
+
188
+ # add the levels to the levels object
189
+ levels[level_current] = []
190
+
191
+ next if level_next == 0
192
+
193
+ levels[level_new] = []
194
+
195
+ end
196
+
197
+ # Get all the existing roles
198
+ current_user.account.roles
199
+ .select(:id, :name, :object_level_permission)
200
+ .where.not(object_level_permission: nil).each do |role|
201
+ levels[role.object_level_permission] = [] if levels[role.object_level_permission].blank?
202
+ # push the role grouping by the object level permission
203
+ levels[role.object_level_permission].push(role)
204
+ end
205
+
206
+ levels_sorted = []
207
+
208
+ levels.keys.each do |key|
209
+ levels_sorted.push({
210
+ level: key,
211
+ roles: levels[key]
212
+ })
213
+ end
214
+
215
+ levels_sorted
216
+ end
217
+ end
218
+ end
@@ -0,0 +1,99 @@
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
+ module LesliVault
35
+ class SystemControllerServices < ApplicationLesliServices
36
+
37
+ # @overwrite
38
+ # ...
39
+ def index
40
+ # get a matrix of controllers and actions
41
+ c = SystemController.joins(:actions).select(
42
+ "lesli_vault_system_controllers.name as id",
43
+ "lesli_vault_system_controllers.name as controller",
44
+ "lesli_vault_system_controllers.id as controller_id",
45
+ "lesli_vault_system_controller_actions.name as action",
46
+ "lesli_vault_system_controller_actions.id as action_id",
47
+ "case lesli_vault_system_controller_actions.name
48
+ when 'index' then 1
49
+ when 'show' then 2
50
+ when 'new' then 3
51
+ when 'edit' then 4
52
+ when 'create' then 5
53
+ when 'update' then 6
54
+ when 'destroy' then 7
55
+ when 'options' then 8
56
+ else 9
57
+ end as importance
58
+ "
59
+ )
60
+ #.where("lesli_vault_system_controller_actions.name in ('index', 'create', 'update', 'show', 'destroy')")
61
+ #.order("lesli_vault_system_controllers.name, importance, lesli_vault_system_controller_actions.name")
62
+ .order("importance DESC")
63
+
64
+ return c unless matrix
65
+
66
+ cc = {}
67
+
68
+ # convert the matrix to a hash of controllers with the available actions as values
69
+ # example:
70
+ # my_controller: [my list of actions]
71
+ c.each do |c|
72
+
73
+ # create a uniq container for every action that belongs to a specific controller
74
+ if cc[c[:controller]].blank?
75
+ cc[c[:controller]] = {
76
+ id: c[:controller_id],
77
+ name: c[:controller],
78
+ actions: []
79
+ }
80
+ end
81
+
82
+ # push every action to his specic controller
83
+ cc[c[:controller]][:actions].push({
84
+ id: c[:action_id],
85
+ action: c[:action]
86
+ })
87
+ end
88
+
89
+ cc
90
+ end
91
+
92
+ # ...
93
+ def options
94
+ {
95
+ categories: SystemController.categories.map {|k, _| { label: k, value: k }}
96
+ }
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Lesli vault</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "lesli_vault/application", media: "all" %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1 @@
1
+ <router-view></router-view>
@@ -0,0 +1,32 @@
1
+ <%#
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
+ %>
@@ -0,0 +1,34 @@
1
+ <%#
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
+ %>
33
+
34
+ <router-view></router-view>
@@ -0,0 +1,34 @@
1
+ <%#
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
+ %>
33
+
34
+ <router-view></router-view>
@@ -0,0 +1,34 @@
1
+ <%#
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
+ %>
33
+
34
+ <router-view></router-view>