Add Docker build
This commit is contained in:
@@ -18,3 +18,4 @@ reqwasm = "0.5"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
wasm-bindgen-futures = "0.4"
|
||||
uikit-rs = { git = "https://github.com/dax/uikit-rs.git" }
|
||||
wasm-bindgen = "0.2.79"
|
||||
|
||||
@@ -1 +1,12 @@
|
||||
extend = "../Makefile.toml"
|
||||
|
||||
[tasks.build-release]
|
||||
install_crate = { crate_name = "trunk", binary = "trunk" }
|
||||
command = "trunk"
|
||||
args = ["build", "--release"]
|
||||
|
||||
[tasks.run]
|
||||
clear = true
|
||||
install_crate = { crate_name = "trunk", binary = "trunk" }
|
||||
command = "trunk"
|
||||
args = ["serve"]
|
||||
|
||||
3
web/js/api.js
Normal file
3
web/js/api.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export function get_api_base_url() {
|
||||
return "http://localhost:8000/api";
|
||||
}
|
||||
@@ -2,10 +2,16 @@ use components::tasks_list::TasksList;
|
||||
use contextswitch::Task;
|
||||
use reqwasm::http::Request;
|
||||
use uikit_rs as uk;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use yew::prelude::*;
|
||||
|
||||
mod components;
|
||||
|
||||
#[wasm_bindgen(module = "/js/api.js")]
|
||||
extern "C" {
|
||||
fn get_api_base_url() -> String;
|
||||
}
|
||||
|
||||
#[function_component(App)]
|
||||
pub fn app() -> Html {
|
||||
let tasks = use_state(Vec::new);
|
||||
@@ -15,7 +21,7 @@ pub fn app() -> Html {
|
||||
move |_| {
|
||||
wasm_bindgen_futures::spawn_local(async move {
|
||||
let fetched_tasks: Vec<Task> =
|
||||
Request::get("http://localhost:8000/tasks?filter=task")
|
||||
Request::get(&format!("{}/tasks?filter=task", get_api_base_url()))
|
||||
.send()
|
||||
.await
|
||||
.unwrap() // TODO
|
||||
|
||||
Reference in New Issue
Block a user