Remove useless verbs in web api urls
This commit is contained in:
parent
559ed139aa
commit
315626b3ed
7 changed files with 100 additions and 94 deletions
|
|
@ -131,113 +131,105 @@ async fn main() {
|
||||||
// Disabled: update user profile is now made with a post data ('edit_user_post').
|
// Disabled: update user profile is now made with a post data ('edit_user_post').
|
||||||
// .route("/user/update", put(services::ron::update_user))
|
// .route("/user/update", put(services::ron::update_user))
|
||||||
.route("/set_lang", put(services::ron::set_lang))
|
.route("/set_lang", put(services::ron::set_lang))
|
||||||
.route("/recipe/get_titles", get(services::ron::recipe::get_titles))
|
.route("/recipe/titles", get(services::ron::recipe::get_titles))
|
||||||
.route("/recipe/set_title", patch(services::ron::recipe::set_title))
|
.route("/recipe/title", patch(services::ron::recipe::set_title))
|
||||||
.route(
|
.route(
|
||||||
"/recipe/set_description",
|
"/recipe/description",
|
||||||
patch(services::ron::recipe::set_description),
|
patch(services::ron::recipe::set_description),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/recipe/set_servings",
|
"/recipe/servings",
|
||||||
patch(services::ron::recipe::set_servings),
|
patch(services::ron::recipe::set_servings),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/recipe/set_estimated_time",
|
"/recipe/estimated_time",
|
||||||
patch(services::ron::recipe::set_estimated_time),
|
patch(services::ron::recipe::set_estimated_time),
|
||||||
)
|
)
|
||||||
.route("/recipe/get_tags", get(services::ron::recipe::get_tags))
|
|
||||||
.route("/recipe/add_tags", post(services::ron::recipe::add_tags))
|
|
||||||
.route("/recipe/rm_tags", delete(services::ron::recipe::rm_tags))
|
|
||||||
.route(
|
.route(
|
||||||
"/recipe/set_difficulty",
|
"/recipe/tags",
|
||||||
|
get(services::ron::recipe::get_tags)
|
||||||
|
.post(services::ron::recipe::add_tags)
|
||||||
|
.delete(services::ron::recipe::rm_tags),
|
||||||
|
)
|
||||||
|
.route(
|
||||||
|
"/recipe/difficulty",
|
||||||
patch(services::ron::recipe::set_difficulty),
|
patch(services::ron::recipe::set_difficulty),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/recipe/set_language",
|
"/recipe/language",
|
||||||
patch(services::ron::recipe::set_language),
|
patch(services::ron::recipe::set_language),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/recipe/set_is_published",
|
"/recipe/is_published",
|
||||||
patch(services::ron::recipe::set_is_published),
|
patch(services::ron::recipe::set_is_published),
|
||||||
)
|
)
|
||||||
.route("/recipe/remove", delete(services::ron::recipe::rm))
|
.route("/recipe", delete(services::ron::recipe::rm))
|
||||||
.route("/recipe/get_groups", get(services::ron::recipe::get_groups))
|
.route("/recipe/groups", get(services::ron::recipe::get_groups))
|
||||||
.route("/recipe/add_group", post(services::ron::recipe::add_group))
|
|
||||||
.route(
|
.route(
|
||||||
"/recipe/remove_group",
|
"/recipe/group",
|
||||||
delete(services::ron::recipe::rm_group),
|
post(services::ron::recipe::add_group).delete(services::ron::recipe::rm_group),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/recipe/set_group_name",
|
"/recipe/group_name",
|
||||||
patch(services::ron::recipe::set_group_name),
|
patch(services::ron::recipe::set_group_name),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/recipe/set_group_comment",
|
"/recipe/group_comment",
|
||||||
patch(services::ron::recipe::set_group_comment),
|
patch(services::ron::recipe::set_group_comment),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/recipe/set_groups_order",
|
"/recipe/groups_order",
|
||||||
patch(services::ron::recipe::set_groups_order),
|
patch(services::ron::recipe::set_groups_order),
|
||||||
)
|
)
|
||||||
.route("/recipe/add_step", post(services::ron::recipe::add_step))
|
|
||||||
.route(
|
.route(
|
||||||
"/recipe/remove_step",
|
"/recipe/step",
|
||||||
delete(services::ron::recipe::rm_step),
|
post(services::ron::recipe::add_step).delete(services::ron::recipe::rm_step),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/recipe/set_step_action",
|
"/recipe/step_action",
|
||||||
patch(services::ron::recipe::set_step_action),
|
patch(services::ron::recipe::set_step_action),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/recipe/set_steps_order",
|
"/recipe/steps_order",
|
||||||
patch(services::ron::recipe::set_steps_order),
|
patch(services::ron::recipe::set_steps_order),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/recipe/add_ingredient",
|
"/recipe/ingredient",
|
||||||
post(services::ron::recipe::add_ingredient),
|
post(services::ron::recipe::add_ingredient)
|
||||||
|
.delete(services::ron::recipe::rm_ingredient),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/recipe/remove_ingredient",
|
"/recipe/ingredient_name",
|
||||||
delete(services::ron::recipe::rm_ingredient),
|
|
||||||
)
|
|
||||||
.route(
|
|
||||||
"/recipe/set_ingredient_name",
|
|
||||||
patch(services::ron::recipe::set_ingredient_name),
|
patch(services::ron::recipe::set_ingredient_name),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/recipe/set_ingredient_comment",
|
"/recipe/ingredient_comment",
|
||||||
patch(services::ron::recipe::set_ingredient_comment),
|
patch(services::ron::recipe::set_ingredient_comment),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/recipe/set_ingredient_quantity",
|
"/recipe/ingredient_quantity",
|
||||||
patch(services::ron::recipe::set_ingredient_quantity),
|
patch(services::ron::recipe::set_ingredient_quantity),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/recipe/set_ingredient_unit",
|
"/recipe/ingredient_unit",
|
||||||
patch(services::ron::recipe::set_ingredient_unit),
|
patch(services::ron::recipe::set_ingredient_unit),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/recipe/set_ingredients_order",
|
"/recipe/ingredients_order",
|
||||||
patch(services::ron::recipe::set_ingredients_order),
|
patch(services::ron::recipe::set_ingredients_order),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/calendar/get_scheduled_recipes",
|
"/calendar/scheduled_recipes",
|
||||||
get(services::ron::calendar::get_scheduled_recipes),
|
get(services::ron::calendar::get_scheduled_recipes),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/calendar/schedule_recipe",
|
"/calendar/schedule_recipe",
|
||||||
post(services::ron::calendar::schedule_recipe),
|
post(services::ron::calendar::schedule_recipe)
|
||||||
|
.delete(services::ron::calendar::rm_scheduled_recipe),
|
||||||
)
|
)
|
||||||
|
.route("/shopping_list", get(services::ron::shopping_list::get))
|
||||||
.route(
|
.route(
|
||||||
"/calendar/remove_scheduled_recipe",
|
"/shopping_list/checked",
|
||||||
delete(services::ron::calendar::rm_scheduled_recipe),
|
|
||||||
)
|
|
||||||
.route(
|
|
||||||
"/shopping_list/get_list",
|
|
||||||
get(services::ron::shopping_list::get),
|
|
||||||
)
|
|
||||||
.route(
|
|
||||||
"/shopping_list/set_checked",
|
|
||||||
patch(services::ron::shopping_list::set_entry_checked),
|
patch(services::ron::shopping_list::set_entry_checked),
|
||||||
)
|
)
|
||||||
.fallback(services::ron::not_found);
|
.fallback(services::ron::not_found);
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,6 @@ futures = "0.3"
|
||||||
|
|
||||||
scanf = "1.2"
|
scanf = "1.2"
|
||||||
|
|
||||||
wasm-bindgen = "0.2"
|
|
||||||
wasm-bindgen-futures = "0.4"
|
|
||||||
web-sys = { version = "0.3", features = [
|
web-sys = { version = "0.3", features = [
|
||||||
"console",
|
"console",
|
||||||
"Document",
|
"Document",
|
||||||
|
|
@ -40,6 +38,7 @@ web-sys = { version = "0.3", features = [
|
||||||
"KeyboardEvent",
|
"KeyboardEvent",
|
||||||
"Element",
|
"Element",
|
||||||
"DomStringMap",
|
"DomStringMap",
|
||||||
|
"HtmlDocument",
|
||||||
"HtmlElement",
|
"HtmlElement",
|
||||||
"HtmlDivElement",
|
"HtmlDivElement",
|
||||||
"HtmlLabelElement",
|
"HtmlLabelElement",
|
||||||
|
|
@ -49,10 +48,14 @@ web-sys = { version = "0.3", features = [
|
||||||
"HtmlDialogElement",
|
"HtmlDialogElement",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
gloo = "0.11"
|
gloo = { version = "0.11", features = ["futures"] }
|
||||||
|
|
||||||
|
wasm-cookies = "0.2"
|
||||||
|
|
||||||
# The `console_error_panic_hook` crate provides better debugging of panics by
|
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||||
# logging them with `console.error`. This is great for development, but requires
|
# logging them with `console.error`. This is great for development, but requires
|
||||||
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||||
# code size when deploying.
|
# code size when deploying.
|
||||||
console_error_panic_hook = { version = "0.1", optional = true }
|
console_error_panic_hook = { version = "0.1", optional = true }
|
||||||
|
wasm-bindgen = "0.2"
|
||||||
|
wasm-bindgen-futures = "0.4"
|
||||||
|
|
|
||||||
|
|
@ -176,8 +176,7 @@ pub fn setup(
|
||||||
date,
|
date,
|
||||||
remove_ingredients_from_shopping_list,
|
remove_ingredients_from_shopping_list,
|
||||||
};
|
};
|
||||||
let _ =
|
let _ = request::delete::<(), _>("calendar/scheduled_recipe", body).await;
|
||||||
request::delete::<(), _>("calendar/remove_scheduled_recipe", body).await;
|
|
||||||
window().location().reload().unwrap();
|
window().location().reload().unwrap();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -83,20 +83,32 @@ pub fn main() -> Result<(), JsValue> {
|
||||||
// Dark/light theme handling.
|
// Dark/light theme handling.
|
||||||
let toggle_theme: HtmlInputElement = selector("#toggle-theme input");
|
let toggle_theme: HtmlInputElement = selector("#toggle-theme input");
|
||||||
EventListener::new(&toggle_theme.clone(), "change", move |_event| {
|
EventListener::new(&toggle_theme.clone(), "change", move |_event| {
|
||||||
wasm_cookies::set(
|
set_cookie_dark_theme(!toggle_theme.checked());
|
||||||
common::consts::COOKIE_DARK_THEME,
|
|
||||||
&(!toggle_theme.checked()).to_string(),
|
|
||||||
&wasm_cookies::CookieOptions {
|
|
||||||
path: Some("/"),
|
|
||||||
domain: None,
|
|
||||||
expires: None,
|
|
||||||
secure: false,
|
|
||||||
same_site: wasm_cookies::SameSite::Strict,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
window().location().reload().unwrap();
|
window().location().reload().unwrap();
|
||||||
})
|
})
|
||||||
.forget();
|
.forget();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `wasm_cookies::set` is specific for the wasm32 target architecture and Rust Analyzer says
|
||||||
|
/// it's an error, it's not possible to configure different target configurations into the same
|
||||||
|
/// workspace. Here is the issue:
|
||||||
|
/// https://users.rust-lang.org/t/can-i-configure-rust-analyzer-vscode-to-use-a-different-target-for-different-crates-in-my-workspce/123661
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
fn set_cookie_dark_theme(dark_theme: bool) {
|
||||||
|
wasm_cookies::set(
|
||||||
|
common::consts::COOKIE_DARK_THEME,
|
||||||
|
&dark_theme.to_string(),
|
||||||
|
&wasm_cookies::CookieOptions {
|
||||||
|
path: Some("/"),
|
||||||
|
domain: None,
|
||||||
|
expires: None,
|
||||||
|
secure: false,
|
||||||
|
same_site: wasm_cookies::SameSite::Strict,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
fn set_cookie_dark_theme(_dark_theme: bool) {}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ pub fn setup_page(recipe_id: i64) {
|
||||||
title: title.value(),
|
title: title.value(),
|
||||||
};
|
};
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let _ = request::patch::<(), _>("recipe/set_title", body).await;
|
let _ = request::patch::<(), _>("recipe/title", body).await;
|
||||||
reload_recipes_list(recipe_id).await;
|
reload_recipes_list(recipe_id).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +56,7 @@ pub fn setup_page(recipe_id: i64) {
|
||||||
description: description.value(),
|
description: description.value(),
|
||||||
};
|
};
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let _ = request::patch::<(), _>("recipe/set_description", body).await;
|
let _ = request::patch::<(), _>("recipe/description", body).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -87,7 +87,7 @@ pub fn setup_page(recipe_id: i64) {
|
||||||
servings,
|
servings,
|
||||||
};
|
};
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let _ = request::patch::<(), _>("recipe/set_servings", body).await;
|
let _ = request::patch::<(), _>("recipe/servings", body).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -119,7 +119,7 @@ pub fn setup_page(recipe_id: i64) {
|
||||||
estimated_time: time,
|
estimated_time: time,
|
||||||
};
|
};
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let _ = request::patch::<(), _>("recipe/set_estimated_time", body).await;
|
let _ = request::patch::<(), _>("recipe/estimated_time", body).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -143,7 +143,7 @@ pub fn setup_page(recipe_id: i64) {
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
};
|
};
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let _ = request::patch::<(), _>("recipe/set_difficulty", body).await;
|
let _ = request::patch::<(), _>("recipe/difficulty", body).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -154,7 +154,7 @@ pub fn setup_page(recipe_id: i64) {
|
||||||
{
|
{
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let tags: ron_api::Tags = request::get(
|
let tags: ron_api::Tags = request::get(
|
||||||
"recipe/get_tags",
|
"recipe/tags",
|
||||||
ron_api::Id { id: recipe_id }, /*[("id", &recipe_id.to_string())]*/
|
ron_api::Id { id: recipe_id }, /*[("id", &recipe_id.to_string())]*/
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -171,7 +171,7 @@ pub fn setup_page(recipe_id: i64) {
|
||||||
recipe_id,
|
recipe_id,
|
||||||
tags: tag_list.clone(),
|
tags: tag_list.clone(),
|
||||||
};
|
};
|
||||||
let _ = request::post::<(), _>("recipe/add_tags", body).await;
|
let _ = request::post::<(), _>("recipe/tags", body).await;
|
||||||
create_tag_elements(recipe_id, &tag_list);
|
create_tag_elements(recipe_id, &tag_list);
|
||||||
}
|
}
|
||||||
by_id::<HtmlInputElement>("input-tags").set_value("");
|
by_id::<HtmlInputElement>("input-tags").set_value("");
|
||||||
|
|
@ -219,7 +219,7 @@ pub fn setup_page(recipe_id: i64) {
|
||||||
lang: language.value(),
|
lang: language.value(),
|
||||||
};
|
};
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let _ = request::patch::<(), _>("recipe/set_language", body).await;
|
let _ = request::patch::<(), _>("recipe/language", body).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -235,7 +235,7 @@ pub fn setup_page(recipe_id: i64) {
|
||||||
is_published: is_published.checked(),
|
is_published: is_published.checked(),
|
||||||
};
|
};
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let _ = request::patch::<(), _>("recipe/set_is_published", body).await;
|
let _ = request::patch::<(), _>("recipe/is_published", body).await;
|
||||||
reload_recipes_list(recipe_id).await;
|
reload_recipes_list(recipe_id).await;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
@ -261,7 +261,7 @@ pub fn setup_page(recipe_id: i64) {
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
let body = ron_api::Id { id: recipe_id };
|
let body = ron_api::Id { id: recipe_id };
|
||||||
let _ = request::delete::<(), _>("recipe/remove", body).await;
|
let _ = request::delete::<(), _>("recipe", body).await;
|
||||||
window()
|
window()
|
||||||
.location()
|
.location()
|
||||||
.set_href(&format!("/{}/", get_current_lang()))
|
.set_href(&format!("/{}/", get_current_lang()))
|
||||||
|
|
@ -275,7 +275,7 @@ pub fn setup_page(recipe_id: i64) {
|
||||||
{
|
{
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let groups: Vec<common::ron_api::Group> =
|
let groups: Vec<common::ron_api::Group> =
|
||||||
request::get("recipe/get_groups", ron_api::Id { id: recipe_id })
|
request::get("recipe/groups", ron_api::Id { id: recipe_id })
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
@ -303,7 +303,7 @@ pub fn setup_page(recipe_id: i64) {
|
||||||
EventListener::new(&button_add_group, "click", move |_event| {
|
EventListener::new(&button_add_group, "click", move |_event| {
|
||||||
let body = ron_api::Id { id: recipe_id };
|
let body = ron_api::Id { id: recipe_id };
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let response: ron_api::Id = request::post("recipe/add_group", body).await.unwrap();
|
let response: ron_api::Id = request::post("recipe/group", body).await.unwrap();
|
||||||
create_group_element(&ron_api::Group {
|
create_group_element(&ron_api::Group {
|
||||||
id: response.id,
|
id: response.id,
|
||||||
name: "".to_string(),
|
name: "".to_string(),
|
||||||
|
|
@ -333,7 +333,7 @@ fn create_group_element(group: &ron_api::Group) -> Element {
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let body = ron_api::Ids { ids };
|
let body = ron_api::Ids { ids };
|
||||||
let _ = request::patch::<(), _>("recipe/set_groups_order", body).await;
|
let _ = request::patch::<(), _>("recipe/groups_order", body).await;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -349,7 +349,7 @@ fn create_group_element(group: &ron_api::Group) -> Element {
|
||||||
name: name.value(),
|
name: name.value(),
|
||||||
};
|
};
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let _ = request::patch::<(), _>("recipe/set_group_name", body).await;
|
let _ = request::patch::<(), _>("recipe/group_name", body).await;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -367,7 +367,7 @@ fn create_group_element(group: &ron_api::Group) -> Element {
|
||||||
comment: comment.value(),
|
comment: comment.value(),
|
||||||
};
|
};
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let _ = request::patch::<(), _>("recipe/set_group_comment", body).await;
|
let _ = request::patch::<(), _>("recipe/group_comment", body).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -393,7 +393,7 @@ fn create_group_element(group: &ron_api::Group) -> Element {
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
let body = ron_api::Id { id: group_id };
|
let body = ron_api::Id { id: group_id };
|
||||||
let _ = request::delete::<(), _>("recipe/remove_group", body).await;
|
let _ = request::delete::<(), _>("recipe/group", body).await;
|
||||||
let group_element = by_id::<Element>(&format!("group-{}", group_id));
|
let group_element = by_id::<Element>(&format!("group-{}", group_id));
|
||||||
group_element.next_element_sibling().unwrap().remove();
|
group_element.next_element_sibling().unwrap().remove();
|
||||||
group_element.remove();
|
group_element.remove();
|
||||||
|
|
@ -407,7 +407,7 @@ fn create_group_element(group: &ron_api::Group) -> Element {
|
||||||
EventListener::new(&add_step_button, "click", move |_event| {
|
EventListener::new(&add_step_button, "click", move |_event| {
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let body = ron_api::Id { id: group_id };
|
let body = ron_api::Id { id: group_id };
|
||||||
let response: ron_api::Id = request::post("recipe/add_step", body).await.unwrap();
|
let response: ron_api::Id = request::post("recipe/step", body).await.unwrap();
|
||||||
create_step_element(
|
create_step_element(
|
||||||
&selector::<Element>(&format!("#group-{} .steps", group_id)),
|
&selector::<Element>(&format!("#group-{} .steps", group_id)),
|
||||||
&ron_api::Step {
|
&ron_api::Step {
|
||||||
|
|
@ -468,7 +468,7 @@ where
|
||||||
recipe_id,
|
recipe_id,
|
||||||
tags: vec![tag],
|
tags: vec![tag],
|
||||||
};
|
};
|
||||||
let _ = request::delete::<(), _>("recipe/rm_tags", body).await;
|
let _ = request::delete::<(), _>("recipe/tags", body).await;
|
||||||
tag_span.remove();
|
tag_span.remove();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
@ -494,7 +494,7 @@ fn create_step_element(group_element: &Element, step: &ron_api::Step) -> Element
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let body = ron_api::Ids { ids };
|
let body = ron_api::Ids { ids };
|
||||||
let _ = request::patch::<(), _>("recipe/set_steps_order", body).await;
|
let _ = request::patch::<(), _>("recipe/steps_order", body).await;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -510,7 +510,7 @@ fn create_step_element(group_element: &Element, step: &ron_api::Step) -> Element
|
||||||
action: action.value(),
|
action: action.value(),
|
||||||
};
|
};
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let _ = request::patch::<(), _>("recipe/set_step_action", body).await;
|
let _ = request::patch::<(), _>("recipe/step_action", body).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -536,7 +536,7 @@ fn create_step_element(group_element: &Element, step: &ron_api::Step) -> Element
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
let body = ron_api::Id { id: step_id };
|
let body = ron_api::Id { id: step_id };
|
||||||
let _ = request::delete::<(), _>("recipe/remove_step", body).await;
|
let _ = request::delete::<(), _>("recipe/step", body).await;
|
||||||
let step_element = by_id::<Element>(&format!("step-{}", step_id));
|
let step_element = by_id::<Element>(&format!("step-{}", step_id));
|
||||||
step_element.next_element_sibling().unwrap().remove();
|
step_element.next_element_sibling().unwrap().remove();
|
||||||
step_element.remove();
|
step_element.remove();
|
||||||
|
|
@ -550,7 +550,7 @@ fn create_step_element(group_element: &Element, step: &ron_api::Step) -> Element
|
||||||
EventListener::new(&add_ingredient_button, "click", move |_event| {
|
EventListener::new(&add_ingredient_button, "click", move |_event| {
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let body = ron_api::Id { id: step_id };
|
let body = ron_api::Id { id: step_id };
|
||||||
let response: ron_api::Id = request::post("recipe/add_ingredient", body).await.unwrap();
|
let response: ron_api::Id = request::post("recipe/ingredient", body).await.unwrap();
|
||||||
create_ingredient_element(
|
create_ingredient_element(
|
||||||
&selector::<Element>(&format!("#step-{} .ingredients", step_id)),
|
&selector::<Element>(&format!("#step-{} .ingredients", step_id)),
|
||||||
&ron_api::Ingredient {
|
&ron_api::Ingredient {
|
||||||
|
|
@ -586,7 +586,7 @@ fn create_ingredient_element(step_element: &Element, ingredient: &ron_api::Ingre
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let body = ron_api::Ids { ids };
|
let body = ron_api::Ids { ids };
|
||||||
let _ = request::patch::<(), _>("recipe/set_ingredients_order", body).await;
|
let _ = request::patch::<(), _>("recipe/ingredients_order", body).await;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -602,7 +602,7 @@ fn create_ingredient_element(step_element: &Element, ingredient: &ron_api::Ingre
|
||||||
name: name.value(),
|
name: name.value(),
|
||||||
};
|
};
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let _ = request::patch::<(), _>("recipe/set_ingredient_name", body).await;
|
let _ = request::patch::<(), _>("recipe/ingredient_name", body).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -620,7 +620,7 @@ fn create_ingredient_element(step_element: &Element, ingredient: &ron_api::Ingre
|
||||||
comment: comment.value(),
|
comment: comment.value(),
|
||||||
};
|
};
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let _ = request::patch::<(), _>("recipe/set_ingredient_comment", body).await;
|
let _ = request::patch::<(), _>("recipe/ingredient_comment", body).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -647,7 +647,7 @@ fn create_ingredient_element(step_element: &Element, ingredient: &ron_api::Ingre
|
||||||
quantity: q,
|
quantity: q,
|
||||||
};
|
};
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let _ = request::patch::<(), _>("recipe/set_ingredient_quantity", body).await;
|
let _ = request::patch::<(), _>("recipe/ingredient_quantity", body).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -665,7 +665,7 @@ fn create_ingredient_element(step_element: &Element, ingredient: &ron_api::Ingre
|
||||||
unit: unit.value(),
|
unit: unit.value(),
|
||||||
};
|
};
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let _ = request::patch::<(), _>("recipe/set_ingredient_unit", body).await;
|
let _ = request::patch::<(), _>("recipe/ingredient_unit", body).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -691,7 +691,7 @@ fn create_ingredient_element(step_element: &Element, ingredient: &ron_api::Ingre
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
let body = ron_api::Id { id: ingredient_id };
|
let body = ron_api::Id { id: ingredient_id };
|
||||||
let _ = request::delete::<(), _>("recipe/remove_ingredient", body).await;
|
let _ = request::delete::<(), _>("recipe/ingredient", body).await;
|
||||||
let ingredient_element = by_id::<Element>(&format!("ingredient-{}", ingredient_id));
|
let ingredient_element = by_id::<Element>(&format!("ingredient-{}", ingredient_id));
|
||||||
ingredient_element.next_element_sibling().unwrap().remove();
|
ingredient_element.next_element_sibling().unwrap().remove();
|
||||||
ingredient_element.remove();
|
ingredient_element.remove();
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ impl RecipeScheduler {
|
||||||
}
|
}
|
||||||
|
|
||||||
let titles: ron_api::Strings = request::get(
|
let titles: ron_api::Strings = request::get(
|
||||||
"recipe/get_titles",
|
"recipe/titles",
|
||||||
ron_api::Ids {
|
ron_api::Ids {
|
||||||
ids: recipe_ids_and_dates
|
ids: recipe_ids_and_dates
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -98,7 +98,7 @@ impl RecipeScheduler {
|
||||||
.collect::<Vec<_>>())
|
.collect::<Vec<_>>())
|
||||||
} else {
|
} else {
|
||||||
let scheduled_recipes: ron_api::ScheduledRecipes = request::get(
|
let scheduled_recipes: ron_api::ScheduledRecipes = request::get(
|
||||||
"calendar/get_scheduled_recipes",
|
"calendar/scheduled_recipes",
|
||||||
ron_api::DateRange {
|
ron_api::DateRange {
|
||||||
start_date,
|
start_date,
|
||||||
end_date,
|
end_date,
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ impl ShoppingList {
|
||||||
if self.is_local {
|
if self.is_local {
|
||||||
Ok(vec![]) // TODO
|
Ok(vec![]) // TODO
|
||||||
} else {
|
} else {
|
||||||
Ok(request::get("shopping_list/get_list", ()).await?)
|
Ok(request::get("shopping_list", ()).await?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@ impl ShoppingList {
|
||||||
todo!();
|
todo!();
|
||||||
} else {
|
} else {
|
||||||
request::patch(
|
request::patch(
|
||||||
"shopping_list/set_checked",
|
"shopping_list/checked",
|
||||||
ron_api::Value {
|
ron_api::Value {
|
||||||
id: item_id,
|
id: item_id,
|
||||||
value: is_checked,
|
value: is_checked,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue