From 6053b098db3f5619db117c3b8f029759076465c2 Mon Sep 17 00:00:00 2001 From: Sijmen Date: Thu, 27 Apr 2023 15:41:28 +0200 Subject: [PATCH] Add button to clear queue --- src/main.rs | 7 +++++++ static/style.css | 30 +++++++++++++++++++++++++----- templates/queue.html | 9 +++++++++ 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index e0a03e5..5998189 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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); diff --git a/static/style.css b/static/style.css index 5e8d095..b71e4d8 100644 --- a/static/style.css +++ b/static/style.css @@ -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 { diff --git a/templates/queue.html b/templates/queue.html index 1e99bd1..b330b62 100644 --- a/templates/queue.html +++ b/templates/queue.html @@ -1,5 +1,14 @@ {# Template #} + +
+
Next in queue
+
+ playlist_remove + Clear +
+
+