From 61fce5c9c6e14b66a9734331c76141960c9b8071 Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 23 May 2024 01:05:59 +0200 Subject: [PATCH] feat(web): better debug, plain, link and copy --- web/src/page/debug.rs | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/web/src/page/debug.rs b/web/src/page/debug.rs index a949258c..a3de8779 100644 --- a/web/src/page/debug.rs +++ b/web/src/page/debug.rs @@ -1,5 +1,3 @@ -use std::sync::Arc; - use leptos::*; use leptos_router::*; use crate::prelude::*; @@ -12,6 +10,7 @@ pub fn DebugPage() -> impl IntoView { }; let cached_ref: NodeRef = create_node_ref(); let auth = use_context::().expect("missing auth context"); + let (plain, set_plain) = create_signal(false); let (text, set_text) = create_signal("".to_string()); let navigate = use_navigate(); @@ -67,8 +66,25 @@ pub fn DebugPage() -> impl IntoView {
-				{move || object.get().map(|o| view! {  })}
+				{move || object.get().map(|o| if plain.get() {
+					serde_json::to_string_pretty(&o).unwrap_or_else(|e| e.to_string()).into_view()
+				} else {
+					view! {  }.into_view()
+				})}
 			
+

+ + " plain :: " + external + " :: " + copy +

} } @@ -97,7 +113,7 @@ fn DocumentNode(obj: serde_json::Value, #[prop(optional)] depth: usize) -> impl serde_json::Value::String(s) => { if s.starts_with("https://") || s.starts_with("http://") { view! { - "\""{s}"\"" + {s} }.into_view() } else { view! { @@ -111,7 +127,7 @@ fn DocumentNode(obj: serde_json::Value, #[prop(optional)] depth: usize) -> impl view! { "[\n" {arr.into_iter().map(|x| view! { - {prefix.clone()}" "",\n" + {prefix.clone()}" ""\n" }).collect_view()} {prefix.clone()}"]" }.into_view() @@ -124,7 +140,7 @@ fn DocumentNode(obj: serde_json::Value, #[prop(optional)] depth: usize) -> impl { map.into_iter() .map(|(k, v)| view! { - {prefix.clone()}" \""{k}"\": "",\n" + {prefix.clone()}" "{k}": ""\n" }) .collect_view() }