feat(web): use forms for login and dbg
This commit is contained in:
parent
5ba1fb66ca
commit
41b9ee4044
2 changed files with 20 additions and 16 deletions
|
@ -36,9 +36,8 @@ pub fn LoginBox(
|
||||||
} />
|
} />
|
||||||
</div>
|
</div>
|
||||||
<div class:hidden=move || token.present() >
|
<div class:hidden=move || token.present() >
|
||||||
<input class="w-100" type="text" node_ref=username_ref placeholder="username" />
|
<form on:submit=move|ev| {
|
||||||
<input class="w-100" type="text" node_ref=password_ref placeholder="password" />
|
ev.prevent_default();
|
||||||
<input class="w-100" type="submit" value="login" on:click=move |_| {
|
|
||||||
logging::log!("logging in...");
|
logging::log!("logging in...");
|
||||||
let email = username_ref.get().map(|x| x.value()).unwrap_or("".into());
|
let email = username_ref.get().map(|x| x.value()).unwrap_or("".into());
|
||||||
let password = password_ref.get().map(|x| x.value()).unwrap_or("".into());
|
let password = password_ref.get().map(|x| x.value()).unwrap_or("".into());
|
||||||
|
@ -70,7 +69,11 @@ pub fn LoginBox(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} />
|
} >
|
||||||
|
<input class="w-100" type="text" node_ref=username_ref placeholder="username" />
|
||||||
|
<input class="w-100" type="text" node_ref=password_ref placeholder="password" />
|
||||||
|
<input class="w-100" type="submit" value="login" />
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,23 +208,24 @@ pub fn DebugPage() -> impl IntoView {
|
||||||
<div>
|
<div>
|
||||||
<Breadcrumb back=true>debug</Breadcrumb>
|
<Breadcrumb back=true>debug</Breadcrumb>
|
||||||
<div class="mt-1" >
|
<div class="mt-1" >
|
||||||
|
<form on:submit=move|ev| {
|
||||||
|
ev.prevent_default();
|
||||||
|
let fetch_url = url_ref.get().map(|x| x.value()).unwrap_or("".into());
|
||||||
|
let url = format!("{URL_BASE}/dbg?id={fetch_url}");
|
||||||
|
spawn_local(async move {
|
||||||
|
match Http::fetch::<serde_json::Value>(&url, auth).await {
|
||||||
|
Ok(x) => set_object.set(x),
|
||||||
|
Err(e) => set_object.set(serde_json::Value::String(e.to_string())),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} >
|
||||||
<table class="align w-100" >
|
<table class="align w-100" >
|
||||||
<tr>
|
<tr>
|
||||||
<td><input class="w-100" type="text" node_ref=url_ref placeholder="AP id" /></td>
|
<td><input class="w-100" type="text" node_ref=url_ref placeholder="AP id" /></td>
|
||||||
<td>
|
<td><input type="submit" class="w-100" value="fetch" /></td>
|
||||||
<input type="submit" class="w-100" value="fetch" on:click=move |_| {
|
|
||||||
let fetch_url = url_ref.get().map(|x| x.value()).unwrap_or("".into());
|
|
||||||
let url = format!("{URL_BASE}/dbg?id={fetch_url}");
|
|
||||||
spawn_local(async move {
|
|
||||||
match Http::fetch::<serde_json::Value>(&url, auth).await {
|
|
||||||
Ok(x) => set_object.set(x),
|
|
||||||
Err(e) => set_object.set(serde_json::Value::String(e.to_string())),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} />
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<pre class="ma-1" >
|
<pre class="ma-1" >
|
||||||
{move || serde_json::to_string_pretty(&object.get()).unwrap_or("unserializable".to_string())}
|
{move || serde_json::to_string_pretty(&object.get()).unwrap_or("unserializable".to_string())}
|
||||||
|
|
Loading…
Reference in a new issue