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,89 @@
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, useRoute } from "vue-router"
40
+ import componentFormRole from "./componentForm.vue"
41
+
42
+
43
+ // · import lesli stores
44
+ import { useRole } from "../../stores/role"
45
+
46
+
47
+ // · initialize/inject plugins
48
+ const router = useRouter()
49
+ const route = useRoute()
50
+ const msg = inject("msg")
51
+ const url = inject("url")
52
+
53
+
54
+ // ·
55
+ const storeRole = useRole()
56
+
57
+
58
+ // ·
59
+ const translations = {
60
+ core: {
61
+ shared: I18n.t('core.shared'),
62
+ roles: I18n.t('core.roles')
63
+ }
64
+ }
65
+
66
+ // · defining props
67
+ const props = defineProps({
68
+ appMountPath: {
69
+ type: String,
70
+ required: false,
71
+ default: "administration/roles",
72
+ }
73
+ })
74
+
75
+ // ·
76
+ onMounted(() => {
77
+ })
78
+
79
+ </script>
80
+ <template>
81
+ <section class="application-component">
82
+ <lesli-header title="Create a new role">
83
+ <lesli-button icon="list" :to="url.root(props.appMountPath)">
84
+ All roles
85
+ </lesli-button>
86
+ </lesli-header>
87
+ <componentFormRole></componentFormRole>
88
+ </section>
89
+ </template>
@@ -0,0 +1,111 @@
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, useRoute } from 'vue-router'
40
+
41
+
42
+ // · import lesli stores
43
+ import { useRole } from "../../stores/role"
44
+ import { useDescriptor } from "../../stores/descriptor"
45
+
46
+
47
+ // · import components
48
+ import componentPrivilegeCustom from "./componentPrivilegeCustom.vue"
49
+ import componentPrivilegeStandard from "./componentPrivilegeStandard.vue"
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
+ const storeDescriptor = useDescriptor()
62
+
63
+ // ·
64
+ const editor = ref('standard')
65
+
66
+ // · defining props
67
+ const props = defineProps({
68
+ appMountPath: {
69
+ type: String,
70
+ required: false,
71
+ default: "administration/roles",
72
+ }
73
+ })
74
+
75
+ // ·
76
+ onMounted(() => {
77
+ storeRole.$reset()
78
+ storeRole.fetchRole(route.params.id)
79
+ })
80
+
81
+
82
+ // ·
83
+ function toggleEditor() {
84
+
85
+ if (editor.value == 'standard') {
86
+ return editor.value = 'custom'
87
+ }
88
+
89
+ editor.value = 'standard'
90
+ }
91
+
92
+ </script>
93
+ <template>
94
+ <section class="application-component">
95
+ <lesli-header :title="'Privileges for: ' + storeRole.role.name + ' role '">
96
+ <lesli-button icon="list" :to="url.root(props.appMountPath)">
97
+ All roles
98
+ </lesli-button>
99
+ <lesli-button icon="edit" :to="url.admin('roles/:id/edit', route.params.id)">
100
+ Edit role
101
+ </lesli-button>
102
+ <lesli-button icon="admin_panel_settings" :solid="editor == 'custom'" @click="toggleEditor">
103
+ Aditional privileges
104
+ </lesli-button>
105
+ </lesli-header>
106
+
107
+ <lesli-toolbar @search="storeRole.searchDescriptors"></lesli-toolbar>
108
+ <componentPrivilegeStandard v-if="editor == 'standard'"></componentPrivilegeStandard>
109
+ <componentPrivilegeCustom v-if="editor == 'custom'"></componentPrivilegeCustom>
110
+ </section>
111
+ </template>
@@ -0,0 +1,208 @@
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
+ // · import vue tools
37
+ import { onMounted, ref } from "vue"
38
+
39
+ // · import lesli stores
40
+ import { useAccountSettings } from "LesliApp/administration/stores/accountSettings"
41
+
42
+ // · implement stores
43
+ const storeAccountSettings = useAccountSettings()
44
+
45
+ // · translations
46
+ const translations = {
47
+ core: {
48
+ accounts: I18n.t("core.accounts"),
49
+ shared: I18n.t('core.shared'),
50
+ account: {
51
+ settings: I18n.t("core.account/settings"),
52
+ }
53
+ },
54
+ }
55
+
56
+ onMounted(() => {
57
+ storeAccountSettings.getSettings()
58
+ storeAccountSettings.getRoles()
59
+
60
+ })
61
+
62
+ </script>
63
+ <template>
64
+
65
+
66
+
67
+ <section class="application-component">
68
+ <lesli-header
69
+ :title="translations.core.account.settings.view_tab_title_security_settings">
70
+ </lesli-header>
71
+ <div class="box">
72
+ <form @submit.prevent="storeAccountSettings.postSettings">
73
+ <div class="columns">
74
+ <div class="column is-4">
75
+ <label class="label">
76
+ {{ translations.core.account.settings.column_password_complex_enable }}
77
+ </label>
78
+ </div>
79
+ <div class="column is-6">
80
+ <lesli-select
81
+ :options="[
82
+ {
83
+ label: translations.core.account.settings.view_text_password_enforcement_enabled,
84
+ value: 'Enabled',
85
+ },
86
+ {
87
+ label: translations.core.account.settings.view_text_password_enforcement_disabled,
88
+ value: 'Disabled',
89
+ },
90
+ ]"
91
+ v-model="storeAccountSettings.settings.password_enforce_complexity"
92
+ >
93
+ </lesli-select>
94
+ <p class="has-text-info">
95
+ {{ translations.core.account.settings.view_text_password_complex_description }}
96
+ </p>
97
+ </div>
98
+ </div>
99
+
100
+ <div class="columns">
101
+ <div class="column is-4">
102
+ <label class="label">
103
+ {{ translations.core.account.settings.column_default_role }}
104
+ </label>
105
+ </div>
106
+ <div class="column is-6">
107
+ <lesli-select
108
+ v-model="storeAccountSettings.settings.default_role_id"
109
+ :placeholder="translations.core.view_placeholder_select_option"
110
+ :options="storeAccountSettings.roles"
111
+ ></lesli-select>
112
+ </div>
113
+ </div>
114
+
115
+ <div class="columns">
116
+ <div class="column is-4">
117
+ <label class="label">
118
+ {{ translations.core.account.settings.column_password_lowercase_count }}
119
+ </label>
120
+ </div>
121
+ <div class="column is-6">
122
+ <div class="control">
123
+ <input class="input" type="number" v-model="storeAccountSettings.settings.password_lowercase_count">
124
+ </div>
125
+ </div>
126
+ </div>
127
+
128
+ <div class="columns">
129
+ <div class="column is-4">
130
+ <label class="label">
131
+ {{ translations.core.account.settings.column_password_uppercase_count }}
132
+ </label>
133
+ </div>
134
+ <div class="column is-6">
135
+ <div class="control">
136
+ <input class="input" type="number" v-model="storeAccountSettings.settings.password_uppercase_count">
137
+ </div>
138
+ </div>
139
+ </div>
140
+
141
+ <div class="columns">
142
+ <div class="column is-4">
143
+ <label class="label">
144
+ {{ translations.core.account.settings.column_password_numeric_count }}
145
+ </label>
146
+ </div>
147
+ <div class="column is-6">
148
+ <div class="control">
149
+ <input class="input" type="number" v-model="storeAccountSettings.settings.password_digit_count">
150
+ </div>
151
+ </div>
152
+ </div>
153
+
154
+ <div class="columns">
155
+ <div class="column is-4">
156
+ <label class="label">
157
+ {{ translations.core.account.settings.column_password_special_char_count }}
158
+ </label>
159
+ </div>
160
+ <div class="column is-6">
161
+ <div class="control">
162
+ <input class="input" type="number" v-model="storeAccountSettings.settings.password_special_char_count">
163
+ </div>
164
+ </div>
165
+ </div>
166
+
167
+ <div class="columns">
168
+ <div class="column is-4">
169
+ <label class="label">
170
+ {{ translations.core.account.settings.column_password_minimum_length }}
171
+ </label>
172
+ </div>
173
+ <div class="column is-6">
174
+ <div class="control">
175
+ <input class="input" type="number" v-model="storeAccountSettings.settings.password_minimum_length">
176
+ </div>
177
+ </div>
178
+ </div>
179
+
180
+ <div class="columns">
181
+ <div class="column is-4">
182
+ <label class="label">
183
+ {{ translations.core.account.settings.column_password_expiration_time_days }}
184
+ </label>
185
+ </div>
186
+ <div class="column is-6">
187
+ <div class="control">
188
+ <input class="input" type="number" v-model="storeAccountSettings.settings.password_expiration_time_days">
189
+ </div>
190
+ </div>
191
+ </div>
192
+
193
+ <div class="field is-grouped is-grouped-centered">
194
+ <div class="control">
195
+ <lesli-button class="button is-primary" icon="save">
196
+ <span v-if="storeAccountSettings.submitting_form">
197
+ {{translations.core.shared.view_btn_saving}}
198
+ </span>
199
+ <span v-else>
200
+ {{translations.core.shared.view_btn_save}}
201
+ </span>
202
+ </lesli-button>
203
+ </div>
204
+ </div>
205
+ </form>
206
+ </div>
207
+ </section>
208
+ </template>
@@ -0,0 +1,116 @@
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
+ All the information provided by this platform is protected by international laws related to
20
+ industrial property, intellectual property, copyright and relative international laws.
21
+ All intellectual or industrial property rights of the code, texts, trade mark, design,
22
+ pictures and any other information belongs to the owner of this platform.
23
+
24
+ Made with ♥ by https://www.lesli.tech
25
+ Building a better future, one line of code at a time.
26
+
27
+ @contact hello@lesli.tech
28
+ @website https://www.lesli.tech
29
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
30
+
31
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
32
+ // ·
33
+ */
34
+
35
+
36
+ // ·
37
+ import { defineStore } from "pinia"
38
+
39
+
40
+ // ·
41
+ export const useDescriptor = defineStore("administration.descriptor", {
42
+ state: () => {
43
+ return {
44
+ list: [],
45
+ descriptor: {},
46
+ privileges: [],
47
+ privilegesLoading: false
48
+ }
49
+ },
50
+ actions: {
51
+
52
+ fetchDescriptor(id) {
53
+ if (this.descriptor.id != null) {
54
+ return
55
+ }
56
+
57
+ this.getDescriptor(id)
58
+ },
59
+
60
+ getDescriptor(id) {
61
+ this.http.get(this.url.admin("descriptors/:id", id)).then(result => {
62
+ this.descriptor = result
63
+ this.getDescriptorPrivileges()
64
+ }).catch(error => {
65
+ this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
66
+ }).finally(() => {
67
+
68
+ })
69
+ },
70
+
71
+ resetDescriptor() {
72
+ this.descriptor = {}
73
+ this.privileges = []
74
+ },
75
+
76
+ getDescriptorPrivileges() {
77
+ this.privilegesLoading = true
78
+ this.http.get(this.url.admin("descriptors/:id/privileges", this.descriptor.id)).then(result => {
79
+ this.privileges = result
80
+ }).catch(error => {
81
+ console.log(error)
82
+ }).finally(() => {
83
+ this.privilegesLoading = false
84
+ })
85
+ },
86
+
87
+ // Add privilege to descriptor
88
+ postDescriptorPrivilege(action) {
89
+
90
+ this.http.post(this.url.admin("descriptors/:id/privileges", this.descriptor.id), {
91
+ descriptor_privilege: {
92
+ //controller_id: action.controller_id,
93
+ action_id: action.action_id
94
+ }
95
+ }).then(result => {
96
+ console.log(result)
97
+ }).catch(error => {
98
+ console.log(error)
99
+ })
100
+ },
101
+
102
+
103
+ // Add privilege to descriptor
104
+ deleteDescriptorPrivilege(action) {
105
+ console.log(action)
106
+ this.http.delete(this.url.admin("descriptors/:descriptorId/privileges/:descriptorPrivilegeId", {
107
+ descriptorId: this.descriptor.id,
108
+ descriptorPrivilegeId: action.descriptor_privilege_id
109
+ })).then(result => {
110
+ console.log(result)
111
+ }).catch(error => {
112
+ console.log(error)
113
+ })
114
+ }
115
+ }
116
+ })
@@ -0,0 +1,167 @@
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 SaaS 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 useDescriptors = defineStore("administration.descriptors", {
39
+ state: () => {
40
+ return {
41
+ list: [],
42
+ descriptor: {},
43
+ index: {
44
+ loading: false,
45
+ pagination: {},
46
+ records: []
47
+ }
48
+ }
49
+ },
50
+ actions: {
51
+
52
+ fetchDescriptors() {
53
+ if (this.index.records.length > 0) {
54
+ return
55
+ }
56
+
57
+ this.getDescriptors()
58
+ },
59
+
60
+ getDescriptors() {
61
+ this.index.loading = true
62
+ this.http.get(this.url.admin("descriptors")).then(result => {
63
+ this.index.pagination = result.pagination
64
+ this.index.records = result.records
65
+ }).catch(error => {
66
+ this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
67
+ }).finally(() => {
68
+ this.index.loading = false
69
+ })
70
+ },
71
+
72
+ postDescriptor() {
73
+ this.loading = true
74
+ this.http.post(this.url.admin("descriptors"), { descriptor: this.descriptor }).then(result => {
75
+ this.descriptor.id = result.id
76
+ this.msg.success(I18n.t("core.users.messages_success_operation"))
77
+ this.loading = false
78
+ }).catch(error => {
79
+ this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
80
+ })
81
+ },
82
+
83
+ resetDescriptor() {
84
+ this.descriptor = {}
85
+ this.privileges = []
86
+ },
87
+
88
+ paginateIndex(page) {
89
+ console.log("store page: ", page)
90
+ this.index.pagination.page = page
91
+ //this.fetch(this.url.admin("descriptors").paginate(this.pagination.page))
92
+ },
93
+
94
+ /*
95
+ fetchDescriptorList() {
96
+ this.http.get(this.url.admin("descriptors/list")).then(result => {
97
+ this.list = result.map(descriptor => {
98
+ descriptor.active = false
99
+ return descriptor
100
+ })
101
+ })
102
+ },
103
+
104
+ /**
105
+ * @description This action is used to reset descriptor object
106
+ * /
107
+
108
+
109
+ /**
110
+ * @description This action is used to create a descriptor
111
+ * /
112
+
113
+
114
+ /**
115
+ * @description This action is used to update a descriptor
116
+ * /
117
+ updateDescriptor(){
118
+ this.loading = true
119
+ this.http.put(this.url.admin("descriptors/:id", this.descriptor.id), { descriptor: this.descriptor }).then(result => {
120
+ this.msg.success(I18n.t("core.users.messages_success_operation"))
121
+ this.loading = false
122
+ }).catch(error => {
123
+ this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
124
+ })
125
+
126
+ },
127
+ /**
128
+ * @description This action is used to sort the results
129
+ * /
130
+ sortIndex(column, direction) {
131
+ this.fetch(this.url.admin("descriptors").order(column, direction))
132
+ },
133
+ /**
134
+ * @description This action is used to search
135
+ * @param {string} search_string
136
+ * /
137
+ search(search_string) {
138
+ this.fetch(this.url.admin("descriptors").search(search_string))
139
+ },
140
+ /**
141
+ * @description This action is used to paginate index
142
+ * @param {string} page actual page
143
+ * /
144
+ paginateIndex(page) {
145
+ this.pagination.page = page
146
+ this.fetch(this.url.admin("descriptors").paginate(this.pagination.page))
147
+ },
148
+ /**
149
+ * @description This action is used to get descriptors as options
150
+ * /
151
+ getDescriptorsOptions(){
152
+ this.loading = true
153
+ this.descriptors_options = []
154
+ this.http.get(this.url.admin("descriptors/list")).then(result => {
155
+ result.forEach((descriptor)=>{
156
+ this.descriptors_options.push({
157
+ label: descriptor.name,
158
+ value: descriptor.id
159
+ })
160
+ })
161
+
162
+ this.loading = false
163
+ })
164
+ },
165
+ */
166
+ }
167
+ })