feat(web): use forms for login and dbg

This commit is contained in:
əlemi 2024-04-21 23:41:30 +02:00
parent 5ba1fb66ca
commit 41b9ee4044
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 20 additions and 16 deletions

View file

@ -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>
} }

View file

@ -208,11 +208,8 @@ 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" >
<table class="align w-100" > <form on:submit=move|ev| {
<tr> ev.prevent_default();
<td><input class="w-100" type="text" node_ref=url_ref placeholder="AP id" /></td>
<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 fetch_url = url_ref.get().map(|x| x.value()).unwrap_or("".into());
let url = format!("{URL_BASE}/dbg?id={fetch_url}"); let url = format!("{URL_BASE}/dbg?id={fetch_url}");
spawn_local(async move { spawn_local(async move {
@ -221,10 +218,14 @@ pub fn DebugPage() -> impl IntoView {
Err(e) => set_object.set(serde_json::Value::String(e.to_string())), Err(e) => set_object.set(serde_json::Value::String(e.to_string())),
} }
}); });
} /> } >
</td> <table class="align w-100" >
<tr>
<td><input class="w-100" type="text" node_ref=url_ref placeholder="AP id" /></td>
<td><input type="submit" class="w-100" value="fetch" /></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())}