effective_logging 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/admin/logs_controller.rb +0 -14
- data/app/controllers/effective/logs_controller.rb +0 -17
- data/app/datatables/effective_log_changes_datatable.rb +9 -9
- data/app/datatables/effective_logs_datatable.rb +5 -7
- data/app/models/effective/log.rb +12 -5
- data/app/views/effective/logs/_log.html.haml +12 -9
- data/lib/effective_logging/version.rb +1 -1
- metadata +2 -4
- data/app/models/effective/access_denied.rb +0 -17
- data/app/views/admin/logs/_actions.html.haml +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1dc7b7f4024ac664b211eba56892cd43828ec911f37361b91f1ac6496f87fb7
|
4
|
+
data.tar.gz: 512c990d5a8dddfcc665e28ff7dd6ef66302ce4f855d68d87fa89af44ef79ed4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 612a1bed2cc27c80ee726a023a079e0a5a2dcf80b7d390e07bb9a692bf60da43c974d754bc29f99a17bc95d589e18457aa52261564da19e509947b47046a8f3c
|
7
|
+
data.tar.gz: 798375484126e11a779eaffbdf1c53e26a5530f701440b4190660948b52ee9c728e1e7f300684b088a636d4b9df1d08087b71dc3477a434a23c2422b576b27c7
|
@@ -16,19 +16,5 @@ module Admin
|
|
16
16
|
@page_title = 'Logs'
|
17
17
|
end
|
18
18
|
|
19
|
-
def show
|
20
|
-
@log = Effective::Log.includes(:logs).find(params[:id])
|
21
|
-
EffectiveResources.authorize!(self, :show, @log)
|
22
|
-
|
23
|
-
@log.next_log = Effective::Log.order(:id).where(parent_id: @log.parent_id).where('id > ?', @log.id).first
|
24
|
-
@log.prev_log = Effective::Log.order(:id).where(parent_id: @log.parent_id).where('id < ?', @log.id).last
|
25
|
-
|
26
|
-
@page_title = "Log ##{@log.to_param}"
|
27
|
-
|
28
|
-
if @log.logs.present?
|
29
|
-
@log.datatable = EffectiveLogsDatatable.new(self, log_id: @log.id)
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
19
|
end
|
34
20
|
end
|
@@ -41,26 +41,9 @@ module Effective
|
|
41
41
|
# This is the User index event
|
42
42
|
def index
|
43
43
|
EffectiveResources.authorize!(self, :index, Effective::Log.new(user_id: current_user.id))
|
44
|
-
|
45
44
|
@datatable = EffectiveLogsDatatable.new(self, user_id: current_user.id)
|
46
45
|
end
|
47
46
|
|
48
|
-
# This is the User show event
|
49
|
-
def show
|
50
|
-
@log = Effective::Log.includes(:logs).find(params[:id])
|
51
|
-
|
52
|
-
EffectiveLogging.authorize!(self, :show, @log)
|
53
|
-
|
54
|
-
@log.next_log = Effective::Log.unscoped.order(:id).where(parent_id: @log.parent_id).where('id > ?', @log.id).first
|
55
|
-
@log.prev_log = Effective::Log.unscoped.order(:id).where(parent_id: @log.parent_id).where('id < ?', @log.id).last
|
56
|
-
|
57
|
-
@page_title = "Log ##{@log.to_param}"
|
58
|
-
|
59
|
-
if @log.logs.present?
|
60
|
-
@log.datatable = EffectiveLogsDatatable.new(self, log_id: @log.id)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
47
|
def html_part
|
65
48
|
@log = Effective::Log.find(params[:id])
|
66
49
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class EffectiveLogChangesDatatable < Effective::Datatable
|
2
4
|
datatable do
|
3
5
|
order :updated_at
|
@@ -5,19 +7,19 @@ class EffectiveLogChangesDatatable < Effective::Datatable
|
|
5
7
|
col :updated_at, label: 'Date'
|
6
8
|
col :id, visible: false
|
7
9
|
|
8
|
-
col :user, sort: false
|
10
|
+
col :user, search: :string, sort: false
|
9
11
|
|
10
12
|
col :associated_type, visible: false
|
11
|
-
col :associated_id, visible: false
|
12
|
-
col :associated_to_s, visible: false
|
13
|
+
col :associated_id, visible: false, label: 'Associated Id'
|
14
|
+
col :associated_to_s, visible: false, label: 'Associated'
|
13
15
|
|
14
16
|
col :message, sort: false do |log|
|
15
|
-
message
|
17
|
+
(log.message || '').gsub!("\n", '<br>')
|
16
18
|
|
17
19
|
if log.associated_id == attributes[:changes_to_id] && log.associated_type == attributes[:changes_to_type]
|
18
|
-
message
|
20
|
+
log.message
|
19
21
|
else
|
20
|
-
"#{log.associated_type} #{log.associated_to_s} - #{message}"
|
22
|
+
"#{log.associated_type} #{log.associated_to_s} - #{log.message}"
|
21
23
|
end
|
22
24
|
|
23
25
|
end.search do |collection, term, column, sql_column|
|
@@ -29,9 +31,7 @@ class EffectiveLogChangesDatatable < Effective::Datatable
|
|
29
31
|
tableize_hash(log.details)
|
30
32
|
end
|
31
33
|
|
32
|
-
|
33
|
-
actions_col partial: 'admin/logs/actions', partial_as: :log
|
34
|
-
end
|
34
|
+
actions_col
|
35
35
|
end
|
36
36
|
|
37
37
|
# A nil attributes[:log_id] means give me all the top level log entries
|
@@ -8,16 +8,16 @@ class EffectiveLogsDatatable < Effective::Datatable
|
|
8
8
|
if attributes[:user] == false
|
9
9
|
# Do not include
|
10
10
|
else
|
11
|
-
col :user, search: :string
|
11
|
+
col :user, search: :string, sort: false
|
12
12
|
end
|
13
13
|
|
14
14
|
unless attributes[:status] == false
|
15
15
|
col :status, search: { collection: EffectiveLogging.statuses }
|
16
16
|
end
|
17
17
|
|
18
|
-
col :associated_type,
|
19
|
-
col :associated_id,
|
20
|
-
col :associated_to_s,
|
18
|
+
col :associated_type, visible: false
|
19
|
+
col :associated_id, visible: false, label: 'Associated Id'
|
20
|
+
col :associated_to_s, label: 'Associated'
|
21
21
|
|
22
22
|
col :message do |log|
|
23
23
|
log.message.gsub("\n", '<br>')
|
@@ -29,9 +29,7 @@ class EffectiveLogsDatatable < Effective::Datatable
|
|
29
29
|
tableize_hash(log.details.except(:email))
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
actions_col partial: 'admin/logs/actions', partial_as: :log
|
34
|
-
end
|
32
|
+
actions_col
|
35
33
|
end
|
36
34
|
|
37
35
|
# A nil attributes[:log_id] means give me all the top level log entries
|
data/app/models/effective/log.rb
CHANGED
@@ -2,11 +2,6 @@ module Effective
|
|
2
2
|
class Log < ActiveRecord::Base
|
3
3
|
self.table_name = EffectiveLogging.logs_table_name.to_s
|
4
4
|
|
5
|
-
# These 3 attr_accessors are set on the controller #show actions
|
6
|
-
attr_accessor :datatable
|
7
|
-
attr_accessor :next_log
|
8
|
-
attr_accessor :prev_log
|
9
|
-
|
10
5
|
# Self-Referencing relationship
|
11
6
|
belongs_to :parent, class_name: 'Effective::Log', counter_cache: true, optional: true
|
12
7
|
has_many :logs, class_name: 'Effective::Log', foreign_key: :parent_id
|
@@ -58,6 +53,18 @@ module Effective
|
|
58
53
|
self[:details] || {}
|
59
54
|
end
|
60
55
|
|
56
|
+
def next_log
|
57
|
+
Log.order(id: :asc).where(parent_id: parent_id).where('id > ?', id).first
|
58
|
+
end
|
59
|
+
|
60
|
+
def prev_log
|
61
|
+
Log.order(id: :desc).where(parent_id: parent_id).where('id < ?', id).first
|
62
|
+
end
|
63
|
+
|
64
|
+
def child_logs_datatable
|
65
|
+
EffectiveLogsDatatable.new(log_id: id)
|
66
|
+
end
|
67
|
+
|
61
68
|
# Dynamically add logging methods based on the defined statuses
|
62
69
|
# EffectiveLogging.info 'my message'
|
63
70
|
(EffectiveLogging.statuses || []).each do |status|
|
@@ -8,18 +8,22 @@
|
|
8
8
|
%p= log.message.to_s.gsub("\n", '<br>').html_safe
|
9
9
|
|
10
10
|
.col-md-4.text-right
|
11
|
-
-
|
12
|
-
|
11
|
+
- prev_log = log.prev_log
|
12
|
+
- next_log = log.next_log
|
13
13
|
|
14
|
-
- if
|
15
|
-
= link_to '
|
14
|
+
- if prev_log.present?
|
15
|
+
= link_to 'Prev', request.fullpath.sub('/' + log.to_param, '/' + prev_log.to_param), class: 'btn btn-primary'
|
16
|
+
|
17
|
+
- if next_log.present?
|
18
|
+
= link_to 'Next', request.fullpath.sub('/' + log.to_param, '/' + next_log.to_param), class: 'btn btn-primary'
|
16
19
|
|
17
20
|
.panel-body.card-body
|
18
21
|
.row
|
19
22
|
.col-md-6
|
20
23
|
%p
|
21
24
|
- status_class = bootstrap_class_for_status(log.status)
|
22
|
-
%span{:
|
25
|
+
%span{class: (defined?(EffectiveBootstrap) ? "badge badge-#{status_class}" : "label label-#{status_class}")}= log.status
|
26
|
+
|
23
27
|
= log.created_at.strftime("%F %H:%M:%S")
|
24
28
|
= '(' + time_ago_in_words(log.created_at) + ' ago)'
|
25
29
|
|
@@ -28,7 +32,8 @@
|
|
28
32
|
%p
|
29
33
|
%strong User:
|
30
34
|
= (log.user.to_s.starts_with?('#<User:0x') ? (log.user.email rescue log.user) : log.user)
|
31
|
-
|
35
|
+
|
36
|
+
- if log.associated_id.present? && log.associated_type.present? && (log.associated.present? rescue false)
|
32
37
|
%p
|
33
38
|
%strong Associated:
|
34
39
|
- if log.associated.to_s.starts_with?('#<')
|
@@ -47,6 +52,4 @@
|
|
47
52
|
- if log.logs.present?
|
48
53
|
%hr
|
49
54
|
%p This log contains #{log.logs_count} additional sub entries:
|
50
|
-
|
51
|
-
- unless log.datatable.nil?
|
52
|
-
= render_datatable(log.datatable)
|
55
|
+
= render_datatable(log.child_logs_datatable)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_logging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -98,10 +98,8 @@ files:
|
|
98
98
|
- app/datatables/effective_logs_datatable.rb
|
99
99
|
- app/helpers/effective_logging_helper.rb
|
100
100
|
- app/models/concerns/acts_as_loggable.rb
|
101
|
-
- app/models/effective/access_denied.rb
|
102
101
|
- app/models/effective/log.rb
|
103
102
|
- app/models/effective_logger.rb
|
104
|
-
- app/views/admin/logs/_actions.html.haml
|
105
103
|
- app/views/admin/logs/index.html.haml
|
106
104
|
- app/views/admin/logs/show.html.haml
|
107
105
|
- app/views/effective/logs/_log.html.haml
|
@@ -1,17 +0,0 @@
|
|
1
|
-
unless defined?(Effective::AccessDenied)
|
2
|
-
module Effective
|
3
|
-
class AccessDenied < StandardError
|
4
|
-
attr_reader :action, :subject
|
5
|
-
|
6
|
-
def initialize(message = nil, action = nil, subject = nil)
|
7
|
-
@message = message
|
8
|
-
@action = action
|
9
|
-
@subject = subject
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_s
|
13
|
-
@message || I18n.t(:'unauthorized.default', :default => 'Access Denied')
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
- show_path = (datatable.admin_namespace? ? effective_logging.admin_log_path(log) : effective_logging.log_path(log))
|
2
|
-
|
3
|
-
- if defined?(EffectiveBootstrap)
|
4
|
-
= dropdown(variation: :dropleft) do
|
5
|
-
= dropdown_link_to 'View', show_path
|
6
|
-
- else
|
7
|
-
= link_to show_path, title: 'View' do
|
8
|
-
%span.glyphicon.glyphicon-eye-open
|