{% extends "base.html" %}
{% block title %}
CyberRange
{% endblock %}
{% block content %}

<div id="admin_area" class="content-container">
  <div class="content">
    <h1>Result Details</h1>

    <div class="details_container">

      <ul>
        <li><label><strong>User</strong></label> <span class="info">{{ user }}</span></li>
        <li><label><strong>Exercise</strong></label> <span class="info">{{ exercise }}</span><br />
          <hr>
        </li>
        <li><label>
            <h5>Details</h5>
          </label>

          {% if data %}
          <ul>
            {% for key, value in data.items() %}
            <li>
              <label class="{% if key | length > 30 %}long{% endif %}">
                {% if value is mapping %}
                <h5>{{ key }}</h5>
                {% else %}
                {{ key | replace("_", " ") }}:
                {% endif %}
              </label>
              {% if value is mapping %}
              <ul>
                {% for subkey, subvalue in value.items() recursive %}
                <li class="mapping"> <label class="{% if subkey | length > 30 %}long{% endif %}">
                    {% if key == "history" and subkey | int %}
                    <b>Submission {{ subkey }}</b>
                    {% else %}
                    {{ subkey | replace("_", " ") }}:
                    {% endif %}
                  </label>
                  {% if subvalue is mapping %}
                  <ul>
                    {{- loop(subvalue.items()) }}
                  </ul>
                  {% else %}
                  <span class="detail {% if subvalue == True %}true{% elif subvalue == False %}false{% endif %}">
                    {% if subvalue != "" and (subvalue | string).startswith('http')  %}
                    <a href="{{subvalue}}" target="_blank">{{subvalue | truncate(150, True, ' ...') }}</a>
                    {% elif subvalue != "" and (subvalue | string).startswith('/upload/')  %}
                    <a href="{{subvalue}}" target="_blank">download attachment</a>
                    {% elif subvalue != "" %}
                    {{subvalue}}
                    {% else %}
                    <i>empty</i>
                    {% endif %}
                  </span>
                  {% endif %}
                </li>
                {% endfor %}
              </ul>
              {% else %}
              <span class="detail {% if value == True %}true{% elif value == False %}false{% endif %}">
                {{ value }}
              </span>
              {% endif %}
            </li>
            {% endfor %}
          </ul>
          {% else %}
          <span class="detail">
            <i>no data</i>
          </span>
          {% endif %}

        </li>
      </ul>

    </div>

  </div>
</div>

<div id="preloader" class="content-container pager">
  <div class="lds-ring">
    <div></div>
    <div></div>
    <div></div>
    <div></div>
  </div>
</div>
{% endblock %}
