1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-09-19 19:01:03 +00:00

WIP: Add some style to web frontend

This commit is contained in:
Óscar García Amor 2017-07-10 14:25:19 +02:00
parent 8a91e23043
commit aa7939cbc7
6 changed files with 79 additions and 40 deletions

View File

@ -22,11 +22,13 @@ from flask import request, session, flash, render_template, redirect, url_for
import uuid import uuid
from supysonic.web import app, store from supysonic.web import app, store
from supysonic.db import Playlist from supysonic.db import Playlist
from supysonic.managers.user import UserManager
@app.route('/playlist') @app.route('/playlist')
def playlist_index(): def playlist_index():
return render_template('playlists.html', mine = store.find(Playlist, Playlist.user_id == uuid.UUID(session.get('userid'))), return render_template('playlists.html', mine = store.find(Playlist, Playlist.user_id == uuid.UUID(session.get('userid'))),
others = store.find(Playlist, Playlist.user_id != uuid.UUID(session.get('userid')))) others = store.find(Playlist, Playlist.user_id != uuid.UUID(session.get('userid'))),
admin = UserManager.get(store, session.get('userid'))[1].admin)
@app.route('/playlist/<uid>') @app.route('/playlist/<uid>')
def playlist_details(uid): def playlist_details(uid):
@ -41,7 +43,7 @@ def playlist_details(uid):
flash('Unknown playlist') flash('Unknown playlist')
return redirect(url_for('playlist_index')) return redirect(url_for('playlist_index'))
return render_template('playlist.html', playlist = playlist) return render_template('playlist.html', playlist = playlist, admin = UserManager.get(store, session.get('userid'))[1].admin)
@app.route('/playlist/<uid>', methods = [ 'POST' ]) @app.route('/playlist/<uid>', methods = [ 'POST' ])
def playlist_update(uid): def playlist_update(uid):

View File

@ -30,7 +30,8 @@ body {
margin-bottom: 0; margin-bottom: 0;
} }
#clients td { #clients td,
#playlist td {
vertical-align: middle; vertical-align: middle;
} }

View File

@ -31,14 +31,14 @@
<div class="form-group"> <div class="form-group">
<label class="sr-only" for="user">Name</label> <label class="sr-only" for="user">Name</label>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-pencil"></i></span> <div class="input-group-addon"><span class="glyphicon glyphicon-pencil"></span></div>
<input type="text" class="form-control" id="name" name="name" value="{{ request.form.name }}" placeholder="Name" /> <input type="text" class="form-control" id="name" name="name" value="{{ request.form.name }}" placeholder="Name" />
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="sr-only" for="user">Path</label> <label class="sr-only" for="user">Path</label>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-folder-open"></i></span> <div class="input-group-addon"><span class="glyphicon glyphicon-folder-open"></span></div>
<input type="text" class="form-control" id="path" name="path" value="{{ request.form.path }}" placeholder="Path" /> <input type="text" class="form-control" id="path" name="path" value="{{ request.form.path }}" placeholder="Path" />
</div> </div>
</div> </div>

View File

@ -18,27 +18,42 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
-#} -#}
{% extends "layout.html" %} {% extends "layout.html" %}
{% block navbar_playlists %}
<li class="active"><a href="{{ url_for('playlist_index') }}">Playlists <span
class="sr-only">(current)</span></a></li>
{% endblock %}
{% block body %} {% block body %}
<h2>Playlist "{{ playlist.name }}"</h2> <div class="page-header">
<h2>Playlist "{{ playlist.name }}"</h2>
</div>
{% if playlist.user_id|str == session.get('userid') %} {% if playlist.user_id|str == session.get('userid') %}
<h3>Edit</h3> <h3>Edit</h3>
<form method="post"> <form method="post">
<table> <table id="playlist" class="table">
<tr><th>Name</th><th>Public</th><th></th></tr> <thead>
<tr> <tr><th>Name</th><th>Public</th><th></th></tr>
<td><input type="text" name="name" value="{{ playlist.name }}" /></td> </thead>
<td><input type="checkbox" name="public" {% if playlist.public %}checked="true"{% endif %} /></td> <tbody>
<td><input type="submit" /></td> <tr>
</tr> <td><input type="text" class="form-control" name="name" value="{{ playlist.name }}" /></td>
<td><input type="checkbox" name="public" {% if playlist.public %}checked="true"{% endif %} /></td>
<td><input class="btn btn-default" type="submit" /></td>
</tr>
</tbody>
</table> </table>
</form> </form>
{% endif %} {% endif %}
<h3>Tracks</h3> <h3>Tracks</h3>
<table> <table class="table table-striped">
<tr><th>Artist</th><th>Title</th><th>Album</th><th>Length</th></tr> <thead>
{% for t in playlist.tracks %} <tr><th>Artist</th><th>Title</th><th>Album</th><th>Length</th></tr>
<tr><td>{{ t.album.artist.name }}</td><td>{{ t.title }}</td><td>{{ t.album.name }}</td><td>{{ t.duration_str() }}</td></tr> </thead>
{% endfor %} <tbody>
{% for t in playlist.tracks %}
<tr><td>{{ t.album.artist.name }}</td><td>{{ t.title }}</td><td>{{ t.album.name }}</td><td>{{ t.duration_str() }}</td></tr>
{% endfor %}
</tbody>
</table> </table>
{% endblock %} {% endblock %}

View File

@ -18,34 +18,55 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
-#} -#}
{% extends "layout.html" %} {% extends "layout.html" %}
{% block navbar_playlists %}
<li class="active"><a href="{{ url_for('playlist_index') }}">Playlists <span
class="sr-only">(current)</span></a></li>
{% endblock %}
{% block body %} {% block body %}
<h2>My playlists</h2> <div class="page-header">
<h2>My playlists</h2>
</div>
{% if not mine.count() %} {% if not mine.count() %}
<p>You don't have any playlists.</p> <p>You don't have any playlists.</p>
{% else %} {% else %}
<table> <table class="table table-striped table-hover">
<tr><th>Playlist</th><th>Tracks</th><th>Public</th><th></th></tr> <thead>
{% for p in mine %} <tr><th>Playlist</th><th>Tracks</th><th>Public</th><th></th></tr>
<tr> </thead>
<td><a href="{{ url_for('playlist_details', uid = p.id) }}">{{ p.name }}</a></td> <tbody>
<td>{{ p.tracks.count() }}</td> {% for p in mine %}
<td><input type="checkbox" disabled="true" {% if p.public %}checked="true"{% endif %} /></td> <tr>
<td><a href="{{ url_for('playlist_delete', uid = p.id) }}">X</a></td> <td><a href="{{ url_for('playlist_details', uid = p.id) }}">{{ p.name }}</a></td>
</tr> <td>{{ p.tracks.count() }}</td>
{% endfor %} <td>{% if p.public %}<span class="glyphicon glyphicon-check"
aria-label="Public playlist"></span>{% else %}<span
class="glyphicon glyphicon-unchecked"
aria-label="Private playlist"></span>{% endif %}</td>
<td><a href="{{ url_for('playlist_delete', uid = p.id) }}" aria-label="Delete playlist">
<span class="glyphicon glyphicon-remove-circle" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="Delete playlist"></span></a></td>
</tr>
{% endfor %}
</tbody>
</table> </table>
{% endif %} {% endif %}
{% if others.count() %} {% if others.count() %}
<h2>Others' playslits</h2> <div class="page-header">
<table> <h2>Others' playlists</h2>
<tr><th>Playlist</th><th>Owner</th><th>Tracks</th></tr> </div>
{% for p in others %} <table class="table table-striped table-hover">
<tr> <thead>
<td><a href="{{ url_for('playlist_details', uid = p.id) }}">{{ p.name }}</a></td> <tr><th>Playlist</th><th>Owner</th><th>Tracks</th></tr>
<td>{{ p.user.name }}</td> </thead>
<td>{{ p.tracks.count() }}</td> <tbody>
</tr> {% for p in others %}
{% endfor %} <tr>
<td><a href="{{ url_for('playlist_details', uid = p.id) }}">{{ p.name }}</a></td>
<td>{{ p.user.name }}</td>
<td>{{ p.tracks.count() }}</td>
</tr>
{% endfor %}
</tbody>
</table> </table>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

@ -35,7 +35,7 @@
{% for user in users %} {% for user in users %}
<tr><td>{{ user.name }}</td><td>{{ user.mail }}</td><td>{{ user.admin }}</td><td>{{ user.last_play_date }}</td><td> <tr><td>{{ user.name }}</td><td>{{ user.mail }}</td><td>{{ user.admin }}</td><td>{{ user.last_play_date }}</td><td>
<a href="{{ url_for('del_user', uid = user.id) }}" aria-label="Delete user"> <a href="{{ url_for('del_user', uid = user.id) }}" aria-label="Delete user">
<span class="glyphicon glyphicon-remove-circle" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="Delete user"></a></td></tr> <span class="glyphicon glyphicon-remove-circle" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="Delete user"></span></a></td></tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>