{% load static %} 
{% include "header.html" %}
{% include "navigation.html" with main_path='/main/' %}

<br/>
<br/>

<div class="container">
  <div class="dashboard">
    <div class="span8 offset2">
      {% if not data.sid %}
      <h1>Task List</h1>
      {% else %}
      <h1>Task Info</h1>
      {% endif %}
       
      <hr>

          
          {% for task in data.tasks %}
          <table class="dashboard">

           <tr>
            <td><b>Task id</b></td>
            <td>{{ task.short_uuid }}</td>
           </tr>

           <tr>
            <td><b>Task name</b></td>
            <td>{{ task.name }}</td>
           </tr>

           <tr>
            <td><b>Task container</b></td>
            <td>{{ task.container.image }}</td>
           </tr>

           <tr>
            <td><b>Task status</b></td>
            <td>{{ task.status }}</td>
           </tr>

           <tr>
            <td><b>Task created</b></td>
            <td>{{ task.created }}</td>
           </tr>

           <!-- <tr>
            <td><b>Task pid</b></td>
            <td>{{ task.pid}}</td>
           </tr> -->

           <tr>
            <td><b>Task ip</b></td>
            <td>{{ task.ip}}</td>
           </tr>

           <tr>
            <td><b>Task port</b></td>
            <td>{{ task.port }}</td>
           </tr>
           
           <tr>
            <td><b>Task tunnel port</b></td>
            <td>{{ task.tunnel_port }}</td>
           </tr>
           
           <tr>
            <td><b>Operations</b></td>
            
            <td>
            {% if task.status == "running" %}
            <a href=?uuid={{task.uuid}}&action=stop>Stop</a> | 
            {% else %}
            <!-- <a href=?uuid={{task.uuid}}&action=start>Start</a> |  -->
            <font color="#c0c0c0">Stop</font> | 
            
            {% endif %}
            {% if task.status == "exited" or task.status == "stopped" %}
            <a href=?uuid={{task.uuid}}&action=delete>Delete</a>
            {% else %}
            <font color="#c0c0c0">Delete</font>
            {% endif %}
            {% if task.status == "running" %}
             | <a href=?uuid={{task.uuid}}&action=connect>Connect</a>
            {% else %}
             | <font color="#c0c0c0">Connect</font>
            {% endif%}
            </td>
  
           </tr>

          </table>
          <br />
          {% endfor %}
          
          
          <br />
          {% if not data.sid %}
          <a href="/create_task">Add new...</a>
          {% endif %}
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      
    </div>
  </div>
</div>

{% include "footer.html" %}





