21
1
Fork 0
mirror of https://github.com/Evolix/chexpire.git synced 2024-05-04 17:55:11 +02:00

Basic checks table

This commit is contained in:
Colin Darie 2018-06-05 17:27:12 +02:00
parent 12b0239e8f
commit 9c8b663de1
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
6 changed files with 53 additions and 22 deletions

View file

@ -5,7 +5,7 @@ class ChecksController < ApplicationController
after_action :verify_policy_scoped, only: :index
def index
@checks = policy_scope(Check)
@checks = policy_scope(Check).order(:domain_expires_at)
end
def new

View file

@ -0,0 +1,5 @@
.table-checks {
.action a {
color: black;
}
}

View file

@ -2,3 +2,4 @@
@import 'layout';
@import 'icons';
@import 'components/users';
@import 'components/checks';

View file

@ -1,2 +1,14 @@
module ChecksHelper
def check_kind_label(check)
check.kind.upcase
end
def check_row_class(check)
expiry_date = check.domain_expires_at
return unless expiry_date.present?
return "table-danger" if expiry_date <= 2.weeks.from_now
return "table-warning" if expiry_date <= 30.days.from_now
end
end

View file

@ -1,20 +1,32 @@
<% checks.each do |check| %>
<div class="mb-4">
<div>Domain: <%= check.domain %></div>
<div>Kind: <%= check.kind %></div>
<div>Created date: <%= l(check.domain_created_at.to_date) if check.domain_created_at.present? %></div>
<div>Update date: <%= l(check.domain_updated_at.to_date) if check.domain_updated_at.present? %></div>
<div>Expire date: <%= l(check.domain_expires_at.to_date) if check.domain_expires_at.present? %></div>
<% if check.comment? %>
<div>Comment: <%= check.comment %></div>
<% end %>
<% if check.vendor? %>
<div>Vendor: <%= check.vendor %></div>
<% end %>
<div>Active: <%= check.active %></div>
<%= link_to "Edit", edit_check_path(check) %>
</div>
<% end %>
<div class="mb-4">
<table class="table table-checks">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">Domain</th>
<th scope="col">Expiry date</th>
<th scope="col">Edit</th>
</tr>
</thead>
<tbody>
<% checks.each do |check| %>
<tr class="check-row <%= check_row_class(check) %>">
<td>
<span class="badge badge-secondary"><%= check_kind_label(check) %></span>
</td>
<td>
<strong><%= check.domain %></strong>
</td>
<td>
<%= format_utc(check.domain_expires_at) if check.domain_expires_at.present? %>
</td>
<td class="action">
<%= link_to edit_check_path(check) do %>
<%== Octicons::Octicon.new("pencil").to_svg %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>

View file

@ -58,7 +58,8 @@ class ChecksTest < ApplicationSystemTestCase
assert_equal checks_path, page.current_path
assert page.has_css?(".alert-success")
assert page.has_content?("My comment")
@check.reload
assert_equal "My comment", @check.comment
end
test "add a notification" do