mass view refactoring
This commit is contained in:
parent
d85ccdf025
commit
b167d6d586
6 changed files with 28 additions and 27 deletions
|
@ -51,9 +51,9 @@ async fn main() -> io::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn welcome() -> impl IntoResponse {
|
async fn welcome() -> impl IntoResponse {
|
||||||
let cat_fact = views::get_cat_fact().await;
|
let fact = views::get_cat_fact().await;
|
||||||
Html(ssr::render(move || {
|
Html(ssr::render(move || {
|
||||||
leptos::view! { <WelcomePage fact=cat_fact /> }
|
leptos::view! { <WelcomePage fact /> }
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ async fn link(
|
||||||
{
|
{
|
||||||
return Ok(Html(ssr::render({
|
return Ok(Html(ssr::render({
|
||||||
let record = record.clone();
|
let record = record.clone();
|
||||||
|| leptos::view! { <DownloadLinkPage id=id record=record /> }
|
|| leptos::view! { <DownloadLinkPage id record /> }
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,31 +23,32 @@ pub(crate) async fn records(State(state): State<AppState>) -> impl IntoResponse
|
||||||
// this behind some kind of authentication
|
// this behind some kind of authentication
|
||||||
pub async fn records_links(State(state): State<AppState>) -> impl IntoResponse {
|
pub async fn records_links(State(state): State<AppState>) -> impl IntoResponse {
|
||||||
let records = state.records.lock().await.clone();
|
let records = state.records.lock().await.clone();
|
||||||
|
|
||||||
|
let records_list_view = records
|
||||||
|
.keys()
|
||||||
|
.map(|key| {
|
||||||
|
leptos::view! {
|
||||||
|
<li class="link-wrapper">
|
||||||
|
<a href="/link/{key}">{key}</a>
|
||||||
|
<button
|
||||||
|
style="margin-left: 1em;"
|
||||||
|
hx-target="closest .link-wrapper"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-delete="/link/{key}"
|
||||||
|
>
|
||||||
|
"X"
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect_view();
|
||||||
|
|
||||||
Html(ssr::render(move || {
|
Html(ssr::render(move || {
|
||||||
leptos::view! {
|
leptos::view! {
|
||||||
<HtmxPage>
|
<HtmxPage>
|
||||||
<div class="form-wrapper">
|
<div class="form-wrapper">
|
||||||
<div class="column-container">
|
<div class="column-container">
|
||||||
<ul>
|
<ul>{records_list_view}</ul>
|
||||||
{records
|
|
||||||
.keys()
|
|
||||||
.map(|key| {
|
|
||||||
leptos::view! {
|
|
||||||
<li class="link-wrapper">
|
|
||||||
<a href="/link/{key}">{key}</a>
|
|
||||||
<button
|
|
||||||
style="margin-left: 1em;"
|
|
||||||
hx-target="closest .link-wrapper"
|
|
||||||
hx-swap="outerHTML"
|
|
||||||
hx-delete="/link/{key}"
|
|
||||||
>
|
|
||||||
X
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect_view()}
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</HtmxPage>
|
</HtmxPage>
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub fn HtmxPage(children: Children) -> impl IntoView {
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>NyaZoom<sup>2</sup></h1>
|
<h1>"NyaZoom"<sup>"2"</sup></h1>
|
||||||
{children()}
|
{children()}
|
||||||
</body>
|
</body>
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub fn LinkView(id: String, record: UploadRecord) -> impl IntoView {
|
||||||
<div class="column-container">
|
<div class="column-container">
|
||||||
<div class="link-wrapper">
|
<div class="link-wrapper">
|
||||||
<a id="link" href="/download/{id}">
|
<a id="link" href="/download/{id}">
|
||||||
Download Now!
|
"Download Now!"
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ pub fn LinkView(id: String, record: UploadRecord) -> impl IntoView {
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<a href="/" class="return-button">
|
<a href="/" class="return-button">
|
||||||
Return to home
|
"Return to home"
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub fn WelcomeView(fact: String) -> impl IntoView {
|
||||||
data-multiple-caption="{{count}} files selected"
|
data-multiple-caption="{{count}} files selected"
|
||||||
multiple
|
multiple
|
||||||
/>
|
/>
|
||||||
<label for="file">Select Files</label>
|
<label for="file">"Select Files"</label>
|
||||||
|
|
||||||
<input type="submit" value="Get Link~" />
|
<input type="submit" value="Get Link~" />
|
||||||
<p id="cat-fact">{fact}</p>
|
<p id="cat-fact">{fact}</p>
|
||||||
|
|
Loading…
Reference in a new issue