Commit 737d21ee authored by Stefano Alberto Russo's avatar Stefano Alberto Russo
Browse files

Rationalized storage views and templates, improved helper functions.

parent 2905a646
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -478,7 +478,11 @@ class Storage(models.Model):
    def id(self):
        return (self.name if not self.computing else '{}:{}'.format(self.computing.name,self.name))


    @property
    def conf_json(self):
        if not self.conf:
            return ''
        return json.dumps(self.conf)



+21 −14
Original line number Diff line number Diff line
@@ -23,6 +23,26 @@
          <td><b>Name</b></td>
          <td><input type="text" name="name" value="" size="30" required /></td>
        </tr>
        <tr>
          <td><b>Owner</b></td>
          <td>
            <select name="user_id" style="width: 220px;">
              <option value="{{ data.user.id }}">{{ data.user.email }}</option>
              {% if data.user.is_staff %}<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 }}">{{ group.name }}</option>
              {% endfor %}
            </select>
          </td>
        </tr>
        <tr>
          <td><b>Type</b></td>
          <td><input type="text" name="type" value="" size="30" required /></td>
@@ -43,17 +63,6 @@
          <td><b>Bind path</b></td>
          <td><input type="text" name="bind_path" value="" size="30" /></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 }}">{{ group.name }}</option>
              {% endfor %}
            </select>
          </td>
        </tr>
        <tr>
          <td><b>Computing</b></td>
          <td>
@@ -80,9 +89,7 @@
      </table>
      <table style="width:500px; border:0; background:#ffffff; margin-top:20px">
        <tr><td align="center">
          <a href="/storage/?manage=True" class="btn btn-primary" style="margin-left:10px">Back</a>
          &nbsp;
          <input type="submit" value="Save" class="btn btn-primary">
          <input type="submit" value="Create" class="btn btn-primary">
        </td></tr>
      </table>
      </form>
+50 −13
Original line number Diff line number Diff line

{% if data.storage and storage.uuid == data.storage.uuid %}
{% if details %}
{% if data.created %}
<div class="alert alert-success" style="width:500px;">Storage created successfully.</div>
{% endif %}
<div style="float:left; width:500px; margin:10px; margin-bottom:20px">
  <table class="dashboard" style="width:100%">
    <tr><td><b>Name</b></td><td>{{ storage.name }}</td></tr>
    <tr><td><b>Type</b></td><td>{{ storage.type }}</td></tr>
    <tr><td><b>Access mode</b></td><td>{{ storage.access_mode }}</td></tr>
    <tr><td><b>Auth mode</b></td><td>{{ storage.auth_mode }}</td></tr>
    <tr><td><b>Base path</b></td><td><code>{{ storage.base_path }}</code></td></tr>
    <tr><td><b>Bind path</b></td><td><code>{{ storage.bind_path }}</code></td></tr>
    <tr><td><b>Read only</b></td><td>{% if storage.read_only %}Yes{% else %}No{% endif %}</td></tr>
    <tr><td><b>Browsable</b></td><td>{% if storage.browsable %}Yes{% else %}No{% endif %}</td></tr>
    <tr><td><b>Group</b></td><td>{% if storage.group %}{{ storage.group }}{% else %}Platform{% endif %}</td></tr>
    <tr><td><b>Computing</b></td><td>{% if storage.computing %}{{ storage.computing.name }}{% else %}None{% endif %}</td></tr>
    <tr><td><b>Conf</b></td><td><pre style="font-size:0.9em">{{ storage.conf|default_if_none:'' }}</pre></td></tr>
    {% if request.user.is_staff %}
    <tr>
      <td><b>Name</b></td>
      <td>{{ storage.name }}</td>
    </tr>
    <tr>
      <td><b>Owner</b></td>
      <td>{% if data.storage.user %}{{ data.storage.user }}{% else %}Platform{% endif %}</td>
    </tr>
    <tr>
      <td><b>Group</b></td>
      <td>{{ data.storage.group }}</td>
    </tr>
    <tr>
      <td><b>Type</b></td>
      <td>{{ storage.type }}</td>
    </tr>
    <tr>
      <td><b>Access mode</b></td>
      <td>{{ storage.access_mode }}</td>
    </tr>
      <tr><td><b>Auth mode</b></td>
      <td>{{ storage.auth_mode }}</td>
    </tr>
    <tr>
      <td><b>Base path</b></td>
      <td><code>{{ storage.base_path }}</code></td>
    </tr>
    <tr>
      <td><b>Bind path</b></td>
      <td><code>{{ storage.bind_path }}</code></td>
    </tr>
    <tr>
      <td><b>Computing</b></td>
      <td>{% if storage.computing %}{{ storage.computing.name }}{% else %}None{% endif %}</td>
    </tr>
    <tr>
      <td><b>Read only</b></td>
      <td>{% if storage.read_only %}Yes{% else %}No{% endif %}</td>
    </tr>
    <tr>
      <td><b>Browsable</b></td>
      <td>{% if storage.browsable %}Yes{% else %}No{% endif %}</td>
    </tr>
    <tr>
      <td><b>Conf</b></td><td><pre style="font-size:0.9em">{{ storage.conf_json }}</pre></td></tr>
    {% if storage.user == data.user or data.user.is_staff %}
    <tr>
      <td><b>Actions</b></td>
      <td>
+32 −19
Original line number Diff line number Diff line
@@ -10,12 +10,14 @@
      <hr>

      {% if data.error %}
        <div class="alert alert-danger">{{ data.error }}</div>
        <div class="alert alert-danger" style="width:500px;">{{ data.error }}</div>
      {% endif %}
      {% if data.edited %}
        <div class="alert alert-success">Storage updated successfully.</div>
      {% 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">
@@ -23,6 +25,30 @@
          <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><input type="text" name="type" value="{{ data.storage.type }}" size="30" required /></td>
@@ -43,17 +69,6 @@
          <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>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>Computing</b></td>
          <td>
@@ -75,14 +90,12 @@
        </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.conf_json }}</textarea></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">
          <a href="/storage/?manage=True&uuid={{ data.storage.uuid }}" class="btn btn-primary" style="margin-left:10px">Back</a>
          &nbsp;
          <input type="submit" value="Save changes" class="btn btn-primary">
          <input type="submit" value="Save" class="btn btn-primary">
        </td></tr>
      </table>
      </form>
+29 −24
Original line number Diff line number Diff line
@@ -7,54 +7,59 @@
  <div class="dashboard" style="height:100%;">
    <div class="span8 offset2" style="height:100%;">

      {% if not data.storage %}
      <h1>Storage resources</h1>
      {% else %}
      {% if data.storage %}
      <h1><a href="/storage/?manage=True">Storage resources</a> <span style="font-size:18px"> / <a href="/storage/?manage=True&uuid={{ data.storage.uuid }}">{{ data.storage.name }}</a></span></h1>
      {% else %}
      <h1>Storage resources</h1>
      {% endif %}
      <hr/>

      {% if not data.manage %}
      <div style="font-size:1.1em; background:whitesmoke; display:inline-block; padding:2px 15px 2px 15px">Browse</div>
      <div style="font-size:1.1em; background:white; display:inline-block; padding:2px 15px 2px 15px"><a href="/storage/?manage=True">Manage</a></div>
      <hr style="margin-top:0;">
      <br/>

      <iframe src="/static/RichFilemanager/index.html" style="overflow:hidden;height:100%;width:100%; border: 1px solid #c0c0c0" height="100%" width="100%"></iframe>
      {% if data.manage %}

      {% else %}
      <div style="font-size:1.1em; background:white; display:inline-block; padding:2px 15px 2px 15px"><a href="/storage/">Browse</a></div>
      <div style="font-size:1.1em; background:whitesmoke; display:inline-block; padding:2px 15px 2px 15px">Manage</div>
      <hr style="margin-top:0;">

      {% if data.storage %}

        {% include "components/storage_component.html" with storage=data.storage details=True %}

      {% if request.user.is_staff %}
      {% if not data.storage %}
      {% else %}
      <div class="form-filter" style="margin-bottom:20px">
        <form action="" method="POST">
          <input type="text" class="form-control" id="search_text" name="search_text" placeholder="Search..." style="width:200px; margin:0; display:inline" value="{{data.search_text}}" autofocus>
          <select class="form-control" id="search_owner" name="search_owner" style="width:120px; margin:0; display:inline">
            {% if data.search_owner == 'All' %}<option selected>All</option>{% else %}<option>All</option>{% endif %}
            {% if data.search_owner == 'Platform' %}<option selected>Platform</option>{% else %}<option>Platform</option>{% endif %}
            {% if data.search_owner == 'User' or data.search_owner == 'Group' %}<option selected>User</option>{% else %}<option>User</option>{% endif %}
          <input type="text" class="form-control" id="filter_text" name="filter_text" placeholder="Search..." style="width:200px; margin:0; display:inline" value="{{data.filter_text}}" autofocus>
          <select class="form-control" id="filter_owner" name="filter_owner" style="width:120px; margin:0; display:inline">
            <option value="all" {% if data.filter_owner == 'all' %}selected{% endif %}>All</option>
            <option value="platform" {% if data.filter_owner == 'platform' %}selected{% endif %}>Platform</option>
            <option value="user" {% if data.filter_owner == 'user' %}selected{% endif %}>Personal</option>
            {% for group in user.groups.all %}
              {% with "group:"|add:group.name as group_identifier %}
              <option value="group:{{ group.name }}" {% if data.filter_owner == group_identifier %}selected{% endif %}>{{ group.name }}</option>
              {% endwith %}
            {% endfor %}
          </select>
          {% csrf_token %}
          <button type="submit" class="btn btn-secondary">Go</button>
          {% if request.user.is_staff %}
          &nbsp; &nbsp; <font size=4.0em>|</font> &nbsp; <a href="/add_storage/">Add new...</a>
          {% endif %}
        </form>
      </div>
      {% endif %}
      {% endif %}

      <div class="row" style="padding:5px">
        {% for storage in data.storages %}
          {% include "components/storage.html" with storage=storage %}
          {% include "components/storage_component.html" with storage=storage %}
        {% empty %}
          <p>No storage resources found.</p>
        {% endfor %}
      </div>
      {% endif %}

      {% else %}

      <div style="font-size:1.1em; background:whitesmoke; display:inline-block; padding:2px 15px 2px 15px">Browse</div>
      <div style="font-size:1.1em; background:white; display:inline-block; padding:2px 15px 2px 15px"><a href="/storage/?manage=True">Manage</a></div>
      <hr style="margin-top:0;">
      <iframe src="/static/RichFilemanager/index.html" style="overflow:hidden;height:100%;width:100%; border: 1px solid #c0c0c0" height="100%" width="100%"></iframe>
      {% endif %}
    </div>
  </div>
</div>
Loading