diff --git a/.gitignore b/.gitignore index fcf9613..4220665 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ backend/launcher/lumiere.sqlite backend/launcher/.env backend/launcher/certs +backend/root_folder frontend/.angular frontend/node_modules \ No newline at end of file diff --git a/backend/application/src/video/service.rs b/backend/application/src/video/service.rs index da68311..4ccebc9 100644 --- a/backend/application/src/video/service.rs +++ b/backend/application/src/video/service.rs @@ -4,6 +4,37 @@ use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; use std::io::Read; +use lumiere_domain::video::error::VideoError; +use lumiere_domain::video::model::library_item::LibraryItem; +use lumiere_domain::video::port::VideoPort; + +#[derive(Clone)] +pub struct VideoService { + video_port: Box +} + +impl VideoService { + pub fn new(video_port: Box) -> Self { + Self { video_port } + } + + pub fn list_root_folder(self) -> Result, VideoError> { + let library_items = self.video_port.list_root_folder()?; + + let items_without_id = library_items.iter().filter(|item| item.id == None); + // generate a new Uuid for each item without id + // assign this new Uuid to the item + // save the item by using the method video_port.save + // replace the items_without_id by modified items_without_id + + Ok(vec!()) + } +} + + + + + /// Basic example: Read file line by line using BufReader pub fn read_file_line_by_line(path: &str) -> std::io::Result<()> { diff --git a/backend/domain/src/video/model/folder.rs b/backend/domain/src/video/model/folder.rs new file mode 100644 index 0000000..5bc02e1 --- /dev/null +++ b/backend/domain/src/video/model/folder.rs @@ -0,0 +1,6 @@ +use uuid::Uuid; + +pub struct FolderItem { + pub id: Option, + pub name: String, +} \ No newline at end of file diff --git a/backend/domain/src/video/model/library_item.rs b/backend/domain/src/video/model/library_item.rs new file mode 100644 index 0000000..63f4ddb --- /dev/null +++ b/backend/domain/src/video/model/library_item.rs @@ -0,0 +1,18 @@ +use uuid::Uuid; + +pub enum LibraryItemType { + VIDEO, + FOLDER +} + +pub struct LibraryItem { + pub id: Uuid, + pub name: String, + pub r#type: LibraryItemType, +} + +pub struct ReadLibraryItem { + pub id: Option, + pub name: String, + pub r#type: LibraryItemType, +} \ No newline at end of file diff --git a/backend/domain/src/video/model/mod.rs b/backend/domain/src/video/model/mod.rs new file mode 100644 index 0000000..8115f95 --- /dev/null +++ b/backend/domain/src/video/model/mod.rs @@ -0,0 +1,3 @@ +pub mod folder; +pub mod library_item; +pub mod video; \ No newline at end of file diff --git a/backend/domain/src/video/model.rs b/backend/domain/src/video/model/video.rs similarity index 89% rename from backend/domain/src/video/model.rs rename to backend/domain/src/video/model/video.rs index aaf4516..db2d5e2 100644 --- a/backend/domain/src/video/model.rs +++ b/backend/domain/src/video/model/video.rs @@ -12,7 +12,7 @@ pub trait VideoFile {} pub struct Video { pub id: Uuid, - pub filename: String, + pub name: String, pub file: Box, pub format: VideoFormat, } \ No newline at end of file diff --git a/backend/domain/src/video/port.rs b/backend/domain/src/video/port.rs index 02b7550..d78bfcb 100644 --- a/backend/domain/src/video/port.rs +++ b/backend/domain/src/video/port.rs @@ -1,11 +1,13 @@ use uuid::Uuid; use crate::video::error::VideoError; -use crate::video::model::Video; +use crate::video::model::library_item::{LibraryItem, ReadLibraryItem}; +use crate::video::model::video::Video; pub trait VideoPort: Send + Sync { - fn list_root(&self) -> Result, VideoError>; - fn list_folder(&self, folder_id: Uuid) -> Result, VideoError>; + fn list_root_folder(&self) -> Result, VideoError>; + fn list_folder(&self, folder_id: Uuid) -> Result, VideoError>; fn get_video_stream(&self, video_id: Uuid) -> Result; + fn save(&self, library_item: LibraryItem) -> Result<(), VideoError>; fn clone_box(&self) -> Box; } diff --git a/backend/exposition/src/lib.rs b/backend/exposition/src/lib.rs index 652a638..16d77be 100644 --- a/backend/exposition/src/lib.rs +++ b/backend/exposition/src/lib.rs @@ -1,9 +1,7 @@ extern crate core; -use crate::user::validator::validator; use actix_web::web::ServiceConfig; use actix_web::{get, web, HttpResponse, Responder}; -use actix_web_httpauth::middleware::HttpAuthentication; use crate::video::handler::download_file; pub mod user; diff --git a/backend/exposition/src/video/video_format_content_type_mapper.rs b/backend/exposition/src/video/video_format_content_type_mapper.rs index 2d2ca28..386aff1 100644 --- a/backend/exposition/src/video/video_format_content_type_mapper.rs +++ b/backend/exposition/src/video/video_format_content_type_mapper.rs @@ -1,4 +1,4 @@ -use lumiere_domain::video::model::VideoFormat; +use lumiere_domain::video::library_item::VideoFormat; pub fn map_to_content_type(video_format: &VideoFormat) -> &'static str { match video_format { diff --git a/backend/infrastructure/src/video/video_format_detector.rs b/backend/infrastructure/src/video/video_format_detector.rs index 417b5b7..2d9b9c4 100644 --- a/backend/infrastructure/src/video/video_format_detector.rs +++ b/backend/infrastructure/src/video/video_format_detector.rs @@ -1,7 +1,7 @@ use std::fs::File; use std::path::Path; -use lumiere_domain::video::model::VideoFormat; -use lumiere_domain::video::model::VideoFormat::{AVI, MKV, MP4, UNKNOWN, WEBM}; +use lumiere_domain::video::library_item::VideoFormat; +use lumiere_domain::video::library_item::VideoFormat::{AVI, MKV, MP4, UNKNOWN, WEBM}; /// Determine Content-Type by reading file headers (magic numbers) pub fn get_content_type(path: &Path) -> VideoFormat { diff --git a/backend/launcher/.env.example b/backend/launcher/.env.example index 0b95465..d56b2b0 100644 --- a/backend/launcher/.env.example +++ b/backend/launcher/.env.example @@ -1,9 +1,4 @@ -HTTPS_ENABLED=false JWT_SECRET=jwt-secret SQLITE_DATABASE_NAME=lumiere.sqlite BCRYPT_SALT=salt -SNAPSHOT_RESOURCES_CRON_FREQUENCY="*/5 * * * * *" -SERVER_MODE=real # real | mocked -#MOCKED_DAEMON_START_SUCCESS=true -#MOCKED_DAEMON_STOP_SUCCESS=true -#MOCKED_DAEMON_RESTART_SUCCESS=true \ No newline at end of file +ROOT_FOLDER= \ No newline at end of file