lesli_audit 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,60 +1,46 @@
1
- module LesliAudit
2
- class RequestsController < ApplicationController
3
- before_action :set_request, only: %i[ show edit update destroy ]
1
+ =begin
4
2
 
5
- # GET /requests
6
- def index
7
- @requests = Request.all
8
- end
3
+ Lesli
9
4
 
10
- # GET /requests/1
11
- def show
12
- end
5
+ Copyright (c) 2023, Lesli Technologies, S. A.
13
6
 
14
- # GET /requests/new
15
- def new
16
- @request = Request.new
17
- 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.
18
11
 
19
- # GET /requests/1/edit
20
- def edit
21
- 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.
22
16
 
23
- # POST /requests
24
- def create
25
- @request = Request.new(request_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/.
26
19
 
27
- if @request.save
28
- redirect_to @request, notice: "Request was successfully created."
29
- else
30
- render :new, status: :unprocessable_entity
31
- end
32
- end
20
+ Lesli · Ruby on Rails SaaS Development Framework.
33
21
 
34
- # PATCH/PUT /requests/1
35
- def update
36
- if @request.update(request_params)
37
- redirect_to @request, notice: "Request was successfully updated.", status: :see_other
38
- else
39
- render :edit, status: :unprocessable_entity
40
- end
41
- end
22
+ Made with ♥ by https://www.lesli.tech
23
+ Building a better future, one line of code at a time.
42
24
 
43
- # DELETE /requests/1
44
- def destroy
45
- @request.destroy
46
- redirect_to requests_url, notice: "Request was successfully destroyed.", status: :see_other
47
- 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
48
32
 
49
- private
50
- # Use callbacks to share common setup or constraints between actions.
51
- def set_request
52
- @request = Request.find(params[:id])
53
- end
54
-
55
- # Only allow a list of trusted parameters through.
56
- def request_params
57
- params.fetch(:request, {})
58
- end
59
- end
33
+ module LesliAudit
34
+ class RequestsController < ApplicationController
35
+
36
+ # GET /requests
37
+ def index
38
+ respond_to do |format|
39
+ format.html
40
+ format.json {
41
+ respond_with_pagination(LesliAudit::RequestService.new(current_user, query).index)
42
+ }
43
+ end
44
+ end
45
+ end
60
46
  end
@@ -1,60 +1,12 @@
1
1
  module LesliAudit
2
- class UsersController < ApplicationController
3
- before_action :set_user, only: %i[ show edit update destroy ]
2
+ class UsersController < ApplicationController
4
3
 
5
- # GET /users
6
- def index
7
- @users = User.all
8
- end
9
-
10
- # GET /users/1
11
- def show
12
- end
13
-
14
- # GET /users/new
15
- def new
16
- @user = User.new
17
- end
18
-
19
- # GET /users/1/edit
20
- def edit
21
- end
22
-
23
- # POST /users
24
- def create
25
- @user = User.new(user_params)
4
+ # GET /users
5
+ def index
6
+ end
26
7
 
27
- if @user.save
28
- redirect_to @user, notice: "User was successfully created."
29
- else
30
- render :new, status: :unprocessable_entity
31
- end
32
- end
33
8
 
34
- # PATCH/PUT /users/1
35
- def update
36
- if @user.update(user_params)
37
- redirect_to @user, notice: "User was successfully updated.", status: :see_other
38
- else
39
- render :edit, status: :unprocessable_entity
40
- end
41
- end
9
+ private
42
10
 
43
- # DELETE /users/1
44
- def destroy
45
- @user.destroy
46
- redirect_to users_url, notice: "User was successfully destroyed.", status: :see_other
47
11
  end
48
-
49
- private
50
- # Use callbacks to share common setup or constraints between actions.
51
- def set_user
52
- @user = User.find(params[:id])
53
- end
54
-
55
- # Only allow a list of trusted parameters through.
56
- def user_params
57
- params.fetch(:user, {})
58
- end
59
- end
60
12
  end
@@ -0,0 +1,4 @@
1
+ module LesliAudit
2
+ class Account::Request < ApplicationRecord
3
+ end
4
+ end
@@ -1,5 +1,6 @@
1
1
  module LesliAudit
2
2
  class Account < ApplicationRecord
3
+ belongs_to :account, class_name: "Lesli::Account"
3
4
  has_many :account_requests
4
5
  has_many :user_requests
5
6
  end
@@ -17,7 +17,7 @@ GNU General Public License for more details.
17
17
  You should have received a copy of the GNU General Public License
18
18
  along with this program. If not, see http://www.gnu.org/licenses/.
19
19
 
20
- Lesli · Ruby on Rails SaaS development platform.
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
21
 
22
22
  Made with ♥ by https://www.lesli.tech
23
23
  Building a better future, one line of code at a time.
@@ -30,8 +30,8 @@ Building a better future, one line of code at a time.
30
30
  // ·
31
31
  =end
32
32
 
33
- module CloudAudit
34
- class RequestServices < ApplicationLesliServices
33
+ module LesliAudit
34
+ class RequestService < Lesli::ApplicationLesliService
35
35
 
36
36
  # @overwrite
37
37
  # @return {Hash} Paginated list of the records
@@ -39,6 +39,17 @@ module CloudAudit
39
39
  # @description
40
40
  # @example
41
41
  def index
42
+
43
+
44
+ requests = Account::Request.all
45
+ .order(created_at: :desc)
46
+ .order(request_count: :desc)
47
+ .page(query[:pagination][:page])
48
+ .per(query[:pagination][:perPage])
49
+
50
+ return requests
51
+
52
+
42
53
  search_string = nil # query[:search].downcase.gsub(" ","%") unless query[:search].blank?
43
54
  order_string = "user_requests.created_at"
44
55
 
@@ -33,7 +33,7 @@ Building a better future, one line of code at a time.
33
33
  %>
34
34
 
35
35
  <%= navigation_item(lesli_audit.dashboard_path, "Dashboard", "ri-dashboard-3-line"); %>
36
- <%= navigation_item(lesli_audit.dashboard_path, "Users", "ri-team-line"); %>
36
+ <%= navigation_item(lesli_audit.users_path, "Users", "ri-team-line"); %>
37
37
  <%= navigation_item(lesli_audit.analytics_path, "Analytics", "ri-pie-chart-line"); %>
38
38
  <%= navigation_item(lesli_audit.dashboard_path, "Account", "ri-briefcase-line"); %>
39
- <%= navigation_item(lesli_audit.dashboard_path, "Requests", "ri-arrow-left-right-fill"); %>
39
+ <%= navigation_item(lesli_audit.requests_path, "Requests", "ri-arrow-left-right-fill"); %>
@@ -1,14 +1 @@
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 %>
1
+ <router-view></router-view>
@@ -1,14 +1 @@
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 %>
1
+ <router-view></router-view>
@@ -2,6 +2,4 @@
2
2
  :en:
3
3
  lesli_audit:
4
4
  shared:
5
- title_lesli: ":lesli.shared.title_lesli:"
6
- users:
7
- title_users: Users
5
+ button_save: Save
@@ -2,6 +2,4 @@
2
2
  :es:
3
3
  lesli_audit:
4
4
  shared:
5
- title_lesli: 'Lesli en español '
6
- users:
7
- title_users: Usuarios
5
+ button_save: Guardar
data/config/routes.rb CHANGED
@@ -51,7 +51,9 @@ LesliAudit::Engine.routes.draw do
51
51
  # Activities changes on users information
52
52
  # Roles total users by role
53
53
  # Logs relevant actions of users
54
- resources :users, only: []
54
+ resources :users, only: [:index] do
55
+
56
+ end
55
57
 
56
58
 
57
59
  # Analytics:
@@ -73,6 +75,6 @@ LesliAudit::Engine.routes.draw do
73
75
 
74
76
 
75
77
  # Requests: Raw request data
76
- resources :request, only: []
78
+ resources :requests, only: [:index]
77
79
 
78
80
  end
@@ -1,4 +1,4 @@
1
1
  module LesliAudit
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  BUILD = "1697000148"
4
4
  end
@@ -32,8 +32,9 @@ Building a better future, one line of code at a time.
32
32
 
33
33
  // ·
34
34
  import application from "Lesli/application"
35
-
36
35
  import appAnalytics from "LesliAudit/apps/analytics/index.vue"
36
+ import appRequests from "LesliAudit/apps/requests/index.vue"
37
+ import appUsers from "LesliAudit/apps/users/index.vue"
37
38
 
38
39
  // ·
39
40
  /*
@@ -51,8 +52,6 @@ import appAccountsActivities from "CloudAudit/apps/accounts/activities.vue"
51
52
 
52
53
  import appSecuritySessions from "CloudAudit/apps/security/sessions.vue"
53
54
  import appSecurityPasswords from "CloudAudit/apps/security/passwords.vue"
54
-
55
- import appRequests from "CloudAudit/apps/requests/index.vue"
56
55
  */
57
56
 
58
57
 
@@ -61,6 +60,12 @@ application("LesliAudit", [{
61
60
  path: "/analytics",
62
61
  component: appAnalytics,
63
62
  props: { engine: "audit" }
63
+ }, {
64
+ path: "/requests",
65
+ component: appRequests
66
+ }, {
67
+ path: "/users",
68
+ component: appUsers,
64
69
  }
65
70
  /*{
66
71
  path: "/",
@@ -90,9 +95,6 @@ application("LesliAudit", [{
90
95
  }, {
91
96
  path: "/analytics/trends",
92
97
  component: appAnalyticsTrends
93
- }, {
94
- path: "/requests",
95
- component: appRequests
96
98
  }, {
97
99
  path: "/security/sessions",
98
100
  component: appSecuritySessions
@@ -1,18 +1,33 @@
1
1
  <script setup>
2
2
  /*
3
- Copyright (c) 2022, all rights reserved.
4
3
 
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.
4
+ Lesli
9
5
 
10
- Without the written permission of the owner, any replication, modification,
11
- transmission, publication is strictly forbidden.
6
+ Copyright (c) 2023, Lesli Technologies, S. A.
12
7
 
13
- For more information read the license file including with this software.
8
+ This program is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
14
12
 
15
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program. If not, see http://www.gnu.org/licenses/.
20
+
21
+ Lesli · Ruby on Rails SaaS Development Framework.
22
+
23
+ Made with ♥ by https://www.lesli.tech
24
+ Building a better future, one line of code at a time.
25
+
26
+ @contact hello@lesli.tech
27
+ @website https://www.lesli.tech
28
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
29
+
30
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
16
31
  // ·
17
32
  */
18
33
 
@@ -22,28 +37,18 @@ import { ref, reactive, onMounted, watch, computed } from "vue"
22
37
 
23
38
 
24
39
  // · import lesli stores
25
- import { useLogRequest } from "CloudAudit/stores/request"
40
+ import { useRequests } from "LesliAudit/stores/request"
26
41
 
27
42
 
28
43
  // · implement stores
29
- const store = useLogRequest()
44
+ const storeRequests = useRequests()
30
45
 
31
46
 
32
47
  // · define variables
33
48
  const columns = [{
34
49
  field: "id",
35
50
  label: "ID"
36
- }, {
37
- field: "email",
38
- label: "Email",
39
- sort: true
40
- }, {
41
- field: "request_agent",
42
- label: "Device"
43
- }, {
44
- field: "request_method",
45
- label: "Method"
46
- }, {
51
+ }, {
47
52
  field: "request_controller",
48
53
  label: "Controller",
49
54
  sort: true
@@ -51,23 +56,20 @@ const columns = [{
51
56
  field: "request_action",
52
57
  label: "Action"
53
58
  }, {
54
- field: "created_at_date",
59
+ field: "request_count",
60
+ align: "center",
61
+ label: "Count"
62
+ }, {
63
+ field: "created_at",
55
64
  label: "Date"
56
65
  }]
57
66
 
58
67
 
59
68
  // · initializing
60
69
  onMounted(() => {
61
- store.fetchLogsIfEmpty()
70
+ storeRequests.fetch()
62
71
  })
63
72
 
64
-
65
- function itemProjection(item){ console.log("itemprojection", item) }
66
- function selectItemEventHandler(item){ console.log("selectItem", item) }
67
- function onInputEventHandler(item){ console.log("onInput", item) }
68
- function onFocusEventHandler(item){ console.log("onFocus", item) }
69
- function onBlurEventHandler(item){ console.log("onBlur", item) }
70
-
71
73
  </script>
72
74
  <script>
73
75
  export default {
@@ -79,12 +81,12 @@ export default {
79
81
  }
80
82
  </script>
81
83
  <template>
82
- <section class="application-component">
84
+ <lesli-application-container>
83
85
  <lesli-header
84
- title="Users activity"
85
- @reload="store.fetchLogs()">
86
+ title="Account requests"
87
+ @reload="storeRequests.fetchLogs()">
86
88
  </lesli-header>
87
- <lesli-toolbar @search="store.search">
89
+ <lesli-toolbar @search="storeRequests.search">
88
90
  <!--
89
91
  <Autocomplete
90
92
  id="typeahead_id"
@@ -111,13 +113,13 @@ export default {
111
113
  -->
112
114
  </lesli-toolbar>
113
115
  <lesli-table
114
- @sort="store.sort"
115
- @paginate="store.paginate"
116
- :pagination="store.pagination"
117
- :loading="store.loading"
116
+ @sort="storeRequests.sort"
117
+ @paginate="storeRequests.paginate"
118
+ :pagination="storeRequests.pagination"
119
+ :loading="storeRequests.loading"
118
120
  :columns="columns"
119
- :records="store.records"
121
+ :records="storeRequests.records"
120
122
  @click="showUser">
121
123
  </lesli-table>
122
- </section>
124
+ </lesli-application-container>
123
125
  </template>
@@ -0,0 +1,31 @@
1
+ <script setup>
2
+
3
+ </script>
4
+ <template>
5
+ <lesli-application-container>
6
+ <lesli-columns>
7
+ <lesli-column>
8
+ <lesli-card title="Users registered">
9
+ <p class="number">160</p>
10
+ </lesli-card>
11
+ </lesli-column>
12
+ <lesli-column>
13
+ <lesli-card title="Active roles">
14
+ <p class="number">12</p>
15
+ </lesli-card>
16
+ </lesli-column>
17
+ <lesli-column>
18
+ <lesli-card title="Active descriptors">
19
+ <p class="number">70</p>
20
+ </lesli-card>
21
+ </lesli-column>
22
+ </lesli-columns>
23
+ </lesli-application-container>
24
+ </template>
25
+ <style>
26
+ .number {
27
+ padding: 1rem;
28
+ font-size: 3rem;
29
+ text-align: center;
30
+ }
31
+ </style>
@@ -46,12 +46,14 @@ const storeAnalytics = useAnalytics()
46
46
  <template>
47
47
  <div class="columns">
48
48
  <div class="column">
49
+ <h3>Most active users</h3>
49
50
  <lesli-table
50
51
  :columns="storeAnalytics.users.columns"
51
52
  :records="storeAnalytics.users.records">
52
53
  </lesli-table>
53
54
  </div>
54
55
  <div class="column">
56
+ <h3>Most active controllers</h3>
55
57
  <lesli-table
56
58
  :columns="storeAnalytics.controllers.columns"
57
59
  :records="storeAnalytics.controllers.records">
@@ -68,7 +68,10 @@ export const useAnalytics = defineStore("analytics", {
68
68
  fetchVisits() {
69
69
  this.visitors.loading = true
70
70
  this.http.get(this.url.audit("analytics/visitors")).then(result => {
71
- this.visitors.records = result.reverse()
71
+ this.visitors.records = result.map(record => {
72
+ record.date = this.date(record.date).date()
73
+ return record
74
+ }).reverse()
72
75
  }).finally(() => {
73
76
  this.visitors.loading = false
74
77
  })
@@ -21,7 +21,7 @@ import { defineStore } from "pinia"
21
21
 
22
22
 
23
23
  // ·
24
- export const useLogRequest = defineStore("logRequest", {
24
+ export const useRequests = defineStore("Requests", {
25
25
  state: () => {
26
26
  return {
27
27
  date: "",
@@ -45,13 +45,13 @@ export const useLogRequest = defineStore("logRequest", {
45
45
  this.fetchLogs(this.url.audit("requests").paginate(page), false)
46
46
  },
47
47
 
48
- fetchLogsIfEmpty() {
48
+ fetch() {
49
49
  if (this.records.length <= 0) {
50
- this.fetchLogs()
50
+ this.getRequests()
51
51
  }
52
52
  },
53
53
 
54
- fetchLogs(url=this.url.audit("requests"), loading=true) {
54
+ getRequests(url=this.url.audit("requests"), loading=true) {
55
55
 
56
56
  this.loading = loading
57
57
 
data/readme.md CHANGED
@@ -1,12 +1,12 @@
1
1
  <p align="center">
2
- <img width="90" alt="LesliCloud logo" src="./app/assets/images/lesli_admin/admin-logo.svg" />
2
+ <img width="90" alt="LesliCloud logo" src="./app/assets/images/lesli_audit/audit-logo.svg" />
3
3
  <h3 align="center">Administration area for the Lesli Framework.</h3>
4
4
  </p>
5
5
 
6
6
  <hr/>
7
7
  <p align="center">
8
- <a target="blank" href="https://rubygems.org/gems/lesli_admin">
9
- <img src="https://badge.fury.io/rb/lesli_admin.svg" alt="Gem Version" height="18">
8
+ <a target="blank" href="https://rubygems.org/gems/lesli_audit">
9
+ <img src="https://badge.fury.io/rb/lesli_audit.svg" alt="Gem Version" height="22">
10
10
  </a>
11
11
  </p>
12
12
  <hr/>
@@ -14,8 +14,8 @@
14
14
  ### Quick start
15
15
 
16
16
  ```shell
17
- # Add LesliAdmin engine
18
- bundle add lesli_admin
17
+ # Add LesliAudit engine
18
+ bundle add lesli_audit
19
19
  ```
20
20
 
21
21
  ```shell
@@ -24,20 +24,20 @@ rake lesli:db:setup
24
24
  ```
25
25
 
26
26
  ```ruby
27
- # Load LesliAdmin
27
+ # Load LesliAudit
28
28
  Rails.application.routes.draw do
29
- mount LesliAdmin::Engine => "/admin"
29
+ mount LesliAudit::Engine => "/audit"
30
30
  end
31
31
  ```
32
32
 
33
33
 
34
34
  ### Documentation
35
- * [Roadmap](./docs/roadmap.md)
35
+ * [website](https://www.lesli.dev/audit/)
36
36
  * [database](./docs/database.md)
37
37
  * [documentation](https://www.lesli.dev/documentation/)
38
38
 
39
39
 
40
- ### Get in touch
40
+ ### Get in touch with Lesli
41
41
 
42
42
  * [Website: https://www.lesli.tech](https://www.lesli.tech)
43
43
  * [Email: hello@lesli.tech](hello@lesli.tech)