Commit 9f5ba22
Changed files (10)
app
helpers
javascript
styles
views
layouts
my
audits
user_sessions
config
locales
app/helpers/application_helper.rb
@@ -23,4 +23,15 @@ module ApplicationHelper
Array(item)
end
end
+
+ def audit_icon_for(audit)
+ case audit.auditable_type
+ when 'User'
+ 'fa-user'
+ when 'UserSession'
+ 'fa-bookmark'
+ else
+ 'fa-archive'
+ end
+ end
end
app/javascript/styles/application.scss
@@ -2,6 +2,7 @@
@import '~@fortawesome/fontawesome-free/scss/regular';
@import '~@fortawesome/fontawesome-free/scss/solid';
@import '~bulma/bulma';
+@import '~bourbon/core/bourbon';
@keyframes spinner {
0% { transform: rotate(0deg); }
@@ -19,3 +20,9 @@
width: 48px;
height: 48px;
}
+
+.my-audits-index {
+ .attribute-truncate {
+ @include ellipsis(200px);
+ }
+}
app/views/layouts/application.html.erb
@@ -8,7 +8,7 @@
<%= javascript_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_pack_tag 'application' %>
</head>
- <body>
+ <body class="<%= body_class %>">
<div class="container" data-controller="content-loader" data-content-loader-url="<%= session_path %>"></div>
<%= render partial: 'flash' %>
<%= yield %>
app/views/my/audits/_audit.html.erb
@@ -1,14 +1,14 @@
<div class="box">
<article class="media">
<div class="media-left">
- <figure class="image is-64x64">
- <img src="https://bulma.io/images/placeholders/128x128.png" alt="Image">
- </figure>
+ <span class="icon is-large">
+ <i class="fas <%= audit_icon_for(audit) %> fa-3x" aria-hidden="true"></i>
+ </span>
</div>
<div class="media-content">
<div class="content">
<p>
- <strong><%= audit.auditable_type.constantize.model_name.human %></strong> <small><%= audit.action %></small> <small><%= local_time_ago(audit.created_at) %></small>
+ <strong><%= audit.auditable_type.constantize.model_name.human %></strong> <small><%= t(audit.action) %></small> <small><%= local_time_ago(audit.created_at) %></small>
by <%= audit.user&.email %> from <%= audit.remote_address %> (version <%= audit.version %>)
</p>
<table class="table is-bordered is-narrow is-hoverable is-striped is-fullwidth">
@@ -20,9 +20,11 @@
<tbody>
<% audit.audited_changes.each do |(key, value)| %>
<tr>
+ <% old = value.is_a?(Array) ? value[0] : nil %>
+ <% new = value.is_a?(Array) ? value[1] : value %>
<td><%= audit.auditable_type.constantize.human_attribute_name(key) %></td>
- <td><%= value.is_a?(Array) ? value[0] : nil %></td>
- <td><%= value.is_a?(Array) ? value[1] : value %></td>
+ <td title="<%= old %>"><p class="attribute-truncate"><%= old %></p></td>
+ <td title="<%= new %>"><p class="attribute-truncate"><%= new %></p></td>
</tr>
<% end %>
</tbody>
app/views/my/user_sessions/_user_session.html.erb
@@ -2,7 +2,7 @@
<article class="media">
<div class="media-left">
<figure class="image is-64x64">
- <img src="https://cdnjs.cloudflare.com/ajax/libs/browser-logos/46.1.0/<%= user_session.browser.name.downcase %>/<%= user_session.browser.name.downcase %>_128x128.png" alt="<%= user_session.browser.name %>" />
+ <img src="https://cdnjs.cloudflare.com/ajax/libs/browser-logos/46.1.0/<%= user_session.browser.name.downcase %>/<%= user_session.browser.name.downcase %>_64x64.png" alt="<%= user_session.browser.name %>" />
</figure>
</div>
<div class="media-content">
config/locales/en.yml
@@ -7,6 +7,17 @@ en:
password: password
schemas: schemas
userName: userName
+ activerecord:
+ attributes:
+ user:
+ mfa_secret: MFA Secret
+ password_digest: Password
+ user_session:
+ ip: IP Address
+ sudo_enabled_at: Sudo Enabled At
+ user_agent: User Agent
+ models:
+ user_session: Session
errors:
bad_request:
title: 400 - Bad Request
@@ -32,6 +43,10 @@ en:
title: MFA Login
my:
audits:
+ audit:
+ attribute: Attribute
+ new: New
+ old: Old
index:
action: Action
associated: Associated
Gemfile
@@ -13,6 +13,7 @@ gem 'dotenv', '~> 2.5'
gem 'email_validator', '~> 1.6'
gem 'flipper', '~> 0.16'
gem 'flipper-active_record', '~> 0.16'
+gem 'flutie', '~> 2.1'
gem 'jbuilder', '~> 2.5'
gem 'jwt', '~> 2.1'
gem 'local_time', '~> 2.1'
Gemfile.lock
@@ -118,6 +118,7 @@ GEM
flipper-active_record (0.16.0)
activerecord (>= 3.2, < 6)
flipper (~> 0.16.0)
+ flutie (2.1.0)
forwardable-extended (2.6.0)
globalid (0.4.1)
activesupport (>= 4.2.0)
@@ -363,6 +364,7 @@ DEPENDENCIES
ffaker (~> 2.10)
flipper (~> 0.16)
flipper-active_record (~> 0.16)
+ flutie (~> 2.1)
i18n-tasks (~> 0.9.24)
jbuilder (~> 2.5)
jekyll (~> 3.8)
package.json
@@ -13,6 +13,7 @@
"dependencies": {
"@rails/webpacker": "3.4",
"@stimulus/polyfills": "^1.1.0",
+ "bourbon": "^5.1.0",
"bulma": "^0.7.2",
"jquery": "^3.3.1",
"json-loader": "^0.5.7",
yarn.lock
@@ -1355,6 +1355,11 @@ boom@2.x.x:
dependencies:
hoek "2.x.x"
+bourbon@^5.1.0:
+ version "5.1.0"
+ resolved "https://registry.yarnpkg.com/bourbon/-/bourbon-5.1.0.tgz#84fa10de4c4e837602d8c2ec716d74bcb8915bad"
+ integrity sha512-rO4rwNAVNuzPmnL+DruxAe7DR2YFFo4nHsgDVRd9URMgDxtHmVBUnvFLXPan6teVe7jkybCyxcnR+CKClotj3g==
+
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"