From b8197aed5981c02522877782881850f0bc891f6c Mon Sep 17 00:00:00 2001 From: Nikhil Sinha Date: Thu, 1 Aug 2024 00:04:58 +0530 Subject: [PATCH] update: dashboard APIs 1. remove stream field from tile struct 2. rename y_key to y_keys in graph config 3. fix to generate tile_id for each tile in POST /dashboards 4. fix to generate tile_id for new tiles where tile_id is not present in the request in the PUT /dashboards/dashboard/ 5. return dashboard json in PUT response --- server/src/handlers/http/users/dashboards.rs | 15 ++++++++++++--- server/src/users/dashboards.rs | 3 +-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/server/src/handlers/http/users/dashboards.rs b/server/src/handlers/http/users/dashboards.rs index 6a558601e..89e47d614 100644 --- a/server/src/handlers/http/users/dashboards.rs +++ b/server/src/handlers/http/users/dashboards.rs @@ -57,7 +57,6 @@ pub async fn post(body: Bytes) -> Result { let dashboard_id = format!("{}.{}", &dashboard.user_id, Utc::now().timestamp_millis()); dashboard.dashboard_id = Some(dashboard_id.clone()); dashboard.version = Some(CURRENT_DASHBOARD_VERSION.to_string()); - DASHBOARDS.update(&dashboard); for tile in dashboard.tiles.iter_mut() { tile.tile_id = Some(format!( "{}.{}", @@ -65,6 +64,7 @@ pub async fn post(body: Bytes) -> Result { Utc::now().timestamp_micros() )); } + DASHBOARDS.update(&dashboard); let path = dashboard_path(&dashboard.user_id, &format!("{}.json", dashboard_id)); @@ -77,7 +77,7 @@ pub async fn post(body: Bytes) -> Result { Ok((web::Json(dashboard), StatusCode::OK)) } -pub async fn update(req: HttpRequest, body: Bytes) -> Result { +pub async fn update(req: HttpRequest, body: Bytes) -> Result { let dashboard_id = req .match_info() .get("dashboard_id") @@ -90,6 +90,15 @@ pub async fn update(req: HttpRequest, body: Bytes) -> Result Result Result { diff --git a/server/src/users/dashboards.rs b/server/src/users/dashboards.rs index c8c85d95e..5fd68cc2d 100644 --- a/server/src/users/dashboards.rs +++ b/server/src/users/dashboards.rs @@ -33,7 +33,6 @@ pub struct Tiles { name: String, pub tile_id: Option, description: String, - stream: String, query: String, order: Option, visualization: Visualization, @@ -57,7 +56,7 @@ pub struct CircularChartConfig { #[derive(Debug, Serialize, Deserialize, Default, Clone)] pub struct GraphConfig { x_key: String, - y_key: Vec, + y_keys: Vec, } #[derive(Debug, Serialize, Deserialize, Default, Clone)]