lesli_security 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +38 -0
  3. data/app/assets/config/lesli_security_manifest.js +38 -0
  4. data/app/assets/images/lesli_security/security-logo.svg +57 -0
  5. data/app/assets/javascripts/lesli_security/application.js +5583 -0
  6. data/app/assets/stylesheets/lesli_security/application.css +95 -0
  7. data/app/controllers/lesli_security/accounts_controller.rb +60 -0
  8. data/app/controllers/lesli_security/application_controller.rb +37 -0
  9. data/app/controllers/lesli_security/dashboard/components_controller.rb +60 -0
  10. data/app/controllers/lesli_security/dashboards_controller.rb +36 -0
  11. data/app/controllers/lesli_security/descriptor/activities_controller.rb +122 -0
  12. data/app/controllers/lesli_security/descriptor/privileges_controller.rb +112 -0
  13. data/app/controllers/lesli_security/descriptors_controller.rb +129 -0
  14. data/app/controllers/lesli_security/role/activities_controller.rb +76 -0
  15. data/app/controllers/lesli_security/role/descriptors_controller.rb +97 -0
  16. data/app/controllers/lesli_security/role/privileges_controller.rb +47 -0
  17. data/app/controllers/lesli_security/roles_controller.rb +185 -0
  18. data/app/controllers/lesli_security/user/roles_controller.rb +98 -0
  19. data/app/controllers/lesli_security/user/sessions_controller.rb +71 -0
  20. data/app/controllers/lesli_security/users_controller.rb +206 -0
  21. data/app/helpers/lesli_security/accounts_helper.rb +4 -0
  22. data/app/helpers/lesli_security/application_helper.rb +4 -0
  23. data/app/helpers/lesli_security/dashboards_helper.rb +4 -0
  24. data/app/helpers/lesli_security/descriptor/activities_helper.rb +4 -0
  25. data/app/helpers/lesli_security/descriptor/privileges_helper.rb +4 -0
  26. data/app/helpers/lesli_security/descriptors_helper.rb +4 -0
  27. data/app/helpers/lesli_security/role/activities_helper.rb +4 -0
  28. data/app/helpers/lesli_security/role/descriptors_helper.rb +4 -0
  29. data/app/helpers/lesli_security/role/privileges_helper.rb +4 -0
  30. data/app/helpers/lesli_security/roles_helper.rb +4 -0
  31. data/app/jobs/lesli_security/application_job.rb +37 -0
  32. data/app/mailers/lesli_security/application_mailer.rb +39 -0
  33. data/app/models/lesli_security/account.rb +43 -0
  34. data/app/models/lesli_security/application_record.rb +37 -0
  35. data/app/models/lesli_security/dashboard/component.rb +42 -0
  36. data/app/models/lesli_security/dashboard.rb +58 -0
  37. data/app/models/lesli_security/descriptor/activity.rb +40 -0
  38. data/app/models/lesli_security/descriptor/privilege.rb +40 -0
  39. data/app/models/lesli_security/descriptor.rb +41 -0
  40. data/app/models/lesli_security/role/activity.rb +40 -0
  41. data/app/services/lesli_security/descriptor_privilege_service.rb +74 -0
  42. data/app/services/lesli_security/descriptor_service.rb +152 -0
  43. data/app/services/lesli_security/role_descriptor_service.rb +61 -0
  44. data/app/services/lesli_security/role_service.rb +215 -0
  45. data/app/services/lesli_security/user_service.rb +305 -0
  46. data/app/views/lesli_security/accounts/_account.html.erb +2 -0
  47. data/app/views/lesli_security/accounts/_form.html.erb +17 -0
  48. data/app/views/lesli_security/accounts/edit.html.erb +10 -0
  49. data/app/views/lesli_security/accounts/index.html.erb +14 -0
  50. data/app/views/lesli_security/accounts/new.html.erb +9 -0
  51. data/app/views/lesli_security/accounts/show.html.erb +10 -0
  52. data/app/views/lesli_security/dashboards/show.html.erb +1 -0
  53. data/app/views/lesli_security/descriptor/activities/_form.html.erb +32 -0
  54. data/app/views/lesli_security/descriptor/activities/edit.html.erb +34 -0
  55. data/app/views/lesli_security/descriptor/activities/index.html.erb +34 -0
  56. data/app/views/lesli_security/descriptor/activities/new.html.erb +34 -0
  57. data/app/views/lesli_security/descriptor/activities/show.html.erb +34 -0
  58. data/app/views/lesli_security/descriptor/privileges/_form.html.erb +32 -0
  59. data/app/views/lesli_security/descriptor/privileges/edit.html.erb +34 -0
  60. data/app/views/lesli_security/descriptor/privileges/index.html.erb +34 -0
  61. data/app/views/lesli_security/descriptor/privileges/new.html.erb +34 -0
  62. data/app/views/lesli_security/descriptor/privileges/show.html.erb +34 -0
  63. data/app/views/lesli_security/descriptors/_form.html.erb +32 -0
  64. data/app/views/lesli_security/descriptors/edit.html.erb +34 -0
  65. data/app/views/lesli_security/descriptors/index.html.erb +34 -0
  66. data/app/views/lesli_security/descriptors/new.html.erb +34 -0
  67. data/app/views/lesli_security/descriptors/show.html.erb +34 -0
  68. data/app/views/lesli_security/partials/_engine-navigation.html.erb +38 -0
  69. data/app/views/lesli_security/role/activities/_form.html.erb +32 -0
  70. data/app/views/lesli_security/role/activities/edit.html.erb +34 -0
  71. data/app/views/lesli_security/role/activities/index.html.erb +34 -0
  72. data/app/views/lesli_security/role/activities/new.html.erb +34 -0
  73. data/app/views/lesli_security/role/activities/show.html.erb +34 -0
  74. data/app/views/lesli_security/role/descriptors/_form.html.erb +32 -0
  75. data/app/views/lesli_security/role/descriptors/edit.html.erb +34 -0
  76. data/app/views/lesli_security/role/descriptors/index.html.erb +34 -0
  77. data/app/views/lesli_security/role/descriptors/new.html.erb +34 -0
  78. data/app/views/lesli_security/role/descriptors/show.html.erb +34 -0
  79. data/app/views/lesli_security/role/privileges/_form.html.erb +32 -0
  80. data/app/views/lesli_security/role/privileges/edit.html.erb +34 -0
  81. data/app/views/lesli_security/role/privileges/index.html.erb +34 -0
  82. data/app/views/lesli_security/role/privileges/new.html.erb +34 -0
  83. data/app/views/lesli_security/role/privileges/show.html.erb +34 -0
  84. data/app/views/lesli_security/roles/edit.html.erb +34 -0
  85. data/app/views/lesli_security/roles/index.html.erb +34 -0
  86. data/app/views/lesli_security/roles/new.html.erb +34 -0
  87. data/app/views/lesli_security/roles/show.html.erb +34 -0
  88. data/app/views/lesli_security/users/edit.html.erb +10 -0
  89. data/app/views/lesli_security/users/index.html.erb +34 -0
  90. data/app/views/lesli_security/users/new.html.erb +34 -0
  91. data/app/views/lesli_security/users/show.html.erb +1 -0
  92. data/config/locales/translations.en.yml +44 -0
  93. data/config/locales/translations.es.yml +44 -0
  94. data/config/locales/translations.fr.yml +44 -0
  95. data/config/locales/translations.it.yml +44 -0
  96. data/config/locales/translations.pt.yml +44 -0
  97. data/config/routes.rb +90 -0
  98. data/db/migrate/v1/0010000210_create_lesli_roles.rb +60 -0
  99. data/db/migrate/v1/0010000310_create_lesli_users.rb +97 -0
  100. data/db/migrate/v1/0010003010_create_lesli_user_details.rb +49 -0
  101. data/db/migrate/v1/0010003110_create_lesli_user_settings.rb +44 -0
  102. data/db/migrate/v1/0010003210_create_lesli_user_sessions.rb +55 -0
  103. data/db/migrate/v1/0010003410_create_lesli_user_powers.rb +43 -0
  104. data/db/migrate/v1/0010004010_create_lesli_user_logs.rb +45 -0
  105. data/db/migrate/v1/0010005010_create_lesli_descriptors.rb +44 -0
  106. data/db/migrate/v1/0010005110_create_lesli_descriptor_privileges.rb +45 -0
  107. data/db/migrate/v1/0010005210_create_lesli_descriptor_activities.rb +49 -0
  108. data/db/migrate/v1/0010005510_create_lesli_role_powers.rb +51 -0
  109. data/db/migrate/v1/0010005710_create_lesli_role_privileges.rb +45 -0
  110. data/db/migrate/v1/0802000110_create_lesli_security_accounts.rb +42 -0
  111. data/db/migrate/v1/0802050110_create_lesli_security_dashboards.rb +51 -0
  112. data/db/migrate/v1/0802050210_create_lesli_security_dashboard_components.rb +53 -0
  113. data/lib/lesli_security/engine.rb +18 -0
  114. data/lib/lesli_security/version.rb +4 -0
  115. data/lib/lesli_security.rb +6 -0
  116. data/lib/scss/application.scss +38 -0
  117. data/lib/scss/users.scss +67 -0
  118. data/lib/tasks/lesli_security_tasks.rake +50 -0
  119. data/lib/vue/application.js +112 -0
  120. data/lib/vue/apps/descriptors/components/form.vue +136 -0
  121. data/lib/vue/apps/descriptors/edit.vue +83 -0
  122. data/lib/vue/apps/descriptors/index.vue +113 -0
  123. data/lib/vue/apps/descriptors/new.vue +69 -0
  124. data/lib/vue/apps/descriptors/show.vue +233 -0
  125. data/lib/vue/apps/roles/components/descriptors.vue +81 -0
  126. data/lib/vue/apps/roles/components/form.vue +253 -0
  127. data/lib/vue/apps/roles/components/privilegeCustom.vue +86 -0
  128. data/lib/vue/apps/roles/components/privilegeStandard.vue +196 -0
  129. data/lib/vue/apps/roles/edit.vue +118 -0
  130. data/lib/vue/apps/roles/index.vue +168 -0
  131. data/lib/vue/apps/roles/logs.vue +110 -0
  132. data/lib/vue/apps/roles/new.vue +86 -0
  133. data/lib/vue/apps/roles/show.vue +109 -0
  134. data/lib/vue/apps/users/components/information-card.vue +104 -0
  135. data/lib/vue/apps/users/components/information-form.vue +176 -0
  136. data/lib/vue/apps/users/components/integrations-information.vue +61 -0
  137. data/lib/vue/apps/users/components/management-roles.vue +107 -0
  138. data/lib/vue/apps/users/components/management-security.vue +113 -0
  139. data/lib/vue/apps/users/components/management-sessions.vue +101 -0
  140. data/lib/vue/apps/users/components/management-settings.vue +93 -0
  141. data/lib/vue/apps/users/index.vue +207 -0
  142. data/lib/vue/apps/users/new.vue +181 -0
  143. data/lib/vue/apps/users/show.vue +131 -0
  144. data/lib/vue/stores/descriptor.js +117 -0
  145. data/lib/vue/stores/descriptors.js +156 -0
  146. data/lib/vue/stores/role.js +203 -0
  147. data/lib/vue/stores/roles.js +58 -0
  148. data/lib/vue/stores/translations.json +277 -0
  149. data/lib/vue/stores/user.js +331 -0
  150. data/lib/vue/stores/users.js +166 -0
  151. data/license +674 -0
  152. data/readme.md +76 -0
  153. metadata +225 -0
@@ -0,0 +1,253 @@
1
+ <script setup>
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 Framework.
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
+
35
+ // · import vue tools
36
+ import { ref, reactive, onMounted, watch, computed, inject } from "vue"
37
+ import { useRouter, useRoute } from "vue-router"
38
+
39
+
40
+ // · import lesli stores
41
+ import { useRole } from "LesliSecurity/vue/stores/role"
42
+
43
+
44
+ // · initialize/inject plugins
45
+ const router = useRouter()
46
+ const route = useRoute()
47
+ const msg = inject("msg")
48
+ const url = inject("url")
49
+ const olpSelected = ref(0)
50
+
51
+
52
+ // ·
53
+ const storeRole = useRole()
54
+
55
+
56
+ // · defining props
57
+ const props = defineProps({
58
+ editable: {
59
+ type: Boolean,
60
+ required: false,
61
+ default: false
62
+ }
63
+ })
64
+
65
+
66
+ // ·
67
+ const translations = {
68
+ lesli: {
69
+ shared: i18n.t("lesli.shared")
70
+ },
71
+ core: {
72
+ shared: I18n.t('core.shared'),
73
+ roles: I18n.t('core.roles')
74
+ }
75
+ }
76
+
77
+
78
+ // ·
79
+ function submitRole() {
80
+
81
+ // role id exists, then just update the role
82
+ if (storeRole.role.id) {
83
+ return storeRole.putRole()
84
+ }
85
+
86
+ return storeRole.postRole()
87
+ }
88
+
89
+
90
+ // ·
91
+ function selectObjectLevelPermission(olpSelectedInForm) {
92
+ olpSelected.value = olpSelectedInForm
93
+ storeRole.role.object_level_permission = olpSelectedInForm
94
+ }
95
+
96
+
97
+ // ·
98
+ onMounted(() => {
99
+ if (route.params.id) {
100
+ storeRole.getRole(route.params.id)
101
+ } else {
102
+ storeRole.$reset()
103
+ }
104
+ storeRole.getOptions()
105
+ })
106
+ </script>
107
+ <template>
108
+ <lesli-form :editable="props.editable" @submit="submitRole">
109
+
110
+ <!-- Role name -->
111
+ <div class="field">
112
+ <label class="label">
113
+ Name
114
+ <sup class="has-text-danger">*</sup>
115
+ </label>
116
+ <div class="control">
117
+ <input v-model="storeRole.role.name" class="input" type="text" required />
118
+ </div>
119
+ </div>
120
+
121
+ <!-- Role Description -->
122
+ <div class="field">
123
+ <label class="label">
124
+ Description
125
+ </label>
126
+ <div class="control">
127
+ <input v-model="storeRole.role.description" class="input" type="text" />
128
+ </div>
129
+ </div>
130
+
131
+ <!-- Role default path -->
132
+ <div class="field">
133
+ <label class="label">Default path</label>
134
+ <div class="control">
135
+ <input v-model="storeRole.role.path_default" class="input" type="text" :placeholder="translations.core.roles.view_placeholder_default_path_at_login">
136
+ </div>
137
+ <p class="help">Default path to redirect after login.</p>
138
+ </div>
139
+
140
+ <hr />
141
+
142
+ <div class="columns">
143
+ <div class="column">
144
+ <!-- Role limited to path -->
145
+ <div class="field">
146
+ <label class="label">
147
+ Limited?
148
+ </label>
149
+ <div class="control">
150
+ <div class="select">
151
+ <lesli-select
152
+ v-model="storeRole.role.path_limited"
153
+ :options="[{
154
+ label: translations.core.roles.view_text_limit_to_path,
155
+ value: true
156
+ }, {
157
+ label: translations.core.roles.view_text_allow_all_paths,
158
+ value: false
159
+ }]">
160
+ </lesli-select>
161
+ </div>
162
+ </div>
163
+ <p class="help">Always redirect role to the default path</p>
164
+ </div>
165
+ </div>
166
+ <div class="column">
167
+ <!-- Role is isolated -->
168
+ <div class="field">
169
+ <label class="label">
170
+ Isolated?
171
+ <sup class="has-text-danger">*</sup>
172
+ </label>
173
+ <div class="control">
174
+ <div class="select">
175
+ <lesli-select
176
+ v-model="storeRole.role.isolated"
177
+ :options="[{
178
+ label: translations.core.roles.view_text_restrict_data_access,
179
+ value: true
180
+ }, {
181
+ label: translations.core.roles.view_text_allow_to_see_all_the_data,
182
+ value: false
183
+ }]">
184
+ </lesli-select>
185
+ </div>
186
+ </div>
187
+ <p class="help">Force the role to query only the data that belongs to the current user</p>
188
+ </div>
189
+ </div>
190
+ <div class="column">
191
+ <!-- Enable/disable role -->
192
+ <div class="field">
193
+ <label class="label">
194
+ Status
195
+ <sup class="has-text-danger">*</sup>
196
+ </label>
197
+ <div class="control">
198
+ <div class="select">
199
+ <lesli-select
200
+ v-model="storeRole.role.active"
201
+ :options="[{
202
+ label: translations.core.roles.view_text_active,
203
+ value: true
204
+ },{
205
+ label: translations.core.roles.view_text_disabled,
206
+ value: false
207
+ }]">
208
+ </lesli-select>
209
+ </div>
210
+ </div>
211
+ <p class="help">Activate/deactivate role</p>
212
+ </div>
213
+ </div>
214
+ </div>
215
+
216
+ <!-- Object level permission -->
217
+ <div class="field">
218
+ <label class="label">
219
+ Hierarchical level
220
+ <sup class="has-text-danger">*</sup>
221
+ </label>
222
+
223
+ <ul class="hierarchical_level_selector">
224
+ <li :class="['hover', 'p-1', { 'has-background-info has-text-light' : olpSelected == olp.level }]"
225
+ v-for="(olp, index) in storeRole.options.object_level_permissions" :key="index"
226
+ @click="selectObjectLevelPermission(olp.level)">
227
+ <p class="icon-text">
228
+ <span class="icon">
229
+ <span class="material-icons">
230
+ {{ olpSelected == olp.level ? 'check_box' : 'check_box_outline_blank' }}
231
+ </span>
232
+ <i :class="['fas', olpSelected == olp.level ? 'fa-check' : 'fa-chevron-right']"></i>
233
+ </span>
234
+ <span>
235
+ {{ `${translations.core.roles.view_text_level || 'Level' } ${ index + 1 }` }}
236
+ <i v-if="olp.roles.length">- {{ olp.roles.map(role => role.name).join(', ') }}</i>
237
+ </span>
238
+ </p>
239
+ </li>
240
+ </ul>
241
+ </div>
242
+
243
+ <hr>
244
+
245
+ <div class="field is-grouped" v-if="props.editable">
246
+ <div class="control">
247
+ <lesli-button main icon="save" :loading="storeRole.role.loading">
248
+ {{ translations.lesli.shared.button_save }}
249
+ </lesli-button>
250
+ </div>
251
+ </div>
252
+ </lesli-form>
253
+ </template>
@@ -0,0 +1,86 @@
1
+ <script setup>
2
+ /*
3
+
4
+ Lesli
5
+
6
+ Copyright (c) 2023, Lesli Technologies, S. A.
7
+
8
+ This program is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program. If not, see http://www.gnu.org/licenses/.
20
+
21
+ Lesli · Your Smart Business Assistant.
22
+
23
+ Made with ♥ by https://www.lesli.tech
24
+ Building a better future, one line of code at a time.
25
+
26
+ @contact hello@lesli.tech
27
+ @website https://lesli.tech
28
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
29
+
30
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
31
+ // ·
32
+
33
+ */
34
+
35
+
36
+
37
+ // · import vue tools
38
+ import { ref, reactive, onMounted, watch, computed, inject } from "vue"
39
+
40
+
41
+ // · import lesli stores
42
+ import { useRole } from "LesliSecurity/vue/stores/role"
43
+ import { useDescriptor } from "LesliSecurity/vue/stores/descriptor"
44
+
45
+
46
+ // · initialize/inject plugins
47
+ const msg = inject("msg")
48
+ const url = inject("url")
49
+
50
+
51
+ // ·
52
+ const storeRole = useRole()
53
+ const storeDescriptor = useDescriptor()
54
+
55
+
56
+ // ·
57
+ const columnDescriptors = [{
58
+ field: 'name',
59
+ label: 'Name'
60
+ },{
61
+ field: 'action',
62
+ label: 'Status',
63
+ align: 'center'
64
+ }]
65
+
66
+
67
+ // ·
68
+ function updateDescriptor(descriptor) {
69
+ storeRole.updateDescriptor(descriptor)
70
+ }
71
+
72
+ </script>
73
+ <template>
74
+ <lesli-table
75
+ :columns="columnDescriptors"
76
+ :records="storeRole.descriptorsCustom">
77
+ <template #name="{ record }">
78
+ <p>{{ record.name }}</p>
79
+ <p><small>/{{ record.controller }}</small></p>
80
+ </template>
81
+ <template #action="{ record, value }">
82
+ <lesli-toggle v-if="value != null" v-model="record.active" @change="updateDescriptor(record)">
83
+ </lesli-toggle>
84
+ </template>
85
+ </lesli-table>
86
+ </template>
@@ -0,0 +1,196 @@
1
+ <script setup>
2
+ /*
3
+
4
+ Lesli
5
+
6
+ Copyright (c) 2023, Lesli Technologies, S. A.
7
+
8
+ This program is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program. If not, see http://www.gnu.org/licenses/.
20
+
21
+ Lesli · Your Smart Business Assistant.
22
+
23
+ Made with ♥ by https://www.lesli.tech
24
+ Building a better future, one line of code at a time.
25
+
26
+ @contact hello@lesli.tech
27
+ @website https://lesli.tech
28
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
29
+
30
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
31
+ // ·
32
+
33
+ */
34
+
35
+
36
+
37
+ // · import vue tools
38
+ import { ref, reactive, onMounted, watch, computed, inject } from "vue"
39
+ import { useRouter } from "vue-router"
40
+
41
+
42
+ // · import lesli stores
43
+ import { useRole } from "LesliSecurity/vue/stores/role"
44
+ import { useDescriptor } from "LesliSecurity/vue/stores/descriptor"
45
+
46
+
47
+ // · initialize/inject plugins
48
+ const msg = inject("msg")
49
+ const url = inject("url")
50
+ const router = useRouter()
51
+
52
+
53
+ // ·
54
+ const storeRole = useRole()
55
+ const storeDescriptor = useDescriptor()
56
+
57
+
58
+ // · list, index, show, create, edit, delete
59
+ const columnDescriptors = [{
60
+ field: 'name',
61
+ label: 'Name'
62
+ },{
63
+ field: 'plist',
64
+ label: 'List',
65
+ align: 'center'
66
+ },{
67
+ field: 'pindex',
68
+ label: 'Index',
69
+ align: 'center'
70
+ },{
71
+ field: 'pshow',
72
+ label: 'Show',
73
+ align: 'center'
74
+ },{
75
+ field: 'pcreate',
76
+ label: 'Create',
77
+ align: 'center'
78
+ },{
79
+ field: 'pupdate',
80
+ label: 'Update',
81
+ align: 'center'
82
+ },{
83
+ field: 'pdestroy',
84
+ label: 'Delete',
85
+ align: 'center'
86
+ }]
87
+
88
+
89
+ // ·
90
+ function updatePrivilege(descriptor) {
91
+ storeRole.updatePrivilege(descriptor)
92
+ }
93
+
94
+
95
+ // ·
96
+ onMounted(() => {
97
+ storeRole.getPrivileges()
98
+ })
99
+ </script>
100
+ <template>
101
+ <lesli-table
102
+ :columns="columnDescriptors"
103
+ :records="storeRole.privileges">
104
+ <template #head(plist)="{ column }">
105
+ <span class="icon-text">
106
+ <span class="icon">
107
+ <span class="material-icons">
108
+ format_list_numbered
109
+ </span>
110
+ </span>
111
+ <span>{{ column.label }}</span>
112
+ </span>
113
+ </template>
114
+ <template #head(pindex)="{ column }">
115
+ <span class="icon-text">
116
+ <span class="icon">
117
+ <span class="material-icons">
118
+ format_list_bulleted
119
+ </span>
120
+ </span>
121
+ <span>{{ column.label }}</span>
122
+ </span>
123
+ </template>
124
+ <template #head(pshow)="{ column }">
125
+ <span class="icon-text">
126
+ <span class="icon">
127
+ <span class="material-icons">
128
+ visibility
129
+ </span>
130
+ </span>
131
+ <span>{{ column.label }}</span>
132
+ </span>
133
+ </template>
134
+ <template #head(pcreate)="{ column }">
135
+ <span class="icon-text">
136
+ <span class="icon">
137
+ <span class="material-icons">
138
+ add
139
+ </span>
140
+ </span>
141
+ <span>{{ column.label }}</span>
142
+ </span>
143
+ </template>
144
+ <template #head(pupdate)="{ column }">
145
+ <span class="icon-text">
146
+ <span class="icon">
147
+ <span class="material-icons">
148
+ edit
149
+ </span>
150
+ </span>
151
+ <span>{{ column.label }}</span>
152
+ </span>
153
+ </template>
154
+ <template #head(pdestroy)="{ column }">
155
+ <span class="icon-text">
156
+ <span class="icon">
157
+ <span class="material-icons">
158
+ delete
159
+ </span>
160
+ </span>
161
+ <span>{{ column.label }}</span>
162
+ </span>
163
+ </template>
164
+
165
+ <template #name="{ record }">
166
+ <router-link :to="url.security('descriptors/:id', record.id).toString()">
167
+ {{ record.name }}
168
+ </router-link>
169
+ </template>
170
+
171
+ <template #plist="{ record }">
172
+ <lesli-toggle v-if="record.has_list" v-model="record.plist" @change="updatePrivilege(record)">
173
+ </lesli-toggle>&nbsp;
174
+ </template>
175
+ <template #pindex="{ record }">
176
+ <lesli-toggle v-if="record.has_index" v-model="record.pindex" @change="updatePrivilege(record)">
177
+ </lesli-toggle>&nbsp;
178
+ </template>
179
+ <template #pshow="{ record }">
180
+ <lesli-toggle v-if="record.has_show" v-model="record.pshow" @change="updatePrivilege(record)">
181
+ </lesli-toggle>&nbsp;
182
+ </template>
183
+ <template #pcreate="{ record }">
184
+ <lesli-toggle v-if="record.has_create" v-model="record.pcreate" @change="updatePrivilege(record)">
185
+ </lesli-toggle>&nbsp;
186
+ </template>
187
+ <template #pupdate="{ record }">
188
+ <lesli-toggle v-if="record.has_update" v-model="record.pupdate" @change="updatePrivilege(record)">
189
+ </lesli-toggle>&nbsp;
190
+ </template>
191
+ <template #pdestroy="{ record }">
192
+ <lesli-toggle v-if="record.has_destroy" v-model="record.pdestroy" @change="updatePrivilege(record)">
193
+ </lesli-toggle>&nbsp;
194
+ </template>
195
+ </lesli-table>
196
+ </template>
@@ -0,0 +1,118 @@
1
+ <script setup>
2
+ /*
3
+
4
+ Lesli
5
+
6
+ Copyright (c) 2023, Lesli Technologies, S. A.
7
+
8
+ This program is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program. If not, see http://www.gnu.org/licenses/.
20
+
21
+ Lesli · Ruby on Rails SaaS Development Framework.
22
+
23
+ Made with ♥ by https://www.lesli.tech
24
+ Building a better future, one line of code at a time.
25
+
26
+ @contact hello@lesli.tech
27
+ @website https://www.lesli.tech
28
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
29
+
30
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
31
+ // ·
32
+ */
33
+
34
+
35
+
36
+ // · import vue tools
37
+ import { ref, reactive, onMounted, watch, computed, inject } from "vue"
38
+ import { useRouter, useRoute } from "vue-router"
39
+
40
+
41
+ // · import components
42
+ import componentFormRole from "./components/form.vue"
43
+ import componentDescriptors from "./components/descriptors.vue"
44
+ import componentPrivilegeCustom from "./components/privilegeCustom.vue"
45
+ import componentPrivilegeStandard from "./components/privilegeStandard.vue"
46
+
47
+
48
+ // · import lesli stores
49
+ import { useRole } from "LesliSecurity/vue/stores/role"
50
+
51
+
52
+ // · initialize/inject plugins
53
+ const router = useRouter()
54
+ const route = useRoute()
55
+ const msg = inject("msg")
56
+ const url = inject("url")
57
+
58
+
59
+ // ·
60
+ const storeRole = useRole()
61
+
62
+
63
+ // ·
64
+ const translations = {
65
+ lesli: {
66
+ shared: i18n.t("lesli.shared"),
67
+ },
68
+ core: {
69
+ shared: I18n.t('core.shared'),
70
+ roles: I18n.t('core.roles')
71
+ }
72
+ }
73
+
74
+ // · defining props
75
+ const props = defineProps({
76
+ appMountPath: {
77
+ type: String,
78
+ required: false,
79
+ default: "guard/roles",
80
+ }
81
+ })
82
+
83
+ // ·
84
+ onMounted(() => {
85
+ storeRole.getRole(route.params.id)
86
+ })
87
+
88
+ </script>
89
+ <template>
90
+ <lesli-application-container>
91
+ <lesli-header :title="'Edit role: ' + storeRole.role.name">
92
+ <lesli-link icon="list" :to="url.security('roles')">
93
+ {{ translations.lesli.shared.button_list }}
94
+ </lesli-link>
95
+ <lesli-link main icon="visibility" :to="url.security('roles/:id', storeRole.role.id)">
96
+ {{ translations.lesli.shared.button_show }}
97
+ </lesli-link>
98
+ </lesli-header>
99
+ <lesli-tabs>
100
+ <lesli-tab-item paddingless icon="info" title="Information">
101
+ <componentFormRole :editable="true"></componentFormRole>
102
+ </lesli-tab-item>
103
+ <lesli-tab-item icon="add_moderator" title="Descriptors">
104
+ <componentDescriptors></componentDescriptors>
105
+ </lesli-tab-item>
106
+ <lesli-tab-item icon="verified_user" title="Privileges">
107
+ <componentPrivilegeStandard></componentPrivilegeStandard>
108
+ </lesli-tab-item>
109
+ </lesli-tabs>
110
+
111
+ <!--
112
+ <lesli-tab-item icon="local_police" title="Custom privileges">
113
+ <componentPrivilegeCustom></componentPrivilegeCustom>
114
+ </lesli-tab-item>
115
+ -->
116
+
117
+ </lesli-application-container>
118
+ </template>