effective_logging 1.10.5 → 1.10.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2de145b956fd6e8284b0176ddb914f149e7e7ddc
4
- data.tar.gz: 693cccaee263fde6fd67e186e20c3f44d72c9e22
3
+ metadata.gz: 4505eb9d63d37917638f060aa88ec3bba0ab1eb7
4
+ data.tar.gz: 7003902e81dc178bd313135f9a199413380a98ef
5
5
  SHA512:
6
- metadata.gz: 9834c2c5d1383e9ea216126aa7dd92ee8c04092fcae2f22ec01b2c99e69633c150d88848212a7736d8db528f29998039f18eb932d4e4eb2a79839af959af9727
7
- data.tar.gz: 43c2a682dda427c41995f9473ff9bf53a7cb5687f216c69fa321fc1a60a975bdb2745cb99204ac2dd14b1ff2efa8c206e1a67f3a86e486d0f0f609738efa9be8
6
+ metadata.gz: 022241e504a0616086c903a81dbac1d127ff1f9565a7a1d44338dc6207c061ea5e57fb6d15f08404621ee61b00399ddfed4c2f1f4b0639369e36f45301e62f54
7
+ data.tar.gz: 286cec2bbe861908b2f6279b404342ca145ede8733b5a80e77bd6dc9b39fe3eb5caa6f80ac18815a056511da2358263312649bf032588e8d03a3c306c750d04f
@@ -8,7 +8,12 @@ module Admin
8
8
  helper EffectiveLoggingHelper
9
9
 
10
10
  def index
11
- @datatable = Effective::Datatables::Logs.new()
11
+ if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
12
+ @datatable = Effective::Datatables::Logs.new()
13
+ else
14
+ @datatable = EffectiveLogsDatatable.new(self)
15
+ end
16
+
12
17
  @page_title = 'Logs'
13
18
 
14
19
  EffectiveLogging.authorized?(self, :index, Effective::Log)
@@ -23,7 +28,11 @@ module Admin
23
28
  @page_title = "Log ##{@log.to_param}"
24
29
 
25
30
  if @log.logs.present?
26
- @log.datatable = Effective::Datatables::Logs.new(log_id: @log.id) if defined?(EffectiveDatatables)
31
+ if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
32
+ @log.datatable = Effective::Datatables::Logs.new(log_id: @log.id)
33
+ else
34
+ @log.datatable = EffectiveLogsDatatable.new(self, log_id: @log.id)
35
+ end
27
36
  end
28
37
 
29
38
  EffectiveLogging.authorized?(self, :show, @log)
@@ -39,8 +39,11 @@ module Effective
39
39
 
40
40
  # This is the User index event
41
41
  def index
42
- @datatable = Effective::Datatables::Logs.new(user_id: current_user.id)
43
- @page_title = 'My Activity'
42
+ if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
43
+ @datatable = Effective::Datatables::Logs.new(user_id: current_user.id)
44
+ else
45
+ @datatable = EffectiveLogsDatatable.new(self, user_id: current_user.id)
46
+ end
44
47
 
45
48
  EffectiveLogging.authorized?(self, :index, Effective::Log.new(user_id: current_user.id))
46
49
  end
@@ -54,7 +57,11 @@ module Effective
54
57
  @page_title = "Log ##{@log.to_param}"
55
58
 
56
59
  if @log.logs.present?
57
- @log.datatable = Effective::Datatables::Logs.new(log_id: @log.id) if defined?(EffectiveDatatables)
60
+ if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
61
+ @log.datatable = Effective::Datatables::Logs.new(log_id: @log.id)
62
+ else
63
+ @log.datatable = EffectiveLogsDatatable.new(self, log_id: @log.id)
64
+ end
58
65
  end
59
66
 
60
67
  EffectiveLogging.authorized?(self, :show, @log)
@@ -0,0 +1,68 @@
1
+ unless Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
2
+ class EffectiveLogsDatatable < Effective::Datatable
3
+ datatable do
4
+ order :updated_at
5
+
6
+ col :updated_at, label: 'Date'
7
+ col :id, visible: false
8
+
9
+ if attributes[:user] == false
10
+ # Do not include
11
+ elsif attributes[:user_id].present?
12
+ col :user, search: { collection: User.where(id: Array(attributes[:user_id])) }
13
+ elsif attributes[:user].present?
14
+ col :user, search: { collection: User.where(id: Array(attributes[:user]).map { |user| user.to_param }) }
15
+ else
16
+ col :user, search: { as: :string }
17
+ end
18
+
19
+ unless attributes[:status] == false
20
+ col :status, search: { collection: EffectiveLogging.statuses }
21
+ end
22
+
23
+ unless attributes[:log_changes]
24
+ col :associated_type, search: { as: :string }, visible: false
25
+ col :associated_id, search: { as: :integer }, visible: false, label: 'Associated Id'
26
+ col :associated_to_s, search: { as: :string }, label: 'Associated'
27
+ end
28
+
29
+ col :message do |log|
30
+ log.message.starts_with?("\t") ? log.message.gsub("\t", "&nbsp;&nbsp;") : log.message
31
+ end
32
+
33
+ col :logs_count, visible: false
34
+
35
+ col :details, visible: false, sort: false do |log|
36
+ tableize_hash(log.details.except(:email), th: true, sub_th: false, width: '100%')
37
+ end
38
+
39
+ actions_col partial: 'admin/logs/actions', partial_as: :log
40
+ end
41
+
42
+ # A nil attributes[:log_id] means give me all the top level log entries
43
+ # If we set a log_id then it's for sub logs
44
+ collection do
45
+ scope = Effective::Log.unscoped.where(parent_id: attributes[:log_id]).includes(:user, :associated)
46
+
47
+ if attributes[:log_changes]
48
+ scope = scope.where(status: EffectiveLogging.log_changes_status)
49
+ end
50
+
51
+ if (attributes[:user] || attributes[:user_id]).present?
52
+ user_ids = Array(attributes[:user].presence || attributes[:user_id]).map { |user| user.kind_of?(User) ? user.id : user.to_i }
53
+ scope = scope.where('user_id IN (?) OR (associated_id IN (?) AND associated_type = ?)', user_ids, user_ids, 'User')
54
+ end
55
+
56
+ if attributes[:associated_id] && attributes[:associated_type]
57
+ scope = scope.where(associated_id: attributes[:associated_id], associated_type: attributes[:associated_type])
58
+ end
59
+
60
+ if attributes[:associated]
61
+ scope = scope.where(associated: attributes[:associated])
62
+ end
63
+
64
+ scope
65
+ end
66
+
67
+ end
68
+ end
@@ -1,4 +1,4 @@
1
- if defined?(EffectiveDatatables) && Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
1
+ if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
2
2
  module Effective
3
3
  module Datatables
4
4
  class Logs < Effective::Datatable
@@ -74,80 +74,3 @@ if defined?(EffectiveDatatables) && Gem::Version.new(EffectiveDatatables::VERSIO
74
74
  end
75
75
  end
76
76
  end
77
-
78
- if defined?(EffectiveDatatables) && Gem::Version.new(EffectiveDatatables::VERSION) >= Gem::Version.new('3.0')
79
- module Effective
80
- module Datatables
81
- class Logs < Effective::Datatable
82
- include EffectiveLoggingHelper
83
-
84
- datatable do
85
- order :updated_at
86
-
87
- col :updated_at, label: 'Date'
88
- col :id, visible: false
89
-
90
- if attributes[:user] == false
91
- # Do not include
92
- elsif attributes[:user_id].present?
93
- col :user, search: { collection: User.where(id: Array(attributes[:user_id])) }
94
- elsif attributes[:user].present?
95
- col :user, search: { collection: User.where(id: Array(attributes[:user]).map { |user| user.to_param }) }
96
- else
97
- col :user, search: {as: :string}
98
- end
99
-
100
- unless attributes[:status] == false
101
- col :status, search: { collection: EffectiveLogging.statuses }
102
- end
103
-
104
- unless attributes[:log_changes]
105
- col :associated_type, search: { as: :string }, visible: false
106
- col :associated_id, search: { as: :integer }, visible: false, label: 'Associated Id'
107
- col :associated_to_s, search: { as: :string }, label: 'Associated'
108
- end
109
-
110
- col :message do |log|
111
- log.message.starts_with?("\t") ? log.message.gsub("\t", "&nbsp;&nbsp;") : log.message
112
- end
113
-
114
- col :logs_count, visible: false
115
-
116
- col :details, visible: false, sort: false do |log|
117
- tableize_hash(log.details.except(:email), th: true, sub_th: false, width: '100%')
118
- end
119
-
120
- # unless attributes[:actions] == false
121
- # actions_col partial: 'admin/logs/actions'
122
- # end
123
- end
124
-
125
- # A nil attributes[:log_id] means give me all the top level log entries
126
- # If we set a log_id then it's for sub logs
127
- collection do
128
- scope = Effective::Log.unscoped.where(parent_id: attributes[:log_id]).includes(:user, :associated)
129
-
130
- if attributes[:log_changes]
131
- scope = scope.where(status: EffectiveLogging.log_changes_status)
132
- end
133
-
134
- if (attributes[:user] || attributes[:user_id]).present?
135
- user_ids = Array(attributes[:user].presence || attributes[:user_id]).map { |user| user.kind_of?(User) ? user.id : user.to_i }
136
- scope = scope.where('user_id IN (?) OR (associated_id IN (?) AND associated_type = ?)', user_ids, user_ids, 'User')
137
- end
138
-
139
- if attributes[:associated_id] && attributes[:associated_type]
140
- scope = scope.where(associated_id: attributes[:associated_id], associated_type: attributes[:associated_type])
141
- end
142
-
143
- if attributes[:associated]
144
- scope = scope.where(associated: attributes[:associated])
145
- end
146
-
147
- scope
148
- end
149
-
150
- end
151
- end
152
- end
153
- end
@@ -1,8 +1,6 @@
1
1
  :ruby
2
2
  show_path =
3
- if datatables_active_admin_path?
4
- admin_effective_log_path(log)
5
- elsif datatables_admin_path?
3
+ if datatable.try(:admin_namespace?)
6
4
  effective_logging.admin_log_path(log)
7
5
  else
8
6
  effective_logging.log_path(log)
@@ -1,18 +1,14 @@
1
1
  .panel{:class => "panel-#{bootstrap_class_for_status(log.status)}"}
2
2
  .panel-heading
3
- - parents_of_log(log).each do |parent|
4
- = link_to(log.message, (request.fullpath.gsub(log.to_param, parent.to_param) rescue '#'))
5
- = ' > '
6
- %strong= log.message
7
- .pull-right
8
- - if log.prev_log.present?
9
- = link_to '< Prev', request.fullpath.gsub(log.to_param, log.prev_log.try(:to_param).to_s)
10
-
11
- - if log.prev_log && log.next_log
12
- = ' - '
13
-
14
- - if log.next_log.present?
15
- = link_to 'Next >', request.fullpath.gsub(log.to_param, log.next_log.try(:to_param).to_s)
3
+ .row
4
+ .col-sm-10
5
+ - parents_of_log(log).each do |parent|
6
+ = link_to(log.message, (request.fullpath.gsub(log.to_param, parent.to_param) rescue '#'))
7
+ = ' > '
8
+ %p= log.message
9
+ .col-sm-2.text-right
10
+ = link_to 'Prev', request.fullpath.gsub(log.to_param, log.prev_log.try(:to_param).to_s), class: 'btn btn-default', disabled: log.prev_log.blank?
11
+ = link_to 'Next', request.fullpath.gsub(log.to_param, log.next_log.try(:to_param).to_s), class: 'btn btn-default', disabled: log.next_log.blank?
16
12
 
17
13
  .panel-body
18
14
  .row
@@ -1,3 +1,3 @@
1
1
  module EffectiveLogging
2
- VERSION = '1.10.5'.freeze
2
+ VERSION = '1.10.6'.freeze
3
3
  end
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: 1.10.5
4
+ version: 1.10.6
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: 2017-03-27 00:00:00.000000000 Z
11
+ date: 2017-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -108,6 +108,7 @@ files:
108
108
  - app/assets/javascripts/effective_logging/effective_logger.js.coffee.erb
109
109
  - app/controllers/admin/logs_controller.rb
110
110
  - app/controllers/effective/logs_controller.rb
111
+ - app/datatables/effective_logs_datatable.rb
111
112
  - app/helpers/effective_logging_helper.rb
112
113
  - app/models/concerns/acts_as_loggable.rb
113
114
  - app/models/effective/access_denied.rb