feat: Phase 9 — Dashboard web embarqué
- Frontend vanilla JS (18.9KB) : dark theme, gallery grid, search, stats, WebSocket - rust-embed : frontend servi depuis le binaire (zéro dépendance externe) - API REST fonctionnelle : /api/health, /api/images, /api/search, /api/images/:id, /api/stats - WebSocket hub (dashmap + broadcast) : notifications temps réel - ImagoClient: méthode get_raw() pour proxy thumbnails, Serialize sur ImageInfo - MIME guess pour servir CSS/JS/images avec bons headers - Fallback SPA : routes inconnues → index.html - Dépendances : tokio-stream, futures-util, dashmap, chrono - Testé : health OK, stats JSON, dashboard 18.9KB HTML, WS upgrade 400 (HTTP) 0 errors, 0 warnings (cargo check + build --release)
This commit is contained in:
+24
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
use anyhow::Result;
|
||||
use reqwest::{Client, multipart};
|
||||
use serde::Deserialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct UploadResponse {
|
||||
@@ -11,7 +11,7 @@ pub struct UploadResponse {
|
||||
pub status: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct ImageInfo {
|
||||
pub id: String,
|
||||
pub filename: String,
|
||||
@@ -33,7 +33,7 @@ pub struct SearchResponse {
|
||||
/// Client pour l'API Imago
|
||||
pub struct ImagoClient {
|
||||
client: Client,
|
||||
base_url: String,
|
||||
pub base_url: String,
|
||||
api_key: String,
|
||||
}
|
||||
|
||||
@@ -110,4 +110,25 @@ impl ImagoClient {
|
||||
|
||||
Ok(info)
|
||||
}
|
||||
|
||||
/// Récupère des données brutes (image, thumbnail) depuis une URL Imago
|
||||
pub async fn get_raw(&self, url: &str) -> Result<(Vec<u8>, String)> {
|
||||
let response = self.client
|
||||
.get(url)
|
||||
.header("Authorization", format!("Bearer {}", self.api_key))
|
||||
.send()
|
||||
.await?
|
||||
.error_for_status()?;
|
||||
|
||||
let content_type = response
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("image/png")
|
||||
.to_string();
|
||||
|
||||
let data = response.bytes().await?.to_vec();
|
||||
|
||||
Ok((data, content_type))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user