Nicer looking file list (basic table)

This commit is contained in:
sharkykh 2017-05-15 09:10:31 +03:00
parent c5d77f996b
commit dd1f1b6834
2 changed files with 28 additions and 15 deletions

View File

@ -504,7 +504,7 @@ def view_torrent(torrent_id):
files = None files = None
if torrent.filelist: if torrent.filelist:
files = utils.flattenDict(json.loads(torrent.filelist.filelist_blob.decode('utf-8'))) files = json.loads(torrent.filelist.filelist_blob.decode('utf-8'))
return flask.render_template('view.html', torrent=torrent, return flask.render_template('view.html', torrent=torrent,
files=files, files=files,

View File

@ -79,20 +79,33 @@
</div> </div>
<div class="panel-collapse collapse" id="collapseFileList"> <div class="panel-collapse collapse" id="collapseFileList">
<table class="table table-bordered table-hover table-striped"> <table class="table table-bordered table-hover table-striped">
<thead> <thead>
<th style="width:auto;">Path</th> <th style="width:auto;">Path</th>
<th style="width:auto;">Size</th> <th style="width:auto;">Size</th>
</thead> </thead>
<tbody> <tbody>
{%- for key, value in files.items() %} {%- for key, value in files.items() recursive %}
<tr> {%- if value is iterable %}
<td>{{ key }}</td> {%- if loop.depth0 is greaterthan 0 %}
<td class="col-md-2">{{ value | filesizeformat(True) }}</td> <tr>
</tr> <td colspan="2" style="padding-left: {{ loop.depth0 * 20 }}px">
{%- endfor %} {%- else %}
<tbody> <tr>
</table> <td colspan="2">
{%- endif %}
<i class="glyphicon glyphicon-folder-open"></i> <b>{{ key }}</b></td>
{{ loop(value.items()) }}
</tr>
{%- else %}
<tr>
<td style="padding-left: {{ loop.depth0 * 20 }}px">
<i class="glyphicon glyphicon-file"></i> {{ key }}</td>
<td class="col-md-2">{{ value | filesizeformat(True) }}</td>
</tr>
{%- endif %}
{%- endfor %}
</table>
</div> </div>
</div> </div>
{% elif files %} {% elif files %}