lesli_audit 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/lesli_audit/application.js +33 -98
  3. data/app/assets/javascripts/lesli_audit/application.js.LICENSE.txt +327 -0
  4. data/app/controllers/lesli_audit/accounts_controller.rb +60 -0
  5. data/app/controllers/lesli_audit/analytics_controller.rb +0 -4
  6. data/app/controllers/lesli_audit/requests_controller.rb +60 -0
  7. data/app/controllers/lesli_audit/users_controller.rb +60 -0
  8. data/app/helpers/lesli_audit/accounts_helper.rb +4 -0
  9. data/app/helpers/lesli_audit/requests_helper.rb +4 -0
  10. data/app/helpers/lesli_audit/users_helper.rb +4 -0
  11. data/app/models/lesli_audit/account.rb +6 -0
  12. data/app/models/lesli_audit/account_request.rb +5 -0
  13. data/app/models/lesli_audit/analytic.rb +2 -2
  14. data/app/models/lesli_audit/request.rb +4 -0
  15. data/app/models/lesli_audit/user.rb +4 -0
  16. data/app/models/lesli_audit/user_request.rb +7 -0
  17. data/app/services/lesli_audit/analytic_service.rb +13 -48
  18. data/app/views/lesli_audit/accounts/_account.html.erb +2 -0
  19. data/app/views/lesli_audit/accounts/_form.html.erb +17 -0
  20. data/app/views/lesli_audit/accounts/edit.html.erb +10 -0
  21. data/app/views/lesli_audit/accounts/index.html.erb +14 -0
  22. data/app/views/lesli_audit/accounts/new.html.erb +9 -0
  23. data/app/views/lesli_audit/accounts/show.html.erb +10 -0
  24. data/app/views/lesli_audit/requests/_form.html.erb +17 -0
  25. data/app/views/lesli_audit/requests/_request.html.erb +2 -0
  26. data/app/views/lesli_audit/requests/edit.html.erb +10 -0
  27. data/app/views/lesli_audit/requests/index.html.erb +14 -0
  28. data/app/views/lesli_audit/requests/new.html.erb +9 -0
  29. data/app/views/lesli_audit/requests/show.html.erb +10 -0
  30. data/app/views/lesli_audit/users/_form.html.erb +17 -0
  31. data/app/views/lesli_audit/users/_user.html.erb +2 -0
  32. data/app/views/lesli_audit/users/edit.html.erb +10 -0
  33. data/app/views/lesli_audit/users/index.html.erb +14 -0
  34. data/app/views/lesli_audit/users/new.html.erb +9 -0
  35. data/app/views/lesli_audit/users/show.html.erb +10 -0
  36. data/config/locales/translations.en.yml +7 -0
  37. data/config/locales/translations.es.yml +7 -0
  38. data/config/routes.rb +17 -11
  39. data/db/migrate/v1.0/0803100010_create_lesli_audit_account_requests.rb +44 -0
  40. data/db/migrate/v1.0/0803110010_create_lesli_audit_user_requests.rb +46 -0
  41. data/db/seed/development.rb +31 -24
  42. data/lib/lesli_audit/version.rb +2 -2
  43. data/lib/vue/apps/analytics/index.vue +3 -7
  44. data/lib/vue/components/requests.vue +0 -6
  45. data/lib/vue/components/visitors.vue +3 -0
  46. data/lib/vue/stores/analytics.js +0 -35
  47. data/lib/vue/stores/translations.json +38 -0
  48. data/readme.md +44 -93
  49. metadata +37 -3
  50. data/lib/vue/components/resources.vue +0 -73
@@ -0,0 +1,17 @@
1
+ <%= form_with(model: account) do |form| %>
2
+ <% if account.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(account.errors.count, "error") %> prohibited this account from being saved:</h2>
5
+
6
+ <ul>
7
+ <% account.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,10 @@
1
+ <h1>Editing account</h1>
2
+
3
+ <%= render "form", account: @account %>
4
+
5
+ <br>
6
+
7
+ <div>
8
+ <%= link_to "Show this account", @account %> |
9
+ <%= link_to "Back to accounts", accounts_path %>
10
+ </div>
@@ -0,0 +1,14 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <h1>Accounts</h1>
4
+
5
+ <div id="accounts">
6
+ <% @accounts.each do |account| %>
7
+ <%= render account %>
8
+ <p>
9
+ <%= link_to "Show this account", account %>
10
+ </p>
11
+ <% end %>
12
+ </div>
13
+
14
+ <%= link_to "New account", new_account_path %>
@@ -0,0 +1,9 @@
1
+ <h1>New account</h1>
2
+
3
+ <%= render "form", account: @account %>
4
+
5
+ <br>
6
+
7
+ <div>
8
+ <%= link_to "Back to accounts", accounts_path %>
9
+ </div>
@@ -0,0 +1,10 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <%= render @account %>
4
+
5
+ <div>
6
+ <%= link_to "Edit this account", edit_account_path(@account) %> |
7
+ <%= link_to "Back to accounts", accounts_path %>
8
+
9
+ <%= button_to "Destroy this account", @account, method: :delete %>
10
+ </div>
@@ -0,0 +1,17 @@
1
+ <%= form_with(model: request) do |form| %>
2
+ <% if request.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(request.errors.count, "error") %> prohibited this request from being saved:</h2>
5
+
6
+ <ul>
7
+ <% request.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,2 @@
1
+ <div id="<%= dom_id request %>">
2
+ </div>
@@ -0,0 +1,10 @@
1
+ <h1>Editing request</h1>
2
+
3
+ <%= render "form", request: @request %>
4
+
5
+ <br>
6
+
7
+ <div>
8
+ <%= link_to "Show this request", @request %> |
9
+ <%= link_to "Back to requests", requests_path %>
10
+ </div>
@@ -0,0 +1,14 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <h1>Requests</h1>
4
+
5
+ <div id="requests">
6
+ <% @requests.each do |request| %>
7
+ <%= render request %>
8
+ <p>
9
+ <%= link_to "Show this request", request %>
10
+ </p>
11
+ <% end %>
12
+ </div>
13
+
14
+ <%= link_to "New request", new_request_path %>
@@ -0,0 +1,9 @@
1
+ <h1>New request</h1>
2
+
3
+ <%= render "form", request: @request %>
4
+
5
+ <br>
6
+
7
+ <div>
8
+ <%= link_to "Back to requests", requests_path %>
9
+ </div>
@@ -0,0 +1,10 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <%= render @request %>
4
+
5
+ <div>
6
+ <%= link_to "Edit this request", edit_request_path(@request) %> |
7
+ <%= link_to "Back to requests", requests_path %>
8
+
9
+ <%= button_to "Destroy this request", @request, method: :delete %>
10
+ </div>
@@ -0,0 +1,17 @@
1
+ <%= form_with(model: user) do |form| %>
2
+ <% if user.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:</h2>
5
+
6
+ <ul>
7
+ <% user.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,2 @@
1
+ <div id="<%= dom_id user %>">
2
+ </div>
@@ -0,0 +1,10 @@
1
+ <h1>Editing user</h1>
2
+
3
+ <%= render "form", user: @user %>
4
+
5
+ <br>
6
+
7
+ <div>
8
+ <%= link_to "Show this user", @user %> |
9
+ <%= link_to "Back to users", users_path %>
10
+ </div>
@@ -0,0 +1,14 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <h1>Users</h1>
4
+
5
+ <div id="users">
6
+ <% @users.each do |user| %>
7
+ <%= render user %>
8
+ <p>
9
+ <%= link_to "Show this user", user %>
10
+ </p>
11
+ <% end %>
12
+ </div>
13
+
14
+ <%= link_to "New user", new_user_path %>
@@ -0,0 +1,9 @@
1
+ <h1>New user</h1>
2
+
3
+ <%= render "form", user: @user %>
4
+
5
+ <br>
6
+
7
+ <div>
8
+ <%= link_to "Back to users", users_path %>
9
+ </div>
@@ -0,0 +1,10 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <%= render @user %>
4
+
5
+ <div>
6
+ <%= link_to "Edit this user", edit_user_path(@user) %> |
7
+ <%= link_to "Back to users", users_path %>
8
+
9
+ <%= button_to "Destroy this user", @user, method: :delete %>
10
+ </div>
@@ -0,0 +1,7 @@
1
+ ---
2
+ :en:
3
+ lesli_audit:
4
+ shared:
5
+ title_lesli: ":lesli.shared.title_lesli:"
6
+ users:
7
+ title_users: Users
@@ -0,0 +1,7 @@
1
+ ---
2
+ :es:
3
+ lesli_audit:
4
+ shared:
5
+ title_lesli: 'Lesli en español '
6
+ users:
7
+ title_users: Usuarios
data/config/routes.rb CHANGED
@@ -31,6 +31,9 @@ Building a better future, one line of code at a time.
31
31
  =end
32
32
 
33
33
  LesliAudit::Engine.routes.draw do
34
+
35
+
36
+ # Dashboard alias
34
37
  root to: "dashboards#show"
35
38
 
36
39
 
@@ -41,32 +44,35 @@ LesliAudit::Engine.routes.draw do
41
44
  # Trends
42
45
  resource :dashboard, only: [:show]
43
46
 
47
+
44
48
  # Users:
45
49
  # Registrations users grouped by creation date
46
50
  # Working hours first and last request of the day
47
51
  # Activities changes on users information
48
52
  # Roles total users by role
49
53
  # Logs relevant actions of users
50
- # resources :users, only: []
51
-
52
- # Account:
53
- # Activities changes on account information
54
- # Logs relevant actions of the account
55
- # resources :account, only: []
54
+ resources :users, only: []
56
55
 
57
- # Requests: Raw request data
58
- # resources :request, only: []
59
56
 
60
57
  # Analytics:
61
- #
62
58
  resources :analytics, only: [:index] do
63
59
  collection do
64
60
  get :trends
65
- get :resourcess
66
- get :visitors
67
61
  get :controllers
62
+ get :visitors
68
63
  get :devices
69
64
  get :users
70
65
  end
71
66
  end
67
+
68
+
69
+ # Account:
70
+ # Activities changes on account information
71
+ # Logs relevant actions of the account
72
+ resources :account, only: []
73
+
74
+
75
+ # Requests: Raw request data
76
+ resources :request, only: []
77
+
72
78
  end
@@ -0,0 +1,44 @@
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 Development Platform.
21
+
22
+ Made with ♥ by https://www.lesli.tech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ =end
32
+
33
+ class CreateLesliAuditAccountRequests < ActiveRecord::Migration[6.0]
34
+ def change
35
+ create_table :lesli_audit_account_requests do |t|
36
+ t.string :request_controller
37
+ t.string :request_action
38
+ t.integer :request_count
39
+ t.date :created_at
40
+ end
41
+ add_reference(:lesli_audit_account_requests, :account, foreign_key: { to_table: :lesli_audit_accounts })
42
+ add_index(:lesli_audit_account_requests, %i[request_controller request_action created_at account_id], unique: true, name: "lesli_audit_account_requests_index")
43
+ end
44
+ end
@@ -0,0 +1,46 @@
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 Development Platform.
21
+
22
+ Made with ♥ by https://www.lesli.tech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ =end
32
+
33
+ class CreateLesliAuditUserRequests < ActiveRecord::Migration[6.0]
34
+ def change
35
+ create_table :lesli_audit_user_requests do |t|
36
+ t.string :request_controller
37
+ t.string :request_action
38
+ t.integer :request_count
39
+ t.date :created_at
40
+ end
41
+ add_reference(:lesli_audit_user_requests, :user, foreign_key: { to_table: :lesli_users })
42
+ add_reference(:lesli_audit_user_requests, :session, foreign_key: { to_table: :lesli_user_sessions })
43
+ add_reference(:lesli_audit_user_requests, :account, foreign_key: { to_table: :lesli_audit_accounts })
44
+ add_index(:lesli_audit_user_requests, %i[request_controller request_action created_at user_id session_id], unique: true, name: "lesli_audit_user_requests_index")
45
+ end
46
+ end
@@ -40,28 +40,35 @@ start_date = 10.days.ago.to_date
40
40
 
41
41
  account = Lesli::Account.first
42
42
 
43
- user = Lesli::User.first
44
-
45
- session = user.sessions.first
46
-
47
- # Iterate through the dates
48
- (start_date..end_date).each do |date|
49
-
50
- Lesli::Account::Request.create_with(
51
- :request_method => "show",
52
- :request_count => rand(1..100),
53
- ).find_or_create_by(
54
- :request_controller => "lesli_audit/dashboards",
55
- :request_action => "show",
56
- :created_at => date,
57
- :account => account
58
- )
59
-
60
- Lesli::User::Request.create_with(
61
- :request_count => rand(1..100)
62
- ).find_or_create_by(
63
- :created_at => date,
64
- :session => session,
65
- :user => user
66
- )
43
+ current_user = Lesli::User.first
44
+
45
+ session = current_user.sessions.first
46
+
47
+ # controllers to seed
48
+ [
49
+ "lesli_audit/dashboards",
50
+ "lesli_audit/analytics"
51
+ ].each do |controller|
52
+
53
+ # Iterate through the dates
54
+ (start_date..end_date).each do |date|
55
+
56
+ current_user.account.audit.account_requests.create_with(
57
+ :request_count => rand(40..80),
58
+ ).find_or_create_by(
59
+ :request_controller => controller,
60
+ :request_action => "show",
61
+ :created_at => date,
62
+ )
63
+
64
+ current_user.account.audit.user_requests.create_with(
65
+ :request_count => rand(40..80),
66
+ ).find_or_create_by(
67
+ :request_controller => controller,
68
+ :request_action => "show",
69
+ :created_at => date,
70
+ :session => session,
71
+ :user => current_user
72
+ )
73
+ end
67
74
  end
@@ -1,4 +1,4 @@
1
1
  module LesliAudit
2
- VERSION = "0.2.0"
3
- BUILD = "1696565622"
2
+ VERSION = "0.3.0"
3
+ BUILD = "1697000148"
4
4
  end
@@ -15,7 +15,6 @@ const storeAnalytics = useAnalytics()
15
15
  // ·
16
16
  import visitors from "../../components/visitors.vue";
17
17
  import requests from "../../components/requests.vue";
18
- import resources from "../../components/resources.vue";
19
18
  //import trends from "./trends.vue";
20
19
 
21
20
 
@@ -28,10 +27,8 @@ function reload() {
28
27
  // · initializing
29
28
  onMounted(() => {
30
29
  storeAnalytics.fetchVisits()
31
- setTimeout(() => storeAnalytics.fetchUsers(), 500)
32
- setTimeout(() => storeAnalytics.fetchDevices(), 1000)
33
- setTimeout(() => storeAnalytics.fetchResources(), 1500)
34
- setTimeout(() => storeAnalytics.fetchControllers(), 2000)
30
+ setTimeout(() => storeAnalytics.fetchUsers(), 600)
31
+ setTimeout(() => storeAnalytics.fetchControllers(), 1200)
35
32
  })
36
33
 
37
34
  </script>
@@ -53,8 +50,7 @@ onMounted(() => {
53
50
  ]">
54
51
  </lesli-select>
55
52
  </lesli-header>
56
- <visitors class="mb-5"></visitors>
57
- <resources class="mb-5"></resources>
53
+ <visitors class="mb-6"></visitors>
58
54
  <requests></requests>
59
55
  </lesli-application-container>
60
56
  </template>
@@ -51,12 +51,6 @@ const storeAnalytics = useAnalytics()
51
51
  :records="storeAnalytics.users.records">
52
52
  </lesli-table>
53
53
  </div>
54
- <div class="column">
55
- <lesli-table
56
- :columns="storeAnalytics.devices.columns"
57
- :records="storeAnalytics.devices.records">
58
- </lesli-table>
59
- </div>
60
54
  <div class="column">
61
55
  <lesli-table
62
56
  :columns="storeAnalytics.controllers.columns"
@@ -58,6 +58,9 @@ watch(() => storeAnalytics.visitors.records, () => {
58
58
  series.value = [{
59
59
  name: "Requests",
60
60
  data: storeAnalytics.visitors.records.map(visit => visit.requests)
61
+ }, {
62
+ name: "Resources",
63
+ data: storeAnalytics.visitors.records.map(visit => visit.resources)
61
64
  }]
62
65
  })
63
66
 
@@ -39,23 +39,6 @@ export const useAnalytics = defineStore("analytics", {
39
39
  label: 'Requests'
40
40
  }]
41
41
  },
42
- devices: {
43
- loading: false,
44
- pagination: {},
45
- records: [],
46
- columns: [{
47
- field: 'device',
48
- label: 'Device'
49
- }, {
50
- field: 'visits',
51
- label: 'Visits'
52
- }]
53
- },
54
- resources: {
55
- loading: false,
56
- pagination: {},
57
- records: []
58
- },
59
42
  visitors: {
60
43
  loading: false,
61
44
  pagination: {},
@@ -91,15 +74,6 @@ export const useAnalytics = defineStore("analytics", {
91
74
  })
92
75
  },
93
76
 
94
- fetchResources() {
95
- this.resources.loading = true
96
- this.http.get(this.url.audit("analytics/resourcess")).then(result => {
97
- this.resources.records = result.reverse()
98
- }).finally(() => {
99
- this.resources.loading = false
100
- })
101
- },
102
-
103
77
  fetchUsers() {
104
78
  this.users.loading = true
105
79
  this.http.get(this.url.audit("analytics/users")).then(result => {
@@ -109,15 +83,6 @@ export const useAnalytics = defineStore("analytics", {
109
83
  })
110
84
  },
111
85
 
112
- fetchDevices() {
113
- this.devices.loading = true
114
- this.http.get(this.url.audit("analytics/devices")).then(result => {
115
- this.devices.records = result
116
- }).finally(() => {
117
- this.devices.loading = false
118
- })
119
- },
120
-
121
86
  fetchControllers() {
122
87
  this.controllers.loading = true
123
88
  this.http.get(this.url.audit("analytics/controllers")).then(result => {
@@ -0,0 +1,38 @@
1
+ {
2
+ "en": {
3
+ "lesli": {
4
+ "shared": {
5
+ "title_lesli": ":lesli.shared.title_lesli:"
6
+ },
7
+ "users": {
8
+ "title_users": "Users"
9
+ }
10
+ },
11
+ "lesli_audit": {
12
+ "shared": {
13
+ "title_lesli": ":lesli.shared.title_lesli:"
14
+ },
15
+ "users": {
16
+ "title_users": "Users"
17
+ }
18
+ }
19
+ },
20
+ "es": {
21
+ "lesli": {
22
+ "shared": {
23
+ "title_lesli": "Lesli en español "
24
+ },
25
+ "users": {
26
+ "title_users": "Usuarios"
27
+ }
28
+ },
29
+ "lesli_audit": {
30
+ "shared": {
31
+ "title_lesli": "Lesli en español "
32
+ },
33
+ "users": {
34
+ "title_users": "Usuarios"
35
+ }
36
+ }
37
+ }
38
+ }