<section>
  <h3>
    <span class="right-divider">Running Processes</span>
  </h3>
  <h5>Debug running processes on your containers</h5>
</section>
<section class="well instances">
  <div class="row r-mb20">
    <ul class="nav nav-pills pull-right r-ml10">
      <li role="presentation" class={{if showRunning '' 'active'}}>
        <a {{action 'showRunningProcesses'}}>All</a>
      </li>
      <li role="presentation" class={{if showRunning 'active' ''}}>
        <a {{action 'showRunningProcesses'}}>Running</a>
      </li>
    </ul>
    <div class="pull-right form-inline">
      <div class="form-group">
        <select id="resource-type" class="form-control" {{action 'updateType' on='change'}}>
          <option value="" selected> -- select an resource type -- </option>
          {{#each model.resourceTypes as |resource|}}
          <option value="{{resource}}">{{resource}}</option>
          {{/each}}
        </select>
        {{input value=ownResourceId class="form-control" enter='submit' placeholder='Resource Id'}}
        {{input value=ownProcessName class="form-control" enter='submit' placeholder='Process Name'}}
        <button class="btn btn-danger r-ml10 r-mr10 pull-right" {{action 'reset'}} disabled={{disabledInputs}}>Clear</button>
        <button class="btn btn-primary r-ml10 r-mr10 pull-right" {{action 'submit'}} disabled={{disabledInputs}}>Search</button>
      </div>
    </div>
  </div>
  <table class="grid fixed table table-hover">
    <thead>
      {{sortable-th sortable=this action="changeSort" name="id" width="75"}}
      {{sortable-th sortable=this action="changeSort" name="processName"}}
      {{sortable-th sortable=this action="changeSort" name="resource" label="Resource Type:Id"}}
      {{sortable-th sortable=this action="changeSort" name="exitReason" width="200"}}
      {{sortable-th sortable=this action="changeSort" name="startTime" width="150"}}
      {{sortable-th sortable=this action="changeSort" name="endTime" width="150"}}
      {{sortable-th sortable=this action="changeSort" name="runTime" width="150"}}
    </thead>
    <tbody>
      {{#each arranged as |instance|}}
        {{#link-to 'admin-tab.processes.process' instance.id tagName="tr" classNames='hand'}}
            <td>
              <span class={{if instance.endTime 'label label-success' 'label label-warning'}}>{{instance.id}}</span>
            </td>
            <td class="clip"><span title={{instance.processName}}>{{instance.processName}}</span></td>
            <td class="clip"><span title={{instance.resourceType}}>{{instance.resourceType}}:{{instance.resourceId}}</span></td>
            <td>{{instance.exitReason}}</td>
            {{#if instance.startTime}}
              <td>{{date-from-now instance.startTime}}</td>
            {{else}}
              <td></td>
            {{/if}}
            {{#if instance.endTime}}
              <td>{{date-from-now instance.endTime}}</td>
            {{else}}
              <td></td>
            {{/if}}
            <td>{{run-time instance.startTimeTS instance.endTimeTS}}</td>
        {{/link-to}}
      {{/each}}
    </tbody>
  </table>
</section>
