{{!
* 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.
}}

{{#if view.service.isRestartRequired}}
  {{#isAccessible ADMIN}}
    <div id="summary-restart-bar">
      <div class="alert alert-warning clearfix">
        <i class="icon-refresh"></i> {{{view.needToRestartMessage}}} {{t services.service.config.restartService.needToRestart}}
        <a href="#" {{action showComponentsShouldBeRestarted controller.content.restartRequiredHostsAndComponents target="App.router.mainServiceInfoConfigsController"}}>{{view.componentsCount}} {{pluralize view.componentsCount singular="t:common.component" plural="t:common.components"}}</a> {{t on}}
        <a href="#" {{action showHostsShouldBeRestarted controller.content.restartRequiredHostsAndComponents target="App.router.mainServiceInfoConfigsController"}}>{{view.hostsCount}} {{pluralize view.hostsCount singular="t:common.host" plural="t:common.hosts"}}</a>
        <span class="restart-components pull-right">&nbsp</span>

        <div class="btn-group pull-right">
          <button type="button" class="btn btn-default dropdown-toggle btn-warning" data-toggle="dropdown">
            {{t hosts.host.details.needToRestart.button}}
            <span class="caret"></span>
          </button>
          <ul class="dropdown-menu">
            <li><a href="#" {{action restartAllStaleConfigComponents target="view"}}>{{t restart.service.all}}</a></li>
            {{#if view.rollingRestartSlaveComponentName}}
              <li>
                <a href="#" {{action rollingRestartStaleConfigSlaveComponents view.rollingRestartSlaveComponentName target="view"}}>{{view.rollingRestartActionName}}</a>
              </li>
            {{/if}}
          </ul>
        </div>
      </div>
    </div>
  {{/isAccessible}}
{{/if}}

<div class="row-fluid service-block">
  <div class="span6">
    <div class="box">
      <div class="box-header summary-box-header">
        <h4>{{controller.content.label}} {{t services.service.info.menu.summary}}</h4>
        {{#if view.hasAlertDefinitions}}
          {{#if view.alertsCount}}
            <span {{action "showServiceAlertsPopup" controller.content target="controller"}}
              {{bindAttr class=":label :pull-right view.hasCriticalAlerts:alerts-crit-count:alerts-warn-count"}}>
              {{view.alertsCount}} {{pluralize view.alertsCount singular="alert" plural="alerts"}}</span>
          {{else}}
            <span {{action "showServiceAlertsPopup" controller.content target="controller"}}
              class="label pull-right no-alerts-label">{{t services.service.summary.alerts.noAlerts}}</span>
          {{/if}}
        {{/if}}
      </div>
      <div class="service-content">
        <table id="summary-info" class="table no-borders table-condensed">
          <tbody>
          {{#if view.serviceSummaryView}}
            {{view view.serviceSummaryView}}
          {{/if}}
          </tbody>
        </table>
      </div>
    </div>
  </div>

  {{#if view.isServiceMetricLoaded}}
    {{#if view.serviceMetricGraphs.length}}
      <div class="span6 service-metrics-block">
        <div class="box">
          <div class="box-header">
            <h4>{{t services.service.metrics}}</h4>
            <div class="btn-group pull-right">
              <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                {{view.currentTimeRange.name}} &nbsp;<span class="caret"></span>
              </button>
              <ul class="dropdown-menu">
                {{#each option in view.timeRangeOptions}}
                    <li><a href="#" {{action setTimeRange option target="view"}}>{{option.name}}</a></li>
                {{/each}}
              </ul>
            </div>
          </div>
          <div class="">
            <table class="graphs">
              {{#each graphs in view.serviceMetricGraphs}}
                <tr>
                  {{#each graph in graphs}}
                    <td>
                        <div class="">
                          {{view graph}}
                        </div>
                    </td>
                  {{/each}}
                </tr>
              {{/each}}
            </table>
          </div>
        </div>
      </div>
    {{/if}}
  {{/if}}

</div>

{{#if view.collapsedSections}}
  <div class="row-fluid">
    <div class="span12 metrics-collapsed-graphs">
      {{#each collapsedSection in view.collapsedSections}}
        <div {{bindAttr class=":accordion collapsedSection.toggleIndex"}}>
          <div class="accordion-group box">
            <div class="accordion-heading box-header">
              <span class="pull-left accordion-toggle"
                    data-toggle="collapse" {{bindAttr dataParent="collapsedSection.toggleIndex" href="collapsedSection.toggleIndex"}}>
                <i class="pull-left icon-caret-toggle"></i>
                <span>{{collapsedSection.header}}</span>
              </span>
              <a class="btn pull-right" {{bindAttr href="collapsedSection.url"}} target="_blank">
                <i class="icon-link"></i>
              </a>

              <div class="clearfix"></div>
            </div>
            <div class="accordion-body collapse in" {{bindAttr id="collapsedSection.id"}}>
              <div class="accordion-inner">
                {{#if collapsedSection.metricView}}
                  {{view collapsedSection.metricView viewDataBinding="collapsedSection.metricViewData"}}
                {{/if}}
              </div>
            </div>
          </div>
        </div>
      {{/each}}
    </div>
  </div>
{{/if}}





