Logs controller added

This commit is contained in:
Christoph Haas 2016-08-23 19:01:01 +02:00
parent 9ad5a05914
commit 230f5ec213
9 changed files with 66 additions and 0 deletions

View 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/

View 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/

View 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

View file

@ -0,0 +1,2 @@
module LogsHelper
end

View 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

View 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'

View file

@ -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

View file

@ -0,0 +1,9 @@
require "test_helper"
class LogsControllerTest < ActionController::TestCase
def test_index
get :index
assert_response :success
end
end

View file

@ -0,0 +1,7 @@
require "test_helper"
class LogsHelperTest < ActionView::TestCase
def test_sanity
flunk "Need real tests"
end
end