<%# $Id: index.rhtml 175 2009-06-27 15:42:20Z toshiyuki.ando1971 $
# To change this template, choose Tools | Templates
# and open the template in the editor.
%>
<style type="text/css">
<!-- div#content {
  background-image: url("<%="#{@settings.url}images/hudson.png"%>");
  background-position: left bottom;
  background-repeat: no-repeat;
}

 .icon-blue { background-image: url("<%="#{@settings.url}images/24x24/blue.gif"%>"); }
 .icon-red { background-image: url("<%="#{@settings.url}images/24x24/red.gif"%>"); }
 .icon-grey { background-image: url("<%="#{@settings.url}images/24x24/grey.gif"%>"); }
 .icon-yellow { background-image: url("<%="#{@settings.url}images/24x24/yellow.gif"%>"); }
 .icon-disabled { background-image: url("<%="#{@settings.url}images/24x24/grey.gif"%>"); }

 .icon-blue_anime { background-image: url("<%="#{@settings.url}images/24x24/blue_anime.gif"%>"); }
 .icon-red_anime { background-image: url("<%="#{@settings.url}images/24x24/red_anime.gif"%>"); }
 .icon-grey_anime { background-image: url("<%="#{@settings.url}images/24x24/grey_anime.gif"%>"); }
 .icon-yellow_anime { background-image: url("<%="#{@settings.url}images/24x24/yellow_anime.gif"%>"); }
-->
</style>

<h2><%=l(:label_job_list)%></h2>

<% if @jobs.length == 0 %>
  <div class="nodata"><%=l(:notice_no_jobs)%></div>
<% else %>
  <div class="flash notice" id="info" style="display:none;">build accepted</div>
  <div class="flash error" id="error" style="display:none;">build failure</div>
  <div id="remote-debug" style="display:none;"></div>

  <% @jobs.each do |job|%>
    <div class="contextual">
     <%= link_to_remote_if_authorized(image_tag("#{@settings.url}images/24x24/clock.gif", :alt => 'build', :title => 'Schedule a build'),
          :url => {:action => 'build', :id => @project, :name => job.name},
          :update => {:success => 'remote-debug', :failure => 'remote-debug'},
          :success => "if(request.responseText.indexOf('build_accepted') > 0 ){Element.show('info');Element.hide('error');}else{Element.show('error');Element.hide('info');}",
          :failure => "Element.show('error');Element.hide('info');")
    %>
    </div>

    <div class="contextual latest-build" id='latest-build-<%=job.name%>'>
      <%=job.latest_build.error if "" != job.latest_build.error%>
      <% if "" == job.latest_build.error %>
        <% if "" != job.latest_build.number %>
          <%=image_tag 'document.png', :class=>'icon-build-history', :id=>"build-history-#{job.name}"%>
          <%=link_to "##{job.latest_build.number}", job.latest_build.url%>
          <%=content_tag("span", job.latest_build.result, :class => "result #{job.latest_build.result.downcase}") if true != job.latest_build.building && "" != job.latest_build.result%>
          <%=content_tag("span", l(:notice_building), :class => "result") if true == job.latest_build.building %>
          <%=content_tag("span", job.latest_build.finished_at.localtime.strftime("%Y/%m/%d %H:%M:%S")) %>
        <% end %>
        <%=l(:notice_no_builds) if "" == job.latest_build.number%>
      <% end %>
    </div>

    <div class="job-state">
      <h3 class="icon icon-<%=job.state%>"><span style="padding-left:10px"><%=link_to job.name, job.url%></span></h3>
    <% if @settings[:show_compact] != true %>
      <div class="wiki">
        <%= textilizable job.description -%>
      </div>

      <ul>
        <% job.health_reports.each do |report| %>
          <%="<li>#{link_to(report.description, report.url)} #{report.score}%" if report.url != ""%>
          <%="<li>#{report.description} #{report.score}%" if report.url == ""%>
        <% end %>
      </ul>
    <% end %>
    </div>
  <% end %>

  <div id="build-history" style="display:none;"></div>
  <%= javascript_tag "new BuildHistory('#{url_for(:controller => 'hudson', :action => 'history', :id=>@project)}')" %>
<% end %>

<% content_for :sidebar do %>
  <%= render :partial => 'hudson_sidebar' %>
<% end %>

<style type="text/css"></style>

<% content_for :header_tags do %>
  <%= stylesheet_link_tag "hudson.css", :plugin => "redmine_hudson", :media => "screen" %>
  <%= javascript_include_tag 'build_history', :plugin => "redmine_hudson" %>
<% end %>
