diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 3292768..a0bb87d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -4,4 +4,9 @@ class ProjectsController < ApplicationController @projects = Project.all end + def show + @project = Project.find(params[:id]) + @errs = @project.errs.paginate + end + end diff --git a/app/models/err.rb b/app/models/err.rb index 45879ac..25efefa 100644 --- a/app/models/err.rb +++ b/app/models/err.rb @@ -34,4 +34,10 @@ class Err notices.last.try(:created_at) end + def where + where = component + where << "##{action}" if action.present? + where + end + end \ No newline at end of file diff --git a/app/models/project.rb b/app/models/project.rb index 9c2e548..cf6d89c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -19,6 +19,10 @@ class Project where(:api_key => key).first || raise(Mongoid::Errors::DocumentNotFound.new(self,key)) end + def last_deploy_at + deploys.last && deploys.last.created_at + end + protected def generate_api_key diff --git a/app/views/errs/_table.html.haml b/app/views/errs/_table.html.haml new file mode 100644 index 0000000..6628366 --- /dev/null +++ b/app/views/errs/_table.html.haml @@ -0,0 +1,23 @@ +%table.errs + %thead + %tr + %th + - unless @project + %th Project + %th What & Where + %th Latest + %th Deploy + %th Count + %tbody + - errs.each do |err| + %tr + %td.environment + %abbr{:title => err.environment}= err.environment.chars.first.upcase + - unless @project + %td.project= err.project + %td.message + = link_to err.message, project_err_path(err.project, err) + %em= err.where + %td.latest #{time_ago_in_words(err.last_notice_at)} ago + %td.deploy= err.project.last_deploy_at ? err.project.last_deploy_at.to_date.to_s(:micro) : 'n/a' + %td.count= err.notices.count \ No newline at end of file diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 334f531..21b044a 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -2,7 +2,7 @@ %html %head %title - Cartless — + Hypnotoad — = yield(:page_title).present? ? yield(:page_title) : yield(:title) %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "content-type" }/ = javascript_include_tag :defaults diff --git a/app/views/projects/index.html.haml b/app/views/projects/index.html.haml index e82ee14..2237e5b 100644 --- a/app/views/projects/index.html.haml +++ b/app/views/projects/index.html.haml @@ -1,12 +1,14 @@ - content_for :title, 'Projects' -%table +%table.projects %thead %tr - %th Project Name + %th Name + %th Last Deploy %th Errors %tbody - @projects.each do |project| %tr - %td= link_to project.name, project_path(project) - %td= link_to project.errs.unresolved.count, project_errs_path(project) \ No newline at end of file + %td.name= link_to project.name, project_path(project) + %td.deploy= project.last_deploy_at ? project.last_deploy_at.to_s(:micro) : 'n/a' + %td.count= link_to project.errs.unresolved.count, project_errs_path(project) \ No newline at end of file diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml new file mode 100644 index 0000000..c127405 --- /dev/null +++ b/app/views/projects/show.html.haml @@ -0,0 +1,13 @@ +- content_for :title, @project.name +- content_for :meta do + %strong Errors Caught: + = @project.errs.count + %strong API Key: + = @project.api_key +- content_for :action_bar do + = link_to 'edit', edit_project_path(@project) + | + = link_to 'destroy', project_path(@project), :method => :destroy, :confirm => 'Seriously?' + +%h3 Errors += render 'errs/table', :errs => @errs \ No newline at end of file diff --git a/app/views/shared/_navigation.html.haml b/app/views/shared/_navigation.html.haml index b8d840e..7e61420 100644 --- a/app/views/shared/_navigation.html.haml +++ b/app/views/shared/_navigation.html.haml @@ -1,5 +1,6 @@ #nav-bar %ul //%li= link_to 'Dashboard', admin_dashboard_path, :class => active_if_here(:dashboards) - %li= link_to 'Projects', projects_path, :class => active_if_here(:projects) + %li= link_to 'Projects', projects_path, :class => active_if_here(:projects) + %li= link_to 'Errors', errs_path, :class => active_if_here(:errs => :index) %div.clear \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 460369c..6f0d7bd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,7 @@ Hypnotoad::Application.routes.draw do match '/notifier_api/v2/notices' => 'notices#create' match '/deploys.txt' => 'deploys#create' + resources :errs, :only => [:index] resources :notices, :only => [:show] resources :deploys, :only => [:show] diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 1da131c..b5ceec7 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -147,7 +147,7 @@ form > div > span { /* Tables */ table { width: 100%; border: 1px solid #C6C6C6; margin-bottom: 1.5em; } table th, table td { border-bottom: 1px solid #C6C6C6; padding: 10px 8px; text-align: left; } -table th { background-color: #E2E2E2; font-weight: bold; text-transform: uppercase; } +table th { background-color: #E2E2E2; font-weight: bold; text-transform: uppercase; white-space: nowrap; } table tbody tr:nth-child(odd) td { background-color: #F9F9F9; } table .main { width: 100%; } @@ -159,3 +159,29 @@ table .main { width: 100%; } .html ul, .html ol { margin-left: 2em; margin-bottom: 1em; } .html ul li { margin-bottom: 0.5em; list-style: disc; } .html ol li { margin-bottom: 0.5em; list-style: decimal; } + +/* Projects Table */ +table.projects td.name { + width: 100%; +} +table.projects td.deploy { + white-space: no-wrap; +} + +/* Err Tables */ +table.errs td.message { + width: 100%; +} +table.errs td.message a { + display: block; +} +table.errs td.message em { + color: #727272; + font-size: 0.9em; +} +table.errs td.latest { + white-space: nowrap; +} +table.errs td.deploy { + white-space: nowrap; +} \ No newline at end of file diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 01c86f3..f55abc5 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -11,4 +11,12 @@ describe ProjectsController do end end + describe "GET /projects/:id" do + it 'finds the project' do + project = Factory(:project) + get :show, :id => project.id + assigns(:project).should == project + end + end + end -- libgit2 0.21.2