Commit 7e53d6cc12296c46c589807919b7f58250e3dc78
1 parent
2f899f22
Exists in
master
and in
1 other branch
Projects#show
Showing
11 changed files
with
96 additions
and
7 deletions
Show diff stats
app/controllers/projects_controller.rb
@@ -4,4 +4,9 @@ class ProjectsController < ApplicationController | @@ -4,4 +4,9 @@ class ProjectsController < ApplicationController | ||
4 | @projects = Project.all | 4 | @projects = Project.all |
5 | end | 5 | end |
6 | 6 | ||
7 | + def show | ||
8 | + @project = Project.find(params[:id]) | ||
9 | + @errs = @project.errs.paginate | ||
10 | + end | ||
11 | + | ||
7 | end | 12 | end |
app/models/err.rb
@@ -34,4 +34,10 @@ class Err | @@ -34,4 +34,10 @@ class Err | ||
34 | notices.last.try(:created_at) | 34 | notices.last.try(:created_at) |
35 | end | 35 | end |
36 | 36 | ||
37 | + def where | ||
38 | + where = component | ||
39 | + where << "##{action}" if action.present? | ||
40 | + where | ||
41 | + end | ||
42 | + | ||
37 | end | 43 | end |
38 | \ No newline at end of file | 44 | \ No newline at end of file |
app/models/project.rb
@@ -19,6 +19,10 @@ class Project | @@ -19,6 +19,10 @@ class Project | ||
19 | where(:api_key => key).first || raise(Mongoid::Errors::DocumentNotFound.new(self,key)) | 19 | where(:api_key => key).first || raise(Mongoid::Errors::DocumentNotFound.new(self,key)) |
20 | end | 20 | end |
21 | 21 | ||
22 | + def last_deploy_at | ||
23 | + deploys.last && deploys.last.created_at | ||
24 | + end | ||
25 | + | ||
22 | protected | 26 | protected |
23 | 27 | ||
24 | def generate_api_key | 28 | def generate_api_key |
@@ -0,0 +1,23 @@ | @@ -0,0 +1,23 @@ | ||
1 | +%table.errs | ||
2 | + %thead | ||
3 | + %tr | ||
4 | + %th | ||
5 | + - unless @project | ||
6 | + %th Project | ||
7 | + %th What & Where | ||
8 | + %th Latest | ||
9 | + %th Deploy | ||
10 | + %th Count | ||
11 | + %tbody | ||
12 | + - errs.each do |err| | ||
13 | + %tr | ||
14 | + %td.environment | ||
15 | + %abbr{:title => err.environment}= err.environment.chars.first.upcase | ||
16 | + - unless @project | ||
17 | + %td.project= err.project | ||
18 | + %td.message | ||
19 | + = link_to err.message, project_err_path(err.project, err) | ||
20 | + %em= err.where | ||
21 | + %td.latest #{time_ago_in_words(err.last_notice_at)} ago | ||
22 | + %td.deploy= err.project.last_deploy_at ? err.project.last_deploy_at.to_date.to_s(:micro) : 'n/a' | ||
23 | + %td.count= err.notices.count | ||
0 | \ No newline at end of file | 24 | \ No newline at end of file |
app/views/layouts/application.html.haml
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | %html | 2 | %html |
3 | %head | 3 | %head |
4 | %title | 4 | %title |
5 | - Cartless — | 5 | + Hypnotoad — |
6 | = yield(:page_title).present? ? yield(:page_title) : yield(:title) | 6 | = yield(:page_title).present? ? yield(:page_title) : yield(:title) |
7 | %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "content-type" }/ | 7 | %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "content-type" }/ |
8 | = javascript_include_tag :defaults | 8 | = javascript_include_tag :defaults |
app/views/projects/index.html.haml
1 | - content_for :title, 'Projects' | 1 | - content_for :title, 'Projects' |
2 | 2 | ||
3 | -%table | 3 | +%table.projects |
4 | %thead | 4 | %thead |
5 | %tr | 5 | %tr |
6 | - %th Project Name | 6 | + %th Name |
7 | + %th Last Deploy | ||
7 | %th Errors | 8 | %th Errors |
8 | %tbody | 9 | %tbody |
9 | - @projects.each do |project| | 10 | - @projects.each do |project| |
10 | %tr | 11 | %tr |
11 | - %td= link_to project.name, project_path(project) | ||
12 | - %td= link_to project.errs.unresolved.count, project_errs_path(project) | ||
13 | \ No newline at end of file | 12 | \ No newline at end of file |
13 | + %td.name= link_to project.name, project_path(project) | ||
14 | + %td.deploy= project.last_deploy_at ? project.last_deploy_at.to_s(:micro) : 'n/a' | ||
15 | + %td.count= link_to project.errs.unresolved.count, project_errs_path(project) | ||
14 | \ No newline at end of file | 16 | \ No newline at end of file |
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +- content_for :title, @project.name | ||
2 | +- content_for :meta do | ||
3 | + %strong Errors Caught: | ||
4 | + = @project.errs.count | ||
5 | + %strong API Key: | ||
6 | + = @project.api_key | ||
7 | +- content_for :action_bar do | ||
8 | + = link_to 'edit', edit_project_path(@project) | ||
9 | + | | ||
10 | + = link_to 'destroy', project_path(@project), :method => :destroy, :confirm => 'Seriously?' | ||
11 | + | ||
12 | +%h3 Errors | ||
13 | += render 'errs/table', :errs => @errs | ||
0 | \ No newline at end of file | 14 | \ No newline at end of file |
app/views/shared/_navigation.html.haml
1 | #nav-bar | 1 | #nav-bar |
2 | %ul | 2 | %ul |
3 | //%li= link_to 'Dashboard', admin_dashboard_path, :class => active_if_here(:dashboards) | 3 | //%li= link_to 'Dashboard', admin_dashboard_path, :class => active_if_here(:dashboards) |
4 | - %li= link_to 'Projects', projects_path, :class => active_if_here(:projects) | 4 | + %li= link_to 'Projects', projects_path, :class => active_if_here(:projects) |
5 | + %li= link_to 'Errors', errs_path, :class => active_if_here(:errs => :index) | ||
5 | %div.clear | 6 | %div.clear |
6 | \ No newline at end of file | 7 | \ No newline at end of file |
config/routes.rb
@@ -4,6 +4,7 @@ Hypnotoad::Application.routes.draw do | @@ -4,6 +4,7 @@ Hypnotoad::Application.routes.draw do | ||
4 | match '/notifier_api/v2/notices' => 'notices#create' | 4 | match '/notifier_api/v2/notices' => 'notices#create' |
5 | match '/deploys.txt' => 'deploys#create' | 5 | match '/deploys.txt' => 'deploys#create' |
6 | 6 | ||
7 | + resources :errs, :only => [:index] | ||
7 | resources :notices, :only => [:show] | 8 | resources :notices, :only => [:show] |
8 | resources :deploys, :only => [:show] | 9 | resources :deploys, :only => [:show] |
9 | 10 |
public/stylesheets/application.css
@@ -147,7 +147,7 @@ form > div > span { | @@ -147,7 +147,7 @@ form > div > span { | ||
147 | /* Tables */ | 147 | /* Tables */ |
148 | table { width: 100%; border: 1px solid #C6C6C6; margin-bottom: 1.5em; } | 148 | table { width: 100%; border: 1px solid #C6C6C6; margin-bottom: 1.5em; } |
149 | table th, table td { border-bottom: 1px solid #C6C6C6; padding: 10px 8px; text-align: left; } | 149 | table th, table td { border-bottom: 1px solid #C6C6C6; padding: 10px 8px; text-align: left; } |
150 | -table th { background-color: #E2E2E2; font-weight: bold; text-transform: uppercase; } | 150 | +table th { background-color: #E2E2E2; font-weight: bold; text-transform: uppercase; white-space: nowrap; } |
151 | table tbody tr:nth-child(odd) td { background-color: #F9F9F9; } | 151 | table tbody tr:nth-child(odd) td { background-color: #F9F9F9; } |
152 | table .main { width: 100%; } | 152 | table .main { width: 100%; } |
153 | 153 | ||
@@ -159,3 +159,29 @@ table .main { width: 100%; } | @@ -159,3 +159,29 @@ table .main { width: 100%; } | ||
159 | .html ul, .html ol { margin-left: 2em; margin-bottom: 1em; } | 159 | .html ul, .html ol { margin-left: 2em; margin-bottom: 1em; } |
160 | .html ul li { margin-bottom: 0.5em; list-style: disc; } | 160 | .html ul li { margin-bottom: 0.5em; list-style: disc; } |
161 | .html ol li { margin-bottom: 0.5em; list-style: decimal; } | 161 | .html ol li { margin-bottom: 0.5em; list-style: decimal; } |
162 | + | ||
163 | +/* Projects Table */ | ||
164 | +table.projects td.name { | ||
165 | + width: 100%; | ||
166 | +} | ||
167 | +table.projects td.deploy { | ||
168 | + white-space: no-wrap; | ||
169 | +} | ||
170 | + | ||
171 | +/* Err Tables */ | ||
172 | +table.errs td.message { | ||
173 | + width: 100%; | ||
174 | +} | ||
175 | +table.errs td.message a { | ||
176 | + display: block; | ||
177 | +} | ||
178 | +table.errs td.message em { | ||
179 | + color: #727272; | ||
180 | + font-size: 0.9em; | ||
181 | +} | ||
182 | +table.errs td.latest { | ||
183 | + white-space: nowrap; | ||
184 | +} | ||
185 | +table.errs td.deploy { | ||
186 | + white-space: nowrap; | ||
187 | +} | ||
162 | \ No newline at end of file | 188 | \ No newline at end of file |
spec/controllers/projects_controller_spec.rb
@@ -11,4 +11,12 @@ describe ProjectsController do | @@ -11,4 +11,12 @@ describe ProjectsController do | ||
11 | end | 11 | end |
12 | end | 12 | end |
13 | 13 | ||
14 | + describe "GET /projects/:id" do | ||
15 | + it 'finds the project' do | ||
16 | + project = Factory(:project) | ||
17 | + get :show, :id => project.id | ||
18 | + assigns(:project).should == project | ||
19 | + end | ||
20 | + end | ||
21 | + | ||
14 | end | 22 | end |