Now that Dashboard depends on background tasks ("delayed jobs") to import
reports, we're showing users the status of these tasks.  We improved the sidebar
notification section with status icons.  We improved the page to which they link
by (a) making a tabbed view, and (b) making it a little shinier.

Reviewed-by: Pieter van de Bruggen <[email protected]>
Signed-off-by: Randall Hansen <[email protected]>
---
Local-branch: ticket/master/7967-delayed-job-warnings
 app/controllers/delayed_job_failures_controller.rb |    3 +-
 app/views/delayed_job_failures/index.html.haml     |   36 +++++++++-----
 app/views/shared/_node_manager_sidebar.html.haml   |   16 +++++--
 public/images/icons/delayed-job-failure.png        |  Bin 0 -> 701 bytes
 public/images/icons/delayed-job-ok.png             |  Bin 0 -> 781 bytes
 public/images/icons/delayed-job-warning.png        |  Bin 0 -> 666 bytes
 public/stylesheets/application.css                 |   31 +++++++++++
 public/stylesheets/sass/application.scss           |   53 ++++++++++++++++++++
 8 files changed, 122 insertions(+), 17 deletions(-)
 create mode 100644 public/images/icons/delayed-job-failure.png
 create mode 100644 public/images/icons/delayed-job-ok.png
 create mode 100644 public/images/icons/delayed-job-warning.png

diff --git a/app/controllers/delayed_job_failures_controller.rb 
b/app/controllers/delayed_job_failures_controller.rb
index ca066dc..8c07b10 100644
--- a/app/controllers/delayed_job_failures_controller.rb
+++ b/app/controllers/delayed_job_failures_controller.rb
@@ -7,11 +7,12 @@ class DelayedJobFailuresController < ApplicationController
       DelayedJobFailure.transaction do
         # Can't just update_all, because this is a WillPaginate collection,
         # and it has a limited API.  Alas. --daniel 2011-06-20
-        @delayed_job_failures.each do |event|
+        DelayedJobFailure.all.each do |event|
           event.read = true
           event.save!
         end
       end
+      @delayed_job_failures = []
     end
   end
 
diff --git a/app/views/delayed_job_failures/index.html.haml 
b/app/views/delayed_job_failures/index.html.haml
index 847aa92..0e20789 100644
--- a/app/views/delayed_job_failures/index.html.haml
+++ b/app/views/delayed_job_failures/index.html.haml
@@ -2,17 +2,29 @@
 #main
   .header
     %h2
-      &= "#{@read ? 'Read' : 'Unread'} Delayed Job Failures"
-      %span.count= page_entries_info(@delayed_job_failures, { :entry_name => 
"#{@read ? 'read' : 'unread'} failure" } )
-    - if @read == false
-      - form_tag request.url, :class => 'REVISIT', :method => :post do
-        %button{:name => :mark_all_read} Mark all Read
+      Background Task Failures
 
   .item
-    %ul
-      - @delayed_job_failures.each do |e|
-        %li{:class => e.read ? :read : :unread}
-          &= "#{e.summary} (#{e.created_at})"
-          %pre
-            &= e.details
-    = pagination_for @delayed_job_failures
+    %ul.tabbed
+      %li{ :class => active_if( controller.action_name == 'index' )}
+        = link_to "#{DelayedJobFailure.unread.count > 0 ? 
DelayedJobFailure.unread.count : ''} New failed tasks", '/delayed_job_failures'
+      %li{ :class => active_if( controller.action_name == 'read' )}
+        = link_to 'Previously-read failures', '/delayed_job_failures/read'
+
+    %div.panel.tabbed
+      - if @delayed_job_failures.count > 0
+        - if @read == false
+          #mark-as-read
+            - form_tag request.url, :method => :post do
+              %button{:name => :mark_all_read} Mark all as read
+              (and we'll stop notifying you about them)
+        %dl
+          - @delayed_job_failures.each do |e|
+            %dt
+              %strong= e.summary
+              at
+              %em= e.created_at
+            %dd= e.details
+        = pagination_for @delayed_job_failures
+      - else
+        %p No unread task failures.
diff --git a/app/views/shared/_node_manager_sidebar.html.haml 
b/app/views/shared/_node_manager_sidebar.html.haml
index dd6ccce..fee67f6 100644
--- a/app/views/shared/_node_manager_sidebar.html.haml
+++ b/app/views/shared/_node_manager_sidebar.html.haml
@@ -1,9 +1,17 @@
 - add_body_class 'with-sidebar'
 
-.group
-  %h3= link_to "Delayed Job Status", "/delayed_job_failures"
-  %h4= link_to "#{DelayedJobFailure.unread.count} unread failures", 
"/delayed_job_failures"
-  %h4= "#{Delayed::Job.count} pending reports"
+.group.delayed-job
+  %h3= link_to "Background Tasks", "/delayed_job_failures"
+
+  - if DelayedJobFailure.unread.count > 0
+    %p.failure
+      =link_to "#{ pluralize DelayedJobFailure.unread.count, 'new failed task' 
}", "/delayed_job_failures"
+  - if Delayed::Job.count > 0
+    %p.warning
+      %em= "#{ pluralize Delayed::Job.count, 'pending task' }"
+  - if Delayed::Job.count == 0 and DelayedJobFailure.unread.count == 0
+    %p.ok
+      %em All systems go
 
 .group
   %h3{:class => active_if(controller_name == "nodes" && action_name == 
"index")}= link_to "Nodes", nodes_path
diff --git a/public/images/icons/delayed-job-failure.png 
b/public/images/icons/delayed-job-failure.png
new file mode 100644
index 
0000000000000000000000000000000000000000..c37bd062e60c3b38fc82e4d1f236a8ac2fae9d8c
GIT binary patch
literal 701
zcmV;u0z&<XP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00004XF*Lt006JZ
zHwB960000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!Pf0{UR5;6}
zlgmq#VHCz6ztjnp=~F?R5pQFPl&gp~;l?gdL<B>N#0$9Ug7g<e5Ea#;%|NSKc)@5f
z;7$;Xq9UY)Lyb<UqnJ8&8J!fJX6Aj*^R}?Q8M8KZcJJYw-+2!2dGd@g_@BuCJt4QR
zG|-rKLw1p@BngtANcK}WWZ&tJ=GN!sDp0pB`wdNCE3eQ~*sve@ZufS6V;#vz1Xgl=
zg_Pck`%i+q0GXSY{D$mHSJV_2H8nzF3t(&k0AP7)V0mk?F%>~-`rQ^qx~m@y2OU8A
z#zh~=7n#Z$Z*fx-GOtDf07cgx0suCz_W(2~Y(0tf@FX@P6EPuM_dgn$vj9LucO)%W
zw%HgMW>=#oL>nZ>M&NEf08>)#)k<{$fCT_r>rPi=BV=hFh6WS^qqze>C6Ek}o{M5%
za|@JGow<Oj0^5dOoQKhLCOSWpAw+HGQ?pSN*k#a4S7iZ8!-#Pje@#@=;p__PCqxJc
zp|wJe0=1luufg)vI#NXu-(QYlbNI0{or=h>u0t{&hgNzySHZxy@LTNh);YzZ2zSp_
zl$^T&Dnc|NLb&RD_!4>pt@VHdP)ZGER%5ZmWEe$lryR&y;2u^3cOkO<wojkI*Ki1l
z#hIAadT_@fO?4jgQ>4#6c%-<rxdo~DIizNzFvh@D?}Mw}hj=)IkFQ6!NOre9eIML)
z%AxZ|{Xz!zmU%tpEr;N;OJNL<O041Y#5fX5vnwQfk3ahm{G%5DVEpXi29oU*c9F8v
jOytms=QDpd)4#+ImC>(EY6a{600000NkvXXu0mjfxS2AI

literal 0
HcmV?d00001

diff --git a/public/images/icons/delayed-job-ok.png 
b/public/images/icons/delayed-job-ok.png
new file mode 100644
index 
0000000000000000000000000000000000000000..89c8129a490b329f3165f32fa0781701aab417ea
GIT binary patch
literal 781
zcmV+o1M>WdP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00004XF*Lt006JZ
zHwB960000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!pGibPR5;6}
zlj}=UVI0T(J9f@?Yy$~oL?MENP<s_55<8j=#k?#_)7`z&He=XKi!yRv#z-kGv(##H
zPHpPc=GK%laoJHq%)RMCwPAFzZ|CgAOcEn{;0q5A&*$@du5ke3{wIG76!;E_a;FdK
zvpp$H#^e2A>4-QibtN)VXQDpczE`xXAkUjh%RI>;okxb7K@0kpyQ1k_Y(|Oe7$m(^
zNYX>mI||sUbmn+c<m#Le&eeX{US5M~t}+^~?^x|a<4hF}*!YoT8=u}L$nm5IGu=t+
z9L!Cu36!D2Ujog{8R*!Qv#Iu-h5hwCT%4+a*g~$0uam-<K;}*|sK&CQl{uILRo+uj
zOcz2iRRHx=A>3<&FnE=4u#()KBS^SH8e)Qs5i!#lY=$-1gbH6VluzU=m=EP78&5vQ
z-?+fFP-G2l&l_QzYealK$;1Rl?FkzXR&Jv<pn=v~#I9rjiy!8pnkdBB+E5h!vH2Zs
z&o03*QH;J|Cj>@fBPNjCr#AYRyJ7UJQ0v#?)7Ott=>3<sG1xL&549^BdiQDc2Rk6B
z`CZUMF*oL$(7tdPx=A_AzG_6ieU8GLKR01{dI4q5ENECkOP~(zUNfjFVrvVjw*&_H
zKpN~TcTqhdhuVD-b<^codbfbK*#?vj9*4ql0y<|7?610!ZaoaDlGr-LWGi2|kG&eR
zM}vpV9aN6yK|7oS)sPHI2Nw>`#-pV!7>9}>Q1jL)H6h&gkP@3nI=+F3nA~M>u#(n*
z8T!#8oEw&-mED4!h4s!N@Jo3S7N&Q6%6l3}nlcd~X@>;uelvPsSkXIgg~e+^T1zSf
z3SNj(5%jK~i8@b;C<CFVY6wQ4<%I<*UYM=Ou+dYcgy^ro@n7=`XV9$WdAihN00000
LNkvXXu0mjf{u*Ke

literal 0
HcmV?d00001

diff --git a/public/images/icons/delayed-job-warning.png 
b/public/images/icons/delayed-job-warning.png
new file mode 100644
index 
0000000000000000000000000000000000000000..628cf2dae3d419ae220c8928ac71393b480745a3
GIT binary patch
literal 666
zcmV;L0%iS)P)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00004XF*Lt006JZ
zHwB960000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!EJ;K`R5;6}
zQ%gvc0TBNFhpVpZYs*vuLt9diOv=bL4R1XR>eOSYYtbpBV}~vsBnU!_?2tr-P=|^T
zED<b;h)xArC`LwRuDi0BivEw8uY($aYXuI>%wc9ezHgW@NMb!^uT_|SvCpFLJylbx
zY%bpaTGI8IYXMN$9w<3j9VkA~NYOKEQXsj?6a9_hcwfU$acAhJhB)zb_w@MVUEy@S
zX&I>K-R!bhu3?(6bHWIg$HEl7{9g>>&l_qdd+UYb(1~BCo9LptNq&8>!yoJ3Ui(i5
zRJ|XnYBklL!{@$-7=3mJ>P@1c=7Oc79e-V7yf+%lD2!I;Y&nXBZ>=B!5?CB>LvEx6
znI%n)qqi$#X#wKB(U7XP2P=+4{b@j#r%9-K(8UqtSDk>0UKzf*HM9yqMZ1D!$2MdZ
zR=`U>0zhOH1XqN?nY@AQqB7)Fp4{v&dKXvb43hZKvnN8;Po;+jY*}~*Z|W9Q0W%{D
z^T}Cc<|r(Su=1K=<sQLMN1ZE<U%m5Ea@1Tp8to2kJ7-hpAhT}(Dgffk;4r2>P5>Z4
zg`et&Va}tdzBS-G-ZcO)zCWpJvGQwrHZ`@wpM420ac@bI5~KkTFfGEM3sPWO8<ADs
zh7X-F%!~{kwpFCFAaZKyF+vTnL(ye%#)|yqz~B3T5kTqQvq%jMT(v1Wka%_eG)1AJ
z_%n+q5XXb>co4^fI6lPnA)Y{ef%@{+SnoUk0+dW+*{8WvF8}}l07*qoM6N<$g7cXs
A&j0`b

literal 0
HcmV?d00001

diff --git a/public/stylesheets/application.css 
b/public/stylesheets/application.css
index ae9ed4a..e5a92ec 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -573,3 +573,34 @@ body {
   body div.token-input-dropdown-facebook ul 
li.token-input-selected-dropdown-item-facebook {
     background-color: #FFFDA4;
     color: #000; }
+  body.delayed_job_failures_controller dl dt {
+    color: #999; }
+    body.delayed_job_failures_controller dl dt strong {
+      color: #000; }
+    body.delayed_job_failures_controller dl dt em {
+      color: #000;
+      font-weight: normal; }
+  body.delayed_job_failures_controller dl dd {
+    padding-bottom: .3em;
+    border-bottom: 1px solid #eee;
+    margin-bottom: .3em; }
+  body #mark-as-read {
+    margin-bottom: 1em; }
+  body .delayed-job {
+    padding-bottom: .5em; }
+    body .delayed-job p {
+      padding: .5em 1em 0 1em;
+      margin: 0; }
+      body .delayed-job p em,
+      body .delayed-job p a {
+        padding-left: 20px;
+        background-color: transparent;
+        background-repeat: no-repeat;
+        background-position: 0% 50%;
+        margin-bottom: .5em; }
+      body .delayed-job p.ok em {
+        background: transparent url(/images/icons/delayed-job-ok.png) 
no-repeat 0% 50%; }
+      body .delayed-job p.failure a {
+        background-image: url(/images/icons/delayed-job-failure.png); }
+      body .delayed-job p.warning em {
+        background-image: url(/images/icons/delayed-job-warning.png); }
diff --git a/public/stylesheets/sass/application.scss 
b/public/stylesheets/sass/application.scss
index 97dfc30..419af24 100644
--- a/public/stylesheets/sass/application.scss
+++ b/public/stylesheets/sass/application.scss
@@ -750,4 +750,57 @@ body {
       }
     }
   }
+
+  &.delayed_job_failures_controller {
+    dl {
+      dt {
+        color : #999;
+        strong {
+          color : #000;
+        }
+        em {
+          color : #000;
+          font-weight : normal;
+        }
+      }
+      dd {
+        padding-bottom : .3em;
+        border-bottom : 1px solid #eee;
+        margin-bottom : .3em;
+      }
+    }
+  }
+  #mark-as-read {
+    margin-bottom : 1em;
+  }
+  .delayed-job {
+    padding-bottom : .5em;
+    p {
+      padding : .5em 1em 0 1em;
+      margin : 0;
+      em,
+      a {
+        padding-left : 20px;
+        background-color : transparent;
+        background-repeat : no-repeat;
+        background-position : 0% 50%;
+        margin-bottom : .5em;
+      }
+      &.ok {
+        em {
+          background : transparent url( /images/icons/delayed-job-ok.png ) 
no-repeat 0% 50%;
+        }
+      }
+      &.failure {
+        a {
+          background-image : url( /images/icons/delayed-job-failure.png );
+        }
+      }
+      &.warning {
+        em {
+          background-image : url( /images/icons/delayed-job-warning.png );
+        }
+      }
+    }
+  }
 }
-- 
1.7.4

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to