effective_logging 3.2.3 → 3.4.0
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/datatables/effective_log_changes_datatable.rb +4 -4
- data/app/datatables/effective_logs_datatable.rb +13 -2
- data/app/models/concerns/acts_as_loggable.rb +5 -1
- data/lib/effective_logging/engine.rb +11 -7
- data/lib/effective_logging/version.rb +1 -1
- data/lib/effective_logging.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb0a8d92372b22e941fa595e0f50219682d53a54cdb3ec2d4d819ca43140d42e
|
4
|
+
data.tar.gz: e4363f68cbb8b53f3616a2681885920b3574e643ab5244d324137ea94e147c28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1fcd0044cb28eaee999297d9b08b9d491fbf7b59938a3097674303d1283816f350d9eed44efca72b8a7c53abff9d38dc299be25d07e90604854ef523846f335
|
7
|
+
data.tar.gz: e21aa1f2ceaa6c3291c385a8c50e83ac2d164fde593472554a432b2cc458e4740f1fa9f56bd72b089727cf3cee9bc93ae750a017d4edf4229cefb12deb0eba8d
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
class EffectiveLogChangesDatatable < Effective::Datatable
|
4
4
|
datatable do
|
5
|
-
order :
|
5
|
+
order :id, :desc
|
6
6
|
|
7
7
|
col :updated_at, label: 'Date'
|
8
8
|
col :id, visible: false
|
@@ -14,12 +14,12 @@ class EffectiveLogChangesDatatable < Effective::Datatable
|
|
14
14
|
col :associated_to_s, visible: false, label: 'Associated'
|
15
15
|
|
16
16
|
col :message, sort: false do |log|
|
17
|
-
(log.message || '').gsub
|
17
|
+
message = (log.message || '').gsub("\n", '<br>')
|
18
18
|
|
19
19
|
if log.associated_id == attributes[:changes_to_id] && log.associated_type == attributes[:changes_to_type]
|
20
|
-
|
20
|
+
message
|
21
21
|
else
|
22
|
-
"#{log.associated_type} #{log.associated_to_s} - #{
|
22
|
+
"#{log.associated_type} #{log.associated_to_s} - #{message}"
|
23
23
|
end
|
24
24
|
|
25
25
|
end.search do |collection, term, column, sql_column|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class EffectiveLogsDatatable < Effective::Datatable
|
2
2
|
datatable do
|
3
|
-
order :
|
3
|
+
order :id, :desc
|
4
4
|
|
5
5
|
col :updated_at, label: 'Date'
|
6
6
|
col :id, visible: false
|
@@ -15,6 +15,9 @@ class EffectiveLogsDatatable < Effective::Datatable
|
|
15
15
|
col :status, search: { collection: EffectiveLogging.statuses }
|
16
16
|
end
|
17
17
|
|
18
|
+
col :changes_to_type, visible: false
|
19
|
+
col :changes_to_id, visible: false
|
20
|
+
|
18
21
|
col :associated_type, visible: false
|
19
22
|
col :associated_id, visible: false, label: 'Associated Id'
|
20
23
|
col :associated_to_s, label: 'Associated'
|
@@ -35,13 +38,21 @@ class EffectiveLogsDatatable < Effective::Datatable
|
|
35
38
|
# A nil attributes[:log_id] means give me all the top level log entries
|
36
39
|
# If we set a log_id then it's for sub logs
|
37
40
|
collection do
|
38
|
-
scope = Effective::Log.
|
41
|
+
scope = Effective::Log.includes(:user).where(parent_id: attributes[:log_id])
|
39
42
|
|
43
|
+
# Older syntax, pass by integer
|
40
44
|
if attributes[:for]
|
41
45
|
user_ids = Array(attributes[:for])
|
42
46
|
scope = scope.where('user_id IN (?) OR (associated_id IN (?) AND associated_type = ?)', user_ids, user_ids, 'User')
|
43
47
|
end
|
44
48
|
|
49
|
+
# Newer syntax, pass by object
|
50
|
+
if attributes[:for_id] && attributes[:for_type]
|
51
|
+
for_scope = scope.where(associated_id: attributes[:for_id], associated_type: attributes[:for_type])
|
52
|
+
.or(scope.where(changes_to_id: attributes[:for_id], changes_to_type: attributes[:for_type]))
|
53
|
+
.or(scope.where(user_id: attributes[:for_id], user_type: attributes[:for_type]))
|
54
|
+
end
|
55
|
+
|
45
56
|
if attributes[:associated_id] && attributes[:associated_type]
|
46
57
|
scope = scope.where(associated_id: attributes[:associated_id], associated_type: attributes[:associated_type])
|
47
58
|
end
|
@@ -64,8 +64,12 @@ module ActsAsLoggable
|
|
64
64
|
EffectiveRoles.roles_for(value) if attribute == :roles_mask && defined?(EffectiveRoles) && respond_to?(:roles)
|
65
65
|
end
|
66
66
|
|
67
|
+
def logs_datatable
|
68
|
+
EffectiveLogsDatatable.new(for: self) if persisted?
|
69
|
+
end
|
70
|
+
|
67
71
|
def log_changes_datatable
|
68
|
-
EffectiveLogChangesDatatable.new(
|
72
|
+
EffectiveLogChangesDatatable.new(changes_to: self) if persisted?
|
69
73
|
end
|
70
74
|
|
71
75
|
end
|
@@ -17,7 +17,7 @@ module EffectiveLogging
|
|
17
17
|
# Automatically Log Emails
|
18
18
|
initializer 'effective_logging.emails' do |app|
|
19
19
|
if EffectiveLogging.email_enabled == true
|
20
|
-
|
20
|
+
app.config.to_prepare do
|
21
21
|
ActionMailer::Base.register_interceptor(EffectiveLogging::EmailLogger)
|
22
22
|
end
|
23
23
|
end
|
@@ -25,15 +25,17 @@ module EffectiveLogging
|
|
25
25
|
|
26
26
|
# Include acts_as_loggable concern and allow any ActiveRecord object to call it with log_changes()
|
27
27
|
initializer 'effective_logging.active_record' do |app|
|
28
|
-
|
29
|
-
|
28
|
+
app.config.to_prepare do
|
29
|
+
ActiveSupport.on_load :active_record do
|
30
|
+
ActiveRecord::Base.extend(ActsAsLoggable::Base)
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
35
|
# Log all ActiveStorage downloads
|
34
36
|
initializer 'effective_logging.active_storage' do |app|
|
35
37
|
if EffectiveLogging.active_storage_enabled == true && defined?(ActiveStorage)
|
36
|
-
|
38
|
+
app.config.to_prepare do
|
37
39
|
ActiveStorage::DiskController.include(EffectiveLogging::ActiveStorageLogger)
|
38
40
|
ActiveStorage::DiskController.class_eval { after_action(:track_downloads, only: :show) }
|
39
41
|
end
|
@@ -42,7 +44,7 @@ module EffectiveLogging
|
|
42
44
|
|
43
45
|
# Register the log_page_views concern so that it can be called in ActionController or elsewhere
|
44
46
|
initializer 'effective_logging.log_changes_action_controller' do |app|
|
45
|
-
|
47
|
+
app.config.to_prepare do
|
46
48
|
ActiveSupport.on_load :action_controller do
|
47
49
|
ActionController::Base.include(EffectiveLogging::SetCurrentUser::ActionController)
|
48
50
|
end
|
@@ -51,8 +53,10 @@ module EffectiveLogging
|
|
51
53
|
|
52
54
|
# Register the log_page_views concern so that it can be called in ActionController or elsewhere
|
53
55
|
initializer 'effective_logging.action_controller' do |app|
|
54
|
-
|
55
|
-
|
56
|
+
app.config.to_prepare do
|
57
|
+
ActiveSupport.on_load :action_controller do
|
58
|
+
ActionController::Base.extend(EffectiveLogging::LogPageViews::ActionController)
|
59
|
+
end
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
data/lib/effective_logging.rb
CHANGED
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.
|
4
|
+
version: 3.4.0
|
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: 2022-
|
11
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|