mirror of
				https://github.com/PhoenixTwoFive/karaoqueue.git
				synced 2025-11-04 01:15:11 +01:00 
			
		
		
		
	Don't close modal on failure, redirect on success
This commit is contained in:
		
							
								
								
									
										2
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								main.py
									
									
									
									
									
								
							@@ -16,7 +16,7 @@ def enqueue():
 | 
			
		||||
    name = request.json['name']
 | 
			
		||||
    song_id = request.json['id']
 | 
			
		||||
    database.add_entry(name,song_id)
 | 
			
		||||
    return "OK"
 | 
			
		||||
    return Response('{"status":"OK"}', mimetype='text/json')
 | 
			
		||||
 | 
			
		||||
@app.route("/list")
 | 
			
		||||
def songlist():
 | 
			
		||||
 
 | 
			
		||||
@@ -23,4 +23,5 @@
 | 
			
		||||
    </tr>
 | 
			
		||||
    {% endfor %}
 | 
			
		||||
</table>
 | 
			
		||||
<a name="end"></a>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
@@ -74,7 +74,7 @@
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    function enqueue(id,name) {
 | 
			
		||||
    function enqueue(id,name,success_callback) {
 | 
			
		||||
        var data = {
 | 
			
		||||
            "name": name,
 | 
			
		||||
            "id": id
 | 
			
		||||
@@ -83,6 +83,7 @@
 | 
			
		||||
            type: 'POST',
 | 
			
		||||
            url: '/api/enqueue',
 | 
			
		||||
            data: JSON.stringify(data), // or JSON.stringify ({name: 'jonas'}),
 | 
			
		||||
            success: success_callback,
 | 
			
		||||
            contentType: "application/json",
 | 
			
		||||
            dataType: 'json'
 | 
			
		||||
        });
 | 
			
		||||
@@ -95,8 +96,11 @@
 | 
			
		||||
    function submitModal() {
 | 
			
		||||
        var name = $("#singerNameInput").val();
 | 
			
		||||
        var id = $("#selectedId").attr("value");
 | 
			
		||||
        enqueue(id,name);
 | 
			
		||||
        $("#enqueueModal").modal('hide');
 | 
			
		||||
        enqueue(id,name,function(){
 | 
			
		||||
            $("#enqueueModal").modal('hide');
 | 
			
		||||
            window.location.href = '/#end';
 | 
			
		||||
        });
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
</script>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user