Skip to content

Commit

Permalink
Update pico
Browse files Browse the repository at this point in the history
  • Loading branch information
Gitznik committed Mar 8, 2024
1 parent 8c98a43 commit 2d6208c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/html_base/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="static/htmx.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@1/css/pico.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css" />
<title>RobsWebHub</title>
<link rel="icon" type="image/x-icon" href="images/favicon.ico">
</head>
6 changes: 2 additions & 4 deletions src/routes/scores/components/batch_upload_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ async fn get_batch_result_form(query: web::Query<QueryData>) -> actix_web::Resul
let body = format!(
r#"
<div id="score_entry_form">
<h3>Batch Entry</h3>
<form id="batch_upload" action="/scores_batch" method="post">
<div class="grid">
<label for="matchup_id">
Matchup Id
<input type="text" id="matchup_id" name="matchup_id" placeholder="Matchup Id" {} required>
</label>
<input type="hidden" id="matchup_id" name="matchup_id" placeholder="Matchup Id" {} required>
<label for="raw_matches_list">
Raw matches list
<textarea id="raw_matches_list" name="raw_matches_list" placeholder="Raw matches list, e.g. 2023-02-22 P1 2:1" rows="5" required></textarea>
Expand Down
8 changes: 2 additions & 6 deletions src/routes/scores/components/single_result_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,14 @@ async fn get_single_result_form(query: web::Query<QueryData>) -> actix_web::Resu
let body = format!(
r#"
<div id="score_entry_form">
<h3>Single Entry</h3>
<form id="single_result" action="/scores/scores_single" method="post">
<div class="grid">
<label for="matchup_id">
Matchup Id
<input type="text" id="matchup_id" name="matchup_id" placeholder="Matchup Id" {} required>
</label>
<input type="hidden" id="matchup_id" name="matchup_id" placeholder="Matchup Id" {} required>
<label for="winner_initials">
Winner Credentials
<input type="text" id="winner_initials" name="winner_initials" placeholder="Winner Initials" required>
</label>
</div>
<div class="grid">
<label for="score">
Score, separated by ":"
<input type="text" id="score" name="score" placeholder="Score" required>
Expand Down
10 changes: 4 additions & 6 deletions src/routes/scores/get.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<h1>Scorekeeper</h1>
<div>
<form action="/scores" method="get">
<div class="grid">
<label for="matchup_id">
Matchup Id
<input type="text" id="matchup_id" name="matchup_id" placeholder="Matchup Id" required>
</label>
<button type="submit">Go to Match</button>
<fieldset role="group">
<input type="text" id="matchup_id" name="matchup_id" placeholder="Matchup Id" required>
<button type="submit">Go</button>
</fieldset>
</form>
</div>
21 changes: 11 additions & 10 deletions src/routes/scores/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,15 @@ async fn add_scores(
.map_err(|e| see_other_error("/scores", Some(e)))?,
None => r#"<div>You can find an example match <a href="/scores?matchup_id=b13a16d8-c46e-4921-83f2-eec9675fce74">here</a>.</div>"#.to_string(),
};
let match_title = match query.matchup_id {
Some(matchup_id) => format!(r#"<h1>Match {}</h1>"#, matchup_id),
None => "".to_string(),
};
let insert_score_form = insert_score_form(query.matchup_id);
let main_div = include_str!("get.html");
let main_div = format!(
"{}\n<main class=\"container\">{}{}{}</main>",
&error_html, &main_div, &insert_score_form, &scores
"{}\n<main class=\"container\">{}{}{}{}</main>",
&error_html, &main_div, &match_title, &insert_score_form, &scores
);
let html = compose_html(&main_div);
Ok(HttpResponse::Ok().body(html))
Expand Down Expand Up @@ -123,8 +127,10 @@ async fn match_summary(match_id: Uuid, pg_pool: &PgPool) -> Result<String, anyho

Ok(format!(
r#"
<h1>Match Scores for Match</h1>
<h2>{}</h2>
<h2>Scores</h2>
<figure align="center">
<img src="images/match_plots/{}.png" alt="Match Results Graph">
</figure>
<table role="grid">
<thead>
<tr>
Expand All @@ -139,14 +145,10 @@ async fn match_summary(match_id: Uuid, pg_pool: &PgPool) -> Result<String, anyho
{}
</tbody>
</table>
<div>
<img src="images/match_plots/{}.png" alt="Match Results Graph" width="640" height="480">
</div>
</main>
"#,
&match_id,
match_rows.join("\n"),
&match_id,
))
}

Expand Down Expand Up @@ -260,12 +262,11 @@ fn insert_score_form(matchup_id: Option<Uuid>) -> String {
r##"
<div>
<h2>Add Score</h2>
<div class="grid">
<div class="grid">
<button hx-get="/scores/single_result_form" hx-trigger="load,click" hx-target="#score_entry_form" hx-vals='{{"matchup_id":"{}"}}' hx-swap="outerHTML ignoreTitle:true">Single Result Entry</button>
<button hx-get="/scores/batch_result_form" hx-target="#score_entry_form" hx-vals='{{"matchup_id":"{}"}}' hx-swap="outerHTML ignoreTitle:true">Multiple Result Entry</button>
</div>
</div>
<p />
<div id="score_entry_form"</div>
</div>
"##,
Expand Down

0 comments on commit 2d6208c

Please sign in to comment.