lesli_guard 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +38 -0
  3. data/app/assets/config/lesli_guard_manifest.js +38 -0
  4. data/app/assets/images/lesli_guard/guard-logo.svg +160 -0
  5. data/app/assets/javascripts/lesli_guard/application.js +4787 -0
  6. data/app/assets/stylesheets/lesli_guard/application.scss +33 -0
  7. data/app/assets/stylesheets/lesli_guard/dashboards.scss +32 -0
  8. data/app/assets/stylesheets/lesli_guard/descriptors.scss +32 -0
  9. data/app/assets/stylesheets/lesli_guard/roles.scss +32 -0
  10. data/app/assets/stylesheets/lesli_guard/system_controller.scss +32 -0
  11. data/app/assets/stylesheets/lesli_guard/users.scss +67 -0
  12. data/app/controllers/lesli_guard/accounts_controller.rb +60 -0
  13. data/app/controllers/lesli_guard/application_controller.rb +37 -0
  14. data/app/controllers/lesli_guard/dashboard/components_controller.rb +60 -0
  15. data/app/controllers/lesli_guard/dashboards_controller.rb +36 -0
  16. data/app/controllers/lesli_guard/descriptor/activities_controller.rb +122 -0
  17. data/app/controllers/lesli_guard/descriptor/privileges_controller.rb +112 -0
  18. data/app/controllers/lesli_guard/descriptors_controller.rb +129 -0
  19. data/app/controllers/lesli_guard/role/activities_controller.rb +76 -0
  20. data/app/controllers/lesli_guard/role/descriptors_controller.rb +97 -0
  21. data/app/controllers/lesli_guard/role/privileges_controller.rb +47 -0
  22. data/app/controllers/lesli_guard/roles_controller.rb +185 -0
  23. data/app/controllers/lesli_guard/user/roles_controller.rb +98 -0
  24. data/app/controllers/lesli_guard/user/sessions_controller.rb +71 -0
  25. data/app/controllers/lesli_guard/users_controller.rb +206 -0
  26. data/app/helpers/lesli_guard/accounts_helper.rb +4 -0
  27. data/app/helpers/lesli_guard/application_helper.rb +4 -0
  28. data/app/helpers/lesli_guard/dashboards_helper.rb +4 -0
  29. data/app/helpers/lesli_guard/descriptor/activities_helper.rb +4 -0
  30. data/app/helpers/lesli_guard/descriptor/privileges_helper.rb +4 -0
  31. data/app/helpers/lesli_guard/descriptors_helper.rb +4 -0
  32. data/app/helpers/lesli_guard/role/activities_helper.rb +4 -0
  33. data/app/helpers/lesli_guard/role/descriptors_helper.rb +4 -0
  34. data/app/helpers/lesli_guard/role/privileges_helper.rb +4 -0
  35. data/app/helpers/lesli_guard/roles_helper.rb +4 -0
  36. data/app/jobs/lesli_guard/application_job.rb +37 -0
  37. data/app/mailers/lesli_guard/application_mailer.rb +39 -0
  38. data/app/models/lesli_guard/account.rb +43 -0
  39. data/app/models/lesli_guard/application_record.rb +37 -0
  40. data/app/models/lesli_guard/dashboard/component.rb +42 -0
  41. data/app/models/lesli_guard/dashboard.rb +58 -0
  42. data/app/models/lesli_guard/descriptor/activity.rb +40 -0
  43. data/app/models/lesli_guard/descriptor/privilege.rb +40 -0
  44. data/app/models/lesli_guard/descriptor.rb +41 -0
  45. data/app/models/lesli_guard/role/activity.rb +40 -0
  46. data/app/services/lesli_guard/descriptor_privilege_service.rb +74 -0
  47. data/app/services/lesli_guard/descriptor_service.rb +152 -0
  48. data/app/services/lesli_guard/role_descriptor_service.rb +61 -0
  49. data/app/services/lesli_guard/role_service.rb +215 -0
  50. data/app/services/lesli_guard/user_service.rb +305 -0
  51. data/app/views/lesli_guard/accounts/_account.html.erb +2 -0
  52. data/app/views/lesli_guard/accounts/_form.html.erb +17 -0
  53. data/app/views/lesli_guard/accounts/edit.html.erb +10 -0
  54. data/app/views/lesli_guard/accounts/index.html.erb +14 -0
  55. data/app/views/lesli_guard/accounts/new.html.erb +9 -0
  56. data/app/views/lesli_guard/accounts/show.html.erb +10 -0
  57. data/app/views/lesli_guard/dashboards/show.html.erb +1 -0
  58. data/app/views/lesli_guard/descriptor/activities/_form.html.erb +32 -0
  59. data/app/views/lesli_guard/descriptor/activities/edit.html.erb +34 -0
  60. data/app/views/lesli_guard/descriptor/activities/index.html.erb +34 -0
  61. data/app/views/lesli_guard/descriptor/activities/new.html.erb +34 -0
  62. data/app/views/lesli_guard/descriptor/activities/show.html.erb +34 -0
  63. data/app/views/lesli_guard/descriptor/privileges/_form.html.erb +32 -0
  64. data/app/views/lesli_guard/descriptor/privileges/edit.html.erb +34 -0
  65. data/app/views/lesli_guard/descriptor/privileges/index.html.erb +34 -0
  66. data/app/views/lesli_guard/descriptor/privileges/new.html.erb +34 -0
  67. data/app/views/lesli_guard/descriptor/privileges/show.html.erb +34 -0
  68. data/app/views/lesli_guard/descriptors/_form.html.erb +32 -0
  69. data/app/views/lesli_guard/descriptors/edit.html.erb +34 -0
  70. data/app/views/lesli_guard/descriptors/index.html.erb +34 -0
  71. data/app/views/lesli_guard/descriptors/new.html.erb +34 -0
  72. data/app/views/lesli_guard/descriptors/show.html.erb +34 -0
  73. data/app/views/lesli_guard/partials/_engine-navigation.html.erb +38 -0
  74. data/app/views/lesli_guard/role/activities/_form.html.erb +32 -0
  75. data/app/views/lesli_guard/role/activities/edit.html.erb +34 -0
  76. data/app/views/lesli_guard/role/activities/index.html.erb +34 -0
  77. data/app/views/lesli_guard/role/activities/new.html.erb +34 -0
  78. data/app/views/lesli_guard/role/activities/show.html.erb +34 -0
  79. data/app/views/lesli_guard/role/descriptors/_form.html.erb +32 -0
  80. data/app/views/lesli_guard/role/descriptors/edit.html.erb +34 -0
  81. data/app/views/lesli_guard/role/descriptors/index.html.erb +34 -0
  82. data/app/views/lesli_guard/role/descriptors/new.html.erb +34 -0
  83. data/app/views/lesli_guard/role/descriptors/show.html.erb +34 -0
  84. data/app/views/lesli_guard/role/privileges/_form.html.erb +32 -0
  85. data/app/views/lesli_guard/role/privileges/edit.html.erb +34 -0
  86. data/app/views/lesli_guard/role/privileges/index.html.erb +34 -0
  87. data/app/views/lesli_guard/role/privileges/new.html.erb +34 -0
  88. data/app/views/lesli_guard/role/privileges/show.html.erb +34 -0
  89. data/app/views/lesli_guard/roles/edit.html.erb +34 -0
  90. data/app/views/lesli_guard/roles/index.html.erb +34 -0
  91. data/app/views/lesli_guard/roles/new.html.erb +34 -0
  92. data/app/views/lesli_guard/roles/show.html.erb +34 -0
  93. data/app/views/lesli_guard/users/edit.html.erb +10 -0
  94. data/app/views/lesli_guard/users/index.html.erb +34 -0
  95. data/app/views/lesli_guard/users/new.html.erb +34 -0
  96. data/app/views/lesli_guard/users/show.html.erb +1 -0
  97. data/config/locales/translations.en.yml +43 -0
  98. data/config/locales/translations.es.yml +43 -0
  99. data/config/routes.rb +90 -0
  100. data/db/migrate/v1/0801000110_create_lesli_guard_accounts.rb +42 -0
  101. data/db/migrate/v1/0801050110_create_lesli_guard_dashboards.rb +51 -0
  102. data/db/migrate/v1/0801050210_create_lesli_guard_dashboard_components.rb +53 -0
  103. data/lib/lesli_guard/engine.rb +18 -0
  104. data/lib/lesli_guard/version.rb +4 -0
  105. data/lib/lesli_guard.rb +6 -0
  106. data/lib/tasks/lesli_guard_tasks.rake +50 -0
  107. data/lib/vue/application.js +112 -0
  108. data/lib/vue/apps/descriptors/components/form.vue +136 -0
  109. data/lib/vue/apps/descriptors/edit.vue +83 -0
  110. data/lib/vue/apps/descriptors/index.vue +113 -0
  111. data/lib/vue/apps/descriptors/new.vue +69 -0
  112. data/lib/vue/apps/descriptors/show.vue +233 -0
  113. data/lib/vue/apps/roles/components/descriptors.vue +81 -0
  114. data/lib/vue/apps/roles/components/form.vue +253 -0
  115. data/lib/vue/apps/roles/components/privilegeCustom.vue +86 -0
  116. data/lib/vue/apps/roles/components/privilegeStandard.vue +196 -0
  117. data/lib/vue/apps/roles/edit.vue +118 -0
  118. data/lib/vue/apps/roles/index.vue +168 -0
  119. data/lib/vue/apps/roles/logs.vue +110 -0
  120. data/lib/vue/apps/roles/new.vue +86 -0
  121. data/lib/vue/apps/roles/show.vue +109 -0
  122. data/lib/vue/apps/users/components/information-card.vue +107 -0
  123. data/lib/vue/apps/users/components/information-form.vue +176 -0
  124. data/lib/vue/apps/users/components/integrations-information.vue +61 -0
  125. data/lib/vue/apps/users/components/management-roles.vue +107 -0
  126. data/lib/vue/apps/users/components/management-security.vue +113 -0
  127. data/lib/vue/apps/users/components/management-sessions.vue +101 -0
  128. data/lib/vue/apps/users/components/management-settings.vue +93 -0
  129. data/lib/vue/apps/users/index.vue +207 -0
  130. data/lib/vue/apps/users/new.vue +181 -0
  131. data/lib/vue/apps/users/show.vue +131 -0
  132. data/lib/vue/stores/descriptor.js +117 -0
  133. data/lib/vue/stores/descriptors.js +156 -0
  134. data/lib/vue/stores/role.js +203 -0
  135. data/lib/vue/stores/roles.js +58 -0
  136. data/lib/vue/stores/translations.json +98 -0
  137. data/lib/vue/stores/user.js +331 -0
  138. data/lib/vue/stores/users.js +176 -0
  139. data/license +674 -0
  140. data/readme.md +76 -0
  141. metadata +199 -0
@@ -0,0 +1,101 @@
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
+ // · import vue tools
35
+ import { ref, reactive, onMounted, watch, computed } from "vue"
36
+
37
+
38
+ // · import vue router composable
39
+ import { useRoute } from "vue-router"
40
+
41
+
42
+ // · import lesli stores
43
+ import { useUser } from "LesliGuard/stores/user"
44
+
45
+
46
+ // · implement stores
47
+ const storeUser = useUser()
48
+
49
+
50
+ // · initialize/inject plugins
51
+ const route = useRoute()
52
+
53
+
54
+ // ·
55
+ const translations = {
56
+ users: I18n.t("core.users"),
57
+ shared: i18n.t("lesli.shared")
58
+ }
59
+
60
+
61
+ // ·
62
+ const columns = [{
63
+ field: 'id',
64
+ label: 'ID'
65
+ }, {
66
+ field: 'device',
67
+ label: 'Device'
68
+ }, {
69
+ field: 'session_source',
70
+ label: 'Source'
71
+ }, {
72
+ field: 'created_at_string',
73
+ label: 'Created at'
74
+ }, {
75
+ field: 'expiration_at_string',
76
+ label: 'Expiration at'
77
+ }]
78
+
79
+
80
+ // ·
81
+ onMounted(() => {
82
+ storeUser.fetchSessions()
83
+ })
84
+
85
+ </script>
86
+ <template>
87
+ <lesli-toolbar>
88
+ <lesli-button icon="refresh">
89
+ Reload
90
+ </lesli-button>
91
+ </lesli-toolbar>
92
+ <lesli-table
93
+ :columns="columns"
94
+ :records="storeUser.sessions.records">
95
+ <template #buttons="{ record, value }">
96
+ <lesli-button small danger icon="delete" @click="storeUser.deleteSession(record.id)">
97
+ {{ translations.shared.button_delete }}
98
+ </lesli-button>
99
+ </template>
100
+ </lesli-table>
101
+ </template>
@@ -0,0 +1,93 @@
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
+ // · import vue tools
36
+ import { ref, reactive, onMounted, watch, computed } from "vue"
37
+
38
+
39
+ // · import lesli stores
40
+ import { useUser } from "LesliGuard/stores/user"
41
+
42
+
43
+ // · implement stores
44
+ const storeUser = useUser()
45
+
46
+
47
+ // · translations
48
+ const translations = {
49
+ users: I18n.t("core.users"),
50
+ shared: i18n.t("lesli.shared")
51
+ }
52
+
53
+
54
+ // · initializing
55
+ onMounted(() => {
56
+ //storeUser.getOptions()
57
+ })
58
+ </script>
59
+ <template>
60
+ <lesli-form flat @submit="storeUser.postLanguage">
61
+ <div class="field is-horizontal">
62
+ <div class="field-label">
63
+ <label class="label">Select preferred language </label>
64
+ </div>
65
+ <div class="field-body">
66
+ <div class="field is-narrow">
67
+ <div class="control">
68
+ <div class="select">
69
+ <lesli-select
70
+ icon="language"
71
+ v-model="storeUser.user.locale.value"
72
+ :options="storeUser.options.locales">
73
+ </lesli-select>
74
+ </div>
75
+ </div>
76
+ </div>
77
+ </div>
78
+ </div>
79
+ <div class="field is-horizontal">
80
+ <div class="field-label is-normal">
81
+ </div>
82
+ <div class="field-body">
83
+ <div class="field">
84
+ <div class="control">
85
+ <lesli-button icon="save">
86
+ {{ translations.shared.button_save }}
87
+ </lesli-button>
88
+ </div>
89
+ </div>
90
+ </div>
91
+ </div>
92
+ </lesli-form>
93
+ </template>
@@ -0,0 +1,207 @@
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
+ // · import vue tools
35
+ import { ref, reactive, onMounted, watch, computed, inject } from "vue"
36
+ import { useRouter, useRoute } from "vue-router"
37
+
38
+
39
+ // · import lesli stores
40
+ import { useUsers } from "LesliGuard/stores/users"
41
+
42
+
43
+ // · initialize/inject plugins
44
+ const router = useRouter()
45
+ const msg = inject("msg")
46
+ const url = inject("url")
47
+
48
+
49
+ // · implement stores
50
+ const storeUsers = useUsers()
51
+
52
+
53
+ // · translations
54
+ const translations = {
55
+ lesli: {
56
+ shared: i18n.t("lesli.shared")
57
+ },
58
+ guard: {
59
+ users: i18n.t("lesli_guard.users")
60
+ },
61
+ core: {
62
+ users: {},
63
+ roles: {},
64
+ shared: {}
65
+ },
66
+
67
+ }
68
+
69
+
70
+ // ·
71
+ const columns = [{
72
+ field: "id",
73
+ label: "ID",
74
+ sort: true
75
+ }, {
76
+ field: "name",
77
+ label: translations.guard.users.table_header_name,
78
+ sort: true
79
+ }, {
80
+ field: "email",
81
+ label: translations.guard.users.table_header_email,
82
+ sort: true
83
+ }, {
84
+ field: "rolenames",
85
+ label: translations.guard.users.table_header_roles,
86
+ sort: true
87
+ }, {
88
+ field: "active",
89
+ label: translations.guard.users.table_header_status,
90
+ sort: true,
91
+ custom: true
92
+ }, {
93
+ field: "current_sign_in_at_string",
94
+ label: translations.guard.users.table_header_last_sign_in,
95
+ sort: true
96
+ }]
97
+
98
+
99
+ // ·
100
+ const selection = ref()
101
+
102
+
103
+ // · defining props
104
+ const props = defineProps({
105
+ appMountPath: {
106
+ type: String,
107
+ required: false,
108
+ default: "lesli/users",
109
+ },
110
+ defaultRole: {
111
+ type: String,
112
+ required: false,
113
+ default: "",
114
+ }
115
+ })
116
+
117
+
118
+ // · initializing
119
+ onMounted(() => {
120
+ storeUsers.fetchUsers()
121
+ })
122
+
123
+
124
+ //
125
+ function showUser(user) {
126
+ router.push(url.root(props.appMountPath+`/${user.id}`).s)
127
+ }
128
+ </script>
129
+ <template>
130
+ <lesli-application-container>
131
+ <lesli-header :title="translations.guard.users.view_title + ' (' + storeUsers.index.pagination.total + ')' ">
132
+ <lesli-button solid icon="add" :to="url.root(props.appMountPath+`/new`)">
133
+ {{ translations.lesli.shared.button_add_new }}
134
+ </lesli-button>
135
+ <lesli-button
136
+ icon="refresh"
137
+ :loading="storeUsers.loading"
138
+ @click="storeUsers.getUsers()">
139
+ {{ translations.lesli.shared.button_reload }}
140
+ </lesli-button>
141
+ </lesli-header>
142
+
143
+ <lesli-toolbar>
144
+ </lesli-toolbar>
145
+ <!--
146
+ <lesli-toolbar
147
+ @search="storeUsers.search"
148
+ :search-placeholder="translations.core.users.view_toolbar_filter_placeholder_search">
149
+ <lesli-select :options="[{
150
+ label: translations.core.users.view_toolbar_filter_placeholder_all_users,
151
+ value: null
152
+ }, {
153
+ label: translations.core.users.view_toolbar_filter_placeholder_active_users,
154
+ value: 'active'
155
+ }, {
156
+ label: translations.core.users.view_toolbar_filter_placeholder_inactive_users,
157
+ value: 'inactive'
158
+ }]"
159
+ v-model="storeUsers.filters.status"
160
+ @change="storeUsers.fetchIndex()">
161
+ </lesli-select>
162
+ <lesli-select :options="storeUsers.roles_options"
163
+ v-model="storeUsers.filters.role"
164
+ @change="storeUsers.fetchIndex()">
165
+ </lesli-select>
166
+ </lesli-toolbar>
167
+ -->
168
+
169
+ <lesli-table
170
+ :loading="storeUsers.loading"
171
+ :columns="columns"
172
+ :records="storeUsers.index.records"
173
+ :pagination="storeUsers.index.pagination"
174
+ :link="(user) => url.guard('users/:id', user.id)"
175
+ @paginate="storeUsers.paginateIndex"
176
+ @sort="storeUsers.sortIndex">
177
+
178
+ <template #active="{ value }">
179
+ <span class="tag is-success" v-if="value">
180
+ {{ translations.lesli.shared.view_status_active }}
181
+ </span>
182
+ <span class="tag is-warning" v-if="!value">
183
+ {{ translations.core.shared.view_status_inactive }}
184
+ </span>
185
+ </template>
186
+
187
+ <template #options="{ record, value }">
188
+ <a class="dropdown-item" @click="storeUsers.doLogout(record.id)">
189
+ <span class="material-icons">
190
+ logout
191
+ </span>
192
+ <span>
193
+ {{ translations.core.users.view_btn_logout }}
194
+ </span>
195
+ </a>
196
+ <a class="dropdown-item" @click="storeUsers.doLock(record.id)">
197
+ <span class="material-icons">
198
+ lock
199
+ </span>
200
+ <span>
201
+ {{ translations.core.users.view_btn_revoke_access }}
202
+ </span>
203
+ </a>
204
+ </template>
205
+ </lesli-table>
206
+ </lesli-application-container>
207
+ </template>
@@ -0,0 +1,181 @@
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 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
+ // · import vue tools
35
+ import { onMounted, inject } from "vue"
36
+ import { useRouter, useRoute } from 'vue-router'
37
+
38
+
39
+ // · import lesli stores
40
+ import { useUsers } from "LesliGuard/stores/users"
41
+ import { useRoles } from "LesliGuard/stores/roles"
42
+
43
+
44
+ // · implement stores
45
+ const storeUsers = useUsers()
46
+ const storeRoles = useRoles()
47
+ const router = useRouter()
48
+ const route = useRoute()
49
+
50
+
51
+ // · implement composables
52
+ const url = inject("url")
53
+ const msg = inject("msg")
54
+
55
+
56
+ // · translations
57
+ const translations = {
58
+ users: I18n.t("core.users"),
59
+ shared: I18n.t("core.shared")
60
+ }
61
+
62
+
63
+ // ·
64
+ const onCreate = () => {
65
+ storeUsers.postUsers().then(result => {
66
+ storeUsers.user = {}
67
+ msg.success(I18n.t("core.users.messages_success_operation"))
68
+ router.push(url.admin("users/:id", result.id).toString())
69
+ }).catch(error => {
70
+ msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
71
+ })
72
+ }
73
+
74
+
75
+ // ·
76
+ onMounted(() => {
77
+ console.log("works")
78
+ storeRoles.fetchList()
79
+ })
80
+ </script>
81
+ <template>
82
+ <lesli-application>
83
+ <lesli-header title="Create User">
84
+ <lesli-button icon="list" :to="url.admin('users')">
85
+ All users
86
+ </lesli-button>
87
+ </lesli-header>
88
+
89
+ <lesli-form @submit="onCreate()">
90
+ <p>User information</p>
91
+ <div class="field is-horizontal">
92
+ <div class="field-label is-normal">
93
+ <label class="label">
94
+ {{translations.shared.view_text_email}}
95
+ <span class="is-danger">*</span>
96
+ </label>
97
+ </div>
98
+ <div class="field-body">
99
+ <div class="field">
100
+ <div class="control">
101
+ <input name="user_email" v-model="storeUsers.user.email" required="required" type="email" class="input">
102
+ </div>
103
+ </div>
104
+ </div>
105
+ </div>
106
+
107
+ <div class="field is-horizontal">
108
+ <div class="field-label is-normal">
109
+ <label class="label">
110
+ {{ translations.shared.view_text_first_name }}
111
+ </label>
112
+ </div>
113
+ <div class="field-body">
114
+ <div class="field">
115
+ <div class="control">
116
+ <input name="first_name" v-model="storeUsers.user.first_name" type="text" class="input">
117
+ </div>
118
+ </div>
119
+ </div>
120
+ </div>
121
+
122
+ <div class="field is-horizontal">
123
+ <div class="field-label is-normal">
124
+ <label class="label"> {{ translations.shared.view_text_last_name }} </label>
125
+ </div>
126
+ <div class="field-body">
127
+ <div class="field">
128
+ <div class="control">
129
+ <input name="last_name" v-model="storeUsers.user.last_name" class="input">
130
+ </div>
131
+ </div>
132
+ </div>
133
+ </div>
134
+
135
+ <div class="field is-horizontal">
136
+ <div class="field-label is-normal">
137
+ <label class="label"> {{ translations.shared.view_text_telephone }} </label>
138
+ </div>
139
+ <div class="field-body">
140
+ <div class="field">
141
+ <div class="control">
142
+ <input name="user_number" v-model="storeUsers.user.telephone" class="input">
143
+ </div>
144
+ </div>
145
+ </div>
146
+ </div>
147
+
148
+ <div class="field is-horizontal">
149
+ <div class="field-label is-normal">
150
+ <label class="label"> {{ translations.users.view_text_role }} </label>
151
+ </div>
152
+ <div class="field-body">
153
+ <div class="field is-narrow">
154
+ <div class="control">
155
+ <div class="select is-fullwidth">
156
+ <lesli-select
157
+ :options="storeRoles.listOptions"
158
+ v-model="storeUsers.user.roles_id">
159
+ </lesli-select>
160
+ </div>
161
+ </div>
162
+ </div>
163
+ </div>
164
+ </div>
165
+
166
+ <div class="field is-horizontal">
167
+ <div class="field-label is-normal">
168
+ </div>
169
+ <div class="field-body">
170
+ <div class="field">
171
+ <div class="control">
172
+ <lesli-button icon="save">
173
+ {{ translations.shared.view_btn_save }}
174
+ </lesli-button>
175
+ </div>
176
+ </div>
177
+ </div>
178
+ </div>
179
+ </lesli-form>
180
+ </lesli-application>
181
+ </template>