modernizing frontend

This commit is contained in:
Diocrafts
2026-02-08 22:44:42 +01:00
parent 03b409bbbc
commit 5bd505ccd7
31 changed files with 3262 additions and 451 deletions
@@ -540,6 +540,41 @@ impl FileHandler {
// MOVE
// ═══════════════════════════════════════════════════════════════════════
/// Renames a file
pub async fn rename_file(
State(state): State<GlobalState>,
Path(id): Path<String>,
Json(payload): Json<serde_json::Value>,
) -> impl IntoResponse {
let new_name = match payload.get("name").and_then(|v| v.as_str()) {
Some(name) if !name.trim().is_empty() => name.trim().to_string(),
_ => {
return (StatusCode::BAD_REQUEST, Json(serde_json::json!({
"error": "Missing or empty 'name' field"
}))).into_response();
}
};
tracing::info!("Renaming file {} to \"{}\"", id, new_name);
let mgmt = &state.applications.file_management_service;
match mgmt.rename_file(&id, &new_name).await {
Ok(file_dto) => (StatusCode::OK, Json(file_dto)).into_response(),
Err(err) => {
tracing::error!("Error renaming file: {}", err);
let status = if err.to_string().contains("not found") || err.to_string().contains("NotFound") {
StatusCode::NOT_FOUND
} else if err.to_string().contains("already exists") {
StatusCode::CONFLICT
} else {
StatusCode::INTERNAL_SERVER_ERROR
};
(status, Json(serde_json::json!({
"error": format!("Error renaming file: {}", err)
}))).into_response()
}
}
}
/// Moves a file to a different folder
pub async fn move_file(
State(state): State<GlobalState>,
+15 -1
View File
@@ -2,13 +2,23 @@ use std::sync::Arc;
use axum::{
routing::{get, post, put, delete},
Router,
response::Json as AxumJson,
};
use serde_json::json;
use tower_http::{
compression::CompressionLayer,
trace::TraceLayer,
};
use crate::common::di::AppState;
/// Returns the application version from Cargo.toml (compile-time constant)
async fn get_version() -> AxumJson<serde_json::Value> {
AxumJson(json!({
"name": "OxiCloud",
"version": env!("CARGO_PKG_VERSION")
}))
}
use crate::interfaces::middleware::cache::{HttpCache, start_cache_cleanup_task};
use crate::application::services::batch_operations::BatchOperationService;
@@ -57,6 +67,9 @@ pub fn create_public_api_routes(app_state: &AppState) -> Router<AppState> {
router = router.nest("/i18n", i18n_router);
}
// Version endpoint — public, no auth required
router = router.route("/version", get(get_version));
router
}
@@ -134,7 +147,8 @@ pub fn create_api_routes(app_state: &AppState) -> Router<AppState> {
// File operations with trash support
let file_operations_router = Router::new()
.route("/{id}", delete(FileHandler::delete_file))
.route("/{id}/move", put(FileHandler::move_file_simple));
.route("/{id}/move", put(FileHandler::move_file_simple))
.route("/{id}/rename", put(FileHandler::rename_file));
// Merge the routers
let files_router = basic_file_router.merge(file_operations_router);