forked from local-resilience-tech/site-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
display dummy public key from server
- Loading branch information
1 parent
df67aef
commit 5b67155
Showing
8 changed files
with
81 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod apps; | ||
pub mod this_node; | ||
pub mod this_region; | ||
pub mod this_site; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use rocket::serde::json::Json; | ||
use rocket::serde::{Deserialize, Serialize}; | ||
use rocket::Route; | ||
use thiserror::Error; | ||
|
||
#[derive(sqlx::FromRow, Serialize, Deserialize)] | ||
#[serde(crate = "rocket::serde")] | ||
pub struct NodeDetails { | ||
pub public_key: String, | ||
} | ||
|
||
#[derive(Debug, Error, Responder)] | ||
pub enum ThisNodeError {} | ||
|
||
#[get("/", format = "json")] | ||
async fn show() -> Result<Json<NodeDetails>, ThisNodeError> { | ||
let dummy_details = NodeDetails { | ||
public_key: "xxx".to_string(), | ||
}; | ||
|
||
Ok(Json(dummy_details)) | ||
} | ||
|
||
pub fn routes() -> Vec<Route> { | ||
routes![show] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,50 @@ | ||
import { Box, Text } from "@chakra-ui/react" | ||
import { VStack, Text, Table } from "@chakra-ui/react" | ||
import { useEffect, useState } from "react" | ||
import ThisSiteApi from "../api" | ||
import { NodeDetails } from "../types" | ||
|
||
const api = new ThisSiteApi() | ||
|
||
const getNode = async (): Promise<NodeDetails | null> => { | ||
const result = await api.showNode() | ||
if ("Ok" in result) return result.Ok | ||
return null | ||
} | ||
|
||
export default function ThisNode() { | ||
const [node, setNode] = useState<NodeDetails | null>(null) | ||
|
||
const fetchNode = async () => { | ||
const node = await getNode() | ||
console.log("fetched node", node) | ||
setNode(node) | ||
} | ||
|
||
useEffect(() => { | ||
fetchNode() | ||
}, []) | ||
|
||
if (!node) { | ||
return <></> | ||
} | ||
|
||
return ( | ||
<Box> | ||
<Text>This node</Text> | ||
</Box> | ||
<VStack alignItems={"stretch"}> | ||
<Text textStyle="xl">This P2Panda Node</Text> | ||
<Table.Root variant="line"> | ||
<Table.Header> | ||
<Table.Row> | ||
<Table.ColumnHeader>Key</Table.ColumnHeader> | ||
<Table.ColumnHeader>Value</Table.ColumnHeader> | ||
</Table.Row> | ||
</Table.Header> | ||
<Table.Body> | ||
<Table.Row> | ||
<Table.Cell>Public key</Table.Cell> | ||
<Table.Cell>{node.public_key}</Table.Cell> | ||
</Table.Row> | ||
</Table.Body> | ||
</Table.Root> | ||
</VStack> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,7 @@ export type RegionDetails = { | |
name: string | ||
description: string | ||
} | ||
|
||
export type NodeDetails = { | ||
public_key: string | ||
} |