mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-23 01:16:18 +00:00
WIP: Add some style to web frontend
This commit is contained in:
parent
8a91e23043
commit
aa7939cbc7
@ -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):
|
||||||
|
@ -30,7 +30,8 @@ body {
|
|||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#clients td {
|
#clients td,
|
||||||
|
#playlist td {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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>
|
||||||
|
@ -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">
|
||||||
|
<thead>
|
||||||
<tr><th>Name</th><th>Public</th><th></th></tr>
|
<tr><th>Name</th><th>Public</th><th></th></tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td><input type="text" name="name" value="{{ playlist.name }}" /></td>
|
<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 type="checkbox" name="public" {% if playlist.public %}checked="true"{% endif %} /></td>
|
||||||
<td><input type="submit" /></td>
|
<td><input class="btn btn-default" type="submit" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<h3>Tracks</h3>
|
<h3>Tracks</h3>
|
||||||
<table>
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
<tr><th>Artist</th><th>Title</th><th>Album</th><th>Length</th></tr>
|
<tr><th>Artist</th><th>Title</th><th>Album</th><th>Length</th></tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
{% for t in playlist.tracks %}
|
{% 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>
|
<tr><td>{{ t.album.artist.name }}</td><td>{{ t.title }}</td><td>{{ t.album.name }}</td><td>{{ t.duration_str() }}</td></tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -18,27 +18,47 @@
|
|||||||
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">
|
||||||
|
<thead>
|
||||||
<tr><th>Playlist</th><th>Tracks</th><th>Public</th><th></th></tr>
|
<tr><th>Playlist</th><th>Tracks</th><th>Public</th><th></th></tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
{% for p in mine %}
|
{% for p in mine %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ url_for('playlist_details', uid = p.id) }}">{{ p.name }}</a></td>
|
<td><a href="{{ url_for('playlist_details', uid = p.id) }}">{{ p.name }}</a></td>
|
||||||
<td>{{ p.tracks.count() }}</td>
|
<td>{{ p.tracks.count() }}</td>
|
||||||
<td><input type="checkbox" disabled="true" {% if p.public %}checked="true"{% endif %} /></td>
|
<td>{% if p.public %}<span class="glyphicon glyphicon-check"
|
||||||
<td><a href="{{ url_for('playlist_delete', uid = p.id) }}">X</a></td>
|
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>
|
</tr>
|
||||||
{% endfor %}
|
{% 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>
|
||||||
|
</div>
|
||||||
|
<table class="table table-striped table-hover">
|
||||||
|
<thead>
|
||||||
<tr><th>Playlist</th><th>Owner</th><th>Tracks</th></tr>
|
<tr><th>Playlist</th><th>Owner</th><th>Tracks</th></tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
{% for p in others %}
|
{% for p in others %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ url_for('playlist_details', uid = p.id) }}">{{ p.name }}</a></td>
|
<td><a href="{{ url_for('playlist_details', uid = p.id) }}">{{ p.name }}</a></td>
|
||||||
@ -46,6 +66,7 @@
|
|||||||
<td>{{ p.tracks.count() }}</td>
|
<td>{{ p.tracks.count() }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user