This commit is contained in:
parent
645411b59c
commit
de0722b430
2 changed files with 54 additions and 18 deletions
|
@ -1,15 +1,15 @@
|
||||||
use std::{collections::HashMap, option::Option, path::PathBuf};
|
use std::{collections::HashMap, option::Option, path::PathBuf};
|
||||||
|
|
||||||
use crisp::types::{Keyword, Symbol, Value};
|
use crisp::types::{Keyword, Symbol, Value};
|
||||||
use miette::{IntoDiagnostic, Result, miette};
|
use miette::{miette, IntoDiagnostic, Result};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{
|
use sqlx::{
|
||||||
FromRow, Row, Sqlite, SqliteConnection, SqlitePool,
|
pool::PoolConnection, query, sqlite::SqliteRow, Acquire, FromRow,
|
||||||
pool::PoolConnection, query, sqlite::SqliteRow,
|
Row, Sqlite, SqliteConnection, SqlitePool,
|
||||||
};
|
};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use crate::{Slide, SlideBuilder, core::slide};
|
use crate::{core::slide, Slide, SlideBuilder};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
content::Content,
|
content::Content,
|
||||||
|
@ -407,6 +407,19 @@ impl Model<Song> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn remove_from_db(
|
||||||
|
&mut self,
|
||||||
|
db: &mut SqlitePool,
|
||||||
|
id: i32,
|
||||||
|
) -> Result<()> {
|
||||||
|
let db = db.acquire().await.expect("probs");
|
||||||
|
query!("delete from songs where id = $1", id)
|
||||||
|
.execute(&mut db.detach())
|
||||||
|
.await
|
||||||
|
.into_diagnostic()
|
||||||
|
.map(|_| ())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_song_in_db(
|
pub async fn update_song_in_db(
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
|
Element, Task,
|
||||||
iced::{
|
iced::{
|
||||||
alignment::Vertical, clipboard::dnd::DndAction,
|
Background, Border, Color, Length, alignment::Vertical,
|
||||||
futures::FutureExt, Background, Border, Color, Length,
|
clipboard::dnd::DndAction, futures::FutureExt,
|
||||||
},
|
},
|
||||||
iced_core::widget::tree::State,
|
iced_core::widget::tree::State,
|
||||||
iced_widget::{column, row as rowm, text as textm},
|
iced_widget::{column, row as rowm, text as textm},
|
||||||
theme,
|
theme,
|
||||||
widget::{
|
widget::{
|
||||||
button, container, context_menu, horizontal_space, icon,
|
Container, DndSource, Space, button, container, context_menu,
|
||||||
|
horizontal_space, icon,
|
||||||
menu::{self, Action as MenuAction},
|
menu::{self, Action as MenuAction},
|
||||||
mouse_area, responsive, row, scrollable, text, text_input,
|
mouse_area, responsive, row, scrollable, text, text_input,
|
||||||
Container, DndSource, Space,
|
|
||||||
},
|
},
|
||||||
Element, Task,
|
|
||||||
};
|
};
|
||||||
use miette::{IntoDiagnostic, Result};
|
use miette::{IntoDiagnostic, Result};
|
||||||
use rapidfuzz::distance::levenshtein;
|
use rapidfuzz::distance::levenshtein;
|
||||||
use sqlx::{pool::PoolConnection, Sqlite, SqlitePool};
|
use sqlx::{Sqlite, SqlitePool, pool::PoolConnection};
|
||||||
use tracing::{debug, error, warn};
|
use tracing::{debug, error, warn};
|
||||||
|
|
||||||
use crate::core::{
|
use crate::core::{
|
||||||
content::Content,
|
content::Content,
|
||||||
images::{update_image_in_db, Image},
|
images::{Image, update_image_in_db},
|
||||||
model::{LibraryKind, Model},
|
model::{LibraryKind, Model},
|
||||||
presentations::{update_presentation_in_db, Presentation},
|
presentations::{Presentation, update_presentation_in_db},
|
||||||
service_items::ServiceItem,
|
service_items::ServiceItem,
|
||||||
songs::{update_song_in_db, Song},
|
songs::{Song, update_song_in_db},
|
||||||
videos::{update_video_in_db, Video},
|
videos::{Video, update_video_in_db},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -132,11 +132,34 @@ impl<'a> Library {
|
||||||
Message::None => (),
|
Message::None => (),
|
||||||
Message::DeleteItem((kind, index)) => {
|
Message::DeleteItem((kind, index)) => {
|
||||||
match kind {
|
match kind {
|
||||||
LibraryKind::Song => todo!(),
|
LibraryKind::Song => {
|
||||||
LibraryKind::Video => todo!(),
|
if let Err(e) =
|
||||||
LibraryKind::Image => todo!(),
|
self.song_library.remove_item(index)
|
||||||
|
{
|
||||||
|
error!(?e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LibraryKind::Video => {
|
||||||
|
if let Err(e) =
|
||||||
|
self.video_library.remove_item(index)
|
||||||
|
{
|
||||||
|
error!(?e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LibraryKind::Image => {
|
||||||
|
if let Err(e) =
|
||||||
|
self.image_library.remove_item(index)
|
||||||
|
{
|
||||||
|
error!(?e);
|
||||||
|
}
|
||||||
|
}
|
||||||
LibraryKind::Presentation => {
|
LibraryKind::Presentation => {
|
||||||
self.presentation_library.remove_item(index);
|
if let Err(e) = self
|
||||||
|
.presentation_library
|
||||||
|
.remove_item(index)
|
||||||
|
{
|
||||||
|
error!(?e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue