admin/logs viewer implemented
This commit is contained in:
parent
79bf7a2276
commit
b1dbcef80b
8 changed files with 27 additions and 15 deletions
|
|
@ -1,4 +1,6 @@
|
|||
class AdminController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
|
||||
def status
|
||||
end
|
||||
|
||||
|
|
@ -7,4 +9,15 @@ class AdminController < ApplicationController
|
|||
|
||||
def integration
|
||||
end
|
||||
|
||||
def logs
|
||||
logs = Log
|
||||
|
||||
if params[:search].present?
|
||||
logger.debug "Searching for #{params[:search]}"
|
||||
logs = logs.where("message ilike ?", "%#{params[:search]}%")
|
||||
end
|
||||
|
||||
@logs = logs.paginate(page: params[:page], per_page: 20)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class Log < ApplicationRecord
|
|||
validates :level, inclusion: { in: ['info', 'error'] }
|
||||
|
||||
default_scope {
|
||||
order('created_at ASC')
|
||||
order('id DESC')
|
||||
}
|
||||
|
||||
def self.log(message, section='frontend', level='info')
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
h1 Admin#integration
|
||||
p Find me in app/views/admin/integration.html.slim
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
.grid-x
|
||||
.small-6.medium-8.large-9.cell
|
||||
// Paginator
|
||||
= render 'logs/paginator'
|
||||
= render 'admin/logs/paginator'
|
||||
|
||||
.small-6.medium-4.large-3.cell
|
||||
// Search form
|
||||
|
|
@ -18,10 +18,10 @@
|
|||
th Message
|
||||
- @logs.each do |log|
|
||||
tr
|
||||
th =log.created_at
|
||||
th =log.message
|
||||
td =log.created_at
|
||||
td =log.message
|
||||
- else
|
||||
p No logs found. Crazy.
|
||||
|
||||
// Second paginator at the bottom so the user does not have to scroll up again
|
||||
= render 'logs/paginator'
|
||||
= render 'admin/logs/paginator'
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
h1 Admin#screenshots
|
||||
p Find me in app/views/admin/screenshots.html.slim
|
||||
|
|
@ -42,16 +42,19 @@ nav.top-bar
|
|||
// TODO: Check correct classes in Zurb/Foundation for top bar!
|
||||
- if user_signed_in? and current_user.is_admin?
|
||||
li.menu-text
|
||||
a href='#' Admin
|
||||
/ ul.menu.vertical
|
||||
/ li = link_to 'Moderate', moderate_path
|
||||
/ li = link_to 'Logs', logs_path
|
||||
ul.menu.dropdown data-dropdown-menu=true
|
||||
li
|
||||
a href='#' Admin
|
||||
ul.menu
|
||||
/ li = link_to 'Health', admin_health_path
|
||||
li = link_to 'Logs', admin_logs_path
|
||||
/ li = link_to 'Users', admin_users_pathlogs_path
|
||||
.top-bar-right
|
||||
ul.menu
|
||||
li.menu-text class=('active' if controller_name=='my')
|
||||
- if user_signed_in?
|
||||
= link_to my_profile_path
|
||||
= image_tag "/images/sso/icons/#{current_user.provider}.svg", width: 20
|
||||
/ = image_tag "/images/sso/icons/#{current_user.provider}.svg", width: 20
|
||||
' My
|
||||
- else
|
||||
= link_to 'Login', new_user_session_path
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Rails.application.routes.draw do
|
|||
get 'packages/list' => 'packages#list', as: :packages_list
|
||||
get 'packages?show=without' => 'packages#grid?show=without', as: :packages_without
|
||||
get 'moderate' => 'moderate#index'
|
||||
get 'logs' => 'logs#index'
|
||||
get 'admin/logs' => 'admin#logs'
|
||||
get 'my/profile'
|
||||
get 'my/uploads'
|
||||
get 'my/welcome'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue