lesli_admin 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/lesli_admin/application.js +284 -841
  3. data/app/controllers/lesli_admin/accounts_controller.rb +3 -5
  4. data/app/controllers/lesli_admin/dashboard/components_controller.rb +60 -0
  5. data/app/controllers/lesli_admin/dashboards_controller.rb +26 -50
  6. data/app/models/lesli_admin/account.rb +6 -0
  7. data/app/{controllers/lesli_admin/profiles_controller.rb → models/lesli_admin/dashboard/component.rb} +13 -19
  8. data/app/models/lesli_admin/dashboard.rb +58 -0
  9. data/app/services/lesli_admin/account_service.rb +39 -0
  10. data/app/views/lesli_admin/dashboards/edit.html.erb +29 -7
  11. data/app/views/lesli_admin/dashboards/index.html.erb +29 -11
  12. data/app/views/lesli_admin/dashboards/new.html.erb +29 -6
  13. data/app/views/lesli_admin/dashboards/show.html.erb +31 -0
  14. data/app/views/lesli_admin/partials/_engine-navigation.html.erb +0 -1
  15. data/config/locales/translations.en.yml +26 -0
  16. data/config/locales/translations.es.yml +26 -0
  17. data/config/routes.rb +46 -5
  18. data/db/migrate/0101050110_create_lesli_admin_dashboards.rb +51 -0
  19. data/db/migrate/0101050210_create_lesli_admin_dashboard_components.rb +53 -0
  20. data/lib/lesli_admin/engine.rb +1 -0
  21. data/lib/lesli_admin/version.rb +1 -1
  22. data/lib/vue/application.js +28 -15
  23. data/lib/vue/apps/account/components/{address-form.vue → form-address.vue} +27 -42
  24. data/lib/vue/apps/account/components/form-contact.vue +122 -0
  25. data/lib/vue/apps/account/components/form-information.vue +12 -30
  26. data/lib/vue/apps/account/show.vue +13 -12
  27. data/lib/vue/apps/{users/components/integrations-information.vue → dashboards/components/lesli-version.vue} +36 -26
  28. data/lib/vue/apps/{profile/components/change-email.vue → dashboards/show.vue} +9 -6
  29. data/lib/vue/stores/translations.json +52 -18
  30. metadata +17 -30
  31. data/app/controllers/lesli_admin/users_controller.rb +0 -238
  32. data/app/services/lesli_admin/user_service.rb +0 -265
  33. data/app/views/lesli_admin/dashboards/_dashboard.html.erb +0 -2
  34. data/app/views/lesli_admin/dashboards/_form.html.erb +0 -17
  35. data/lib/vue/apps/account/components/contact-form.vue +0 -162
  36. data/lib/vue/apps/dashboard/show.vue +0 -30
  37. data/lib/vue/apps/profile/components/subscriptions.vue +0 -94
  38. data/lib/vue/apps/profile/show.vue +0 -152
  39. data/lib/vue/apps/users/components/information-card.vue +0 -116
  40. data/lib/vue/apps/users/components/information-form.vue +0 -177
  41. data/lib/vue/apps/users/components/management-roles.vue +0 -109
  42. data/lib/vue/apps/users/components/management-security.vue +0 -113
  43. data/lib/vue/apps/users/components/management-sessions.vue +0 -106
  44. data/lib/vue/apps/users/components/management-settings.vue +0 -94
  45. data/lib/vue/apps/users/index.vue +0 -206
  46. data/lib/vue/apps/users/new.vue +0 -181
  47. data/lib/vue/apps/users/show.vue +0 -116
  48. data/lib/vue/stores/user.js +0 -331
  49. data/lib/vue/stores/users.js +0 -175
@@ -2,36 +2,70 @@
2
2
  "en": {
3
3
  "lesli": {
4
4
  "shared": {
5
- "title_lesli": ":lesli.shared.title_lesli:"
6
- },
7
- "users": {
8
- "title_users": "Users"
5
+ "button_add_new": "Add new",
6
+ "button_delete": "Delete",
7
+ "button_edit": "Edit",
8
+ "button_list": "List",
9
+ "button_reload": "Reload",
10
+ "button_save": "Save",
11
+ "view_discussions": "Discussions",
12
+ "view_files": "Files",
13
+ "view_quick_actions": "Quick actions"
9
14
  }
10
15
  },
11
16
  "lesli_admin": {
12
- "shared": {
13
- "title_lesli": ":lesli.shared.title_lesli:"
14
- },
15
- "users": {
16
- "title_users": "Users"
17
+ "accounts": {
18
+ "column_address": "Address",
19
+ "column_city": "City",
20
+ "column_company_name": "Company name",
21
+ "column_company_name_legal": "Legal name",
22
+ "column_country": "Country",
23
+ "column_phone_number": "Phonenumber",
24
+ "column_postal_code": "Postal code",
25
+ "column_public_email": "Public email",
26
+ "column_region": "Region",
27
+ "column_tag_line": "Slogan",
28
+ "column_website": "Website",
29
+ "tab_address": "Address",
30
+ "tab_contact": "Contact",
31
+ "tab_general_information": "General Information",
32
+ "view_subtitle_social_media": "Social media",
33
+ "view_title": "Account information"
17
34
  }
18
35
  }
19
36
  },
20
37
  "es": {
21
38
  "lesli": {
22
39
  "shared": {
23
- "title_lesli": "Lesli en español "
24
- },
25
- "users": {
26
- "title_users": "Usuarios"
40
+ "button_add_new": "Agregar nuevo",
41
+ "button_delete": "Eliminar",
42
+ "button_edit": "Editar",
43
+ "button_list": "Lista",
44
+ "button_reload": "Recargar",
45
+ "button_save": "Guardar",
46
+ "view_discussions": "Discusiones",
47
+ "view_files": "Archivos",
48
+ "view_quick_actions": "Acciones rapidas"
27
49
  }
28
50
  },
29
51
  "lesli_admin": {
30
- "shared": {
31
- "title_lesli": "Lesli en español "
32
- },
33
- "users": {
34
- "title_users": "Usuarios"
52
+ "accounts": {
53
+ "column_address": "Dirección",
54
+ "column_city": "Ciudad",
55
+ "column_company_name": "Nombre de Empresa",
56
+ "column_company_name_legal": "Razon social",
57
+ "column_country": "País",
58
+ "column_phone_number": "Teléfono",
59
+ "column_postal_code": "Código postal",
60
+ "column_public_email": "Email publico",
61
+ "column_region": "Región",
62
+ "column_tag_line": "Slogan",
63
+ "column_website": "Sitio web",
64
+ "tab_address": "Dirección",
65
+ "tab_contact": "Contacto",
66
+ "tab_general_information": "Información General",
67
+ "view_subtitle_social_media": "Redes sociales",
68
+ "view_title": "Informacion de cuenta"
35
69
  }
36
70
  }
37
71
  }
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lesli_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Lesli Development Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-02 00:00:00.000000000 Z
11
+ date: 2023-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 7.0.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 7.0.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: lesli
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5'
41
41
  description: Administration area for the Lesli Framework
@@ -53,9 +53,8 @@ files:
53
53
  - app/assets/stylesheets/lesli_admin/users.scss
54
54
  - app/controllers/lesli_admin/accounts_controller.rb
55
55
  - app/controllers/lesli_admin/application_controller.rb
56
+ - app/controllers/lesli_admin/dashboard/components_controller.rb
56
57
  - app/controllers/lesli_admin/dashboards_controller.rb
57
- - app/controllers/lesli_admin/profiles_controller.rb
58
- - app/controllers/lesli_admin/users_controller.rb
59
58
  - app/helpers/lesli_admin/application_helper.rb
60
59
  - app/helpers/lesli_admin/dashboards_helper.rb
61
60
  - app/helpers/lesli_admin/profiles_helper.rb
@@ -63,7 +62,9 @@ files:
63
62
  - app/mailers/lesli_admin/application_mailer.rb
64
63
  - app/models/lesli_admin/account.rb
65
64
  - app/models/lesli_admin/application_record.rb
66
- - app/services/lesli_admin/user_service.rb
65
+ - app/models/lesli_admin/dashboard.rb
66
+ - app/models/lesli_admin/dashboard/component.rb
67
+ - app/services/lesli_admin/account_service.rb
67
68
  - app/views/layouts/lesli_admin/application.html.erb
68
69
  - app/views/lesli_admin/accounts/_account.html.erb
69
70
  - app/views/lesli_admin/accounts/_form.html.erb
@@ -71,8 +72,6 @@ files:
71
72
  - app/views/lesli_admin/accounts/index.html.erb
72
73
  - app/views/lesli_admin/accounts/new.html.erb
73
74
  - app/views/lesli_admin/accounts/show.html.erb
74
- - app/views/lesli_admin/dashboards/_dashboard.html.erb
75
- - app/views/lesli_admin/dashboards/_form.html.erb
76
75
  - app/views/lesli_admin/dashboards/edit.html.erb
77
76
  - app/views/lesli_admin/dashboards/index.html.erb
78
77
  - app/views/lesli_admin/dashboards/new.html.erb
@@ -87,34 +86,22 @@ files:
87
86
  - config/locales/translations.es.yml
88
87
  - config/routes.rb
89
88
  - db/migrate/0101000110_create_lesli_admin_accounts.rb
89
+ - db/migrate/0101050110_create_lesli_admin_dashboards.rb
90
+ - db/migrate/0101050210_create_lesli_admin_dashboard_components.rb
90
91
  - lib/lesli_admin.rb
91
92
  - lib/lesli_admin/engine.rb
92
93
  - lib/lesli_admin/version.rb
93
94
  - lib/tasks/lesli_admin_tasks.rake
94
95
  - lib/vue/application.js
95
- - lib/vue/apps/account/components/address-form.vue
96
- - lib/vue/apps/account/components/contact-form.vue
96
+ - lib/vue/apps/account/components/form-address.vue
97
+ - lib/vue/apps/account/components/form-contact.vue
97
98
  - lib/vue/apps/account/components/form-information.vue
98
99
  - lib/vue/apps/account/show.vue
99
- - lib/vue/apps/dashboard/show.vue
100
- - lib/vue/apps/profile/components/change-email.vue
101
- - lib/vue/apps/profile/components/subscriptions.vue
102
- - lib/vue/apps/profile/show.vue
103
- - lib/vue/apps/users/components/information-card.vue
104
- - lib/vue/apps/users/components/information-form.vue
105
- - lib/vue/apps/users/components/integrations-information.vue
106
- - lib/vue/apps/users/components/management-roles.vue
107
- - lib/vue/apps/users/components/management-security.vue
108
- - lib/vue/apps/users/components/management-sessions.vue
109
- - lib/vue/apps/users/components/management-settings.vue
110
- - lib/vue/apps/users/index.vue
111
- - lib/vue/apps/users/new.vue
112
- - lib/vue/apps/users/show.vue
100
+ - lib/vue/apps/dashboards/components/lesli-version.vue
101
+ - lib/vue/apps/dashboards/show.vue
113
102
  - lib/vue/stores/account_settings.js
114
103
  - lib/vue/stores/roles.js
115
104
  - lib/vue/stores/translations.json
116
- - lib/vue/stores/user.js
117
- - lib/vue/stores/users.js
118
105
  - readme.md
119
106
  homepage: https://www.lesli.dev/
120
107
  licenses:
@@ -131,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
118
  requirements:
132
119
  - - ">="
133
120
  - !ruby/object:Gem::Version
134
- version: '0'
121
+ version: '2.7'
135
122
  required_rubygems_version: !ruby/object:Gem::Requirement
136
123
  requirements:
137
124
  - - ">="
@@ -1,238 +0,0 @@
1
- =begin
2
-
3
- Lesli
4
-
5
- Copyright (c) 2023, Lesli Technologies, S. A.
6
-
7
- This program is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation, either version 3 of the License, or
10
- (at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU General Public License for more details.
16
-
17
- You should have received a copy of the GNU General Public License
18
- along with this program. If not, see http://www.gnu.org/licenses/.
19
-
20
- Lesli · Ruby on Rails SaaS Development 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
- =end
32
-
33
- module LesliAdmin
34
- class UsersController < Lesli::ApplicationLesliController
35
- before_action :set_user, only: [
36
- :show,
37
- :update,
38
- :destroy,
39
- :requestpassword,
40
- :passwordreset,
41
- :revokeaccess,
42
- :logout
43
- ]
44
-
45
- # GET /users/list
46
- def list
47
- respond_to do |format|
48
- format.json {
49
- respond_with_successful(UserService.new("current_user").list(query, params))
50
- }
51
- end
52
- end
53
-
54
- # GET /users
55
- def index
56
- respond_to do |format|
57
- format.html
58
- format.json {
59
- return respond_with_pagination(UserService.new(current_user, query).index(params))
60
- }
61
- end
62
- end
63
-
64
- def show
65
- respond_to do |format|
66
- format.html
67
- format.json {
68
- return respond_with_not_found unless @user.found?
69
- return respond_with_successful(@user.show)
70
- }
71
- end
72
- end
73
-
74
- def create
75
- user = UserService.new(current_user).create(user_params)
76
- if user.successful?
77
- respond_with_successful(user.result)
78
- else
79
- respond_with_error("Error creating user", user.errors)
80
- end
81
- end
82
-
83
- def update
84
-
85
- # check if the user trully exists
86
- return respond_with_not_found unless @user.found?
87
-
88
- # update the user information
89
- @user.update(user_params)
90
-
91
- # check saved
92
- if @user.successful?
93
- respond_with_successful(@user.result)
94
- else
95
- respond_with_error(@user.errors)
96
- end
97
- end
98
-
99
- def destroy
100
- return respond_with_not_found unless @user
101
-
102
- # get the user found in the UserServices
103
- user = @user.result
104
-
105
- if user.delete
106
- current_user.logs.create({ title: "deleted_user", description: "by_user_id: #{ current_user.email }" })
107
- respond_with_successful()
108
- else
109
- respond_with_error(user.errors.full_messages.to_sentence)
110
- end
111
- end
112
-
113
- # Force the user to update his password
114
- def requestpassword
115
- if @user.request_password
116
- respond_with_successful
117
- else
118
- respond_with_error
119
- end
120
- end
121
-
122
- # Reset password (generate random)
123
- def passwordreset
124
-
125
- pass = @user.password_reset
126
-
127
- if pass
128
- respond_with_successful(pass)
129
- else
130
- respond_with_error
131
- end
132
- end
133
-
134
- # this method is going to close all the open user sessions
135
- def logout
136
- if @user.logout
137
- respond_with_successful
138
- else
139
- respond_with_error
140
- end
141
- end
142
-
143
- # Remove all user access
144
- def revokeaccess
145
- if @user.revoke_access
146
- respond_with_successful
147
- else
148
- respond_with_error
149
- end
150
- end
151
-
152
- def become
153
-
154
- # always should be disabled
155
- if Rails.configuration.lesli.dig(:security, :enable_becoming) != true
156
- return respond_with_unauthorized
157
- end
158
-
159
- # Allow only sysadmin to become as user
160
- return respond_with_unauthorized if current_user.email != Rails.application.config.lesli.dig(:account, :user, :email) # sysadmin user
161
-
162
- # Search for desire user
163
- becoming_user = User.find(params[:id])
164
-
165
- # Return an error if user does not exist
166
- return respond_with_error I18n.t("core.shared.messages_warning_user_not_found") if becoming_user.blank?
167
-
168
- # Extrictly save a log when becoming
169
- current_user.activities.create!({
170
- users_id: becoming_user.id,
171
- owner_id: current_user.id,
172
- description: "#{current_user.full_name} -> #{becoming_user.full_name}",
173
- category: "action_become"
174
- })
175
-
176
- # Sign in as the becoming user
177
- sign_in(:user, becoming_user)
178
-
179
- # Create a new session for the becoming user
180
- becoming_session = becoming_user.sessions.create({
181
- :user_agent => get_user_agent,
182
- :user_remote => request.remote_ip,
183
- :session_source => "become_session",
184
- :last_used_at => LC::Date.now,
185
- :expiration_at => 60.minutes.from_now
186
- })
187
-
188
- # assign the session of the becomer user to the becoming user
189
- session[:user_session_id] = becoming_session[:id]
190
-
191
- # Response successful
192
- respond_with_successful([current_user, becoming_user])
193
-
194
- end
195
-
196
- def options
197
- respond_with_successful({
198
- #regions: current_user.account.locations.where(level: "region"),
199
- salutations: User::Detail.salutations.map {|k, v| {value: k, text: v}},
200
- locales: Rails.application.config.lesli.dig(:configuration, :locales_available),
201
- mfa_methods: Rails.application.config.lesli.dig(:configuration, :mfa_methods)
202
- })
203
- end
204
-
205
- private
206
-
207
- # @return [void]
208
- # @description Sets the requested user based on the current_users's account
209
- # @example
210
- # # Executing this method from a controller action:
211
- # set_user
212
- # puts @user
213
- # # This will either display nil or an instance of Account::User
214
- def set_user
215
- @user = UserService.new(current_user).find(params[:id])
216
- end
217
-
218
- def user_params
219
- params.require(:user).permit(
220
- :active,
221
- :email,
222
- :alias,
223
- :roles_id,
224
- :first_name,
225
- :last_name,
226
- :telephone,
227
- detail_attributes: [
228
- :title,
229
- :salutation,
230
- :address,
231
- :work_city,
232
- :work_region,
233
- :work_address
234
- ]
235
- )
236
- end
237
- end
238
- end