Add task for adding data file from FS. Improve home page

This commit is contained in:
2024-11-04 05:15:42 +01:00
parent feeaecac85
commit 918d7ea327
10 changed files with 222 additions and 12 deletions

View File

@@ -0,0 +1,38 @@
use loco_rs::prelude::*;
use crate::services;
pub struct AddDataFile;
#[async_trait]
impl Task for AddDataFile {
fn task(&self) -> TaskInfo {
TaskInfo {
name: "add_data_file".to_string(),
detail: "Task for adding a new data file".to_string(),
}
}
async fn run(&self, app_context: &AppContext, vars: &task::Vars) -> Result<()> {
let file_path = vars.cli_arg("file_path")?;
let file_name = vars.cli_arg("file_name")?;
let protected = vars.cli_arg("protected")?;
let uuid_name = vars.cli_arg("uuid_name")?;
let protected = protected.parse::<bool>().unwrap_or(false);
let uuid_name = uuid_name.parse::<bool>().unwrap_or(false);
services::data::add_data_file_from_path(
&app_context,
file_path,
file_name,
protected,
uuid_name,
)
.await?;
tracing::info!("Data file added successfully");
Ok(())
}
}

View File

@@ -1,3 +1,4 @@
pub mod add_data_file;
pub mod create_job;
pub mod create_skill;
pub mod create_user;