diff --git a/app/src/components/NodeDisplay.module.scss b/app/src/components/NodeDisplay.module.scss index 3c80077..c012c94 100644 --- a/app/src/components/NodeDisplay.module.scss +++ b/app/src/components/NodeDisplay.module.scss @@ -1,9 +1,18 @@ .container { - max-width: 400px; + width: 400px; overflow-wrap: break-word; overflow-y: auto; border: 1px solid lightgray; + border-radius: 4px; +} +.header { + padding: 2px 12px; + background-color: lightgray; + color: gray; +} + +.body { padding: 12px; } \ No newline at end of file diff --git a/app/src/components/NodeDisplay.tsx b/app/src/components/NodeDisplay.tsx index aef9edb..c40e7b0 100644 --- a/app/src/components/NodeDisplay.tsx +++ b/app/src/components/NodeDisplay.tsx @@ -10,15 +10,33 @@ export default function NodeDisplay({ id }: NodeDisplayProps) { queryKey: ["fetchNode", id], queryFn: async () => { const resp = await fetch(`http://localhost:5195/node/${id}`); - console.log("id", resp); - return "helloge"; + const json = await resp.json(); + return json; }, }); + const { isSuccess, status, data } = query; return (
- Node {id} -

{JSON.stringify(query)}

+
+ ID {id} +
+
+ {isSuccess ? ( + + ) : ( + <>Status: {status} + )} +
); } + +function NodeDisplayLoaded({ id, data }) { + return ( + <> + Node {id} +

{JSON.stringify(data)}

+ + ); +} diff --git a/crates/panorama-daemon/src/error.rs b/crates/panorama-daemon/src/error.rs index 7feba6b..d87307e 100644 --- a/crates/panorama-daemon/src/error.rs +++ b/crates/panorama-daemon/src/error.rs @@ -12,6 +12,7 @@ pub struct AppError(miette::Report); // Tell axum how to convert `AppError` into a response. impl IntoResponse for AppError { fn into_response(self) -> Response { + eprintln!("Encountered error: {}", self.0); ( StatusCode::INTERNAL_SERVER_ERROR, format!("Something went wrong: {}", self.0), diff --git a/crates/panorama-daemon/src/main.rs b/crates/panorama-daemon/src/main.rs index 3e2f09d..bb2d63d 100644 --- a/crates/panorama-daemon/src/main.rs +++ b/crates/panorama-daemon/src/main.rs @@ -56,7 +56,7 @@ async fn main() -> Result<()> { // build our application with a single route let app = Router::new() .route("/", get(|| async { "Hello, World!" })) - .route("/node/{id}", get(get_node)) + .route("/node/:id", get(get_node)) .route("/journal/get_todays_journal_id", get(get_todays_journal_id)) .layer(ServiceBuilder::new().layer(cors)) .with_state(state); diff --git a/crates/panorama-daemon/src/node.rs b/crates/panorama-daemon/src/node.rs index b8efd14..c733f93 100644 --- a/crates/panorama-daemon/src/node.rs +++ b/crates/panorama-daemon/src/node.rs @@ -13,15 +13,31 @@ pub async fn get_node( ) -> AppResult> { let result = state.db.run_script( " - ?[extra_data] := *node{ id, extra_data }, id = $node_id + j[plaintext] := *journal{ node_id, plaintext }, node_id = $node_id + j[plaintext] := not *journal{ node_id }, node_id = $node_id, plaintext = null + + jd[day] := *journal_days{ node_id, day }, node_id = $node_id + jd[day] := not *journal_days{ node_id }, node_id = $node_id, day = null + + ?[extra_data, plaintext, day] := *node{ id, extra_data }, + j[plaintext], + jd[day], + id = $node_id + :limit 1 ", btmap! {"node_id".to_owned() => node_id.clone().into()}, ScriptMutability::Immutable, )?; - println!("REUSLT {:?}", result); + let row = &result.rows[0]; + let extra_data = row[0].get_str(); + let plaintext = row[1].get_str(); + let day = row[2].get_str(); Ok(Json(json!({ "node": node_id, + "extra_data": extra_data, + "plaintext": plaintext, + "day": day, }))) }