Adding flush command on web page

This commit is contained in:
BrokenFire 2018-01-08 11:05:14 +01:00
parent f5e83ce1cf
commit 7a2374c69f
3 changed files with 32 additions and 4 deletions

View File

@ -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

View File

@ -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");

View File

@ -86,8 +86,11 @@
<tr>
<th style="padding: 0px;">
<div class="row center valign-wrapper" style="margin: 0px">
<div class="col s5 center"><h5>Playlist</h5></div>
<div class="col s5 offset-s2 center">
<div class="col s4 center"><h5>Playlist</h5></div>
<div class="col s4 center">
<a class="waves-effect waves-light btn modal-trigger blue-grey darken-4" id="flush_btn">Flush</a>
</div>
<div class="col s4 center">
<!-- Modal Trigger -->
<a class="waves-effect waves-light btn modal-trigger blue-grey darken-4" id="add_btn" href="#modalAdd">Add</a>