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 class:hidden=move || token.present() >
<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" on:click=move |_| {
<form on:submit=move|ev| {
ev.prevent_default();
logging::log!("logging in...");
let email = username_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>
}

View file

@ -208,23 +208,24 @@ pub fn DebugPage() -> impl IntoView {
<div>
<Breadcrumb back=true>debug</Breadcrumb>
<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" >
<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" 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>
<td><input type="submit" class="w-100" value="fetch" /></td>
</tr>
</table>
</form>
</div>
<pre class="ma-1" >
{move || serde_json::to_string_pretty(&object.get()).unwrap_or("unserializable".to_string())}