<% javascript 'charts', 'hosts' %>
<% title @host.to_label, icon(@host.operatingsystem) + @host.to_label %>
<%= host_title_actions(@host) %>
<% content_for(:search_bar) {reports_show} %>
<div id="host-show" class="row" data-history-url='<%= host_path(@host)%>'>
  <div class="col-md-4">
    <table id="details_table" class="table table-bordered table-striped">
      <thead>
        <tr>
          <th><%= _('Details') %></th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>
            <% show_appropriate_host_buttons(@host).each do |btn| %>
              <%= btn %>
            <% end %>
          </td>
        </tr>
      </tbody>
    </table>
    <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 @host.compute_resource_id %>
        <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 %>
      <li><a href="#nics" data-toggle="tab"><%= _('NICs') %></a></li>
    </ul>
    <div id="myTabContent" class="tab-content">
      <div class="tab-pane active in" id="properties" data-ajax-url='<%= overview_host_path(@host)%>'>
        <p id="spinner">
          <%= image_tag 'spinner.gif' %>
          <%= _('Loading host information ...') %>
        </p>
      </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" data-ajax-url='<%= templates_host_path(@host)%>'>
        <p id="spinner">
          <%= image_tag 'spinner.gif' %>
          <%= _('Loading template information ...') %>
        </p>
      </div>
      <%  if @host.compute_resource_id %>
        <div class="tab-pane" id="vm" data-ajax-url='<%= vm_host_path(@host)%>' data-on-complete='setPowerState'>
          <p id="spinner">
            <%= image_tag 'spinner.gif' %>
            <%= _('Loading VM information ...') %>
          </p>
        </div>
      <% end %>
      <div id="nics" class="tab-pane" data-ajax-url='<%= nics_host_path(@host)%>' data-on-complete='onContentLoad'>
        <p id="spinner">
          <%= image_tag 'spinner.gif' %>
          <%= _('Loading NICs information ...') %>
        </p>
      </div>
      <% if @host.bmc_available? %>
        <div id="bmc" class="tab-pane" data-ajax-url='<%= bmc_host_path(@host) %>' data-on-complete='setPowerState'>
          <p id="spinner">
            <%= image_tag '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>
      <div class="chart" data-ajax-url='<%= runtime_host_path(@host, :range => @range) %>' data-on-complete='updateChart'>
        <p id="spinner">
          <%= image_tag 'spinner.gif' %>
          <%= _('Loading runtime information ...') %>
        </p>
      </div>
    </div>
    <div class="stats-well">
      <h4 class="ca"><%= _("Resources") %></h4>
      <h6 class="ca"><%= n_("last %s day", "last %s days", @range) % @range %></h6>
      <div class="chart" data-ajax-url='<%= resources_host_path(@host, :range => @range) %>' data-on-complete='updateChart'>
        <p id="spinner">
          <%= image_tag 'spinner.gif' %>
          <%= _('Loading resources information ...') %>
        </p>
      </div>
    </div>
  </div>
</div>
<div id="review_before_build" class="modal fade hide">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <%= alert_close('modal') %>
        <h4 class="modal-title"><%= _('Review build status for %s') % @host %></h4>
      </div>
      <div class="modal-body">
        <%= alert(:header => _('Warning: This will delete this host and all of its data!'),
                  :text   => _("This host's stored facts and reports will be deleted too."),
                  :close  => false,
                  :class => 'alert-warning'
                 ) %>
        <div class="loading"><%= image_tag 'spinner.gif' %></div>
        <div id="build_status"></div>
      </div>
    </div>
  </div>
</div>
<div id="processing_message" class="modal fade hide">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <%= alert_close('modal') %>
        <h4 class="modal-title"><%= _('Loading...') %>
          <%= image_tag 'spinner.gif' %></h4>
      </div>
      <div class="modal-body"><%= _('Please wait while your request is being processed') %></div>
    </div>
  </div>
</div>
