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
|
class AdminController < ApplicationController
|
||||||
|
before_action :authenticate_user!
|
||||||
|
|
||||||
def status
|
def status
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -7,4 +9,15 @@ class AdminController < ApplicationController
|
||||||
|
|
||||||
def integration
|
def integration
|
||||||
end
|
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ class Log < ApplicationRecord
|
||||||
validates :level, inclusion: { in: ['info', 'error'] }
|
validates :level, inclusion: { in: ['info', 'error'] }
|
||||||
|
|
||||||
default_scope {
|
default_scope {
|
||||||
order('created_at ASC')
|
order('id DESC')
|
||||||
}
|
}
|
||||||
|
|
||||||
def self.log(message, section='frontend', level='info')
|
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
|
.grid-x
|
||||||
.small-6.medium-8.large-9.cell
|
.small-6.medium-8.large-9.cell
|
||||||
// Paginator
|
// Paginator
|
||||||
= render 'logs/paginator'
|
= render 'admin/logs/paginator'
|
||||||
|
|
||||||
.small-6.medium-4.large-3.cell
|
.small-6.medium-4.large-3.cell
|
||||||
// Search form
|
// Search form
|
||||||
|
|
@ -18,10 +18,10 @@
|
||||||
th Message
|
th Message
|
||||||
- @logs.each do |log|
|
- @logs.each do |log|
|
||||||
tr
|
tr
|
||||||
th =log.created_at
|
td =log.created_at
|
||||||
th =log.message
|
td =log.message
|
||||||
- else
|
- else
|
||||||
p No logs found. Crazy.
|
p No logs found. Crazy.
|
||||||
|
|
||||||
// Second paginator at the bottom so the user does not have to scroll up again
|
// 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!
|
// TODO: Check correct classes in Zurb/Foundation for top bar!
|
||||||
- if user_signed_in? and current_user.is_admin?
|
- if user_signed_in? and current_user.is_admin?
|
||||||
li.menu-text
|
li.menu-text
|
||||||
a href='#' Admin
|
ul.menu.dropdown data-dropdown-menu=true
|
||||||
/ ul.menu.vertical
|
li
|
||||||
/ li = link_to 'Moderate', moderate_path
|
a href='#' Admin
|
||||||
/ li = link_to 'Logs', logs_path
|
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
|
.top-bar-right
|
||||||
ul.menu
|
ul.menu
|
||||||
li.menu-text class=('active' if controller_name=='my')
|
li.menu-text class=('active' if controller_name=='my')
|
||||||
- if user_signed_in?
|
- if user_signed_in?
|
||||||
= link_to my_profile_path
|
= 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
|
' My
|
||||||
- else
|
- else
|
||||||
= link_to 'Login', new_user_session_path
|
= 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/list' => 'packages#list', as: :packages_list
|
||||||
get 'packages?show=without' => 'packages#grid?show=without', as: :packages_without
|
get 'packages?show=without' => 'packages#grid?show=without', as: :packages_without
|
||||||
get 'moderate' => 'moderate#index'
|
get 'moderate' => 'moderate#index'
|
||||||
get 'logs' => 'logs#index'
|
get 'admin/logs' => 'admin#logs'
|
||||||
get 'my/profile'
|
get 'my/profile'
|
||||||
get 'my/uploads'
|
get 'my/uploads'
|
||||||
get 'my/welcome'
|
get 'my/welcome'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue