{{!
 * 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="col-md-12">
  <div class="form-group">
    <label>Service Components</label>
    <span class="glyphicon glyphicon-info-sign info-icon" data-info="components"></span>
    <button class="btn btn-primary btn-xs pull-right" {{action "showAddComponentModal"}}>
      <span class="glyphicon glyphicon-plus"></span>
    </button>
    <div class="panel panel-default">
      <table class="table table-hover table-custom-bordered table-custom-striped table-custom-action">
        <thead>
          <tr>
            <th>Component Name</th>
            <th>CPU</th>
            <th>Memory</th>
            <th># Containers</th>
            <th>Artifact Id</th>
            <th>Launch Command</th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          {{#each serviceDef.serviceComponents as |component|}}
            <tr>
              <td>{{component.name}}</td>
              <td>{{component.cpus}}</td>
              <td>{{component.memory}}</td>
              <td>{{component.numOfContainers}}</td>
              <td>{{component.artifactId}}</td>
              <td>{{component.launchCommand}}</td>
              <td class="align-center">
                <span class="glyphicon glyphicon-remove remove-icon" {{action "removeComponent" component}}></span>
              </td>
            </tr>
          {{else}}
            <tr class="align-center">
              <td colspan="7">No data available</td>
            </tr>
          {{/each}}
        </tbody>
      </table>
    </div>
  </div>
</div>

<div class="modal fade deploy-service-modal" tabindex="-1" role="dialog" id="addComponentModal">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">Add Component</h4>
      </div>
      <div class="modal-body">
        {{#if duplicateNameError}}
          <div class="alert alert-danger alert-dismissible" role="alert">
            <strong>Component name already exists</strong>
          </div>
        {{/if}}
        <div class="form-group">
          <label class="required">Component Name</label>
          {{input type="text" class="form-control" value=currentComponent.name}}
        </div>
        <div class="form-group">
          <label class="required">CPU</label>
          {{input type="number" min="0" class="form-control" value=currentComponent.cpus}}
        </div>
        <div class="form-group">
          <label class="required">Memory</label>
          {{input type="number" min="0" class="form-control" value=currentComponent.memory}}
        </div>
        <div class="form-group">
          <label class="required"># Containers</label>
          {{input type="number" min="0" class="form-control" value=currentComponent.numOfContainers}}
        </div>
        <div class="form-group">
          <label>Artifact Id</label>
          {{input type="text" class="form-control" value=currentComponent.artifactId}}
        </div>
        <div class="form-group">
          <label class="required">Launch Command</label>
          {{input type="text" class="form-control" value=currentComponent.launchCommand}}
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary" {{action "addNewComponent"}} disabled={{unless isValidCurrentComponent "disabled"}}>Add</button>
      </div>
    </div>
  </div>
</div>
