Logs controller added
This commit is contained in:
parent
9ad5a05914
commit
230f5ec213
9 changed files with 66 additions and 0 deletions
3
app/assets/javascripts/logs.coffee
Normal file
3
app/assets/javascripts/logs.coffee
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
3
app/assets/stylesheets/logs.scss
Normal file
3
app/assets/stylesheets/logs.scss
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the logs controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
7
app/controllers/logs_controller.rb
Normal file
7
app/controllers/logs_controller.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class LogsController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
|
||||
def index
|
||||
@logs = Log.paginate(page: params[:page], per_page: 20)
|
||||
end
|
||||
end
|
||||
2
app/helpers/logs_helper.rb
Normal file
2
app/helpers/logs_helper.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
module LogsHelper
|
||||
end
|
||||
8
app/views/logs/_paginator.slim
Normal file
8
app/views/logs/_paginator.slim
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
- if @logs.length>0
|
||||
// Use different pagination navigators depending on the screen width
|
||||
div.show-for-large
|
||||
=will_paginate @logs, :renderer => FoundationPaginationRenderer, :inner_window => 3
|
||||
div.show-for-medium-only
|
||||
=will_paginate @logs, :renderer => FoundationPaginationRenderer, :inner_window => 1
|
||||
div.show-for-small-only
|
||||
=will_paginate @logs, :renderer => FoundationPaginationRenderer, :page_links => false
|
||||
26
app/views/logs/index.html.slim
Normal file
26
app/views/logs/index.html.slim
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// Paginator and search bar
|
||||
.row
|
||||
.small-6.medium-8.large-9.columns
|
||||
// Paginator
|
||||
= render 'logs/paginator'
|
||||
|
||||
.small-6.medium-4.large-3.columns
|
||||
// Search form
|
||||
= render 'packages/searchfield'
|
||||
|
||||
// List of log messages
|
||||
.row
|
||||
- if @logs.length>0
|
||||
table
|
||||
tr
|
||||
th Timestamp
|
||||
th Message
|
||||
- @logs.each do |log|
|
||||
tr
|
||||
th =log.created_at
|
||||
th =log.message
|
||||
- else
|
||||
p No logs. Crazy.
|
||||
|
||||
// Second paginator at the bottom so the user does not have to scroll up again
|
||||
= render 'logs/paginator'
|
||||
|
|
@ -15,6 +15,7 @@ Debshots::Application.routes.draw do
|
|||
get 'packages' => 'packages#grid', as: :packages_grid
|
||||
get 'packages/list' => 'packages#list', as: :packages_list
|
||||
get 'moderate' => 'moderate#index'
|
||||
get 'logs' => 'logs#index'
|
||||
get 'package/:name' => 'packages#details', as: :package, name: /[^\/]+/
|
||||
get 'package_reviews/:name' => 'packages#reviews', as: :package_reviews, name: /[^\/]+/
|
||||
get 'upload', to: redirect('/packages') # legacy upload form
|
||||
|
|
|
|||
9
test/controllers/logs_controller_test.rb
Normal file
9
test/controllers/logs_controller_test.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
require "test_helper"
|
||||
|
||||
class LogsControllerTest < ActionController::TestCase
|
||||
def test_index
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
||||
7
test/helpers/logs_helper_test.rb
Normal file
7
test/helpers/logs_helper_test.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class LogsHelperTest < ActionView::TestCase
|
||||
def test_sanity
|
||||
flunk "Need real tests"
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue