{{!
* 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 class="btn-group dropdown span2">
  <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">{{t dashboard.widgets.wizard.step2.newMetric}}
    &nbsp;<span class="caret"></span></a>
  <ul class="dropdown-menu service-level-dropdown">
    {{#if controller.content.isMetricsLoaded}}
      <!--service level-->
      {{#each service in view.componentMap}}
        <li class="dropdown-submenu">
          <a class="" tabindex="-1" href="javascript:void(null);">{{service.displayName}}</a>
          <ul class="dropdown-menu">
            {{#each component in service.components}}
              <!--component level-->
              <li class="dropdown-submenu">
                <a href="javascript:void(null);">{{component.displayName}}</a>
                <ul class="dropdown-menu select-options-dropdown">
                  <!--metrics level-->
                  <li class="keep-open metric-select" {{action selectComponents component target="view"}}>
                      {{view App.JqueryChosenView optionsBinding="component.metrics" elementIdBinding="component.id" selectionObjBinding="view.metricsSelectionObj"}}
                  </li>
                  <!--select aggregator function -->
                  <li {{bindAttr class=":keep-open :aggregator-select component.showAggregateSelect::hidden"}}
                    {{action selectComponents component target="view"}}
                    {{translateAttr data-original-title="dashboard.widgets.wizard.step2.aggregateTooltip"}}>
                    {{view App.JqueryChosenView optionsBinding="view.parentView.AGGREGATE_FUNCTIONS" elementIdBinding="component.aggregatorId" selectionObjBinding="view.aggregateFnSelectionObj"}}
                  </li>
                  <li class="actions-buttons">
                    <button class="btn" href="#" {{action cancel target="view"}}>{{t common.cancel}}</button>
                    <button {{bindAttr class=":btn :btn-primary component.isAddEnabled::disabled"}} href="#"
                      {{action addMetric component target="view"}}>{{t common.add}}</button>
                  </li>
                </ul>
              </li>
            {{/each}}
          </ul>
        </li>
      {{/each}}
    {{else}}
      <div class="spinner"></div>
    {{/if}}
  </ul>
</div>

