<% javascript 'charts' %>
<% title @host.to_label, icon(@host.os) + @host.to_label %>

<% @vm = @host.compute_resource.find_vm_by_uuid(@host.uuid) rescue nil %>
<%= host_title_actions(@host, @vm) %>
<% content_for(:search_bar) {reports_show} %>

<div id="host-show" class="row">
  <div class="col-md-4">
    <ul id="myTab" class="nav nav-tabs">
      <li class="active"><a href="#properties" data-toggle="tab"><%= _('Properties') %></a></li>
      <li><a href="#metrics" data-toggle="tab"><%= _('Metrics') %></a></li>
      <% if SETTINGS[:unattended] %>
        <li><a href="#template" data-toggle="tab"><%= _('Templates') %></a></li>
      <% end %>
      <%  if @vm %>
        <li><a href="#vm" data-toggle="tab"><%= _('VM') %></a></li>
      <% end %>
      <% if @host.bmc_available? %>
        <li><a href="#bmc" data-toggle="tab"><%= _('BMC') %></a></li>
      <% end %>
    </ul>
    <div id="myTabContent" class="tab-content">
      <div class="tab-pane active in" id="properties">
        <%= render :partial => "hosts/overview", :locals => { :host => @host } %>
      </div>
      <div class="tab-pane" id="metrics">
        <% if @report_summary.size == 0 %>
            <div class="alert alert-warning"><%= _('No puppet activity for this host in the last %s days') % @range %></div>
        <% else %>
            <%= render :partial => "hosts/metrics", :locals => { :report_summary => @report_summary[@host.name][:metrics] } %>
        <% end %>
      </div>
      <div class="tab-pane" id="template">
        <%= show_templates %>
      </div>
      <div class="tab-pane" id="vm">
        <%  if @vm %>
          <% @compute_resource = @host.compute_resource %>
          <%= render("compute_resources_vms/show/#{@host.compute_resource.provider.downcase}") rescue nil %>
        <% end %>
      </div>
      <% if @host.bmc_available? %>
        <div id="bmc" class="tab-pane" data-ajax-url=<%= bmc_host_path(@host) %>>
          <p id="spinner">
            <%= image_tag '/assets/spinner.gif' %>
            <%= _('Loading BMC information ...') %>
          </p>
        </div>

      <% end %>

    </div>
  </div>
  <div class="col-md-8">
    <div class="stats-well">
      <h4 class="ca"><%= _("Runtime") %></h4>
      <h6 class="ca"><%= n_("last %s day", "last %s days", @range) % @range %></h6>
      <%= flot_chart 'runtime_graph','', _('Time in Seconds'), runtime_chart(@range.days.ago), :class=>"statistics-chart stack" %>
    </div>
    <div class="stats-well">
      <h4 class="ca"><%= _("Resources") %></h4>
      <h6 class="ca"><%= n_("last %s day", "last %s days", @range) % @range %></h6>
      <%= flot_chart 'resource_graph', '', _("Number of Events"), resources_chart(@range.days.ago) %>
    </div>
  </div>
</div>
