{{!
* 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="label-capacity-container">
  <div class="panel panel-default">
    <div class="panel-heading">
      <div class="panel-title">
        Label Capacity <a id="collapseLabelCapacityPanelBtn" href="#collapsibleLabelCapacityPanel" data-toggle="collapse" {{bind-attr class=":pull-right view.isLabelsPanelCollapsed:collapsed"}}><i {{bind-attr class=":fa view.isLabelsPanelCollapsed:fa-plus:fa-minus"}}></i></a>
      </div>
    </div>
    <div id="collapsibleLabelCapacityPanel" {{bind-attr class=":panel-collapse :collapse view.isLabelsPanelCollapsed::in"}}>
      <div class="panel-body">
        {{#if isOperator}}
          {{#if isNodeLabelsEnabledByRM}}
            <div class="label-names">
              <label>Accessible Node Labels: </label>
              <span>{{accessibleLabelNames}}</span>
            </div>
            {{#if isRoot}}
              <div class="border-wrapper">
                <div class="row">
                  <div class="col-sm-2 col-md-2">
                    <label>Label</label>
                  </div>
                  <div class="col-sm-3 col-md-3">
                    <label>Label Capacity</label>
                  </div>
                  <div class="col-sm-3 col-md-3">
                    <label>Label Max Capacity</label>
                  </div>
                </div>
                {{#if hasAnyNodeLabelsForQueue}}
                  {{#each label in allLabelsForQueue}}
                    {{display-root-label queueLabels=queueNodeLabels nonAccessibleLabels=nonAccessibleLabels label=label isRoot=isRoot}}
                  {{/each}}
                {{else}}
                  <div class="row">
                    <div class="col-md-12 col-sm-12">
                      <small>No Node Labels Defined</small>
                    </div>
                  </div>
                {{/if}}
              </div>
            {{/if}}
            {{#if isLeafQ}}
              {{#if hasQueueLabels}}
                {{#each label in queueNodeLabels}}
                  {{display-leaf-label label=label}}
                {{/each}}
              {{else}}
                <div class="">
                  <small>Node labels are not enabled. Goto parent queue to enable them.</small>
                </div>
              {{/if}}
            {{else}}
              {{#if hasChildrenQueueLabels}}
                {{#each childQLabel in childrenQueueLabels}}
                  <div class="border-wrapper">
                    <div class="">
                      <label>Label: </label>
                      <span>{{childQLabel.labelName}}</span>
                    </div>
                    <div class="row">
                      <div class="col-md-2 col-sm-2">
                        <label>Children</label>
                      </div>
                      <div class="col-sm-4 col-md-4">
                        <label>Label Capacity</label>
                      </div>
                      <div class="col-sm-4 col-md-4">
                        <label>Label Max Capacity</label>
                      </div>
                    </div>
                    {{#each row in childQLabel.childrenQueueLabels}}
                      {{edit-label-capacity label=row.label queue=row.queue parentQueue=row.parentQueue}}
                    {{/each}}

                    {{label-capacity-bar queueLabels=childQLabel.childrenQueueLabels}}
                  </div>
                {{/each}}
              {{else}}
                <div class="">
                  <small>Node labels are not enabled. Goto parent queue to enable them.</small>
                </div>
              {{/if}}
            {{/if}}
          {{else}}
            <div>
              <small>Node labels are disabled by RM. Configure and enable labels to map the labels to queues.</small>
            </div>
          {{/if}}
        {{else}}
          {{#if isNodeLabelsEnabledByRM}}
            <div class="label-names">
              <label>Accessible Node Labels: </label>
              <span>{{accessibleLabelNames}}</span>
            </div>
            {{#if hasQueueLabels}}
              {{#each label in queueNodeLabels}}
                {{display-leaf-label label=label}}
              {{/each}}
            {{else}}
              <div class="">
                <small>Node labels are not enabled</small>
              </div>
            {{/if}}
          {{else}}
            <div>
              <small>Node labels are disabled</small>
            </div>
          {{/if}}
        {{/if}}
      </div>
    </div>
  </div>
</div>
