lesli_audit 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +5 -0
- data/app/assets/config/lesli_audit_manifest.js +38 -0
- data/app/assets/images/lesli_audit/audit-logo.svg +72 -0
- data/app/assets/javascripts/lesli_audit/application.js +3592 -0
- data/app/assets/stylesheets/lesli_audit/application.scss +35 -0
- data/app/assets/stylesheets/lesli_audit/dashboard.scss +0 -0
- data/app/controllers/lesli_audit/analytics_controller.rb +36 -0
- data/app/controllers/lesli_audit/application_controller.rb +4 -0
- data/app/controllers/lesli_audit/dashboards_controller.rb +59 -0
- data/app/helpers/lesli_audit/analytics_helper.rb +4 -0
- data/app/helpers/lesli_audit/application_helper.rb +4 -0
- data/app/helpers/lesli_audit/dashboards_helper.rb +4 -0
- data/app/jobs/lesli_audit/application_job.rb +4 -0
- data/app/mailers/lesli_audit/application_mailer.rb +6 -0
- data/app/models/lesli_audit/analytic.rb +4 -0
- data/app/models/lesli_audit/application_record.rb +5 -0
- data/app/models/lesli_audit/dashboard.rb +4 -0
- data/app/services/lesli_audit/account/activity_services.rb +69 -0
- data/app/services/lesli_audit/analytic_service.rb +151 -0
- data/app/services/lesli_audit/analytics/trend_services.rb +84 -0
- data/app/services/lesli_audit/analytics/visitor_service.rb +166 -0
- data/app/services/lesli_audit/request_services.rb +71 -0
- data/app/services/lesli_audit/users/activity_services.rb +61 -0
- data/app/services/lesli_audit/users/log_services.rb +62 -0
- data/app/services/lesli_audit/users/registration_services.rb +62 -0
- data/app/services/lesli_audit/users/role_services.rb +61 -0
- data/app/services/lesli_audit/users/working_hour_services.rb +78 -0
- data/app/views/lesli_audit/analytics/_analytic.html.erb +2 -0
- data/app/views/lesli_audit/analytics/_form.html.erb +17 -0
- data/app/views/lesli_audit/analytics/edit.html.erb +10 -0
- data/app/views/lesli_audit/analytics/index.html.erb +1 -0
- data/app/views/lesli_audit/analytics/new.html.erb +9 -0
- data/app/views/lesli_audit/analytics/show.html.erb +10 -0
- data/app/views/lesli_audit/dashboards/_dashboard.html.erb +2 -0
- data/app/views/lesli_audit/dashboards/_form.html.erb +17 -0
- data/app/views/lesli_audit/dashboards/edit.html.erb +10 -0
- data/app/views/lesli_audit/dashboards/index.html.erb +14 -0
- data/app/views/lesli_audit/dashboards/new.html.erb +9 -0
- data/app/views/lesli_audit/dashboards/show.html.erb +1 -0
- data/app/views/lesli_audit/partials/_engine-navigation.html.erb +39 -0
- data/config/routes.rb +45 -0
- data/db/migrate/v1.0/0803000110_create_lesli_audit_accounts.rb +42 -0
- data/db/migrate/v1.0/0803050110_create_lesli_audit_dashboards.rb +51 -0
- data/db/migrate/v1.0/0803050210_create_lesli_audit_dashboard_components.rb +53 -0
- data/lib/lesli_audit/engine.rb +18 -0
- data/lib/lesli_audit/version.rb +3 -0
- data/lib/lesli_audit.rb +6 -0
- data/lib/tasks/lesli_audit_tasks.rake +4 -0
- data/lib/vue/application.js +102 -0
- data/lib/vue/apps/accounts/activities.vue +48 -0
- data/lib/vue/apps/analytics/index.vue +18 -0
- data/lib/vue/apps/analytics/requests.vue +67 -0
- data/lib/vue/apps/analytics/trends.vue +149 -0
- data/lib/vue/apps/analytics/visitors.vue +91 -0
- data/lib/vue/apps/requests/index.vue +123 -0
- data/lib/vue/apps/security/passwords.vue +52 -0
- data/lib/vue/apps/security/sessions.vue +63 -0
- data/lib/vue/apps/users/activities.vue +49 -0
- data/lib/vue/apps/users/logs.vue +49 -0
- data/lib/vue/apps/users/registrations.vue +98 -0
- data/lib/vue/apps/users/roles.vue +70 -0
- data/lib/vue/apps/users/workingHours.vue +52 -0
- data/lib/vue/stores/accounts/activities.js +87 -0
- data/lib/vue/stores/analytics/visitors.js +130 -0
- data/lib/vue/stores/request.js +70 -0
- data/lib/vue/stores/security/password.js +75 -0
- data/lib/vue/stores/security/session.js +78 -0
- data/lib/vue/stores/users/activities.js +76 -0
- data/lib/vue/stores/users/logs.js +74 -0
- data/lib/vue/stores/users/registrations.js +61 -0
- data/lib/vue/stores/users/roles.js +52 -0
- data/lib/vue/stores/users/working_hours.js +92 -0
- data/license +674 -0
- data/readme.md +120 -0
- metadata +134 -0
@@ -0,0 +1,51 @@
|
|
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
|
+
class CreateLesliAuditDashboards < ActiveRecord::Migration[6.1]
|
34
|
+
def change
|
35
|
+
gem_path = Lesli::System.engine("Lesli", "dir")
|
36
|
+
table_base_structure = JSON.parse(File.read(File.join(gem_path, "db", "structure", "00000501_dashboards.json")))
|
37
|
+
create_table :lesli_audit_dashboards do |t|
|
38
|
+
table_base_structure.each do |column|
|
39
|
+
t.send(
|
40
|
+
column["type"].parameterize.underscore.to_sym,
|
41
|
+
column["name"].parameterize.underscore.to_sym
|
42
|
+
)
|
43
|
+
end
|
44
|
+
t.timestamps
|
45
|
+
end
|
46
|
+
|
47
|
+
add_reference(:lesli_audit_dashboards, :account, foreign_key: { to_table: :lesli_audit_accounts })
|
48
|
+
add_reference(:lesli_audit_dashboards, :user, foreign_key: { to_table: :lesli_users })
|
49
|
+
#add_reference(:lesli_audit_dashboards, :role, foreign_key: { to_table: :roles })
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,53 @@
|
|
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
|
+
class CreateLesliAuditDashboardComponents < ActiveRecord::Migration[6.1]
|
34
|
+
def change
|
35
|
+
gem_path = Lesli::System.engine("Lesli", "dir")
|
36
|
+
table_base_structure = JSON.parse(File.read(File.join(gem_path, "db", "structure", "00000502_dashboard_components.json")))
|
37
|
+
create_table :lesli_audit_dashboard_components do |t|
|
38
|
+
table_base_structure.each do |column|
|
39
|
+
t.send(
|
40
|
+
column["type"].parameterize.underscore.to_sym,
|
41
|
+
column["name"].parameterize.underscore.to_sym
|
42
|
+
)
|
43
|
+
end
|
44
|
+
t.timestamps
|
45
|
+
end
|
46
|
+
|
47
|
+
add_reference(
|
48
|
+
:lesli_audit_dashboard_components, :dashboard,
|
49
|
+
foreign_key: { to_table: :lesli_audit_dashboards },
|
50
|
+
index: { name: "lesli_audit_dashboard_components_dashboards" }
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module LesliAudit
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace LesliAudit
|
4
|
+
|
5
|
+
initializer :lesli_admin do |app|
|
6
|
+
|
7
|
+
# register assets manifest
|
8
|
+
config.assets.precompile += %w[lesli_audit_manifest.js]
|
9
|
+
|
10
|
+
# register engine migrations path
|
11
|
+
unless app.root.to_s.match root.to_s
|
12
|
+
config.paths["db/migrate"].expanded.each do |expanded_path|
|
13
|
+
app.config.paths["db/migrate"] << expanded_path
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/lesli_audit.rb
ADDED
@@ -0,0 +1,102 @@
|
|
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 application from "Lesli/application"
|
35
|
+
|
36
|
+
import appAnalytics from "LesliAudit/apps/analytics/index.vue"
|
37
|
+
|
38
|
+
// ·
|
39
|
+
/*
|
40
|
+
import dashboard from "Lesli/shared/dashboards/apps/show.vue"
|
41
|
+
import appUsersRegistrations from "CloudAudit/apps/users/registrations.vue"
|
42
|
+
import appUsersWorkingHours from "CloudAudit/apps/users/workingHours.vue"
|
43
|
+
import appUsersActivities from "CloudAudit/apps/users/activities.vue"
|
44
|
+
import appUsersLogs from "CloudAudit/apps/users/logs.vue"
|
45
|
+
import appUsersRoles from "CloudAudit/apps/users/roles.vue"
|
46
|
+
|
47
|
+
import appAnalyticsVisitors from "CloudAudit/apps/analytics/visitors.vue"
|
48
|
+
import appAnalyticsTrends from "CloudAudit/apps/analytics/trends.vue"
|
49
|
+
|
50
|
+
import appAccountsActivities from "CloudAudit/apps/accounts/activities.vue"
|
51
|
+
|
52
|
+
import appSecuritySessions from "CloudAudit/apps/security/sessions.vue"
|
53
|
+
import appSecurityPasswords from "CloudAudit/apps/security/passwords.vue"
|
54
|
+
|
55
|
+
import appRequests from "CloudAudit/apps/requests/index.vue"
|
56
|
+
*/
|
57
|
+
|
58
|
+
|
59
|
+
// ·
|
60
|
+
application("LesliAudit", [{
|
61
|
+
path: "/analytics",
|
62
|
+
component: appAnalytics,
|
63
|
+
props: { engine: "audit" }
|
64
|
+
}
|
65
|
+
/*{
|
66
|
+
path: "/",
|
67
|
+
component: dashboard,
|
68
|
+
props: { engine: "audit" }
|
69
|
+
}, {
|
70
|
+
path: "/users/working_hours",
|
71
|
+
component: appUsersWorkingHours,
|
72
|
+
}, {
|
73
|
+
path: "/users/activities",
|
74
|
+
component: appUsersActivities,
|
75
|
+
}, {
|
76
|
+
path: "/users/logs",
|
77
|
+
component: appUsersLogs,
|
78
|
+
}, {
|
79
|
+
path: "/users/registrations",
|
80
|
+
component: appUsersRegistrations,
|
81
|
+
}, {
|
82
|
+
path: "/users/roles",
|
83
|
+
component: appUsersRoles,
|
84
|
+
}, {
|
85
|
+
path: "/accounts/activities",
|
86
|
+
component: appAccountsActivities,
|
87
|
+
}, {
|
88
|
+
path: "/analytics/visitors",
|
89
|
+
component: appAnalyticsVisitors,
|
90
|
+
}, {
|
91
|
+
path: "/analytics/trends",
|
92
|
+
component: appAnalyticsTrends
|
93
|
+
}, {
|
94
|
+
path: "/requests",
|
95
|
+
component: appRequests
|
96
|
+
}, {
|
97
|
+
path: "/security/sessions",
|
98
|
+
component: appSecuritySessions
|
99
|
+
}, {
|
100
|
+
path: "/security/passwords",
|
101
|
+
component: appSecurityPasswords
|
102
|
+
}*/])
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<script setup>
|
2
|
+
/*
|
3
|
+
Copyright (c) 2022, all rights reserved.
|
4
|
+
|
5
|
+
All the information provided by this platform is protected by international laws related to
|
6
|
+
industrial property, intellectual property, copyright and relative international laws.
|
7
|
+
All intellectual or industrial property rights of the code, texts, trade mark, design,
|
8
|
+
pictures and any other information belongs to the owner of this platform.
|
9
|
+
|
10
|
+
Without the written permission of the owner, any replication, modification,
|
11
|
+
transmission, publication is strictly forbidden.
|
12
|
+
|
13
|
+
For more information read the license file including with this software.
|
14
|
+
|
15
|
+
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
16
|
+
// ·
|
17
|
+
*/
|
18
|
+
|
19
|
+
|
20
|
+
// · import vue tools
|
21
|
+
import { ref, reactive, onMounted, watch, computed } from "vue"
|
22
|
+
|
23
|
+
|
24
|
+
// · import stores
|
25
|
+
import { useAccountsActivities } from "CloudAudit/stores/accounts/activities"
|
26
|
+
|
27
|
+
|
28
|
+
// · implement stores
|
29
|
+
const storeAccountsActivities = useAccountsActivities()
|
30
|
+
|
31
|
+
|
32
|
+
// · initializing
|
33
|
+
onMounted(() => {
|
34
|
+
storeAccountsActivities.fetchIfEmpty()
|
35
|
+
})
|
36
|
+
|
37
|
+
</script>
|
38
|
+
<template>
|
39
|
+
<section class="application-component">
|
40
|
+
<lesli-header title="Account activities"></lesli-header>
|
41
|
+
<lesli-toolbar @reload="storeAccountsActivities.fetch()" @search="storeAccountsActivities.search"></lesli-toolbar>
|
42
|
+
<lesli-table
|
43
|
+
:columns="storeAccountsActivities.columns"
|
44
|
+
:records="storeAccountsActivities.records">
|
45
|
+
</lesli-table>
|
46
|
+
</section>
|
47
|
+
</template>
|
48
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<script setup>
|
2
|
+
|
3
|
+
// · import vue tools
|
4
|
+
import { ref, reactive, onMounted, watch, computed } from "vue"
|
5
|
+
|
6
|
+
|
7
|
+
import visitors from "./visitors.vue";
|
8
|
+
import requests from "./requests.vue";
|
9
|
+
//import trends from "./trends.vue";
|
10
|
+
|
11
|
+
</script>
|
12
|
+
<template>
|
13
|
+
<lesli-application-container>
|
14
|
+
<lesli-header title="Analytics"></lesli-header>
|
15
|
+
<visitors></visitors>
|
16
|
+
<requests></requests>
|
17
|
+
</lesli-application-container>
|
18
|
+
</template>
|
@@ -0,0 +1,67 @@
|
|
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 { } from "vue"
|
36
|
+
|
37
|
+
|
38
|
+
// · import stores
|
39
|
+
import { useAnalytics } from "LesliAudit/stores/analytics/visitors"
|
40
|
+
|
41
|
+
|
42
|
+
// · implement stores
|
43
|
+
const storeAnalytics = useAnalytics()
|
44
|
+
|
45
|
+
</script>
|
46
|
+
<template>
|
47
|
+
<div class="columns mt-3">
|
48
|
+
<div class="column">
|
49
|
+
<lesli-table
|
50
|
+
:columns="storeAnalytics.users.columns"
|
51
|
+
:records="storeAnalytics.users.records">
|
52
|
+
</lesli-table>
|
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
|
+
<div class="column">
|
61
|
+
<lesli-table
|
62
|
+
:columns="storeAnalytics.controllers.columns"
|
63
|
+
:records="storeAnalytics.controllers.records">
|
64
|
+
</lesli-table>
|
65
|
+
</div>
|
66
|
+
</div>
|
67
|
+
</template>
|
@@ -0,0 +1,149 @@
|
|
1
|
+
<script setup>
|
2
|
+
/*
|
3
|
+
Copyright (c) 2022, all rights reserved.
|
4
|
+
|
5
|
+
All the information provided by this platform is protected by international laws related to
|
6
|
+
industrial property, intellectual property, copyright and relative international laws.
|
7
|
+
All intellectual or industrial property rights of the code, texts, trade mark, design,
|
8
|
+
pictures and any other information belongs to the owner of this platform.
|
9
|
+
|
10
|
+
Without the written permission of the owner, any replication, modification,
|
11
|
+
transmission, publication is strictly forbidden.
|
12
|
+
|
13
|
+
For more information read the license file including with this software.
|
14
|
+
|
15
|
+
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
16
|
+
// ·
|
17
|
+
*/
|
18
|
+
|
19
|
+
|
20
|
+
// · import vue tools
|
21
|
+
import { ref, reactive, onMounted, watch, computed } from "vue"
|
22
|
+
|
23
|
+
|
24
|
+
// . import Lesli components
|
25
|
+
import chartBar from "Lesli/components/charts/bar.vue"
|
26
|
+
import chartLine from "Lesli/components/charts/line.vue"
|
27
|
+
|
28
|
+
|
29
|
+
// · import lesli stores
|
30
|
+
import { useAnalytics } from "CloudAudit/stores/analytics/visitors"
|
31
|
+
|
32
|
+
|
33
|
+
// · implement stores
|
34
|
+
const storeAnalytics = useAnalytics()
|
35
|
+
|
36
|
+
|
37
|
+
// · define variables
|
38
|
+
var daySeries = ref([]);
|
39
|
+
var dayLabels = ref([]);
|
40
|
+
var timeSeries = ref([]);
|
41
|
+
var timeLabels = ref([]);
|
42
|
+
var days = {"Monday":0,"Tuesday":0,"Wednesday":0,"Thursday":0,"Friday":0,"Saturday":0,"Sunday":0}
|
43
|
+
var hours = {};
|
44
|
+
var finalDate = ref("");
|
45
|
+
var startDate = ref("");
|
46
|
+
|
47
|
+
|
48
|
+
// · initializing
|
49
|
+
onMounted(() => {
|
50
|
+
storeAnalytics.time('day',startDate.value,finalDate.value)
|
51
|
+
storeAnalytics.time('hour',startDate.value,finalDate.value)
|
52
|
+
})
|
53
|
+
|
54
|
+
|
55
|
+
// ·
|
56
|
+
watch(() => storeAnalytics.trends.recordsDays, () => {
|
57
|
+
days = {"Monday":0,"Tuesday":0,"Wednesday":0,"Thursday":0,"Friday":0,"Saturday":0,"Sunday":0}
|
58
|
+
|
59
|
+
if(storeAnalytics.trends.recordsDays){
|
60
|
+
storeAnalytics.trends.recordsDays.forEach((record) => {
|
61
|
+
days[record.day] += record.count
|
62
|
+
})
|
63
|
+
} else {
|
64
|
+
storeAnalytics.msg.info("There is no information for this date range")
|
65
|
+
}
|
66
|
+
|
67
|
+
dayLabels.value = Object.keys(days)
|
68
|
+
daySeries.value = [{
|
69
|
+
name: "Requests",
|
70
|
+
data: Object.values(days)
|
71
|
+
}]
|
72
|
+
|
73
|
+
daySeries.value = Object.values(days)
|
74
|
+
|
75
|
+
})
|
76
|
+
|
77
|
+
|
78
|
+
// ·
|
79
|
+
watch(() => storeAnalytics.trends.recordsHours, () => {
|
80
|
+
hours = {}
|
81
|
+
if(storeAnalytics.trends.recordsHours){
|
82
|
+
storeAnalytics.trends.recordsHours.forEach((record) => {
|
83
|
+
hours [record.hour+":00"] = record.count
|
84
|
+
})
|
85
|
+
}
|
86
|
+
|
87
|
+
timeLabels.value = Object.keys(hours)
|
88
|
+
timeSeries.value = [{
|
89
|
+
name: "Requests",
|
90
|
+
data: Object.values(hours)
|
91
|
+
}]
|
92
|
+
})
|
93
|
+
|
94
|
+
|
95
|
+
// Update date range when date picker change
|
96
|
+
function updateDates(){
|
97
|
+
if (startDate.value != "" && finalDate.value != "") {
|
98
|
+
|
99
|
+
if (startDate.value >= finalDate.value){
|
100
|
+
storeAnalytics.msg.danger("Select valid range for date")
|
101
|
+
} else {
|
102
|
+
storeAnalytics.time('day',startDate.value,finalDate.value)
|
103
|
+
storeAnalytics.time('hour',startDate.value,finalDate.value)
|
104
|
+
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
</script>
|
110
|
+
<template>
|
111
|
+
<section class="application-component">
|
112
|
+
<lesli-header title="Trends">
|
113
|
+
</lesli-header>
|
114
|
+
|
115
|
+
<!--
|
116
|
+
<div class="grid-container">
|
117
|
+
<div class="grid-item">
|
118
|
+
<label>From</label>
|
119
|
+
<br/>
|
120
|
+
<input class="input is-info" type="date" v-model="startDate" @change="updateDates">
|
121
|
+
</div>
|
122
|
+
<div class="grid-item">
|
123
|
+
<label>To</label>
|
124
|
+
<br/>
|
125
|
+
<input class="input is-info" type="date" v-model="finalDate" @change="updateDates" />
|
126
|
+
</div>
|
127
|
+
</div>
|
128
|
+
-->
|
129
|
+
<div class="card mb-5">
|
130
|
+
<div class="card-content">
|
131
|
+
<chartBar
|
132
|
+
title="Requests by day of the week"
|
133
|
+
:series="daySeries"
|
134
|
+
:labels="dayLabels">
|
135
|
+
</chartBar>
|
136
|
+
</div>
|
137
|
+
</div>
|
138
|
+
|
139
|
+
<div class="card">
|
140
|
+
<div class="card-content">
|
141
|
+
<chartLine
|
142
|
+
title="Requests by time of the day"
|
143
|
+
:series="timeSeries"
|
144
|
+
:labels="timeLabels">
|
145
|
+
</chartLine>
|
146
|
+
</div>
|
147
|
+
</div>
|
148
|
+
</section>
|
149
|
+
</template>
|
@@ -0,0 +1,91 @@
|
|
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, reactive, onMounted, watch, computed } from "vue"
|
36
|
+
|
37
|
+
|
38
|
+
// · import Lesli components
|
39
|
+
import { lesliChartLine } from "lesli-vue/components"
|
40
|
+
|
41
|
+
|
42
|
+
// · import stores
|
43
|
+
import { useAnalytics } from "LesliAudit/stores/analytics/visitors"
|
44
|
+
|
45
|
+
|
46
|
+
// · implement stores
|
47
|
+
const storeAnalytics = useAnalytics()
|
48
|
+
|
49
|
+
|
50
|
+
// · define variables
|
51
|
+
var series = ref([]);
|
52
|
+
var labels = ref([]);
|
53
|
+
|
54
|
+
|
55
|
+
// · initializing
|
56
|
+
onMounted(() => {
|
57
|
+
storeAnalytics.fetchVisits()
|
58
|
+
setTimeout(() => storeAnalytics.fetchUsers(), 500)
|
59
|
+
setTimeout(() => storeAnalytics.fetchDevices(), 1000)
|
60
|
+
setTimeout(() => storeAnalytics.fetchControllers(), 1500)
|
61
|
+
})
|
62
|
+
|
63
|
+
|
64
|
+
// ·
|
65
|
+
function reload() {
|
66
|
+
storeAnalytics.fetch()
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
// ·
|
71
|
+
watch(() => storeAnalytics.visitors.records, () => {
|
72
|
+
labels.value = storeAnalytics.visitors.records.map(visit => visit.date)
|
73
|
+
series.value = [{
|
74
|
+
name: "Requests",
|
75
|
+
data: storeAnalytics.visitors.records.map(visit => visit.requests)
|
76
|
+
}, {
|
77
|
+
name: "Resources",
|
78
|
+
data: storeAnalytics.visitors.records.map(visit => visit.resources)
|
79
|
+
}]
|
80
|
+
})
|
81
|
+
|
82
|
+
</script>
|
83
|
+
<template>
|
84
|
+
<lesli-application-component>
|
85
|
+
<lesli-chart-line
|
86
|
+
:title="'Visitors'"
|
87
|
+
:series="series"
|
88
|
+
:labels="labels">
|
89
|
+
</lesli-chart-line>
|
90
|
+
</lesli-application-component>
|
91
|
+
</template>
|