Skip to content

Commit

Permalink
fix: minor fixes for hot water
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmay committed Nov 14, 2024
1 parent afab8f0 commit 311b1ed
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion robotica-common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub struct Config {
pub cars: Vec<CarConfig>,

/// The hotwater config for this UI
pub hot_water: Vec<HotWaterConfig>,
pub hot_waters: Vec<HotWaterConfig>,

/// The name of the server in MQTT topics
pub instance: String,
Expand Down
6 changes: 5 additions & 1 deletion robotica-frontend/src/components/hot_water.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ impl Component for HotWaterComponent {
let id = Id::new(&props.id);

let hot_water = if let Some(config) = &self.config {
config.cars.iter().find(|car| car.id == id).cloned()
config
.hot_waters
.iter()
.find(|hot_water| hot_water.id == id)
.cloned()
} else {
None
};
Expand Down
6 changes: 2 additions & 4 deletions robotica-frontend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ mod robotica_wasm;
mod services;

use paste::paste;
use tracing::debug;

use std::collections::HashMap;
use std::rc::Rc;
Expand Down Expand Up @@ -141,7 +140,6 @@ impl Component for App {
fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> bool {
match msg {
AppMsg::Config(config) => {
debug!("!!!Got config: {:?}", config.cars);
self.config = Some(config);
true
}
Expand Down Expand Up @@ -196,7 +194,7 @@ fn nav_bar() -> Html {
};

let hot_water = match &config {
Some(config) => config.hot_water.clone(),
Some(config) => config.hot_waters.clone(),
None => vec![],
};

Expand Down Expand Up @@ -281,7 +279,7 @@ fn nav_bar() -> Html {
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
{ "Hot Water" }
{ "Hot Waters" }
</a>
<ul class="dropdown-menu">
{ hot_water.iter().map(|hot_water| html! {
Expand Down
2 changes: 1 addition & 1 deletion robotica-tokio/src/services/http/api/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub async fn config_handler(
title: "My Tesla".to_string(),
}],
// FIXME: This should not be hardcoded.
hot_water: vec![config::HotWaterConfig {
hot_waters: vec![config::HotWaterConfig {
id: Id::new("hot_water"),
title: "Hot Water Bathroom".to_string(),
}],
Expand Down

0 comments on commit 311b1ed

Please sign in to comment.