From 7a2374c69fa9217679783ca89819bc1eacf57a08 Mon Sep 17 00:00:00 2001 From: BrokenFire Date: Mon, 8 Jan 2018 11:05:14 +0100 Subject: [PATCH] Adding flush command on web page --- .../Broken/RestApi/MusicWebController.java | 9 +++++++++ src/main/resources/static/js/init.js | 20 +++++++++++++++++-- src/main/resources/templates/music.html | 7 +++++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/Broken/RestApi/MusicWebController.java b/src/main/java/net/Broken/RestApi/MusicWebController.java index 65a97cb..91ce83e 100644 --- a/src/main/java/net/Broken/RestApi/MusicWebController.java +++ b/src/main/java/net/Broken/RestApi/MusicWebController.java @@ -106,6 +106,15 @@ public class MusicWebController { case "ADD": return new WebLoadUtils(musicCommande ,data).getResponse(); + case "FLUSH": + try { + musicCommande.getAudioManager().getMusicManager().scheduler.flush(); + return new ResponseEntity<>(new CommandResponseData(data.command, "Accepted"), HttpStatus.OK); + } catch (NullMusicManager | NotConectedException nullMusicManager) { + return new ResponseEntity<>(new CommandResponseData(data.command, "Not connected to vocal!"), HttpStatus.NOT_ACCEPTABLE); + } + + } } else diff --git a/src/main/resources/static/js/init.js b/src/main/resources/static/js/init.js index 9e39df9..9ccaa96 100644 --- a/src/main/resources/static/js/init.js +++ b/src/main/resources/static/js/init.js @@ -65,6 +65,13 @@ $(document).ready(function() { } }); + $('#flush_btn').click(function () { + var command = { + command: "FLUSH" + }; + sendCommand(JSON.stringify(command)); + }); + $('#btn_add_top').click(function () { var command = { command: "ADD", @@ -74,7 +81,7 @@ $(document).ready(function() { }; $('#input_link').val(''); sendCommand(JSON.stringify(command)); - }) + }); $('#btn_add_bottom').click(function () { var command = { @@ -85,7 +92,7 @@ $(document).ready(function() { }; $('#input_link').val(''); sendCommand(JSON.stringify(command)); - }) + }); }) @@ -120,6 +127,9 @@ function getCurentMusic() { if ($('#add_btn').hasClass("disabled")) { $('#add_btn').removeClass("disabled"); } + if ($('#flush_btn').hasClass("disabled")) { + $('#flush_btn').removeClass("disabled"); + } $('#music_img').attr("src","/img/no_music.jpg"); $('#total_time').text("00:00"); @@ -170,6 +180,9 @@ function getCurentMusic() { if (!$('#add_btn').hasClass("disabled")) { $('#add_btn').addClass("disabled"); } + if (!$('#flush_btn').hasClass("disabled")) { + $('#flush_btn').addClass("disabled"); + } $('#music_img').attr("src","/img/disconnected.png"); @@ -254,6 +267,9 @@ function updateControl(data){ if ($('#add_btn').hasClass("disabled")) { $('#add_btn').removeClass("disabled"); } + if ($('#flush_btn').hasClass("disabled")) { + $('#flush_btn').removeClass("disabled"); + } if ($('#btn_next').hasClass("disabled")) { $('#btn_next').removeClass("disabled"); diff --git a/src/main/resources/templates/music.html b/src/main/resources/templates/music.html index 08e8e68..37d9021 100644 --- a/src/main/resources/templates/music.html +++ b/src/main/resources/templates/music.html @@ -86,8 +86,11 @@
-
Playlist
-
+
Playlist
+
+ Flush +
+
Add