Minor design improvements

This commit is contained in:
Lol3rrr
2024-11-01 21:47:25 +01:00
parent 1d6b6555b1
commit 101833d0d8
5 changed files with 87 additions and 40 deletions

View File

@@ -25,9 +25,9 @@ pub fn scoreboard() -> impl leptos::IntoView {
.get()
.into_iter()
.flat_map(|v| v.teams.into_iter())
.map(|(team, players)| {
.map(|team| {
view! {
<TeamScoreboard value=players team_name=format!("Team {}", team) />
<TeamScoreboard value=team.players team_name=format!("Team {} - {}", team.number, team.score) />
}
})
.collect::<Vec<_>>()

View File

@@ -3,9 +3,7 @@ use leptos::*;
#[leptos::component]
pub fn homepage(get_notification: ReadSignal<u8>) -> impl leptos::IntoView {
let demo_data = create_resource(
move || {
get_notification.get()
},
move || get_notification.get(),
|_| async move {
let res = reqwasm::http::Request::get("/api/demos/list")
.send()
@@ -16,11 +14,17 @@ pub fn homepage(get_notification: ReadSignal<u8>) -> impl leptos::IntoView {
},
);
let pending_display = move || demo_data.get().map(|d| d.pending).filter(|p| p.len() > 0).map(|pending| {
view! {
<p>{pending.len()} demos are pending/waiting for analysis</p>
}
});
let pending_display = move || {
demo_data
.get()
.map(|d| d.pending)
.filter(|p| p.len() > 0)
.map(|pending| {
view! {
<p>{pending.len()} demos are pending/waiting for analysis</p>
}
})
};
view! {
<div>
@@ -117,8 +121,8 @@ fn demo_list_entry(demo: common::BaseDemoInfo, idx: usize) -> impl leptos::IntoV
view! {
class=style,
<span
class="score"
<span
class="score"
style=format!("grid-row: {};", idx + 1)
class:won=won
class:lost=lost

View File

@@ -112,23 +112,24 @@ pub fn upload_demo(
let uploading = RwSignal::new(false);
let handle_resp: std::rc::Rc<dyn Fn(&leptos::web_sys::Response)> = std::rc::Rc::new(move |resp: &leptos::web_sys::Response| {
if resp.status() != 200 {
// TODO
// Display error somehow
return;
}
let handle_resp: std::rc::Rc<dyn Fn(&leptos::web_sys::Response)> =
std::rc::Rc::new(move |resp: &leptos::web_sys::Response| {
if resp.status() != 200 {
// TODO
// Display error somehow
return;
}
uploading.set(false);
uploading.set(false);
// Remove the Upload popup
update_shown.set(DemoUploadStatus::Hidden);
// Remove the Upload popup
update_shown.set(DemoUploadStatus::Hidden);
// Reload the demo list
reload_demos.update(|v| {
*v = v.wrapping_add(1);
// Reload the demo list
reload_demos.update(|v| {
*v = v.wrapping_add(1);
});
});
});
let on_submit: std::rc::Rc<dyn Fn(&leptos::web_sys::FormData)> = std::rc::Rc::new(move |_| {
uploading.set(true);