{{!
 * 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="row">
  <div class="col-md-12">
    <div class="panel panel-default">
      <div class="panel-heading">
        Threaddump {{collapsible-panel targetId="threaddumpFilesCollapsablePanel"}}
      </div>
      <div class="panel-body" id="threaddumpFilesCollapsablePanel">
        {{#if _isLoadingTopPanel}}
          <div class="text-center" style="z-index: 100; position: absolute; left: 46%; top: 45px;">
            <img src="assets/images/spinner.gif" alt="Loading...">
          </div>
        {{/if}}
        {{#unless isRunningApp}}
          <div class="row">
            <div class="col-md-8 col-md-offset-2 alert alert-warning text-center">
              <span class="glyphicon glyphicon-warning-sign" style="padding-right: 10px"></span>
              <span>Threaddump cannot be collected for an application that is not running.</span>
            </div>
          </div>
        {{else}}
            {{#if runningAttempt}}
                <div class="row">
                    <div class="col-md-6">
                        <label>Choose the running attempt to fetch containers</label>
                        <div>
                            <select class="js-fetch-attempt-containers" onchange={{action "showContainersForAttemptId" value="target.value"}} style="max-width:350px;">
                                <option value="" selected={{eq selectedAttemptId ''}}>None</option>
                                <option value="{{runningAttempt}}" selected={{eq selectedAttemptId runningAttempt}}>{{runningAttempt}}</option>
                            </select>
                        </div>
                    </div>
                    {{#if attemptContainerList}}
                        <div class="col-md-6">
                            <label>Choose container to fetch threaddump</label>
                            <div>
                                <select class="js-fetch-threaddump-containers" onchange={{action "showThreaddumpForContainer" value="target.value"}} style="max-width:350px">
                                    <option value="" selected={{eq selectedContainerId ''}}>None</option>
                                    {{#each attemptContainerList as |container|}}
                                        <option value="{{container.id}}" selected={{eq selectedContainerId container.id}}>{{container.id}}</option>
                                    {{/each}}
                                </select>
                            </div>
                        </div>
                    {{else}}
                        {{#if (and selectedAttemptId (not _isLoadingTopPanel))}}
                            <div class="col-md-4">
                                <h4 class="text-center" style="margin-top:25px;">No container data available!</h4>
                            </div>
                        {{/if}}
                    {{/if}}
                </div>
            {{else}}
                <div class="col-md-12">
                    <h4 class="text-center">No data available!</h4>
                </div>
            {{/if}}
        {{/unless}}
      </div>
    </div>
  </div>
</div>
{{#if selectedContainerId}}
  <div class="row">
    <div class="col-md-12">
      <div class="panel panel-default" style="min-height:150px;">
        <div class="panel-heading">
          Threaddump: [ {{selectedContainerId}} &amp; {{selectedAttemptId}} ]
          {{collapsible-panel targetId="threaddumpContentCollapsablePanel"}}
        </div>
        <div class="panel-body" id="threaddumpContentCollapsablePanel">
          {{#if _isLoadingBottomPanel}}
            <div class="text-center" style="z-index: 100; position: absolute; left: 46%;">
              <img src="assets/images/spinner.gif" alt="Loading...">
            </div>
          {{/if}}
          <div>
            {{#if _isThreaddumpAttemptFailed}}
              <div class="col-md-10 col-md-offset-1 alert alert-warning text-center">
                <span class="glyphicon glyphicon-warning-sign" style="padding-right: 10px"></span>
                <span>Threaddump fetch failed for container: {{selectedContainerId}} due to: &#8220;{{threaddumpErrorMessage}}&#8221;</span>
              </div>
            {{else if _isStdoutLogsFetchFailed}}
              <div class="col-md-10 col-md-offset-1 alert alert-warning text-center">
                <span class="glyphicon glyphicon-warning-sign" style="padding-right: 10px"></span>
                <span>Logs fetch failed for container: {{selectedContainerId}} due to: &#8220;{{stdoutLogsFetchFailedError}}&#8221;</span>
              </div>
            {{else}}
                <pre id="logContentTextArea1234554321" class="log-content-area">{{showThreaddumpContent}}</pre>
            {{/if}}
          </div>
        </div>
      </div>
    </div>
  </div>
{{/if}}
