Add button to remove song from queue
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
63a365d11d
commit
e713a65f06
4 changed files with 41 additions and 12 deletions
18
src/main.rs
18
src/main.rs
|
@ -122,8 +122,22 @@ async fn post_queue(req: tide::Request<()>) -> tide::Result {
|
||||||
Ok("".into())
|
Ok("".into())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete_queue(_req: tide::Request<()>) -> tide::Result {
|
#[derive(Deserialize)]
|
||||||
mpd::connect()?.clear()?;
|
struct DeleteQueueQuery {
|
||||||
|
#[serde(default)]
|
||||||
|
id: Option<u32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn delete_queue(req: tide::Request<()>) -> tide::Result {
|
||||||
|
let query: DeleteQueueQuery = req.query()?;
|
||||||
|
|
||||||
|
let mut mpd = mpd::connect()?;
|
||||||
|
if let Some(id) = query.id {
|
||||||
|
mpd.deleteid(id)?;
|
||||||
|
} else {
|
||||||
|
mpd.clear()?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok("".into())
|
Ok("".into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ pub fn ls(path: &str) -> anyhow::Result<Vec<Entry>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct QueueItem {
|
pub struct QueueItem {
|
||||||
|
pub id: u32,
|
||||||
pub file: String,
|
pub file: String,
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub artist: Option<String>,
|
pub artist: Option<String>,
|
||||||
|
@ -70,6 +71,7 @@ pub fn playlist() -> anyhow::Result<Vec<QueueItem>> {
|
||||||
.queue()?
|
.queue()?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|song| QueueItem {
|
.map(|song| QueueItem {
|
||||||
|
id: song.place.unwrap().id,
|
||||||
file: song.file.clone(),
|
file: song.file.clone(),
|
||||||
title: song.title.as_ref().unwrap_or(&song.file).clone(),
|
title: song.title.as_ref().unwrap_or(&song.file).clone(),
|
||||||
artist: song.artist.clone(),
|
artist: song.artist.clone(),
|
||||||
|
|
|
@ -108,12 +108,20 @@ ul {
|
||||||
.queue ul .metadata {
|
.queue ul .metadata {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.queue ul .metadata * {
|
||||||
|
-webkit-line-clamp: 1;
|
||||||
|
line-clamp: 1;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
}
|
||||||
|
|
||||||
.queue ul .song__name {
|
.queue ul .song__name {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
-webkit-line-clamp: 2; /* number of lines to show */
|
}
|
||||||
line-clamp: 2;
|
|
||||||
-webkit-box-orient: vertical;
|
.queue ul li:not(:hover) .remove {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.browser .header {
|
.browser .header {
|
||||||
|
@ -134,12 +142,8 @@ ul {
|
||||||
margin-right: 1.0rem;
|
margin-right: 1.0rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.breadcrumb {
|
ul.breadcrumb { position: relative;
|
||||||
display: flex;
|
rast: more) {
|
||||||
flex-wrap: wrap;
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
@media (prefers-contrast: more) {
|
|
||||||
ul.breadcrumb {
|
ul.breadcrumb {
|
||||||
background-color: black;
|
background-color: black;
|
||||||
border: 2px solid white;
|
border: 2px solid white;
|
||||||
|
@ -187,14 +191,20 @@ ul.dir li .material-symbols-outlined {
|
||||||
|
|
||||||
.albumart {
|
.albumart {
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
background-color: #445;
|
|
||||||
width: 48px;
|
width: 48px;
|
||||||
height: 48px;
|
height: 48px;
|
||||||
|
background: #445 url(/static/placeholder.webp);
|
||||||
|
background-size: contain;
|
||||||
}
|
}
|
||||||
|
|
||||||
.albumart a {
|
.albumart a {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.albumart img {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
.queue .albumart {
|
.queue .albumart {
|
||||||
margin: 0.75rem;
|
margin: 0.75rem;
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
<div class="song__artist" title="Artist">{{ artist }}</div>
|
<div class="song__artist" title="Artist">{{ artist }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="remove">
|
||||||
|
<button class="material-symbols-outlined" title="Remove" hx-delete="/queue?id={{ item.id }}">close</button>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in a new issue