- node_count      = local_assigns[:nodes].count
- nodes           = paginate_scope(local_assigns[:nodes])
- container       = local_assigns[:container]
- selected_status = local_assigns[:selected_status]
- more_link       = local_assigns[:more_link]

- column_filter = { |
  'all' => ['total', 'failed', 'pending', 'changed', 'unchanged'], |
  'failed' => ['total', 'failed', 'pending', 'changed', 'unchanged'], |
  'pending' => ['total', 'pending', 'changed', 'unchanged'], |
  'unresponsive' => ['total', 'failed', 'pending', 'changed', 'unchanged'], |
  'changed' => ['total', 'changed', 'unchanged'], |
  'unchanged' => ['total', 'unchanged'], |
  'unreported' => [], |
  'hidden' => ['total', 'failed', 'pending', 'changed', 'unchanged'], |
}
- column_filter[ 'index' ] = column_filter[ 'all' ]
-# XXX this is a dirty hack to pass tests [randall@puppetlabs.com 2011-06-13]
- selected_status = 'all' if selected_status == nil

- unless nodes.empty?
  %table.main
    %thead
      %tr
        %th.empty{:colspan => container.nil? ? 3 : 4}
          = link_to "Export nodes as CSV", url_for(:controller => "nodes", :action => selected_status == "all" ? :index : selected_status, :format => 'csv')
        - unless column_filter[ selected_status ] && column_filter[ selected_status ].empty?
          %th(colspan="5")
            Resources
      %tr
        %th.status
        %th.node
          Node
        - unless container.nil?
          %th Source
        %th.latest_report.desc
          &darr; Latest report
        - column_filter[ selected_status ].each do |status|
          %th
            = status.capitalize
    %tfoot
      %tr
        %td{:colspan => container.nil? ? 8 : 9 }
          = pagination_for nodes, more_link, (node_count - nodes.count)
    %tbody
      %tr
        %td{:colspan => container.nil? ? 3 : 4} Total
        - column_filter[ selected_status ].each do |status|
          %td= Node.resource_status_totals(status, selected_status)
      - nodes.each do |node|
        - sources = container.nodes_with_sources[node] unless container.nil?
        %tr{:class => "#{'active' if node == @node}"}
          %td.status{:class => node.status}
            = node_status_icon(node)
          %td.node
            = link_to h(node.name), node
          - unless container.nil?
            %td
              - if sources.include?(container)
                = node.name
              - else
                = sources.map{|s| link_to(s.name,s)}.join(", ")
          %td.latest_report
            = node.last_apply_report ? link_to(h(node.last_apply_report.time), node.last_apply_report) : "Has not reported"
          - column_filter[ selected_status ].each do |status|
            %td
              = node.last_apply_report.metric_value("resources", status).to_i if node.last_apply_report
- else
  %p
    = describe_no_matches_for :nodes
