audit-log 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/audit_log/logs_controller.rb +4 -5
- data/app/views/audit_log/logs/index.html.erb +7 -0
- data/config/locales/audit-log.yml +7 -0
- data/lib/audit-log.rb +8 -0
- data/lib/audit-log/version.rb +1 -1
- data/lib/generators/audit_log/install_generator.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff47ceeaafa81e2d3304bb1af31fb95c8452259143fda90885098f19cf845629
|
4
|
+
data.tar.gz: d02286a6864dae879eebf298ab978843b21ec1917090f676ec9855f1efe00075
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cc4a89d75d0003e9e321dfc92c03e7ae1fb50abf1cb8ecfce22f92ec099ef884917671641496c1040490dac058b1167664e531fff3f2c9ce7f92f0e4e9bbe69
|
7
|
+
data.tar.gz: d1e3b71587b23079eb19b7b05c0b5520bcdd2a79f236d18d4e041343abdda15fa5c5a73d2691d21727d31af41d53e505799fe8dd724a932282b485cb250c87f9
|
data/README.md
CHANGED
@@ -7,11 +7,10 @@ module AuditLog
|
|
7
7
|
|
8
8
|
def index
|
9
9
|
@logs = Log.order('id desc').includes(:user)
|
10
|
-
|
11
|
-
if params[:
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
@logs = @logs.where('action like ?', "%#{params[:q]}%") if params[:q].present?
|
11
|
+
@logs = @logs.where("action = ?", params[:action_type]) if params[:action_type].present?
|
12
|
+
@logs = @logs.where("created_at >= ?", Time.parse(params[:start_time])) if params[:start_time].present?
|
13
|
+
@logs = @logs.where("created_at < ?", Time.parse(params[:end_time])) if params[:end_time].present?
|
15
14
|
@logs = @logs.page(params[:page]).per(15)
|
16
15
|
end
|
17
16
|
|
@@ -1,7 +1,14 @@
|
|
1
1
|
<div class="toolbar">
|
2
2
|
<form class="form-inline" action="<%= audit_log.logs_path %>" method="GET">
|
3
|
+
<div class="form-group">
|
4
|
+
<%= select_tag(:action_type, options_for_select(AuditLog.action_options, params[:action_type]), include_blank: "All actions", class: "form-control") %>
|
5
|
+
</div>
|
6
|
+
|
3
7
|
<div class="form-group">
|
4
8
|
<input name="q" type="text" class="form-control" placeholder="Search action" value="<%= params[:q] %>" />
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="form-group">
|
5
12
|
<button type="submit" class="btn btn-primary">Search</button>
|
6
13
|
</div>
|
7
14
|
</form>
|
data/lib/audit-log.rb
CHANGED
@@ -33,6 +33,9 @@ module AuditLog
|
|
33
33
|
}
|
34
34
|
end
|
35
35
|
|
36
|
+
# Set nil if record is a new_record, do this for avoid create record.
|
37
|
+
record = nil if record&.new_record?
|
38
|
+
|
36
39
|
AuditLog::Log.create!(
|
37
40
|
action: action,
|
38
41
|
record: record,
|
@@ -41,5 +44,10 @@ module AuditLog
|
|
41
44
|
request: request_info.deep_stringify_keys
|
42
45
|
)
|
43
46
|
end
|
47
|
+
|
48
|
+
# Get I18n action name options for select
|
49
|
+
def action_options(locale: I18n.default_locale)
|
50
|
+
I18n.backend.send(:translations)[locale][:audit_log][:action].map { |k, v| [v, k.to_s] }
|
51
|
+
end
|
44
52
|
end
|
45
53
|
end
|
data/lib/audit-log/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: audit-log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kaminari
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- app/views/audit_log/logs/show.html.erb
|
72
72
|
- app/views/layouts/audit-log/application.html.erb
|
73
73
|
- config/initializers/audit-log.rb
|
74
|
+
- config/locales/audit-log.yml
|
74
75
|
- config/routes.rb
|
75
76
|
- db/migrate/20190527035005_create_audit_logs.rb
|
76
77
|
- lib/audit-log.rb
|