Add list of played songs

This commit is contained in:
2019-06-29 01:24:54 +02:00
parent 438bcffd0b
commit 5f551ac092
7 changed files with 181 additions and 12 deletions

View File

@ -39,6 +39,11 @@
<li class="nav-item">
<a class="nav-link" href="/list">Songsuche</a>
</li>
{% if auth %}
<li class="nav-item">
<a class="nav-link" href="/plays">Abspielliste</a>
</li>
{% endif %}
</ul>
<!--<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
@ -79,6 +84,9 @@
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min.js"
integrity="sha256-4F7e4JsAJyLUdpP7Q8Sah866jCOhv72zU5E8lIRER4w=" crossorigin="anonymous">
</script>
{% block extrajs %}{% endblock %}
<script>
$(document).ready(function () {

View File

@ -21,7 +21,7 @@
<th scope="col">Name</th>
<th scope="col">Song</th>
<th scope="col">Künstler</th>
<th scope="col">Löschen</th>
<th scope="col">Aktionen</th>
</tr>
{% for entry in list: %}
<tr>
@ -35,7 +35,12 @@
{{ entry[2] }}
</td>
<td>
<button type='button' class='btn btn-danger justify-content-center align-content-between'
<button type='button' class='btn btn-success'
data-toggle="tooltip" data-placement="top" title="Als gesungen markieren"
onclick='markEntryAsSung({{ entry[3] }})'><i
class="fas fa-check"></i></button>
<button type='button' class='btn btn-danger'
data-toggle="tooltip" data-placement="top" title="Eintrag löschen"
onclick='confirmDeleteEntry("{{ entry[0] }}",{{ entry[3] }})'><i
class="fas fa-trash"></i></button>
</td>
@ -47,9 +52,10 @@
</div>
{% endblock %}
{% block extrajs %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min.js"
integrity="sha256-4F7e4JsAJyLUdpP7Q8Sah866jCOhv72zU5E8lIRER4w=" crossorigin="anonymous"></script>
<script>
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
function confirmDeleteEntry(name, entry_id) {
bootbox.confirm("Wirklich den Eintrag von "+name+" löschen?", function(result){
if (result) {
@ -107,7 +113,18 @@
type: 'GET',
url: '/api/entries/delete/'+entry_id,
contentType: "application/json",
dataType: 'json'
dataType: 'json',
async: false
});
location.reload();
}
function markEntryAsSung(entry_id) {
$.ajax({
type: 'GET',
url: '/api/entries/mark_sung/'+entry_id,
contentType: "application/json",
dataType: 'json',
async: false
});
location.reload();
}
@ -116,7 +133,8 @@
type: 'GET',
url: '/api/entries/delete_all',
contentType: "application/json",
dataType: 'json'
dataType: 'json',
async: false
});
location.reload();
}

View File

@ -0,0 +1,61 @@
{% extends 'base.html' %}
{% block title %}Songsuche{% endblock %}
{% block content %}
<div class="card admincontrols" style="width: 100%">
<div class="card-body">
<button type="button" class="topbutton btn btn-danger" onclick="confirmDeleteAllEntries()"><i
class="fas fa-trash mr-2"></i>Abspielliste löschen</button>
</div>
</div>
<table class="table">
<tr>
<th scope="col">Song</th>
<th scope="col">Wiedergaben</th>
</tr>
{% for entry in list: %}
<tr>
<td>
{{ entry[0] }}
</td>
<td>
{{ entry[1] }}
</td>
</tr>
{% endfor %}
</table>
</table>
{% endblock %}
{% block extrajs %}
<script>
function confirmDeleteAllEntries() {
bootbox.confirm({
message: "Wirklich Abspielliste löschen?",
buttons: {
confirm: {
label: 'Ja',
className: 'btn btn-danger'
},
cancel: {
label: 'Nein',
className: 'btn btn-secondary'
}
},
callback: function(result){
if (result) {
deleteAllEntries()
}
}
})
}
function deleteAllEntries() {
$.ajax({
type: 'GET',
url: '/api/played/clear',
contentType: "application/json",
dataType: 'json',
async: false
});
location.reload();
}
</script>
{% endblock %}