{% load static %} 
{% include "header.html" %}
{% include "navigation.html" %}

<br/>
<br/>

<div class="container">
  <div class="dashboard">
    <div class="span8 offset2">
      <h1>Account and profile</h1>
      <hr>

      <br />
      <h3>Account</h3>
      <form action="/account/" method="POST">
      {% csrf_token %}
      <table class="dashboard">

       <tr>
        <td>
        <b>ID</b>
        </td>
        <td>
        {{data.user.username}}
        </td>
       </tr>
      
       <tr>
        <td>
        <b>Email</b>
        </td>
        <td>
        {% if data.edit == 'email' %}    
          <table class="frametab"><tr><td>
          <input type='hidden' name='edit' value='email' />
          <input type="email" value="{{data.user.email}}" name='value' style='width:95%' required autofocus />
          </td><td>
          <input type="submit" value="Go">
          </td></tr></table>          
        {% else %}
         {{data.user.email}}{% if data.user.profile.auth == 'local' %} | <a href="/account/?edit=email">Change</a>{% endif %}
        {% endif %}
        </td>
       </tr>      

       {% if data.user.profile.auth == 'local' %}
       <tr>
        <td>
        <b>Password</b>
        </td>
        <td>
        {% if data.edit == 'password' %}    
          <table class="frametab"><tr><td>
          <input type='hidden' name='edit' value='password' />
          <input type="password" name='value' style='width:95%' required autofocus />
          </td><td>
          <input type="submit" value="Go">
          </td></tr></table>          
        {% else %}
         ******* | <a href="/account/?edit=password">Change</a>
        {% endif %}
        </td>
       </tr>
       {% endif %}  


       <tr>
        <td>
        <b>Auth</b>
        </td>
        <td>
        {% if data.user.profile.auth == 'local' %}
        Local
        {% elif data.user.profile.auth == 'oidc' %}
        Open ID Connect
        {% else %}
        {{ data.user.profile.auth }}
        {% endif %}
        </td>    
       </tr>



      </table>
      <br />
       
      <h3>Profile</h3>
      <table class="dashboard">
       
       <tr>
        <td>
        <b>Time Zone</b>
        </td>
        <td>
        
        {% if data.edit == 'timezone' %}    
          {% include "components/tzselect.html" %}
          <input type='hidden' name='edit' value='timezone' />
          <input type="submit" value="Go">
        {% else %}
         {{data.profile.timezone}} | <a href="/account/?edit=timezone">Change</a>
        {% endif %}
        </td>
       </tr>
       

       <tr>
        <td valign=top>
        <b>Extra configurations</b>
        </td>
        <td>
        {% for conf_uuid, conf_data in data.profile.extra_confs.items %}
        <code>{{ conf_data.type }}</code>
        {% if conf_data.object_uuid %}
        {% for computing in data.computings %}
        {% if conf_data.object_uuid == computing.uuid_as_str %}
        <font style="font-size:0.9em"> @ {{ computing.name }}</font>
        {% endif %}
        {% endfor %}
        {% endif %}
        
        : <code>{{conf_data.value}}</code> |  <a href='?delete_extra_conf_uuid={{conf_uuid}}'>delete</a>
        <br/> 
        {% endfor %}
        
        
        
        <span style="margin:3px"><a href="/add_profile_conf" style="line-height:2em">Add new...</a></span>
        </td>
       </tr>       

      </table>

      <br />
      <h3>KeyPair</h3>
      <table class="dashboard">
       
       <tr>
        <td valign="top">
        <b>Default public key</b>
        </td>
        <td>
            <textarea style="width:100%; max-width:500px; word-wrap:break-word; display:inline-block; font-family:monospace" rows=3 cols=41>{{ data.default_public_key}}</textarea>
        </td>
       </tr>

      </table>
      </form>
      
      <div style="margin-left:10px; margin-top:40px">
        {% if data.user.profile.auth == 'oidc' %}
        <form action="{% url 'oidc_logout' %}" method="post">
        {% csrf_token %}
        <input type="submit" value="logout">
        </form>
        {% else %}
        <form action="/logout/" method="get">
        <input type="submit" value="logout">
        </form>        
        {% endif %}
      </div>

      
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      
    </div>
  </div>
</div>


{% include "footer.html" %}





