{% extends 'layout.jinja2.html' %}
{% from 'test_macro.jinja2.html' import test_table %}

{% block title %}Test: {{test['test_id']}}{% endblock %}

{% block style %}
#artifacts_tbl pre {
     white-space: pre-wrap;
}

{% endblock %}


{% block body %}
<h3>Test: {{test['test_id']}}</h3>
<div class='hidden' id='test_id'>{{test['test_id']}}</div>
<table class='table'>
<tr><td class='col-md-2'>Title</td><td>{{test['test_definition']['title']}}</td></tr>
<tr><td>User</td><td>{{test['user']}}</td></tr>
<tr><td>Cluster</td><td><a href="/cluster/{{test['cluster']}}">{{test['cluster']}}</a>
</td></tr>
<tr><td>Status</td><td><span id='test_status'>{{test['status']}}</span>
  {% if test['status'] == 'in_progress' %}
  <span style='margin-left: 20px' class='attention'>This test is currently in
  progress, <a href="/cluster/{{test['cluster']}}">view the
  console</a> to monitor progress</span>
  {% endif %}
</td></tr>
<tr><td>Date Scheduled</td><td>{{test['scheduled_date']}}</td></tr>
{% if test['completed_date'] %}
<tr><td>Date Completed</td><td>{{test['completed_date']}}</td></tr>
{% endif %}
{% if test['test_definition']['description']|length > 0 %}
<tr><td>Description</td><td><pre>{{test['test_definition']['description']}}</pre></td></tr>
{% endif %}
<tr><td>Number of nodes</td><td>{{test['test_definition']['num_nodes']}}</td></tr>
{% if has_chart %}
<tr><td>Chart</td><td><a class='btn btn-primary' role='button' href="/tests/artifacts/{{test['test_id']}}/graph">View Chart</a></td></tr>
{% endif %}
{% if artifacts|length > 0 %}
<tr><th colspan="100%">Artifacts</th></tr>
<tr><td colspan="100%"><table id="artifacts_tbl" class='col-md-12'>
  {% for artifact in artifacts %}
   {% if artifact['artifact_type'] in ('failure',) %}
     <tr><td class='col-md-2'>{{artifact['artifact_type']}}</td><td><pre>{{artifact['artifact']}}</pre></td><td></b></td></tr>
   {% elif artifact['artifact_type'] in ('link',) %}
     <tr><td class='col-md-2'>{{artifact['artifact_type']}}</td><td><a href='{{artifact['artifact']}}'>{{artifact['description']}}</a></td><td></td></tr>
   {% else %}
     <tr><td class='col-md-2'>{{artifact['artifact_type']}}</td><td><a href='/tests/artifacts/{{test['test_id']}}/{{artifact['artifact_type']}}'>{{artifact['description']}}</a></td><td></td></tr>
   {% endif %} 
  {% endfor %}
</td></tr></table>
{% endif %}
<tr><th colspan="100%">Revisions</th></tr>
{% for rev_n in range(test['test_definition']['revisions']|length) %}
  {% set revision = test['test_definition']['revisions'][rev_n] %}
  <tr><td>Revision {{rev_n + 1}}</td><td>
    <table class='table'>
      <tr><td class='col-md-2'>Revision</td><td><b>{{revision['revision']}}</b></td></tr>
      {% if revision['label'] %}
        <tr><td>Label</td><td>{{revision['label']}}</td></tr>
      {% endif %}
      {% if revision['yaml'] %}
        <tr><td>Cassandra.yaml</td><td><pre>{{revision['yaml']}}</pre></td></tr>
      {% endif %}
      {% if revision['env'] %}
        <tr><td>Environment</td><td><pre>{{revision['env']}}</pre></td></tr>
      {% endif %}
      {% for option, value in revision['options'].items() %}
        <tr><td>{{option}}</td><td>{{value}}</td></tr>
      {% endfor %}
    </table>
  </td></tr>
{% endfor %}
<tr><th colspan="100%">Operations</th></tr>
{% for op_n in range(test['test_definition']['operations']|length) %}
  {% set op = test['test_definition']['operations'][op_n] %}
  <tr><td>Operation {{op_n + 1}}</td><td>
    <table class='table'>
      <tr><td class='col-md-2'>Operation</td><td><b>{{op['operation']}}</b></td></tr>
      {% if op['command'] %}
        <tr><td>Command</td><td><code>{{op['command']}}</code></td></tr>
      {% endif %}
    </table>
  </td></tr>
{% endfor %}

<script src="/static/js/view_test.js"></script>
{% endblock %}
