Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions server/src/handlers/http/users/dashboards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ pub async fn post(body: Bytes) -> Result<impl Responder, PostError> {
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!(
"{}.{}",
&dashboard.user_id,
Utc::now().timestamp_micros()
));
}
DASHBOARDS.update(&dashboard);

let path = dashboard_path(&dashboard.user_id, &format!("{}.json", dashboard_id));

Expand All @@ -77,7 +77,7 @@ pub async fn post(body: Bytes) -> Result<impl Responder, PostError> {
Ok((web::Json(dashboard), StatusCode::OK))
}

pub async fn update(req: HttpRequest, body: Bytes) -> Result<HttpResponse, PostError> {
pub async fn update(req: HttpRequest, body: Bytes) -> Result<impl Responder, PostError> {
let dashboard_id = req
.match_info()
.get("dashboard_id")
Expand All @@ -90,6 +90,15 @@ pub async fn update(req: HttpRequest, body: Bytes) -> Result<HttpResponse, PostE
let mut dashboard: Dashboard = serde_json::from_slice(&body)?;
dashboard.dashboard_id = Some(dashboard_id.to_string());
dashboard.version = Some(CURRENT_DASHBOARD_VERSION.to_string());
for tile in dashboard.tiles.iter_mut() {
if tile.tile_id.is_none() {
tile.tile_id = Some(format!(
"{}.{}",
&dashboard.user_id,
Utc::now().timestamp_micros()
));
}
}
DASHBOARDS.update(&dashboard);

let path = dashboard_path(&dashboard.user_id, &format!("{}.json", dashboard_id));
Expand All @@ -100,7 +109,7 @@ pub async fn update(req: HttpRequest, body: Bytes) -> Result<HttpResponse, PostE
.put_object(&path, Bytes::from(dashboard_bytes))
.await?;

Ok(HttpResponse::Ok().finish())
Ok((web::Json(dashboard), StatusCode::OK))
}

pub async fn delete(req: HttpRequest) -> Result<HttpResponse, PostError> {
Expand Down
3 changes: 1 addition & 2 deletions server/src/users/dashboards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub struct Tiles {
name: String,
pub tile_id: Option<String>,
description: String,
stream: String,
query: String,
order: Option<u64>,
visualization: Visualization,
Expand All @@ -57,7 +56,7 @@ pub struct CircularChartConfig {
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
pub struct GraphConfig {
x_key: String,
y_key: Vec<String>,
y_keys: Vec<String>,
}

#[derive(Debug, Serialize, Deserialize, Default, Clone)]
Expand Down