{{!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
}}

<div id="hosts">

  <div class="box-header row">
    <div class="hosts-actions pull-left">
      {{#isAccessible ADMIN}}
        {{view App.HostTableMenuView}}
      {{/isAccessible}}
    </div>
    <div class="health-status-bar pull-left">
      {{#view view.statusFilter categoriesBinding="view.categories"}}
        <div class="btn-group display-inline-block">
          <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
            <span class="filters-label">{{t common.filter}}: </span>
            <span>
              <span {{bindAttr class="view.class"}}></span>
              {{view.comboBoxLabel}}
              <span class="caret"></span>
            </span>
          </a>
          <ul class="dropdown-menu">
            <li {{bindAttr class=":category-item view.filtersUsed::active"}}>
              <a {{action clearFilter target="view"}} href="#">{{t common.all}} ({{view.parentView.totalCount}})</a>
            </li>
            {{#each category in view.categories}}
              {{#if category.isVisible}}
                <li {{bindAttr class=":category-item category.itemClass"}}>
                  <a {{action selectCategory category target="view"}} href="#">
                      <span {{bindAttr class="category.isHealthStatus:health-status category.healthClass category.class"}}></span>
                    {{category.label}}
                  </a>
               </li>
             {{/if}}
           {{/each}}
         </ul>
       </div>
      {{/view}}
    </div>
  </div>

  <table class="table advanced-header-table table-bordered table-striped" id="hosts-table">
    <thead>
      {{#view view.sortView classNames="label-row" contentBinding="view.filteredContent"}}
        <th class="first"> </th>
        <th> </th>
        {{view view.parentView.nameSort}}
        <th> </th>
        <th> </th>
        {{view view.parentView.ipSort}}
        {{view view.parentView.cpuSort}}
        {{view view.parentView.memorySort}}
        {{view view.parentView.diskUsageSort}}
        {{view view.parentView.loadAvgSort}}
        <th {{bindAttr class="App.supports.stackUpgrade::hidden App.stackVersionsAvailable::hidden :sort-view-11"}}>
          {{t hosts.host.menu.stackVersions}}
        </th>
        <th class="sort-view-6">{{t common.components}}</th>
      {{/view}}
      <tr class="filter-row">
        <th class="first"><div class="ember-view view-wrapper">{{view Ember.Checkbox checkedBinding="view.selectAllHosts"}}</div></th>
        <th> </th>
        <th>{{view view.nameFilterView}}</th>
        <th> </th>
        <th> </th>
        <th>{{view view.ipFilterView}}</th>
        <th>{{view view.cpuFilterView}}</th>
        <th>{{view view.ramFilterView}}</th>
        <th> </th>
        <th>{{view view.loadAvgFilterView}}</th>
        <th {{bindAttr class="App.supports.stackUpgrade::hidden App.stackVersionsAvailable::hidden"}}>
          {{view view.versionsFilterView}}
        </th>
        <th>{{view view.componentsFilterView}}</th>
      </tr>
    </thead>
    <tbody>
    {{#if view.pageContent}}
      {{#each host in view.pageContent}}
        {{#view view.HostView contentBinding="host"}}

          <td class="first">{{view Ember.Checkbox checkedBinding="host.selected"}}</td>

          <td class="health">
            <span rel="HealthTooltip" {{bindAttr class="host.healthClass host.healthIconClass"}} {{bindAttr data-original-title="host.healthToolTip" }}></span>
          </td>

          <td class="name">
            <span class="trim_hostname">
              <a title="{{unbound host.hostName}}" href="#" {{action "showDetails" host}}>{{unbound host.hostName}}</a>
            </span>
            {{#if host.criticalWarningAlertsCount}}
              {{#if host.alertsSummary.CRITICAL}}
                <span class="label alerts-crit-count" {{action "goToHostAlerts" host target="controller"}}>{{host.criticalWarningAlertsCount}}</span>
              {{else}}
                <span class="label alerts-warn-count" {{action "goToHostAlerts" host target="controller"}}>{{host.criticalWarningAlertsCount}}</span>
              {{/if}}
            {{/if}}
          </td>
          <td class="restart">
            {{#if host.componentsWithStaleConfigsCount}}
              <span class="muted icon-refresh" rel="ComponentsTooltip" {{bindAttr title="view.restartRequiredComponentsMessage"}}></span>
            {{/if}}
          </td>
          <td class="passive-state">
              <span rel="ComponentsTooltip" {{bindAttr data-original-title="view.componentsInPassiveStateMessage" class="host.componentsInPassiveStateCount:icon-medkit"}}></span>
          </td>
          <td class="host-ip">{{host.ip}}</td>
          <td class="cores-formatted">{{host.coresFormatted}}</td>
          <td class="memory-formatted">{{host.memoryFormatted}}</td>

          <td class="disk-info">
            <div class="progress progress-info" {{bindAttr title="host.diskInfoBar"}} rel="UsageTooltip">
              <div class="bar" {{bindAttr style="view.usageStyle"}}></div>
            </div>
          </td>

          <td class="load-avg">{{host.loadAvg}}</td>
          <td {{bindAttr class="App.supports.stackUpgrade::hidden App.stackVersionsAvailable::hidden view.hasSingleVersion:not-active-link :host-table-versions"}}>
            <a href="#" class="expander black" {{action toggleVersions target="view"}}>
              {{#unless view.hasSingleVersion}}
                <span {{bindAttr class="view.isVersionsCollapsed:icon-caret-right:icon-caret-down"}}></span>
              {{/unless}}
              {{view.currentVersion}}
            </a>
            <div {{bindAttr class="view.isVersionsCollapsed:noDisplay:display :stack-versions :collapsed-list"}}>
              {{{view.versionLabels}}}
            </div>
          </td>
          <td class="host-table-components">
            <a href="#" class="expander" {{action toggleComponents target="view"}}> <span {{bindAttr class="view.isComponentsCollapsed:icon-caret-right:icon-caret-down"}}></span>
              {{view.content.hostComponents.length}} {{pluralize view.content.hostComponents.length singular="t:common.component" plural="t:common.components"}}</a>
            <div {{bindAttr class="view.isComponentsCollapsed:noDisplay:display :host-components :collapsed-list"}}>
              {{{view.labels}}}
            </div>
          </td>
        {{/view}}
      {{/each}}
    {{else}}
      <tr>
        <td class="first"> </td>
        <td {{bindAttr colspan="view.colspan"}}>
          {{t hosts.table.noHosts}}
        </td>
      </tr>
    {{/if}}
    </tbody>
  </table>

  <div {{bindAttr class="view.filteringComplete:hidden :table-overlay"}}>
    <div class="spinner"></div>
  </div>

  <div class="page-bar">
    <div class="filtered-info span4">
      <label>{{view.filteredContentInfo}} - <a {{action clearFilters target="view"}} id="hosts-page-clear-filters" href="#">{{t tableView.filters.clearAllFilters}}</a></label>
    </div>
    <div class="selected-hosts-info span4">
      {{#if view.showSelectedFilter}}
        <div>
          <a {{action filterSelected target="view"}} href="#">
            {{view.selectedHosts.length}}
            {{pluralize view.selectedHostsCount singular="t:hosts.filters.selectedHostInfo" plural="t:hosts.filters.selectedHostsInfo"}}
          </a>
        </div> - <a {{action clearSelection target="view"}} href="#">{{t hosts.filters.clearSelection}}</a>
      {{/if}}
    </div>
    <div class="items-on-page">
      <label>{{t common.show}}: {{view view.rowsPerPageSelectView selectionBinding="view.displayLength"}}</label>
    </div>
    <div class="info">{{view.paginationInfo}}</div>
    <div class="paging_two_button">
      <a {{bindAttr class="view.paginationLeftClass"}}{{action previousPage target="view"}}><i class="icon-arrow-left"></i></a>
      <a {{bindAttr class="view.paginationRightClass"}}{{action nextPage target="view"}}><i class="icon-arrow-right"></i></a>
    </div>
  </div>
</div>

