Skip to content

Commit

Permalink
feat: add link to thread in dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonVirgo committed Aug 5, 2024
1 parent 08911e2 commit db6b440
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/routes/pages/dashboard.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use crate::{
components::header::{generate_header, Header},
utils::app_state::AppState,
scraping::parser::ThreadURL,
utils::{
app_state::AppState,
url::{ForumURL, URLType},
},
};
use actix_web::{get, web, HttpResponse, Responder};
use maud::html;
Expand Down Expand Up @@ -49,6 +53,8 @@ async fn dashboard(
title: format!("Dashboard - {}", thread_id).as_str(),
});

let thread = ForumURL::new(thread_id.clone());

let gen_url = |url: &str| format!("/api/dashboard/{}/{}", url, thread_id);
let get_url_param = |param: &str| format!("/dashboard/{}?d={}", thread_id, param);

Expand Down Expand Up @@ -76,8 +82,11 @@ async fn dashboard(
let markup = html! {
(header)
body."bg-zinc-900 w-screen h-screen flex flex-row items-center justify-center text-white" {
div."bg-zinc-800 border-r border-zinc-600 shrink h-full" {
ul."w-64 flex flex-col gap-2 p-4"{
div."bg-zinc-800 border-r border-zinc-600 p-4 shrink h-full flex flex-col gap-2" {
h1."text-3xl text-white font-bold pb-2" { "Dashboard" }
a."pb-2 underline hover:pointer hover:italic" href=(thread.url(URLType::Thread)) target="_blank" rel="noopener" { "Open Thread URL" }
hr;
ul."w-64 flex flex-col gap-2"{
@for (tab_name, tab_id) in tabs.iter() {
li."cursor-pointer" hx-get=(gen_url(tab_name)) hx-target="#dashboard-content" hx-trigger=(get_htmx_trigger(tab_id)) hx-push-url=(get_url_param(tab_id)) {
(tab_name.chars().next().map(|c| c.to_uppercase().collect::<String>() + &tab_name[c.len_utf8()..]).unwrap_or(tab_name.to_string()))
Expand Down

0 comments on commit db6b440

Please sign in to comment.