effective_logging 1.10.1 → 1.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/app/models/effective/datatables/logs.rb +9 -3
- data/app/models/effective/log.rb +4 -0
- data/lib/effective_logging/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c25bb89ed7d4ea61f1a557b544bc2476d87346a
|
4
|
+
data.tar.gz: c648b6749add1af7a26aa1ae8afc189b90b906b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9900a5a17e851dae1b6e41a61c73972c29b91108bfb1359a436baa828f00c07e30ddfd46112cb51b145f8e8f9b3852d1d94c83d23cc8e6c3944a54737aeae470
|
7
|
+
data.tar.gz: 0da0a1ce53129cbe60680b5766e7dac74a2710e3ac6295247e0fcb10a1d0aeb1bfecbcb2dcb15333cd39ba22784f48313d7ceb5ce518d3dfe462f4c81de353cb
|
data/README.md
CHANGED
@@ -261,6 +261,12 @@ First, require the javascript in your application.js:
|
|
261
261
|
//= require effective_logging
|
262
262
|
```
|
263
263
|
|
264
|
+
and add the user permission:
|
265
|
+
|
266
|
+
```ruby
|
267
|
+
can :create, Effective::Log
|
268
|
+
```
|
269
|
+
|
264
270
|
then logging an event from JavaScript is almost the same one-liner as from ruby:
|
265
271
|
|
266
272
|
```javascript
|
@@ -10,7 +10,13 @@ if defined?(EffectiveDatatables)
|
|
10
10
|
table_column :created_at
|
11
11
|
table_column :id, visible: false
|
12
12
|
|
13
|
-
|
13
|
+
if attributes[:user] == false
|
14
|
+
# Do not include
|
15
|
+
elsif attributes[:user_id].present?
|
16
|
+
table_column :user, filter: { collection: User.where(id: Array(attributes[:user_id])) }
|
17
|
+
elsif attributes[:user].present?
|
18
|
+
table_column :user, filter: { collection: User.where(id: Array(attributes[:user]).map { |user| user.to_param }) }
|
19
|
+
else
|
14
20
|
table_column :user
|
15
21
|
end
|
16
22
|
|
@@ -49,8 +55,8 @@ if defined?(EffectiveDatatables)
|
|
49
55
|
end
|
50
56
|
|
51
57
|
if (attributes[:user] || attributes[:user_id]).present?
|
52
|
-
|
53
|
-
collection = collection.where('user_id
|
58
|
+
user_ids = Array(attributes[:user].presence || attributes[:user_id]).map { |user| user.kind_of?(User) ? user.id : user.to_i }
|
59
|
+
collection = collection.where('user_id IN (?) OR (associated_id IN (?) AND associated_type = ?)', user_ids, user_ids, 'User')
|
54
60
|
end
|
55
61
|
|
56
62
|
if attributes[:associated_id] && attributes[:associated_type]
|
data/app/models/effective/log.rb
CHANGED
@@ -46,6 +46,10 @@ module Effective
|
|
46
46
|
"Log #{id}"
|
47
47
|
end
|
48
48
|
|
49
|
+
def message=(msg)
|
50
|
+
write_attribute(:message, msg.kind_of?(String) ? msg.to_s[0...255] : msg)
|
51
|
+
end
|
52
|
+
|
49
53
|
def log(message, status = EffectiveLogging.statuses.first, options = {})
|
50
54
|
EffectiveLogger.log(message, status, (options || {}).merge(parent: self))
|
51
55
|
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.
|
4
|
+
version: 1.10.2
|
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-01-
|
11
|
+
date: 2017-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|