Add button to clear queue

This commit is contained in:
Sijmen 2023-04-27 15:41:28 +02:00
parent eb834b02a8
commit 6053b098db
Signed by: vijfhoek
GPG Key ID: DAF7821E067D9C48
3 changed files with 41 additions and 5 deletions

View File

@ -94,6 +94,11 @@ async fn post_queue(req: tide::Request<()>) -> tide::Result {
Ok("".into())
}
async fn delete_queue(_req: tide::Request<()>) -> tide::Result {
mpd::connect()?.clear()?;
Ok("".into())
}
async fn post_play(_req: tide::Request<()>) -> tide::Result {
mpd::connect()?.play()?;
Ok("".into())
@ -182,6 +187,8 @@ async fn main() -> tide::Result<()> {
app.at("/sse").get(tide::sse::endpoint(sse));
app.at("/queue").post(post_queue);
app.at("/queue").delete(delete_queue);
app.at("/play").post(post_play);
app.at("/pause").post(post_pause);
app.at("/previous").post(post_previous);

View File

@ -2,6 +2,10 @@
box-sizing: border-box;
}
[role=button] {
cursor: pointer;
}
html {
height: 100%;
}
@ -38,18 +42,35 @@ ul {
margin: 0;
}
ul.queue {
.queue-header {
margin-top: 1.0rem;
display: flex;
align-items: center;
}
.queue-next {
font-weight: bold;
flex: 1;
}
.queue-clear {
font-weight: bold;
display: flex;
line-height: 24px;
}
.queue-clear .material-symbols-outlined {
margin-right: 0.25rem;
}
ul.queue li {
.queue {
margin-top: 0.5rem;
}
.queue li {
padding: 0 0.5rem;
border-radius: .25rem;
display: flex;
align-items: center;
}
ul.queue li.playing {
.queue li.playing {
background-color: #334;
}
@ -152,7 +173,6 @@ ul.dir li .material-symbols-outlined {
.player .control {
font-size: 40px;
cursor: pointer;
}
.player .current {

View File

@ -1,5 +1,14 @@
{# Template #}
<!DOCTYPE html>
<div class="queue-header">
<div class="queue-next">Next in queue</div>
<div class="queue-clear" role="button" hx-delete="/queue">
<span class="material-symbols-outlined">playlist_remove</span>
Clear
</div>
</div>
<ul class="queue">
{% for item in queue %}
<li {% if item.playing %}class="playing"{% endif %}>