lesli_admin 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/config/lesli_admin_manifest.js +1 -0
- data/app/assets/images/lesli_admin/admin-logo.svg +1 -0
- data/app/assets/javascripts/lesli_admin/application.js +2635 -244
- data/app/assets/javascripts/lesli_admin/translations.js +2291 -0
- data/app/assets/stylesheets/lesli_admin/application.scss +32 -0
- data/app/assets/stylesheets/lesli_admin/users.scss +67 -0
- data/app/controllers/lesli_admin/profiles_controller.rb +56 -0
- data/app/controllers/lesli_admin/users_controller.rb +5 -196
- data/app/helpers/lesli_admin/profiles_helper.rb +4 -0
- data/app/views/lesli_admin/profiles/edit.html.erb +10 -0
- data/app/views/lesli_admin/profiles/index.html.erb +14 -0
- data/app/views/lesli_admin/profiles/new.html.erb +9 -0
- data/app/views/lesli_admin/profiles/show.html.erb +1 -0
- data/app/views/lesli_admin/users/show.html.erb +1 -10
- data/config/locales/translations.en.yml +6 -0
- data/config/locales/translations.es.yml +6 -0
- data/config/routes.rb +4 -7
- data/lib/lesli_admin/engine.rb +31 -0
- data/lib/lesli_admin/version.rb +2 -1
- data/lib/vue/application.js +15 -98
- data/lib/vue/apps/account/show.vue +2 -2
- data/lib/vue/apps/dashboard/show.vue +6 -8
- data/lib/vue/apps/profile/show.vue +22 -15
- data/lib/vue/apps/users/components/information-card.vue +4 -7
- data/lib/vue/apps/users/components/information-form.vue +4 -7
- data/lib/vue/apps/users/index.vue +10 -4
- data/lib/vue/apps/users/show.vue +25 -10
- data/lib/vue/stores/translations.json +20 -0
- data/lib/vue/stores/users.js +1 -1
- data/readme.md +61 -18
- metadata +16 -14
- data/app/assets/stylesheets/lesli_admin/application.css +0 -15
- data/app/models/lesli_admin/dashboard.rb +0 -4
- data/app/models/lesli_admin/user.rb +0 -4
- data/app/services/lesli_admin/user_service.rb +0 -300
- data/lib/vue/stores/account.js +0 -113
- data/lib/vue/stores/descriptor.js +0 -116
- data/lib/vue/stores/descriptors.js +0 -167
- data/lib/vue/stores/integration.js +0 -103
- data/lib/vue/stores/role.js +0 -243
- data/lib/vue/stores/systemController.js +0 -67
- data/lib/vue/stores/user.js +0 -319
- /data/lib/vue/stores/{accountSettings.js → account_settings.js} +0 -0
@@ -1,300 +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 UserService < Lesli::ApplicationLesliService
|
35
|
-
|
36
|
-
|
37
|
-
# Return a list of users that belongs to the account of the current_user
|
38
|
-
# this list is meant to be used in selectors, autocomplets, etc
|
39
|
-
def list query=nil, params=nil
|
40
|
-
#users = current_user.account.users
|
41
|
-
users = Lesli::Account.first.users
|
42
|
-
|
43
|
-
if params[:role].present?
|
44
|
-
# add simple quotes to the roles so the sql can manage the query
|
45
|
-
roles = params[:role].split(",").map { |role| "'#{role}'" }.join(", ")
|
46
|
-
users = users.joins("
|
47
|
-
inner join (
|
48
|
-
select
|
49
|
-
ur.users_id, string_agg(r.\"name\", ', ') role_names
|
50
|
-
from user_roles ur
|
51
|
-
join roles r
|
52
|
-
on r.id = ur.role_id
|
53
|
-
and r.name in ( #{ roles } )
|
54
|
-
where ur.deleted_at is null
|
55
|
-
group by ur.users_id
|
56
|
-
) roles on roles.users_id = users.id
|
57
|
-
")
|
58
|
-
end
|
59
|
-
|
60
|
-
users.order(name: :asc).select(
|
61
|
-
:id,
|
62
|
-
:email,
|
63
|
-
"CONCAT_WS(' ', first_name, last_name) as name",
|
64
|
-
:alias
|
65
|
-
).as_json
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
# @return [Array] Paginated index of users.
|
70
|
-
# @description Return a paginated array of users, used mostly in frontend views
|
71
|
-
# TODO: Implement pg_search
|
72
|
-
def index query, params
|
73
|
-
|
74
|
-
# sql string to join to user_roles and get all the roles assigned to a user
|
75
|
-
sql_string_for_user_roles = "left join (
|
76
|
-
select
|
77
|
-
ur.user_id, string_agg(r.\"name\", ', ') rolenames
|
78
|
-
from user_roles ur
|
79
|
-
join roles r
|
80
|
-
on r.id = ur.role_id
|
81
|
-
where ur.deleted_at is null
|
82
|
-
group by ur.user_id
|
83
|
-
) roles on roles.user_id = users.id"
|
84
|
-
|
85
|
-
# sql string to joing to user_sessions and get all the active sessions of a user
|
86
|
-
sql_string_for_user_sessions = "left join (
|
87
|
-
select
|
88
|
-
max(last_used_at) as last_action_performed_at,
|
89
|
-
user_id
|
90
|
-
from user_sessions us
|
91
|
-
where us.deleted_at is null
|
92
|
-
group by(us.user_id)
|
93
|
-
) sessions on sessions.user_id = users.id"
|
94
|
-
|
95
|
-
#users = current_user.account.users
|
96
|
-
users = Lesli::Account.first.users
|
97
|
-
#.joins(sql_string_for_user_roles)
|
98
|
-
#.joins(sql_string_for_user_sessions)
|
99
|
-
users = users.page(query[:pagination][:page])
|
100
|
-
.per(query[:pagination][:perPage])
|
101
|
-
.order("#{query[:order][:by]} #{query[:order][:dir]} NULLS LAST")
|
102
|
-
|
103
|
-
users.select(
|
104
|
-
:id,
|
105
|
-
"CONCAT(COALESCE(first_name, ''), ' ', COALESCE(last_name, '')) as name",
|
106
|
-
:email,
|
107
|
-
:active,
|
108
|
-
#:rolenames,
|
109
|
-
#Date2.new.date_time.db_column("current_sign_in_at"),
|
110
|
-
#Date2.new.date_time.db_column("last_action_performed_at")
|
111
|
-
)
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
|
116
|
-
# Creates a query that selects all user information from several tables if CloudLock is present
|
117
|
-
def show
|
118
|
-
|
119
|
-
user = resource
|
120
|
-
|
121
|
-
return {
|
122
|
-
id: user[:id],
|
123
|
-
email: user[:email],
|
124
|
-
alias: user[:alias],
|
125
|
-
active: user[:active],
|
126
|
-
full_name: user.full_name,
|
127
|
-
salutation: user[:salutation],
|
128
|
-
first_name: user[:first_name],
|
129
|
-
last_name: user[:last_name],
|
130
|
-
telephone: user[:telephone],
|
131
|
-
|
132
|
-
locale: user.settings.select(:value).find_by(:name => "locale"),
|
133
|
-
|
134
|
-
roles: user.roles.map { |r| { id: r[:id], name: r[:name], permission_level: r[:object_level_permission]} },
|
135
|
-
|
136
|
-
mfa_enabled: user.mfa_settings[:enabled],
|
137
|
-
mfa_method: user.mfa_settings[:method],
|
138
|
-
|
139
|
-
created_at: user[:created_at],
|
140
|
-
updated_at: user[:updated_at],
|
141
|
-
|
142
|
-
detail_attributes: {
|
143
|
-
title: user.detail[:title],
|
144
|
-
address: user.detail[:address],
|
145
|
-
work_city: user.detail[:work_city],
|
146
|
-
work_region: user.detail[:work_region],
|
147
|
-
work_address: user.detail[:work_address]
|
148
|
-
}
|
149
|
-
}
|
150
|
-
end
|
151
|
-
|
152
|
-
def create user_params
|
153
|
-
|
154
|
-
# check if request has an email to create the user
|
155
|
-
if user_params[:email].blank?
|
156
|
-
self.error(I18n.t("core.users.messages_danger_not_valid_email_found"))
|
157
|
-
end
|
158
|
-
|
159
|
-
|
160
|
-
# register the new user
|
161
|
-
user = User.new({
|
162
|
-
:active => true,
|
163
|
-
:email => user_params[:email],
|
164
|
-
:alias => user_params[:alias] || "",
|
165
|
-
:first_name => user_params[:first_name] || "",
|
166
|
-
:last_name => user_params[:last_name] || "",
|
167
|
-
:telephone => user_params[:telephone] || "",
|
168
|
-
#:detail_attributes => user_params[:detail_attributes] || {}
|
169
|
-
})
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
# assign a random password
|
174
|
-
user.password = Devise.friendly_token
|
175
|
-
|
176
|
-
# enrol user to my own account
|
177
|
-
user.account = current_user.account
|
178
|
-
|
179
|
-
# users created through the administration area does not need to confirm their accounts
|
180
|
-
# instead we send a password reset link, so they can have access to the platform
|
181
|
-
#user.confirm
|
182
|
-
|
183
|
-
if user.save
|
184
|
-
|
185
|
-
# if a role is provided to assign to the new user
|
186
|
-
# unless user_params[:roles_id].blank?
|
187
|
-
# # check if current user can work with the sent role
|
188
|
-
# if current_user.can_work_with_role?(user_params[:roles_id])
|
189
|
-
# # Search the role assigned
|
190
|
-
# role = current_user.account.roles.find_by(id: user_params[:roles_id])
|
191
|
-
# # assign role to the new user
|
192
|
-
# user.user_roles.create({ role: role })
|
193
|
-
# end
|
194
|
-
# end
|
195
|
-
|
196
|
-
# role validation - if new user does not have any role assigned
|
197
|
-
# if user.roles.blank?
|
198
|
-
|
199
|
-
# default_role_id = current_user.account.settings.find_by(:name => "default_role_id")&.value
|
200
|
-
# owner_role_id = current_user.account.roles.find_by(:name => "owner").id
|
201
|
-
# if default_role_id.present? && default_role_id != owner_role_id
|
202
|
-
# # assign default role
|
203
|
-
# user.user_roles.create({ role: current_user.account.roles.find_by(:id => default_role_id)})
|
204
|
-
|
205
|
-
# else
|
206
|
-
# # assign limited role
|
207
|
-
# user.user_roles.create({ role: current_user.account.roles.find_by(:name => "limited") })
|
208
|
-
# end
|
209
|
-
# end
|
210
|
-
|
211
|
-
# saving logs with information about the creation of the user
|
212
|
-
# user.logs.create({ title: "user_created_at", description: Date2.new.date_time.to_s })
|
213
|
-
# user.logs.create({ title: "user_created_by", description: current_user.email })
|
214
|
-
# user.logs.create({ title: "user_created_with_role", description: user.user_roles.first.role.name + " " + user.user_roles.first.role.id.to_s})
|
215
|
-
# User.log_activity_create(current_user, user)
|
216
|
-
|
217
|
-
self.resource = user
|
218
|
-
|
219
|
-
begin
|
220
|
-
# users created through the administration area does not need to confirm their accounts
|
221
|
-
# instead we send a password reset link, so they can have access to the platform
|
222
|
-
#UserMailer.with(user: user).invitation_instructions.deliver_now
|
223
|
-
rescue => exception
|
224
|
-
#Honeybadger.notify(exception)
|
225
|
-
#user.logs.create({ title: "user_creation_email_failed ", description: exception.message })
|
226
|
-
end
|
227
|
-
|
228
|
-
else
|
229
|
-
self.error(user.errors.full_messages.to_sentence)
|
230
|
-
end
|
231
|
-
|
232
|
-
self
|
233
|
-
|
234
|
-
end
|
235
|
-
|
236
|
-
def update params
|
237
|
-
|
238
|
-
old_attributes = resource.detail.attributes.merge({
|
239
|
-
active: resource.active
|
240
|
-
})
|
241
|
-
|
242
|
-
if resource.update(params)
|
243
|
-
new_attributes = resource.detail.attributes.merge({
|
244
|
-
active: resource.active
|
245
|
-
})
|
246
|
-
|
247
|
-
resource.log_activity_update(current_user, resource, old_attributes, new_attributes)
|
248
|
-
else
|
249
|
-
self.error(resource.errors.full_messages.to_sentence)
|
250
|
-
end
|
251
|
-
|
252
|
-
self
|
253
|
-
end
|
254
|
-
|
255
|
-
|
256
|
-
# force the user to change the password (at next login)
|
257
|
-
def request_password
|
258
|
-
|
259
|
-
# expire password
|
260
|
-
resource.set_password_as_expired
|
261
|
-
|
262
|
-
resource.logs.create({ title: "request_password", description: "by_user: " + current_user.email })
|
263
|
-
end
|
264
|
-
|
265
|
-
|
266
|
-
# generate a random password for the user
|
267
|
-
def password_reset
|
268
|
-
|
269
|
-
# generate random password
|
270
|
-
pass = resource.password_reset
|
271
|
-
|
272
|
-
resource.logs.create({ title: "password_reset", description: "by_user: " + current_user.email })
|
273
|
-
|
274
|
-
pass
|
275
|
-
end
|
276
|
-
|
277
|
-
def logout
|
278
|
-
# delete user active sessions
|
279
|
-
resource.sessions.destroy_all
|
280
|
-
|
281
|
-
resource.logs.create({ title: "close_sessions", description: "by_user: " + current_user.email })
|
282
|
-
end
|
283
|
-
|
284
|
-
def revoke_access
|
285
|
-
|
286
|
-
# delete user active sessions
|
287
|
-
self.logout
|
288
|
-
|
289
|
-
# add delete date to the last active session
|
290
|
-
resource.revoke_access
|
291
|
-
|
292
|
-
resource.logs.create({ title: "revoke_access", description: "by_user: " + current_user.email })
|
293
|
-
end
|
294
|
-
|
295
|
-
def find id
|
296
|
-
#super(current_user.account.users.joins(:detail).find_by(id: id))
|
297
|
-
super(current_user.account.users.find_by(id: id))
|
298
|
-
end
|
299
|
-
end
|
300
|
-
end
|
data/lib/vue/stores/account.js
DELETED
@@ -1,113 +0,0 @@
|
|
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
|
-
});
|
@@ -1,116 +0,0 @@
|
|
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
|
-
})
|
@@ -1,167 +0,0 @@
|
|
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
|
-
})
|