lesli_audit 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/lesli_audit/application.js +1994 -1735
  3. data/app/controllers/lesli_audit/dashboard/components_controller.rb +60 -0
  4. data/app/controllers/lesli_audit/dashboards_controller.rb +26 -49
  5. data/app/helpers/lesli_audit/dashboard/components_helper.rb +4 -0
  6. data/app/models/lesli_audit/account.rb +7 -0
  7. data/app/models/lesli_audit/dashboard/component.rb +18 -0
  8. data/app/models/lesli_audit/dashboard.rb +30 -2
  9. data/app/views/lesli_audit/dashboard/components/_component.html.erb +2 -0
  10. data/app/views/lesli_audit/dashboard/components/_form.html.erb +17 -0
  11. data/app/views/lesli_audit/dashboard/components/edit.html.erb +1 -0
  12. data/app/views/lesli_audit/dashboard/components/index.html.erb +14 -0
  13. data/app/views/lesli_audit/dashboard/components/new.html.erb +9 -0
  14. data/app/views/lesli_audit/dashboard/components/show.html.erb +1 -0
  15. data/app/views/lesli_audit/dashboards/edit.html.erb +1 -10
  16. data/config/locales/translations.en.yml +16 -1
  17. data/config/locales/translations.es.yml +16 -1
  18. data/config/routes.rb +13 -1
  19. data/db/seeds.rb +4 -1
  20. data/lib/lesli_audit/version.rb +1 -1
  21. data/lib/vue/application.js +43 -1
  22. data/lib/vue/apps/dashboards/components/roles.vue +71 -0
  23. data/lib/vue/apps/dashboards/components/users.vue +71 -0
  24. data/lib/vue/apps/dashboards/show.vue +8 -0
  25. data/lib/vue/components/visitors.vue +3 -3
  26. data/lib/vue/stores/translations.json +32 -22
  27. metadata +19 -8
  28. data/app/assets/javascripts/lesli_audit/application.js.LICENSE.txt +0 -327
  29. /data/db/migrate/v1.0/{0803000110_create_lesli_audit_accounts.rb → 0503000110_create_lesli_audit_accounts.rb} +0 -0
  30. /data/db/migrate/v1.0/{0803050110_create_lesli_audit_dashboards.rb → 0503050110_create_lesli_audit_dashboards.rb} +0 -0
  31. /data/db/migrate/v1.0/{0803050210_create_lesli_audit_dashboard_components.rb → 0503050210_create_lesli_audit_dashboard_components.rb} +0 -0
  32. /data/db/migrate/v1.0/{0803100010_create_lesli_audit_account_requests.rb → 0503100010_create_lesli_audit_account_requests.rb} +0 -0
  33. /data/db/migrate/v1.0/{0803110010_create_lesli_audit_user_requests.rb → 0503110010_create_lesli_audit_user_requests.rb} +0 -0
@@ -0,0 +1,60 @@
1
+ module LesliAudit
2
+ class Dashboard::ComponentsController < ApplicationController
3
+ before_action :set_dashboard_component, only: %i[ show edit update destroy ]
4
+
5
+ # GET /dashboard/components
6
+ def index
7
+ @dashboard_components = Dashboard::Component.all
8
+ end
9
+
10
+ # GET /dashboard/components/1
11
+ def show
12
+ end
13
+
14
+ # GET /dashboard/components/new
15
+ def new
16
+ @dashboard_component = Dashboard::Component.new
17
+ end
18
+
19
+ # GET /dashboard/components/1/edit
20
+ def edit
21
+ end
22
+
23
+ # POST /dashboard/components
24
+ def create
25
+ @dashboard_component = Dashboard::Component.new(dashboard_component_params)
26
+
27
+ if @dashboard_component.save
28
+ redirect_to @dashboard_component, notice: "Component was successfully created."
29
+ else
30
+ render :new, status: :unprocessable_entity
31
+ end
32
+ end
33
+
34
+ # PATCH/PUT /dashboard/components/1
35
+ def update
36
+ if @dashboard_component.update(dashboard_component_params)
37
+ redirect_to @dashboard_component, notice: "Component was successfully updated.", status: :see_other
38
+ else
39
+ render :edit, status: :unprocessable_entity
40
+ end
41
+ end
42
+
43
+ # DELETE /dashboard/components/1
44
+ def destroy
45
+ @dashboard_component.destroy
46
+ redirect_to dashboard_components_url, notice: "Component was successfully destroyed.", status: :see_other
47
+ end
48
+
49
+ private
50
+ # Use callbacks to share common setup or constraints between actions.
51
+ def set_dashboard_component
52
+ @dashboard_component = Dashboard::Component.find(params[:id])
53
+ end
54
+
55
+ # Only allow a list of trusted parameters through.
56
+ def dashboard_component_params
57
+ params.fetch(:dashboard_component, {})
58
+ end
59
+ end
60
+ end
@@ -1,59 +1,36 @@
1
- module LesliAudit
2
- class DashboardsController < ApplicationController
3
- #before_action :set_dashboard, only: %i[ show edit update destroy ]
1
+ =begin
4
2
 
5
- # GET /dashboards
6
- def index
7
- end
3
+ Lesli
8
4
 
9
- # GET /dashboards/1
10
- def show
11
- end
5
+ Copyright (c) 2023, Lesli Technologies, S. A.
12
6
 
13
- # GET /dashboards/new
14
- def new
15
- @dashboard = Dashboard.new
16
- end
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.
17
11
 
18
- # GET /dashboards/1/edit
19
- def edit
20
- end
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.
21
16
 
22
- # POST /dashboards
23
- def create
24
- @dashboard = Dashboard.new(dashboard_params)
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/.
25
19
 
26
- if @dashboard.save
27
- redirect_to @dashboard, notice: "Dashboard was successfully created."
28
- else
29
- render :new, status: :unprocessable_entity
30
- end
31
- end
20
+ Lesli · Ruby on Rails SaaS Development Framework.
32
21
 
33
- # PATCH/PUT /dashboards/1
34
- def update
35
- if @dashboard.update(dashboard_params)
36
- redirect_to @dashboard, notice: "Dashboard was successfully updated.", status: :see_other
37
- else
38
- render :edit, status: :unprocessable_entity
39
- end
40
- end
22
+ Made with ♥ by https://www.lesli.tech
23
+ Building a better future, one line of code at a time.
41
24
 
42
- # DELETE /dashboards/1
43
- def destroy
44
- @dashboard.destroy
45
- redirect_to dashboards_url, notice: "Dashboard was successfully destroyed.", status: :see_other
46
- end
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
47
32
 
48
- private
49
- # Use callbacks to share common setup or constraints between actions.
50
- def set_dashboard
51
- @dashboard = Dashboard.find(params[:id])
52
- end
53
-
54
- # Only allow a list of trusted parameters through.
55
- def dashboard_params
56
- params.fetch(:dashboard, {})
57
- end
58
- end
33
+ module LesliAudit
34
+ class DashboardsController < Lesli::Shared::DashboardsController
35
+ end
59
36
  end
@@ -0,0 +1,4 @@
1
+ module LesliAudit
2
+ module Dashboard::ComponentsHelper
3
+ end
4
+ end
@@ -3,5 +3,12 @@ module LesliAudit
3
3
  belongs_to :account, class_name: "Lesli::Account"
4
4
  has_many :account_requests
5
5
  has_many :user_requests
6
+ has_many :dashboards
7
+
8
+ after_create :initialize_account
9
+
10
+ def initialize_account
11
+ Dashboard.initialize_account(self)
12
+ end
6
13
  end
7
14
  end
@@ -0,0 +1,18 @@
1
+ module LesliAudit
2
+ class Dashboard::Component < ApplicationRecord
3
+
4
+ belongs_to :dashboard, inverse_of: :components
5
+
6
+ def self.component_ids
7
+ ["audit-users", "audit-roles"]
8
+ end
9
+ # components_ids: {
10
+ # list_new_tickets: "list_new_tickets",
11
+ # list_my_tickets: "list_my_tickets",
12
+ # list_unassigned_tickets: "list_unassigned_tickets",
13
+ # chart_tickets_by_type: "chart_tickets_by_type",
14
+ # chart_tickets_by_category: "chart_tickets_by_category",
15
+ # hours_worked: "hours_worked"
16
+ # }
17
+ end
18
+ end
@@ -1,4 +1,32 @@
1
1
  module LesliAudit
2
- class Dashboard < ApplicationRecord
3
- end
2
+ #class Dashboard < Lesli::ApplicationLesliRecord
3
+ class Dashboard < Lesli::Shared::Dashboard
4
+ self.table_name = "lesli_audit_dashboards"
5
+ belongs_to :account
6
+
7
+ has_many :components, inverse_of: :dashboard, autosave: true, dependent: :destroy
8
+ accepts_nested_attributes_for :components, allow_destroy: true
9
+
10
+ def self.initialize_account(account)
11
+ self.create!(
12
+ account: account,
13
+ name: "Audit Default Dashboard",
14
+ default: true,
15
+ main: false,
16
+ components_attributes: [{
17
+ name: "Total users",
18
+ component_id: "audit-users",
19
+ layout: 3,
20
+ query_configuration: {},
21
+ custom_configuration: {}
22
+ }, {
23
+ name: "Roles",
24
+ component_id: "audit-roles",
25
+ layout: 3,
26
+ query_configuration: {},
27
+ custom_configuration: {}
28
+ }]
29
+ )
30
+ end
31
+ end
4
32
  end
@@ -0,0 +1,2 @@
1
+ <div id="<%= dom_id component %>">
2
+ </div>
@@ -0,0 +1,17 @@
1
+ <%= form_with(model: dashboard_component) do |form| %>
2
+ <% if dashboard_component.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(dashboard_component.errors.count, "error") %> prohibited this dashboard_component from being saved:</h2>
5
+
6
+ <ul>
7
+ <% dashboard_component.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= form.submit %>
16
+ </div>
17
+ <% end %>
@@ -0,0 +1 @@
1
+ <router-view></router-view>
@@ -0,0 +1,14 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <h1>Components</h1>
4
+
5
+ <div id="dashboard_components">
6
+ <% @dashboard_components.each do |dashboard_component| %>
7
+ <%= render dashboard_component %>
8
+ <p>
9
+ <%= link_to "Show this component", dashboard_component %>
10
+ </p>
11
+ <% end %>
12
+ </div>
13
+
14
+ <%= link_to "New component", new_dashboard_component_path %>
@@ -0,0 +1,9 @@
1
+ <h1>New component</h1>
2
+
3
+ <%= render "form", dashboard_component: @dashboard_component %>
4
+
5
+ <br>
6
+
7
+ <div>
8
+ <%= link_to "Back to components", dashboard_components_path %>
9
+ </div>
@@ -0,0 +1 @@
1
+ <router-view></router-view>
@@ -1,10 +1 @@
1
- <h1>Editing dashboard</h1>
2
-
3
- <%= render "form", dashboard: @dashboard %>
4
-
5
- <br>
6
-
7
- <div>
8
- <%= link_to "Show this dashboard", @dashboard %> |
9
- <%= link_to "Back to dashboards", dashboards_path %>
10
- </div>
1
+ <router-view></router-view>
@@ -1,5 +1,20 @@
1
1
  ---
2
2
  :en:
3
- lesli_audit:
3
+ lesli:
4
4
  shared:
5
+ view_discussions: Discussions
6
+ button_add_new: Add new
7
+ button_reload: Reload
8
+ view_files: Files
9
+ view_quick_actions: Quick actions
10
+ button_list: List
5
11
  button_save: Save
12
+ button_delete: Delete
13
+ button_edit: Edit
14
+ view_status_active: Active
15
+ view_status_inactive: Inactive
16
+ button_settings: Settings
17
+ button_show: Show
18
+ application:
19
+ navigation_logout: Logout
20
+ navigation_my_profile: My profile
@@ -1,5 +1,20 @@
1
1
  ---
2
2
  :es:
3
- lesli_audit:
3
+ lesli:
4
4
  shared:
5
+ view_discussions: Discusiones
6
+ button_add_new: Agregar nuevo
7
+ button_reload: Recargar
8
+ view_files: Archivos
9
+ view_quick_actions: Acciones rapidas
10
+ button_list: Lista
5
11
  button_save: Guardar
12
+ button_delete: Eliminar
13
+ button_edit: Editar
14
+ view_status_active: Activo
15
+ view_status_inactive: Inactivo
16
+ button_settings: Configuración
17
+ button_show: Ver
18
+ application:
19
+ navigation_logout: Cerrar sesión
20
+ navigation_my_profile: Mi perfil
data/config/routes.rb CHANGED
@@ -32,7 +32,6 @@ Building a better future, one line of code at a time.
32
32
 
33
33
  LesliAudit::Engine.routes.draw do
34
34
 
35
-
36
35
  # Dashboard alias
37
36
  root to: "dashboards#show"
38
37
 
@@ -43,6 +42,15 @@ LesliAudit::Engine.routes.draw do
43
42
  # Visits
44
43
  # Trends
45
44
  resource :dashboard, only: [:show]
45
+ resources :dashboards do
46
+ collection do
47
+ post "list" => :index
48
+ get :options
49
+ end
50
+ scope module: :dashboard do
51
+ resources :components
52
+ end
53
+ end
46
54
 
47
55
 
48
56
  # Users:
@@ -57,6 +65,10 @@ LesliAudit::Engine.routes.draw do
57
65
 
58
66
 
59
67
  # Analytics:
68
+ # Visitors by date
69
+ # Trends by date
70
+ # Most active users
71
+ # Most active controllers
60
72
  resources :analytics, only: [:index] do
61
73
  collection do
62
74
  get :trends
data/db/seeds.rb CHANGED
@@ -35,6 +35,9 @@ Building a better future, one line of code at a time.
35
35
  # Seed files are only for development, if you need to create default resources
36
36
  # for production you must use the initializer method in the Engine account model
37
37
  if Rails.env.development?
38
- L2.msg("Loading seeds for LesliAudit", "Version: #{LesliAudit::VERSION}", "Build: #{LesliAudit::BUILD}")
38
+ L2.msg(
39
+ "LesliAudit",
40
+ "Version: #{LesliAudit::VERSION}",
41
+ "Build: #{LesliAudit::BUILD}")
39
42
  load(LesliAudit::Engine.root.join("db", "seed", "#{ Rails.env.downcase }.rb"))
40
43
  end
@@ -1,4 +1,4 @@
1
1
  module LesliAudit
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  BUILD = "1697000148"
4
4
  end
@@ -30,12 +30,24 @@ Building a better future, one line of code at a time.
30
30
  */
31
31
 
32
32
 
33
- // ·
33
+ // · Import Lesli builders
34
34
  import application from "Lesli/application"
35
+ import translation from "Lesli/translation"
36
+
37
+
38
+ // · Import engine translations
39
+ import translations from "LesliAudit/stores/translations.json"
40
+
41
+
42
+ // ·
35
43
  import appAnalytics from "LesliAudit/apps/analytics/index.vue"
36
44
  import appRequests from "LesliAudit/apps/requests/index.vue"
37
45
  import appUsers from "LesliAudit/apps/users/index.vue"
38
46
 
47
+ //import appDashboardShow from "LesliAudit/apps/dashboards/show.vue"
48
+ import appDashboardShow from "Lesli/shared/dashboards/apps/show.vue"
49
+ import appDashboardEdit from "Lesli/shared/dashboards/apps/edit.vue"
50
+
39
51
  // ·
40
52
  /*
41
53
  import dashboard from "Lesli/shared/dashboards/apps/show.vue"
@@ -56,7 +68,37 @@ import appSecurityPasswords from "CloudAudit/apps/security/passwords.vue"
56
68
 
57
69
 
58
70
  // ·
71
+ import componentDashboardUsers from "LesliAudit/apps/dashboards/components/users.vue"
72
+ import componentDashboardRoles from "LesliAudit/apps/dashboards/components/roles.vue"
73
+
74
+
75
+ // ·
76
+ const dashboardProps = {
77
+ components: {
78
+ "audit-users": componentDashboardUsers,
79
+ "audit-roles": componentDashboardRoles
80
+ }
81
+ }
82
+
83
+
84
+ // · Buil Lesli translations
85
+ translation(translations)
86
+
87
+
88
+ // · Build a new Lesli application
59
89
  application("LesliAudit", [{
90
+ path: "/",
91
+ component: appDashboardShow,
92
+ props: dashboardProps
93
+ }, {
94
+ path: "/dashboard",
95
+ component: appDashboardShow,
96
+ props: dashboardProps
97
+ }, {
98
+ path: "/dashboards/:id/edit",
99
+ component: appDashboardEdit,
100
+ props: dashboardProps
101
+ }, {
60
102
  path: "/analytics",
61
103
  component: appAnalytics,
62
104
  props: { engine: "audit" }
@@ -0,0 +1,71 @@
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
+ // ·
35
+ import { onMounted } from "vue"
36
+
37
+
38
+ // ·
39
+ import { useUsers } from "Lesli/stores/users"
40
+
41
+
42
+ // ·
43
+ const storeUsers = useUsers()
44
+
45
+
46
+ // ·
47
+ const props = defineProps({
48
+ component: {
49
+ type: Object,
50
+ required: true
51
+ }
52
+ })
53
+
54
+
55
+ // ·
56
+ onMounted(() => {
57
+ storeUsers.getUsersList()
58
+ })
59
+
60
+ </script>
61
+ <template>
62
+ <lesli-card>
63
+ <h6 class="title is-6 mb-4">{{ props.component.name }}</h6>
64
+ <p>{{ storeUsers.list.length }}</p>
65
+ </lesli-card>
66
+ </template>
67
+ <style scoped>
68
+ p {
69
+ font-size: 2rem;
70
+ }
71
+ </style>
@@ -0,0 +1,71 @@
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
+ // ·
35
+ import { onMounted } from "vue"
36
+
37
+
38
+ // ·
39
+ import { useUsers } from "Lesli/stores/users"
40
+
41
+
42
+ // ·
43
+ const storeUsers = useUsers()
44
+
45
+
46
+ // ·
47
+ const props = defineProps({
48
+ component: {
49
+ type: Object,
50
+ required: true
51
+ }
52
+ })
53
+
54
+
55
+ // ·
56
+ onMounted(() => {
57
+ storeUsers.getUsersList()
58
+ })
59
+
60
+ </script>
61
+ <template>
62
+ <lesli-card>
63
+ <h6 class="title is-6 mb-4">{{ props.component.name }}</h6>
64
+ <p>{{ storeUsers.list.length }}</p>
65
+ </lesli-card>
66
+ </template>
67
+ <style scoped>
68
+ p {
69
+ font-size: 2rem;
70
+ }
71
+ </style>
@@ -0,0 +1,8 @@
1
+ <script setup>
2
+
3
+ import LesliDashboard from "Lesli/shared/dashboards/apps/show.vue"
4
+
5
+ </script>
6
+ <template>
7
+ <lesli-dashboard></lesli-dashboard>
8
+ </template>
@@ -36,7 +36,7 @@ import { ref, reactive, onMounted, watch, computed } from "vue"
36
36
 
37
37
 
38
38
  // · import Lesli components
39
- import { lesliChartLine } from "lesli-vue/components"
39
+ import { ChartLine } from "lesli-vue/components"
40
40
 
41
41
 
42
42
  // · import stores
@@ -67,10 +67,10 @@ watch(() => storeAnalytics.visitors.records, () => {
67
67
  </script>
68
68
  <template>
69
69
  <lesli-application-component>
70
- <lesli-chart-line
70
+ <chart-line
71
71
  :title="'Visitors'"
72
72
  :series="series"
73
73
  :labels="labels">
74
- </lesli-chart-line>
74
+ </chart-line>
75
75
  </lesli-application-component>
76
76
  </template>