lesli_admin 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +5 -0
  3. data/app/assets/config/lesli_admin_manifest.js +38 -0
  4. data/app/assets/javascripts/lesli_admin/application.js +3713 -0
  5. data/app/assets/stylesheets/lesli_admin/application.css +15 -0
  6. data/app/controllers/lesli_admin/accounts_controller.rb +125 -0
  7. data/app/controllers/lesli_admin/application_controller.rb +4 -0
  8. data/app/controllers/lesli_admin/dashboards_controller.rb +60 -0
  9. data/app/controllers/lesli_admin/users_controller.rb +244 -0
  10. data/app/helpers/lesli_admin/application_helper.rb +4 -0
  11. data/app/helpers/lesli_admin/dashboards_helper.rb +4 -0
  12. data/app/jobs/lesli_admin/application_job.rb +4 -0
  13. data/app/mailers/lesli_admin/application_mailer.rb +6 -0
  14. data/app/models/lesli_admin/account.rb +66 -0
  15. data/app/models/lesli_admin/application_record.rb +5 -0
  16. data/app/models/lesli_admin/dashboard.rb +4 -0
  17. data/app/models/lesli_admin/user.rb +4 -0
  18. data/app/services/lesli_admin/user_service.rb +300 -0
  19. data/app/views/layouts/lesli_admin/application.html.erb +15 -0
  20. data/app/views/lesli_admin/accounts/_account.html.erb +2 -0
  21. data/app/views/lesli_admin/accounts/_form.html.erb +17 -0
  22. data/app/views/lesli_admin/accounts/edit.html.erb +10 -0
  23. data/app/views/lesli_admin/accounts/index.html.erb +34 -0
  24. data/app/views/lesli_admin/accounts/new.html.erb +9 -0
  25. data/app/views/lesli_admin/accounts/show.html.erb +34 -0
  26. data/app/views/lesli_admin/dashboards/_dashboard.html.erb +2 -0
  27. data/app/views/lesli_admin/dashboards/_form.html.erb +17 -0
  28. data/app/views/lesli_admin/dashboards/edit.html.erb +10 -0
  29. data/app/views/lesli_admin/dashboards/index.html.erb +14 -0
  30. data/app/views/lesli_admin/dashboards/new.html.erb +9 -0
  31. data/app/views/lesli_admin/dashboards/show.html.erb +1 -0
  32. data/app/views/lesli_admin/partials/_engine-navigation.html.erb +52 -0
  33. data/app/views/lesli_admin/users/edit.html.erb +10 -0
  34. data/app/views/lesli_admin/users/index.html.erb +34 -0
  35. data/app/views/lesli_admin/users/new.html.erb +34 -0
  36. data/app/views/lesli_admin/users/show.html.erb +10 -0
  37. data/config/routes.rb +13 -0
  38. data/lib/lesli_admin/engine.rb +18 -0
  39. data/lib/lesli_admin/version.rb +3 -0
  40. data/lib/lesli_admin.rb +6 -0
  41. data/lib/tasks/lesli_admin_tasks.rake +4 -0
  42. data/lib/vue/application.js +153 -0
  43. data/lib/vue/apps/account/components/address-form.vue +134 -0
  44. data/lib/vue/apps/account/components/contact-form.vue +162 -0
  45. data/lib/vue/apps/account/components/form-information.vue +107 -0
  46. data/lib/vue/apps/account/show.vue +89 -0
  47. data/lib/vue/apps/dashboard/show.vue +33 -0
  48. data/lib/vue/apps/profile/components/change-email.vue +38 -0
  49. data/lib/vue/apps/profile/components/subscriptions.vue +94 -0
  50. data/lib/vue/apps/profile/show.vue +141 -0
  51. data/lib/vue/apps/users/components/information-card.vue +119 -0
  52. data/lib/vue/apps/users/components/information-form.vue +180 -0
  53. data/lib/vue/apps/users/components/integrations-information.vue +61 -0
  54. data/lib/vue/apps/users/components/management-roles.vue +109 -0
  55. data/lib/vue/apps/users/components/management-security.vue +113 -0
  56. data/lib/vue/apps/users/components/management-sessions.vue +106 -0
  57. data/lib/vue/apps/users/components/management-settings.vue +94 -0
  58. data/lib/vue/apps/users/index.vue +201 -0
  59. data/lib/vue/apps/users/new.vue +181 -0
  60. data/lib/vue/apps/users/show.vue +101 -0
  61. data/lib/vue/stores/account.js +113 -0
  62. data/lib/vue/stores/accountSettings.js +342 -0
  63. data/lib/vue/stores/descriptor.js +116 -0
  64. data/lib/vue/stores/descriptors.js +167 -0
  65. data/lib/vue/stores/integration.js +103 -0
  66. data/lib/vue/stores/role.js +243 -0
  67. data/lib/vue/stores/roles.js +89 -0
  68. data/lib/vue/stores/systemController.js +67 -0
  69. data/lib/vue/stores/user.js +319 -0
  70. data/lib/vue/stores/users.js +150 -0
  71. data/readme.md +28 -0
  72. metadata +130 -0
@@ -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 "LesliAdmin/stores/users"
41
+ import { useRoles } from "LesliAdmin/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>
@@ -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 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 { ref, onMounted } from "vue"
36
+ import { useRouter, useRoute } from 'vue-router'
37
+
38
+
39
+ // · import lesli stores
40
+ import { useUser } from "CloudAdmin/stores/user"
41
+
42
+
43
+ // · import profile components
44
+ import informationCard from "CloudAdmin/apps/users/components/information-card.vue"
45
+ import informationForm from "CloudAdmin/apps/users/components/information-form.vue"
46
+
47
+ import managementRoles from "CloudAdmin/apps/users/components/management-roles.vue"
48
+ import managementSession from "CloudAdmin/apps/users/components/management-sessions.vue"
49
+ import managementSecurity from "CloudAdmin/apps/users/components/management-security.vue"
50
+ import managementSettings from "CloudAdmin/apps/users/components/management-settings.vue"
51
+
52
+
53
+ // · implement stores
54
+ const storeUser = useUser()
55
+ const router = useRouter()
56
+ const route = useRoute()
57
+
58
+
59
+ // · translations
60
+ const translations = {
61
+ core: {
62
+ roles: I18n.t("core.roles"),
63
+ users: I18n.t("core.users"),
64
+ shared: I18n.t("core.shared")
65
+ }
66
+ }
67
+
68
+
69
+ // ·
70
+ const tab = ref(0)
71
+
72
+
73
+ // · initializing
74
+ onMounted(() => {
75
+ storeUser.$reset()
76
+ storeUser.getOptions()
77
+ storeUser.getUser(route.params?.id)
78
+ })
79
+ </script>
80
+ <template>
81
+ <application-component>
82
+ <information-card></information-card>
83
+ <lesli-tabs v-model="tab" v-if="storeUser.user.id">
84
+ <lesli-tab-item icon="info_outline" :title="translations.core.users.view_tab_title_information">
85
+ <information-form></information-form>
86
+ </lesli-tab-item>
87
+ <lesli-tab-item icon="security" :title="translations.core.users.view_tab_title_roles_and_privileges">
88
+ <management-roles></management-roles>
89
+ </lesli-tab-item>
90
+ <lesli-tab-item icon="lock_outline" :title="translations.core.users.view_tab_title_security || 'Security'">
91
+ <management-security></management-security>
92
+ </lesli-tab-item>
93
+ <lesli-tab-item icon="devices" :title="translations.core.users.view_tab_title_session || 'Sessions'" paddingless>
94
+ <management-session></management-session>
95
+ </lesli-tab-item>
96
+ <lesli-tab-item icon="settings" :title="translations.core.users.view_tab_title_settings">
97
+ <management-settings></management-settings>
98
+ </lesli-tab-item>
99
+ </lesli-tabs>
100
+ </application-component>
101
+ </template>
@@ -0,0 +1,113 @@
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 Framework.
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 useAccount = defineStore("account", {
39
+ state: () => {
40
+ return {
41
+ accountInfo: {},
42
+ options: {
43
+ countries: [],
44
+ regions: [],
45
+ time_zones: []
46
+ }
47
+ }
48
+ },
49
+ actions: {
50
+
51
+ fetch (){
52
+ this.loading = true
53
+ this.http.get(this.url.admin("account")).then(result => {
54
+ this.accountInfo = result
55
+ delete this.accountInfo.created_at
56
+ delete this.accountInfo.updated_at
57
+ delete this.accountInfo.phone_number_2
58
+ delete this.accountInfo.phone_number_3
59
+ delete this.accountInfo.phone_number_4
60
+ }).catch(error => {
61
+ this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
62
+ }).finally(() => {
63
+ this.loading = false
64
+ })
65
+ },
66
+
67
+ update() {
68
+ this.submitting_form = true
69
+ this.http.patch(this.url.admin("account"), {
70
+ account: this.accountInfo
71
+ }).then(result => {
72
+ this.msg.success(I18n.t("core.users.messages_success_operation"))
73
+ }).catch(error => {
74
+ this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
75
+ }).finally(() => {
76
+ this.fetch()
77
+ })
78
+ },
79
+ getOptions (){
80
+ this.loading = true
81
+ this.http.get(this.url.admin("account/options")).then(result => {
82
+ this.options.countries = result.countries.map((country)=> {
83
+ return {
84
+ label: country.name,
85
+ value: country.id
86
+ }
87
+ } )
88
+ this.options.regions = result.regions.map((region)=> {
89
+ return {
90
+ label: region.value,
91
+ value: region.key
92
+ }
93
+ } )
94
+ }).catch(error => {
95
+ this.msg.danger(this.translations.core.shared.messages_danger_internal_error)
96
+ }).finally(() => {
97
+ this.loading = false
98
+ })
99
+ // Get options for time zone selection
100
+ this.http.get(this.url.admin("account/settings/options")).then(result => {
101
+ this.options.time_zones = result.time_zones.map((time_zone)=> {
102
+ return {
103
+ label: time_zone.text,
104
+ value: time_zone.value
105
+ }
106
+ } )
107
+ }).catch(error => {
108
+ this.msg.danger(this.translations.core.shared.messages_danger_internal_error)
109
+ })
110
+ }
111
+
112
+ },
113
+ });