lesli_guard 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +38 -0
- data/app/assets/config/lesli_guard_manifest.js +38 -0
- data/app/assets/images/lesli_guard/guard-logo.svg +160 -0
- data/app/assets/javascripts/lesli_guard/application.js +4787 -0
- data/app/assets/stylesheets/lesli_guard/application.scss +33 -0
- data/app/assets/stylesheets/lesli_guard/dashboards.scss +32 -0
- data/app/assets/stylesheets/lesli_guard/descriptors.scss +32 -0
- data/app/assets/stylesheets/lesli_guard/roles.scss +32 -0
- data/app/assets/stylesheets/lesli_guard/system_controller.scss +32 -0
- data/app/assets/stylesheets/lesli_guard/users.scss +67 -0
- data/app/controllers/lesli_guard/accounts_controller.rb +60 -0
- data/app/controllers/lesli_guard/application_controller.rb +37 -0
- data/app/controllers/lesli_guard/dashboard/components_controller.rb +60 -0
- data/app/controllers/lesli_guard/dashboards_controller.rb +36 -0
- data/app/controllers/lesli_guard/descriptor/activities_controller.rb +122 -0
- data/app/controllers/lesli_guard/descriptor/privileges_controller.rb +112 -0
- data/app/controllers/lesli_guard/descriptors_controller.rb +129 -0
- data/app/controllers/lesli_guard/role/activities_controller.rb +76 -0
- data/app/controllers/lesli_guard/role/descriptors_controller.rb +97 -0
- data/app/controllers/lesli_guard/role/privileges_controller.rb +47 -0
- data/app/controllers/lesli_guard/roles_controller.rb +185 -0
- data/app/controllers/lesli_guard/user/roles_controller.rb +98 -0
- data/app/controllers/lesli_guard/user/sessions_controller.rb +71 -0
- data/app/controllers/lesli_guard/users_controller.rb +206 -0
- data/app/helpers/lesli_guard/accounts_helper.rb +4 -0
- data/app/helpers/lesli_guard/application_helper.rb +4 -0
- data/app/helpers/lesli_guard/dashboards_helper.rb +4 -0
- data/app/helpers/lesli_guard/descriptor/activities_helper.rb +4 -0
- data/app/helpers/lesli_guard/descriptor/privileges_helper.rb +4 -0
- data/app/helpers/lesli_guard/descriptors_helper.rb +4 -0
- data/app/helpers/lesli_guard/role/activities_helper.rb +4 -0
- data/app/helpers/lesli_guard/role/descriptors_helper.rb +4 -0
- data/app/helpers/lesli_guard/role/privileges_helper.rb +4 -0
- data/app/helpers/lesli_guard/roles_helper.rb +4 -0
- data/app/jobs/lesli_guard/application_job.rb +37 -0
- data/app/mailers/lesli_guard/application_mailer.rb +39 -0
- data/app/models/lesli_guard/account.rb +43 -0
- data/app/models/lesli_guard/application_record.rb +37 -0
- data/app/models/lesli_guard/dashboard/component.rb +42 -0
- data/app/models/lesli_guard/dashboard.rb +58 -0
- data/app/models/lesli_guard/descriptor/activity.rb +40 -0
- data/app/models/lesli_guard/descriptor/privilege.rb +40 -0
- data/app/models/lesli_guard/descriptor.rb +41 -0
- data/app/models/lesli_guard/role/activity.rb +40 -0
- data/app/services/lesli_guard/descriptor_privilege_service.rb +74 -0
- data/app/services/lesli_guard/descriptor_service.rb +152 -0
- data/app/services/lesli_guard/role_descriptor_service.rb +61 -0
- data/app/services/lesli_guard/role_service.rb +215 -0
- data/app/services/lesli_guard/user_service.rb +305 -0
- data/app/views/lesli_guard/accounts/_account.html.erb +2 -0
- data/app/views/lesli_guard/accounts/_form.html.erb +17 -0
- data/app/views/lesli_guard/accounts/edit.html.erb +10 -0
- data/app/views/lesli_guard/accounts/index.html.erb +14 -0
- data/app/views/lesli_guard/accounts/new.html.erb +9 -0
- data/app/views/lesli_guard/accounts/show.html.erb +10 -0
- data/app/views/lesli_guard/dashboards/show.html.erb +1 -0
- data/app/views/lesli_guard/descriptor/activities/_form.html.erb +32 -0
- data/app/views/lesli_guard/descriptor/activities/edit.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/activities/index.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/activities/new.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/activities/show.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/privileges/_form.html.erb +32 -0
- data/app/views/lesli_guard/descriptor/privileges/edit.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/privileges/index.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/privileges/new.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/privileges/show.html.erb +34 -0
- data/app/views/lesli_guard/descriptors/_form.html.erb +32 -0
- data/app/views/lesli_guard/descriptors/edit.html.erb +34 -0
- data/app/views/lesli_guard/descriptors/index.html.erb +34 -0
- data/app/views/lesli_guard/descriptors/new.html.erb +34 -0
- data/app/views/lesli_guard/descriptors/show.html.erb +34 -0
- data/app/views/lesli_guard/partials/_engine-navigation.html.erb +38 -0
- data/app/views/lesli_guard/role/activities/_form.html.erb +32 -0
- data/app/views/lesli_guard/role/activities/edit.html.erb +34 -0
- data/app/views/lesli_guard/role/activities/index.html.erb +34 -0
- data/app/views/lesli_guard/role/activities/new.html.erb +34 -0
- data/app/views/lesli_guard/role/activities/show.html.erb +34 -0
- data/app/views/lesli_guard/role/descriptors/_form.html.erb +32 -0
- data/app/views/lesli_guard/role/descriptors/edit.html.erb +34 -0
- data/app/views/lesli_guard/role/descriptors/index.html.erb +34 -0
- data/app/views/lesli_guard/role/descriptors/new.html.erb +34 -0
- data/app/views/lesli_guard/role/descriptors/show.html.erb +34 -0
- data/app/views/lesli_guard/role/privileges/_form.html.erb +32 -0
- data/app/views/lesli_guard/role/privileges/edit.html.erb +34 -0
- data/app/views/lesli_guard/role/privileges/index.html.erb +34 -0
- data/app/views/lesli_guard/role/privileges/new.html.erb +34 -0
- data/app/views/lesli_guard/role/privileges/show.html.erb +34 -0
- data/app/views/lesli_guard/roles/edit.html.erb +34 -0
- data/app/views/lesli_guard/roles/index.html.erb +34 -0
- data/app/views/lesli_guard/roles/new.html.erb +34 -0
- data/app/views/lesli_guard/roles/show.html.erb +34 -0
- data/app/views/lesli_guard/users/edit.html.erb +10 -0
- data/app/views/lesli_guard/users/index.html.erb +34 -0
- data/app/views/lesli_guard/users/new.html.erb +34 -0
- data/app/views/lesli_guard/users/show.html.erb +1 -0
- data/config/locales/translations.en.yml +43 -0
- data/config/locales/translations.es.yml +43 -0
- data/config/routes.rb +90 -0
- data/db/migrate/v1/0801000110_create_lesli_guard_accounts.rb +42 -0
- data/db/migrate/v1/0801050110_create_lesli_guard_dashboards.rb +51 -0
- data/db/migrate/v1/0801050210_create_lesli_guard_dashboard_components.rb +53 -0
- data/lib/lesli_guard/engine.rb +18 -0
- data/lib/lesli_guard/version.rb +4 -0
- data/lib/lesli_guard.rb +6 -0
- data/lib/tasks/lesli_guard_tasks.rake +50 -0
- data/lib/vue/application.js +112 -0
- data/lib/vue/apps/descriptors/components/form.vue +136 -0
- data/lib/vue/apps/descriptors/edit.vue +83 -0
- data/lib/vue/apps/descriptors/index.vue +113 -0
- data/lib/vue/apps/descriptors/new.vue +69 -0
- data/lib/vue/apps/descriptors/show.vue +233 -0
- data/lib/vue/apps/roles/components/descriptors.vue +81 -0
- data/lib/vue/apps/roles/components/form.vue +253 -0
- data/lib/vue/apps/roles/components/privilegeCustom.vue +86 -0
- data/lib/vue/apps/roles/components/privilegeStandard.vue +196 -0
- data/lib/vue/apps/roles/edit.vue +118 -0
- data/lib/vue/apps/roles/index.vue +168 -0
- data/lib/vue/apps/roles/logs.vue +110 -0
- data/lib/vue/apps/roles/new.vue +86 -0
- data/lib/vue/apps/roles/show.vue +109 -0
- data/lib/vue/apps/users/components/information-card.vue +107 -0
- data/lib/vue/apps/users/components/information-form.vue +176 -0
- data/lib/vue/apps/users/components/integrations-information.vue +61 -0
- data/lib/vue/apps/users/components/management-roles.vue +107 -0
- data/lib/vue/apps/users/components/management-security.vue +113 -0
- data/lib/vue/apps/users/components/management-sessions.vue +101 -0
- data/lib/vue/apps/users/components/management-settings.vue +93 -0
- data/lib/vue/apps/users/index.vue +207 -0
- data/lib/vue/apps/users/new.vue +181 -0
- data/lib/vue/apps/users/show.vue +131 -0
- data/lib/vue/stores/descriptor.js +117 -0
- data/lib/vue/stores/descriptors.js +156 -0
- data/lib/vue/stores/role.js +203 -0
- data/lib/vue/stores/roles.js +58 -0
- data/lib/vue/stores/translations.json +98 -0
- data/lib/vue/stores/user.js +331 -0
- data/lib/vue/stores/users.js +176 -0
- data/license +674 -0
- data/readme.md +76 -0
- metadata +199 -0
@@ -0,0 +1,131 @@
|
|
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, onMounted } from "vue"
|
36
|
+
import { useRouter, useRoute } from 'vue-router'
|
37
|
+
|
38
|
+
|
39
|
+
// · import lesli stores
|
40
|
+
import { useUser } from "LesliGuard/stores/user"
|
41
|
+
|
42
|
+
|
43
|
+
// · implement stores
|
44
|
+
const storeUser = useUser()
|
45
|
+
const router = useRouter()
|
46
|
+
const route = useRoute()
|
47
|
+
|
48
|
+
|
49
|
+
// · import profile components
|
50
|
+
import informationCard from "LesliGuard/apps/users/components/information-card.vue"
|
51
|
+
import informationForm from "LesliGuard/apps/users/components/information-form.vue"
|
52
|
+
import managementRoles from "LesliGuard/apps/users/components/management-roles.vue"
|
53
|
+
import managementSession from "LesliGuard/apps/users/components/management-sessions.vue"
|
54
|
+
import managementSettings from "LesliGuard/apps/users/components/management-settings.vue"
|
55
|
+
import managementSecurity from "LesliGuard/apps/users/components/management-security.vue"
|
56
|
+
|
57
|
+
|
58
|
+
// · translations
|
59
|
+
const translations = {
|
60
|
+
guard: {
|
61
|
+
users: i18n.t("lesli_guard.users")
|
62
|
+
},
|
63
|
+
core: {
|
64
|
+
roles: I18n.t("core.roles"),
|
65
|
+
users: I18n.t("core.users"),
|
66
|
+
shared: I18n.t("core.shared")
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
// ·
|
72
|
+
const tab = ref(0)
|
73
|
+
|
74
|
+
|
75
|
+
// · initializing
|
76
|
+
onMounted(() => {
|
77
|
+
// storeUser.$reset()
|
78
|
+
// storeUser.getOptions()
|
79
|
+
if (route.params?.id) {
|
80
|
+
storeUser.getUser(route.params?.id)
|
81
|
+
} else {
|
82
|
+
storeUser.getUser(lesli.current_user.id)
|
83
|
+
}
|
84
|
+
})
|
85
|
+
</script>
|
86
|
+
<template>
|
87
|
+
<lesli-application-container>
|
88
|
+
<information-card></information-card>
|
89
|
+
<lesli-tabs v-model="tab">
|
90
|
+
<lesli-tab-item icon="info_outline" :title="translations.guard.users.tab_information">
|
91
|
+
<information-form></information-form>
|
92
|
+
</lesli-tab-item>
|
93
|
+
|
94
|
+
<lesli-tab-item icon="security" :title="translations.guard.users.tab_roles_and_privileges">
|
95
|
+
<management-roles></management-roles>
|
96
|
+
</lesli-tab-item>
|
97
|
+
|
98
|
+
<lesli-tab-item icon="lock_outline" :title="translations.guard.users.tab_security">
|
99
|
+
<management-security></management-security>
|
100
|
+
</lesli-tab-item>
|
101
|
+
|
102
|
+
<lesli-tab-item icon="devices" :title="translations.guard.users.tab_sessions">
|
103
|
+
<management-session></management-session>
|
104
|
+
</lesli-tab-item>
|
105
|
+
|
106
|
+
<lesli-tab-item icon="settings" :title="translations.guard.users.tab_settings">
|
107
|
+
<management-settings></management-settings>
|
108
|
+
</lesli-tab-item>
|
109
|
+
</lesli-tabs>
|
110
|
+
</lesli-application-container>
|
111
|
+
<!--
|
112
|
+
<application-component>
|
113
|
+
<information-card></information-card>
|
114
|
+
<lesli-tabs v-model="tab" v-if="storeUser.user.id">
|
115
|
+
<lesli-tab-item icon="info_outline" :title="translations.core.users.view_tab_title_information">
|
116
|
+
<information-form></information-form>
|
117
|
+
</lesli-tab-item>
|
118
|
+
|
119
|
+
<lesli-tab-item icon="lock_outline" :title="translations.core.users.view_tab_title_security || 'Security'">
|
120
|
+
<management-security></management-security>
|
121
|
+
</lesli-tab-item>
|
122
|
+
<lesli-tab-item icon="devices" :title="translations.core.users.view_tab_title_session || 'Sessions'" paddingless>
|
123
|
+
<management-session></management-session>
|
124
|
+
</lesli-tab-item>
|
125
|
+
<lesli-tab-item icon="settings" :title="translations.core.users.view_tab_title_settings">
|
126
|
+
<management-settings></management-settings>
|
127
|
+
</lesli-tab-item>
|
128
|
+
</lesli-tabs>
|
129
|
+
</application-component>
|
130
|
+
-->
|
131
|
+
</template>
|
@@ -0,0 +1,117 @@
|
|
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 useDescriptor = defineStore("guard.descriptor", {
|
39
|
+
state: () => {
|
40
|
+
return {
|
41
|
+
descriptor: {
|
42
|
+
loading: false,
|
43
|
+
payload: {
|
44
|
+
name: ""
|
45
|
+
}
|
46
|
+
},
|
47
|
+
privileges: [],
|
48
|
+
privilegesLoading: false
|
49
|
+
}
|
50
|
+
},
|
51
|
+
actions: {
|
52
|
+
|
53
|
+
getDescriptor(id) {
|
54
|
+
this.http.get(this.url.guard("descriptors/:id", id)).then(result => {
|
55
|
+
this.descriptor = result
|
56
|
+
this.getDescriptorPrivileges()
|
57
|
+
}).catch(error => {
|
58
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
59
|
+
}).finally(() => {
|
60
|
+
|
61
|
+
})
|
62
|
+
},
|
63
|
+
|
64
|
+
resetDescriptor() {
|
65
|
+
},
|
66
|
+
|
67
|
+
postDescriptor() {
|
68
|
+
this.loading = true
|
69
|
+
this.http.post(this.url.guard("descriptors"), {
|
70
|
+
descriptor: this.descriptor.payload
|
71
|
+
}).then(result => {
|
72
|
+
this.descriptor.payload.id = result.id
|
73
|
+
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
74
|
+
}).catch(error => {
|
75
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
76
|
+
}).finally(() => {
|
77
|
+
this.loading = false
|
78
|
+
})
|
79
|
+
},
|
80
|
+
|
81
|
+
getDescriptorPrivileges() {
|
82
|
+
this.privilegesLoading = true
|
83
|
+
this.http.get(this.url.guard("descriptors/:id/privileges", this.descriptor.id)).then(result => {
|
84
|
+
this.privileges = result
|
85
|
+
}).catch(error => {
|
86
|
+
console.log(error)
|
87
|
+
}).finally(() => {
|
88
|
+
this.privilegesLoading = false
|
89
|
+
})
|
90
|
+
},
|
91
|
+
|
92
|
+
// Add privilege to descriptor
|
93
|
+
postDescriptorPrivilege(action) {
|
94
|
+
this.http.post(this.url.guard("descriptors/:id/privileges", this.descriptor.id), {
|
95
|
+
descriptor_privilege: {
|
96
|
+
action_id: action
|
97
|
+
}
|
98
|
+
}).then(result => {
|
99
|
+
console.log(result)
|
100
|
+
}).catch(error => {
|
101
|
+
console.log(error)
|
102
|
+
})
|
103
|
+
},
|
104
|
+
|
105
|
+
// Add privilege to descriptor
|
106
|
+
deleteDescriptorPrivilege(action) {
|
107
|
+
this.http.delete(this.url.guard("descriptors/:descriptorId/privileges/:descriptorPrivilegeId", {
|
108
|
+
descriptorId: this.descriptor.id,
|
109
|
+
descriptorPrivilegeId: action
|
110
|
+
})).then(result => {
|
111
|
+
console.log(result)
|
112
|
+
}).catch(error => {
|
113
|
+
console.log(error)
|
114
|
+
})
|
115
|
+
}
|
116
|
+
}
|
117
|
+
})
|
@@ -0,0 +1,156 @@
|
|
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 useDescriptors = defineStore("guard.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.guard("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
|
+
resetDescriptor() {
|
73
|
+
this.descriptor = {}
|
74
|
+
this.privileges = []
|
75
|
+
},
|
76
|
+
|
77
|
+
paginateIndex(page) {
|
78
|
+
console.log("store page: ", page)
|
79
|
+
this.index.pagination.page = page
|
80
|
+
//this.fetch(this.url.admin("descriptors").paginate(this.pagination.page))
|
81
|
+
},
|
82
|
+
|
83
|
+
/*
|
84
|
+
fetchDescriptorList() {
|
85
|
+
this.http.get(this.url.admin("descriptors/list")).then(result => {
|
86
|
+
this.list = result.map(descriptor => {
|
87
|
+
descriptor.active = false
|
88
|
+
return descriptor
|
89
|
+
})
|
90
|
+
})
|
91
|
+
},
|
92
|
+
|
93
|
+
/**
|
94
|
+
* @description This action is used to reset descriptor object
|
95
|
+
* /
|
96
|
+
|
97
|
+
|
98
|
+
/**
|
99
|
+
* @description This action is used to create a descriptor
|
100
|
+
* /
|
101
|
+
|
102
|
+
|
103
|
+
/**
|
104
|
+
* @description This action is used to update a descriptor
|
105
|
+
* /
|
106
|
+
updateDescriptor(){
|
107
|
+
this.loading = true
|
108
|
+
this.http.put(this.url.admin("descriptors/:id", this.descriptor.id), { descriptor: this.descriptor }).then(result => {
|
109
|
+
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
110
|
+
this.loading = false
|
111
|
+
}).catch(error => {
|
112
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
113
|
+
})
|
114
|
+
|
115
|
+
},
|
116
|
+
/**
|
117
|
+
* @description This action is used to sort the results
|
118
|
+
* /
|
119
|
+
sortIndex(column, direction) {
|
120
|
+
this.fetch(this.url.admin("descriptors").order(column, direction))
|
121
|
+
},
|
122
|
+
/**
|
123
|
+
* @description This action is used to search
|
124
|
+
* @param {string} search_string
|
125
|
+
* /
|
126
|
+
search(search_string) {
|
127
|
+
this.fetch(this.url.admin("descriptors").search(search_string))
|
128
|
+
},
|
129
|
+
/**
|
130
|
+
* @description This action is used to paginate index
|
131
|
+
* @param {string} page actual page
|
132
|
+
* /
|
133
|
+
paginateIndex(page) {
|
134
|
+
this.pagination.page = page
|
135
|
+
this.fetch(this.url.admin("descriptors").paginate(this.pagination.page))
|
136
|
+
},
|
137
|
+
/**
|
138
|
+
* @description This action is used to get descriptors as options
|
139
|
+
* /
|
140
|
+
getDescriptorsOptions(){
|
141
|
+
this.loading = true
|
142
|
+
this.descriptors_options = []
|
143
|
+
this.http.get(this.url.admin("descriptors/list")).then(result => {
|
144
|
+
result.forEach((descriptor)=>{
|
145
|
+
this.descriptors_options.push({
|
146
|
+
label: descriptor.name,
|
147
|
+
value: descriptor.id
|
148
|
+
})
|
149
|
+
})
|
150
|
+
|
151
|
+
this.loading = false
|
152
|
+
})
|
153
|
+
},
|
154
|
+
*/
|
155
|
+
}
|
156
|
+
})
|
@@ -0,0 +1,203 @@
|
|
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 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
|
+
import { useRouter } from "vue-router"
|
36
|
+
|
37
|
+
|
38
|
+
// · initialize/inject plugins
|
39
|
+
const router = useRouter()
|
40
|
+
|
41
|
+
|
42
|
+
// ·
|
43
|
+
export const useRole = defineStore("guard.role", {
|
44
|
+
state: () => {
|
45
|
+
return {
|
46
|
+
loading: false,
|
47
|
+
router: useRouter(),
|
48
|
+
role: {
|
49
|
+
name: ""
|
50
|
+
},
|
51
|
+
|
52
|
+
options: {},
|
53
|
+
descriptors: [],
|
54
|
+
descriptorsCustom: [],
|
55
|
+
descriptorSearchString: '',
|
56
|
+
|
57
|
+
privileges: [],
|
58
|
+
}
|
59
|
+
},
|
60
|
+
actions: {
|
61
|
+
|
62
|
+
getRole(id) {
|
63
|
+
this.loading = true
|
64
|
+
this.http.get(this.url.guard("roles/:id", id)).then(result => {
|
65
|
+
this.role = result
|
66
|
+
this.getDescriptors()
|
67
|
+
this.loading = false
|
68
|
+
})
|
69
|
+
},
|
70
|
+
|
71
|
+
postRole() {
|
72
|
+
this.role.loading = true
|
73
|
+
this.http.post(this.url.guard("roles"), this.role).then(result => {
|
74
|
+
//msg.success(translations.core.roles.messages_success_role_created_successfully)
|
75
|
+
this.router.push(this.url.guard("roles/:id/edit", result.id).s)
|
76
|
+
}).catch(error => {
|
77
|
+
console.log(error)
|
78
|
+
}).finally(() => {
|
79
|
+
this.role.loading = false
|
80
|
+
})
|
81
|
+
},
|
82
|
+
|
83
|
+
putRole() {
|
84
|
+
this.role.loading = true
|
85
|
+
this.http.put(this.url.admin("roles/:id", this.role.id), this.role).then(result => {
|
86
|
+
this.msg.success(I18n.t('core.roles.messages_success_role_successfully_updated'))
|
87
|
+
}).finally(() => {
|
88
|
+
this.role.loading = false
|
89
|
+
})
|
90
|
+
},
|
91
|
+
|
92
|
+
searchDescriptors(string) {
|
93
|
+
this.descriptorSearchString = string
|
94
|
+
this.getDescriptors()
|
95
|
+
},
|
96
|
+
|
97
|
+
getDescriptors() {
|
98
|
+
|
99
|
+
let url = this.url.guard("roles/:id/descriptors", this.role.id)
|
100
|
+
|
101
|
+
if (this.descriptorSearchString != '') {
|
102
|
+
url = url.search(this.descriptorSearchString)
|
103
|
+
}
|
104
|
+
|
105
|
+
this.http.get(url).then(descriptors => {
|
106
|
+
this.descriptors = descriptors
|
107
|
+
})
|
108
|
+
},
|
109
|
+
|
110
|
+
postDescriptor(descriptor) {
|
111
|
+
this.http.post(this.url.guard("roles/:id/descriptors", this.role.id), {
|
112
|
+
role_descriptor: {
|
113
|
+
id: descriptor.id
|
114
|
+
}
|
115
|
+
})
|
116
|
+
},
|
117
|
+
|
118
|
+
deleteDescriptor(descriptor) {
|
119
|
+
|
120
|
+
this.http.delete(this.url.guard("roles/:id/descriptors/:descriptor_id", {
|
121
|
+
id: this.role.id,
|
122
|
+
descriptor_id: descriptor.id
|
123
|
+
})).then(result => {
|
124
|
+
console.log(result)
|
125
|
+
}).catch(error => {
|
126
|
+
console.log(error)
|
127
|
+
})
|
128
|
+
},
|
129
|
+
|
130
|
+
getPrivileges() {
|
131
|
+
|
132
|
+
let url = this.url.guard("roles/:id/privileges", this.role.id)
|
133
|
+
|
134
|
+
this.http.get(url).then(descriptors => {
|
135
|
+
this.privileges = descriptors
|
136
|
+
}).catch(error => {
|
137
|
+
console.log(error)
|
138
|
+
})
|
139
|
+
},
|
140
|
+
updatePrivilege(descriptor) {
|
141
|
+
this.http.put(this.url.guard("roles/:id/descriptors/:descriptor_id", {
|
142
|
+
id: this.role.id,
|
143
|
+
descriptor_id: descriptor.id
|
144
|
+
}), {
|
145
|
+
role_descriptor: {
|
146
|
+
id: descriptor.id,
|
147
|
+
plist: descriptor.plist,
|
148
|
+
pindex: descriptor.pindex,
|
149
|
+
pshow: descriptor.pshow,
|
150
|
+
pcreate: descriptor.pcreate,
|
151
|
+
pupdate: descriptor.pupdate,
|
152
|
+
pdestroy: descriptor.pdestroy,
|
153
|
+
}
|
154
|
+
})
|
155
|
+
},
|
156
|
+
|
157
|
+
getOptions() {
|
158
|
+
this.http.get(this.url.guard("roles/options")).then(result => {
|
159
|
+
this.options = result
|
160
|
+
})
|
161
|
+
},
|
162
|
+
/**
|
163
|
+
* @description This action is used to sort the results
|
164
|
+
*/
|
165
|
+
sortIndex(column, direction) {
|
166
|
+
this.order.column = column
|
167
|
+
this.order.direction = direction
|
168
|
+
this.fetch()
|
169
|
+
},
|
170
|
+
/**
|
171
|
+
* @description This action is used to search
|
172
|
+
* @param {string} search_string
|
173
|
+
*/
|
174
|
+
search(search_string) {
|
175
|
+
this.search_string = search_string
|
176
|
+
this.fetch()
|
177
|
+
},
|
178
|
+
/**
|
179
|
+
* @description This action is used to delete a role
|
180
|
+
* @param {Integer} role_id id of the role to be deleted
|
181
|
+
*/
|
182
|
+
deleteRole(role_id){
|
183
|
+
this.http.delete(this.url.admin('roles/:id', {id: role_id})).then(result => {
|
184
|
+
this.msg.success(I18n.t("core.users.messages_success_operation"))
|
185
|
+
this.fetch()
|
186
|
+
}).catch(error => {
|
187
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
188
|
+
})
|
189
|
+
},
|
190
|
+
/**
|
191
|
+
* @description This action is used to fetch activity logs from a role
|
192
|
+
*/
|
193
|
+
fetchLogs(){
|
194
|
+
this.loading = true
|
195
|
+
this.http.get(this.url.admin('roles/:id/activities', {id: this.role.id})).then(result => {
|
196
|
+
this.role_activities = result.activities
|
197
|
+
this.loading = false
|
198
|
+
}).catch(error => {
|
199
|
+
this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
|
200
|
+
})
|
201
|
+
}
|
202
|
+
}
|
203
|
+
})
|
@@ -0,0 +1,58 @@
|
|
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 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 useRoles = defineStore("guard.roles", {
|
39
|
+
state: () => {
|
40
|
+
return {
|
41
|
+
loading: false,
|
42
|
+
pagination: {},
|
43
|
+
records: []
|
44
|
+
}
|
45
|
+
},
|
46
|
+
actions: {
|
47
|
+
get() {
|
48
|
+
this.loading = true
|
49
|
+
this.http.get(this.url.guard("roles")).then(result => {
|
50
|
+
this.records = result
|
51
|
+
}).catch(error => {
|
52
|
+
console.log(error)
|
53
|
+
}).finally(() => {
|
54
|
+
this.loading = false
|
55
|
+
})
|
56
|
+
},
|
57
|
+
}
|
58
|
+
})
|