Add basic exception view
This commit is contained in:
parent
0a69a6a8cb
commit
dac8ef2283
9
app/controllers/exceptions_controller.rb
Normal file
9
app/controllers/exceptions_controller.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class ExceptionsController < ApplicationController
|
||||
def index
|
||||
@pagy, @exceptions = pagy(ExceptionLog.order(id: :desc), items: 25)
|
||||
end
|
||||
|
||||
def show
|
||||
@exception = ExceptionLog.find(params[:id])
|
||||
end
|
||||
end
|
|
@ -6,6 +6,7 @@
|
|||
@import "yiff.media/home";
|
||||
@import "yiff.rest/home";
|
||||
@import "yiff.rocks/home";
|
||||
@import "exceptions";
|
||||
|
||||
div#notice {
|
||||
padding: 0.25em;
|
||||
|
@ -51,3 +52,64 @@ body.c-application {
|
|||
.backtrace-line {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
// Bootstrap does not have built in dark pagination
|
||||
.pagy-bootstrap {
|
||||
$gray-100: #f8f9fa;
|
||||
$gray-600: #6c757d;
|
||||
$gray-800: #343a40;
|
||||
$pagination-focus-outline: 0;
|
||||
$focus-ring-width: 0.25rem;
|
||||
$focus-ring-opacity: 0.25;
|
||||
$blue: #0d6efd;
|
||||
$white: #fff;
|
||||
$primary: $blue;
|
||||
$focus-ring-color: rgba($primary, $focus-ring-opacity);
|
||||
$focus-ring-blur: 0;
|
||||
$focus-ring-box-shadow: 0 0 $focus-ring-blur $focus-ring-width
|
||||
$focus-ring-color;
|
||||
$pagination-focus-box-shadow: $focus-ring-box-shadow;
|
||||
|
||||
$pagination-dark-color: $gray-100;
|
||||
$pagination-dark-bg: $gray-800;
|
||||
$pagination-dark-border-color: $gray-600;
|
||||
|
||||
$pagination-dark-hover-color: $pagination-dark-color;
|
||||
$pagination-dark-hover-bg: $gray-600;
|
||||
$pagination-dark-hover-border-color: $pagination-dark-border-color;
|
||||
$component-active-color: $white;
|
||||
$component-active-bg: $primary;
|
||||
$pagination-active-color: $component-active-color;
|
||||
$pagination-active-bg: $component-active-bg;
|
||||
$pagination-active-border-color: $component-active-bg;
|
||||
|
||||
.page-link {
|
||||
color: $pagination-dark-color;
|
||||
background-color: $pagination-dark-bg;
|
||||
border-color: $pagination-dark-border-color;
|
||||
|
||||
&:hover {
|
||||
color: $pagination-dark-hover-color;
|
||||
background-color: $pagination-dark-hover-bg;
|
||||
border-color: $pagination-dark-hover-border-color;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
outline: $pagination-focus-outline;
|
||||
box-shadow: $pagination-focus-box-shadow;
|
||||
}
|
||||
}
|
||||
|
||||
.page-item {
|
||||
&.active .page-link {
|
||||
color: $pagination-active-color;
|
||||
background-color: $pagination-active-bg;
|
||||
border-color: $pagination-active-border-color;
|
||||
}
|
||||
|
||||
&.disabled .page-link {
|
||||
background-color: $pagination-dark-bg;
|
||||
border-color: $pagination-dark-border-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
12
app/javascript/styles/exceptions.scss
Normal file
12
app/javascript/styles/exceptions.scss
Normal file
|
@ -0,0 +1,12 @@
|
|||
body.c-exceptions {
|
||||
background-color: #2C2F33;
|
||||
color: #FFFDD0;
|
||||
|
||||
a {
|
||||
color: #FFF;
|
||||
}
|
||||
}
|
||||
|
||||
.backtrace-line {
|
||||
list-style: none;
|
||||
}
|
|
@ -7,67 +7,6 @@ body.s-v2-yiff-rest {
|
|||
text-decoration: none;
|
||||
}
|
||||
|
||||
// Bootstrap does not have built in dark pagination
|
||||
.pagy-bootstrap {
|
||||
$gray-100: #f8f9fa;
|
||||
$gray-600: #6c757d;
|
||||
$gray-800: #343a40;
|
||||
$pagination-focus-outline: 0;
|
||||
$focus-ring-width: 0.25rem;
|
||||
$focus-ring-opacity: 0.25;
|
||||
$blue: #0d6efd;
|
||||
$white: #fff;
|
||||
$primary: $blue;
|
||||
$focus-ring-color: rgba($primary, $focus-ring-opacity);
|
||||
$focus-ring-blur: 0;
|
||||
$focus-ring-box-shadow: 0 0 $focus-ring-blur $focus-ring-width
|
||||
$focus-ring-color;
|
||||
$pagination-focus-box-shadow: $focus-ring-box-shadow;
|
||||
|
||||
$pagination-dark-color: $gray-100;
|
||||
$pagination-dark-bg: $gray-800;
|
||||
$pagination-dark-border-color: $gray-600;
|
||||
|
||||
$pagination-dark-hover-color: $pagination-dark-color;
|
||||
$pagination-dark-hover-bg: $gray-600;
|
||||
$pagination-dark-hover-border-color: $pagination-dark-border-color;
|
||||
$component-active-color: $white;
|
||||
$component-active-bg: $primary;
|
||||
$pagination-active-color: $component-active-color;
|
||||
$pagination-active-bg: $component-active-bg;
|
||||
$pagination-active-border-color: $component-active-bg;
|
||||
|
||||
.page-link {
|
||||
color: $pagination-dark-color;
|
||||
background-color: $pagination-dark-bg;
|
||||
border-color: $pagination-dark-border-color;
|
||||
|
||||
&:hover {
|
||||
color: $pagination-dark-hover-color;
|
||||
background-color: $pagination-dark-hover-bg;
|
||||
border-color: $pagination-dark-hover-border-color;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
outline: $pagination-focus-outline;
|
||||
box-shadow: $pagination-focus-box-shadow;
|
||||
}
|
||||
}
|
||||
|
||||
.page-item {
|
||||
&.active .page-link {
|
||||
color: $pagination-active-color;
|
||||
background-color: $pagination-active-bg;
|
||||
border-color: $pagination-active-border-color;
|
||||
}
|
||||
|
||||
&.disabled .page-link {
|
||||
background-color: $pagination-dark-bg;
|
||||
border-color: $pagination-dark-border-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.category-list, .category-image-list {
|
||||
a {
|
||||
color: #ede660;
|
||||
|
|
|
@ -30,11 +30,10 @@ class YiffyAPIErrorCodes
|
|||
METHOD_NOT_ALLOWED = new(1025, 405)
|
||||
|
||||
# legacy codes that are spread out
|
||||
# unused
|
||||
IMAGES_INVALID_RESPONSE_TYPE = new(1023, nil)
|
||||
IMAGES_INVALID_RESPONSE_TYPE = new(1023, nil) # unused
|
||||
IMAGES_CATEGORY_NOT_FOUND = new(1030, 404)
|
||||
# unused
|
||||
IMAGES_EMPTY_CATEGORY = new(1031, nil)
|
||||
|
||||
IMAGES_EMPTY_CATEGORY = new(1031, nil) # unused
|
||||
IMAGES_NOT_FOUND = new(1040, 404)
|
||||
IMAGES_NO_RESULTS = new(1041, 400)
|
||||
IMAGES_AMOUNT_LT_ONE = new(1051, 400)
|
||||
|
|
|
@ -35,7 +35,7 @@ class APIImage < ApplicationRecord
|
|||
invalidate_cache
|
||||
end
|
||||
|
||||
def file_header_info(file_path)
|
||||
def file_header_info(file_path)
|
||||
File.open(file_path) do |bin|
|
||||
mime_type = Marcel::MimeType.for(bin)
|
||||
ext = case mime_type
|
||||
|
|
30
app/views/exceptions/index.html.erb
Normal file
30
app/views/exceptions/index.html.erb
Normal file
|
@ -0,0 +1,30 @@
|
|||
<table class="table table-striped table-dark">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 200px">Created At</th>
|
||||
<th>Code</th>
|
||||
<th style="width: 100px">Commit</th>
|
||||
<th>Controller/Action</th>
|
||||
<th>Message</th>
|
||||
<th>Stacktrace</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @exceptions.each do |exception| %>
|
||||
<tr>
|
||||
<td><%= compact_time(exception.created_at) %></td>
|
||||
<td><%= exception.code %></td>
|
||||
<td><%= exception.version.present? ? link_to(exception.version, GitHelper.commit_url(exception.version)) : "Unknown" %></td>
|
||||
<td><%= exception.extra_params.dig("params", "controller") %>/<%= exception.extra_params.dig("params", "action") %></td>
|
||||
<td><%= truncate(exception.message, length: 50) %></td>
|
||||
<td><%= link_to("View", exception_path(exception)) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
|
||||
<footer class="bg-dark pt-3 fixed-bottom">
|
||||
<div class=" d-flex align-items-center justify-content-center">
|
||||
<%== pagy_bootstrap_nav(@pagy) if @pagy.pages > 1 %>
|
||||
</div>
|
||||
</footer>
|
23
app/views/exceptions/show.html.erb
Normal file
23
app/views/exceptions/show.html.erb
Normal file
|
@ -0,0 +1,23 @@
|
|||
<div>
|
||||
<div class="box-section">
|
||||
<h3><%= @exception.class_name %></h3>
|
||||
<pre><code><%= @exception.message %></code></pre>
|
||||
<br>
|
||||
<div>
|
||||
Error Code: <%= @exception.code %><br/>
|
||||
Created At: <%= compact_time @exception.created_at %><br/>
|
||||
Commit: <%= @exception.version %><br/>
|
||||
IP Address: <%= @exception.ip_addr %><br/>
|
||||
</div>
|
||||
</div>
|
||||
<strong>Extra Params:</strong>
|
||||
<pre class="box-section"><%= JSON.pretty_generate(@exception.extra_params) %></pre>
|
||||
<strong>Stacktrace:</strong>
|
||||
<pre class="box-section"><%= Rails.backtrace_cleaner.clean(@exception.trace.split("\n")).join("\n") %></pre>
|
||||
<strong>Raw Stacktrace:</strong>
|
||||
<pre class="box-section"><%= @exception.trace %></pre>
|
||||
</div>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Exceptions - <%= @exception.code %>
|
||||
<% end %>
|
|
@ -264,6 +264,9 @@ module Websites
|
|||
|
||||
def e621_apikey
|
||||
end
|
||||
|
||||
def exceptions_domain
|
||||
end
|
||||
end
|
||||
|
||||
class EnvironmentConfiguration
|
||||
|
|
|
@ -9,6 +9,8 @@ Rails.application.routes.draw do
|
|||
extend YiffMediaRoutes
|
||||
extend YiffRestRoutes
|
||||
extend YiffRocksRoutes
|
||||
extend OtherRoutes
|
||||
|
||||
get "up" => "rails/health#show", as: :rails_health_check
|
||||
|
||||
get "/online", to: "application#online"
|
||||
|
|
11
config/routes/other_routes.rb
Normal file
11
config/routes/other_routes.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module OtherRoutes
|
||||
def self.extended(router)
|
||||
router.instance_exec do
|
||||
constraints(DomainConstraint.new(Websites.config.exceptions_domain, "exceptions")) do
|
||||
resources(:exceptions, only: %i[index show], path: "")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user