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

<div class="container">
  <div class="dashboard">
    <div class="span8 offset2">
      <h1><a href="/storage">Storage</a> <span style="font-size:18px"> / 
           <a href="/storage/?manage=True&uuid={{ data.storage.uuid }}">{% if data.storage.computing %}{{ data.storage.computing.name }}:{% endif %}{{ data.storage.name }}</a> /edit</span></h1>
      <hr>
      {% if data.error %}
      <div class="alert alert-danger" style="width:500px;">{{ data.error }}</div>
      {% endif %}
      {% if data.saved %}
      <div class="alert alert-success" style="width:500px;">Storage updated successfully.</div>
      {% endif %}
      {% if data.created %}
      <div class="alert alert-success" style="width:500px;">Storage created successfully.</div>
      {% endif %}
      <form action="#" method="POST">
      {% csrf_token %}
      <table class="dashboard" style="width:500px; margin-bottom:25px">
        <tr>
          <td><b>Computing</b></td>
          <td>
            <select name="computing_uuid" style="width: 220px;">
              <option value="">None</option>
              {% for computing in data.computings %}
                <option value="{{ computing.uuid }}" {% if data.storage.computing and computing.uuid == data.storage.computing.uuid %}selected{% endif %}>{{ computing.name }}</option>
              {% endfor %}
            </select>
          </td>
        </tr>
        <tr>
          <td><b>Name</b></td>
          <td><input type="text" name="name" value="{{ data.storage.name }}" size="30" required /></td>
        </tr>
        <tr>
          <td><b>Owner</b></td>
          <td>
            <select name="user_id" style="width: 220px;">
              {% if data.storage.user %}
              <option value="{{ data.storage.user.id }}">{{ data.storage.user.email }}</option>
              {% if data.user.is_staff %}<option value="">Platform</option>{% endif %}
              {% else %}
              <option value="">Platform</option>
              {% endif %}
            </select>
          </td>
        </tr>
        <tr>
          <td><b>Group</b></td>
          <td>
            <select name="group_id" style="width: 220px;">
              <option value="">None</option>
              {% for group in data.groups %}
              <option value="{{ group.id }}" {% if data.storage.group and group.id == data.storage.group.id %}selected{% endif %}>{{ group.name }}</option>
              {% endfor %}
            </select>
          </td>
        </tr>
        <tr>
          <td><b>Type</b></td>
          <td>
            <select name="type" style="width: 220px;" required>
              <option value="generic_posix" {% if data.storage.type == 'generic_posix' %}selected{% endif %}>generic_posix</option>
              <option value="internal" {% if data.storage.type == 'internal' %}selected{% endif %}>internal</option>
            </select>
          </td>
        </tr>
        <tr>
          <td><b>Access mode</b></td>
          <td>
            <select name="access_mode" style="width: 220px;" required>
              <option value="ssh+cli" {% if data.storage.access_mode == 'ssh+cli' %}selected{% endif %}>ssh+cli</option>
              <option value="internal" {% if data.storage.access_mode == 'internal' %}selected{% endif %}>internal</option>
            </select>
          </td>
        </tr>
        <tr>
          <td><b>Access via computing</b></td>
          <td><input type="checkbox" name="access_through_computing" value="True" {% if data.storage.access_through_computing %}checked{% endif %} /></td>
        </tr>
        <tr>
          <td><b>Auth mode</b></td>
          <td>
            <select name="auth_mode" style="width: 220px;" required>
              <option value="user_keys" {% if data.storage.auth_mode == 'user_keys' %}selected{% endif %}>user_keys</option>
              <option value="platform_keys" {% if data.storage.auth_mode == 'platform_keys' %}selected{% endif %}>platform_keys</option>
              <option value="internal" {% if data.storage.auth_mode == 'internal' %}selected{% endif %}>internal</option>
            </select>
          </td>
        </tr>
        <tr>
          <td><b>Base path</b></td>
          <td><input type="text" name="base_path" value="{{ data.storage.base_path }}" size="30" required /></td>
        </tr>
        <tr>
          <td><b>Bind path</b></td>
          <td><input type="text" name="bind_path" value="{{ data.storage.bind_path }}" size="30" /></td>
        </tr>
        <tr>
          <td><b>Read only</b></td>
          <td><input type="checkbox" name="read_only" value="True" {% if data.storage.read_only %}checked{% endif %} /></td>
        </tr>
        <tr>
          <td><b>Browsable</b></td>
          <td><input type="checkbox" name="browsable" value="True" {% if data.storage.browsable %}checked{% endif %} /></td>
        </tr>
        <tr>
          <td><b>Conf</b><br/><span style="font-size:0.8em">(JSON dict)</span></td>
          <td><textarea name="conf" rows="2" cols="30">{{ data.storage.conf_json }}</textarea></td>
        </tr>
      </table>
      <table style="width:500px; border:0; background:#ffffff; margin-top:20px">
        <tr><td align="center">
          <input type="submit" value="Save" class="btn btn-primary">
        </td></tr>
      </table>
      </form>
    </div>
  </div>
</div>

{% include "footer.html" %} 