mirror of
https://github.com/PhoenixTwoFive/karaoqueue.git
synced 2025-05-19 02:51:48 +02:00
Merge branch 'legacy_feature_transferred_tagging' into legacy
This commit is contained in:
commit
99c7917573
@ -33,7 +33,7 @@ def import_songs(song_csv):
|
||||
def create_entry_table():
|
||||
conn = open_db()
|
||||
conn.execute('CREATE TABLE IF NOT EXISTS '+entry_table +
|
||||
' (ID INTEGER PRIMARY KEY NOT NULL, Song_Id INTEGER NOT NULL, Name VARCHAR(255), Client_Id VARCHAR(36))')
|
||||
' (ID INTEGER PRIMARY KEY NOT NULL, Song_Id INTEGER NOT NULL, Name VARCHAR(255), Client_Id VARCHAR(36), Transferred INTEGER DEFAULT 0)')
|
||||
conn.close()
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ def create_song_table():
|
||||
def create_list_view():
|
||||
conn = open_db()
|
||||
conn.execute("""CREATE VIEW IF NOT EXISTS [Liste] AS
|
||||
SELECT Name, Title, Artist, entries.Id, songs.Id
|
||||
SELECT Name, Title, Artist, entries.Id, songs.Id, entries.Transferred
|
||||
FROM entries, songs
|
||||
WHERE entries.Song_Id=songs.Id""")
|
||||
conn.close()
|
||||
@ -139,18 +139,37 @@ def add_sung_song(entry_id):
|
||||
return True
|
||||
|
||||
|
||||
def toggle_transferred(entry_id):
|
||||
conn = open_db()
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT Transferred FROM entries WHERE ID =?", (entry_id,))
|
||||
marked = cur.fetchall()[0][0]
|
||||
if(marked == 0):
|
||||
cur.execute(
|
||||
"UPDATE entries SET Transferred = 1 WHERE ID =?", (entry_id,))
|
||||
else:
|
||||
cur.execute(
|
||||
"UPDATE entries SET Transferred = 0 WHERE ID =?", (entry_id,))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return True
|
||||
|
||||
|
||||
def check_entry_quota(client_id):
|
||||
conn = open_db()
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT Count(*) FROM entries WHERE entries.Client_Id = ?", (client_id,))
|
||||
cur.execute(
|
||||
"SELECT Count(*) FROM entries WHERE entries.Client_Id = ?", (client_id,))
|
||||
return cur.fetchall()[0][0]
|
||||
|
||||
|
||||
def check_queue_length():
|
||||
conn = open_db()
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT Count(*) FROM entries")
|
||||
return cur.fetchall()[0][0]
|
||||
|
||||
|
||||
def clear_played_songs():
|
||||
conn = open_db()
|
||||
cur = conn.cursor()
|
||||
|
@ -172,6 +172,15 @@ def mark_sung(entry_id):
|
||||
else:
|
||||
return Response('{"status": "FAIL"}', mimetype='text/json')
|
||||
|
||||
@app.route("/api/entries/mark_transferred/<entry_id>")
|
||||
@nocache
|
||||
@basic_auth.required
|
||||
def mark_transferred(entry_id):
|
||||
if database.toggle_transferred(entry_id):
|
||||
return Response('{"status": "OK"}', mimetype='text/json')
|
||||
else:
|
||||
return Response('{"status": "FAIL"}', mimetype='text/json')
|
||||
|
||||
|
||||
@app.route("/api/entries/accept/<value>")
|
||||
@nocache
|
||||
|
@ -146,6 +146,19 @@ table td:nth-child(2) {
|
||||
$("#entrytable").bootstrapTable('refresh')
|
||||
|
||||
}
|
||||
|
||||
function markEntryAsTransferred(entry_id) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/entries/mark_transferred/'+entry_id,
|
||||
contentType: "application/json",
|
||||
dataType: 'json',
|
||||
async: false
|
||||
});
|
||||
$("#entrytable").bootstrapTable('refresh')
|
||||
|
||||
}
|
||||
|
||||
function DeleteSelectedEntries(ids) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
@ -182,7 +195,13 @@ table td:nth-child(2) {
|
||||
});
|
||||
}
|
||||
function TableActions (value, row, index) {
|
||||
return "<button type=\"button\" class=\"btn btn-success\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Als gesungen markieren\" onclick=\"markEntryAsSung("+row.ID+")\"><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('"+row.Name+"',"+row.ID+")\"><i class=\"fas fa-trash\"></i></button>";
|
||||
let outerHTML = ""
|
||||
if (row.Transferred==1) {
|
||||
outerHTML = "<button type=\"button\" class=\"btn btn-default\" onclick=\"markEntryAsTransferred("+row.ID+")\"><i class=\"fas fa-backward\"></i></button> <button type=\"button\" class=\"btn btn-success\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Als gesungen markieren\" onclick=\"markEntryAsSung("+row.ID+")\"><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('"+row.Name+"',"+row.ID+")\"><i class=\"fas fa-trash\"></i></button>";
|
||||
} else {
|
||||
outerHTML = "<button type=\"button\" class=\"btn btn-info\" onclick=\"markEntryAsTransferred("+row.ID+")\"><i class=\"fas fa-exchange-alt\"></i></button> <button type=\"button\" class=\"btn btn-success\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Als gesungen markieren\" onclick=\"markEntryAsSung("+row.ID+")\"><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('"+row.Name+"',"+row.ID+")\"><i class=\"fas fa-trash\"></i></button>";
|
||||
}
|
||||
return outerHTML;
|
||||
}
|
||||
function getIdSelections() {
|
||||
return $.map($("#entrytable").bootstrapTable('getSelections'), function (row) {
|
||||
|
@ -111,6 +111,7 @@
|
||||
|
||||
}
|
||||
|
||||
{% if not auth %}
|
||||
function entriesAccepted() {
|
||||
$.getJSON("/api/entries/accept", (data, out) => {
|
||||
if (data["value"] == 0) {
|
||||
@ -125,6 +126,11 @@
|
||||
|
||||
})
|
||||
}
|
||||
{% else %}
|
||||
function entriesAccepted() {
|
||||
$(".enqueueButton").prop("disabled", false)
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user