adjust coingecko option

This commit is contained in:
aglkm
2024-06-01 17:38:13 +03:00
parent 99fdb00f18
commit 8f5d015f6a
4 changed files with 30 additions and 20 deletions

View File

@@ -19,6 +19,7 @@ use crate::data::Dashboard;
use crate::data::Block;
use crate::data::Transactions;
use crate::data::Kernel;
use crate::requests::CONFIG;
// Rendering main (Dashboard) page.
@@ -30,7 +31,7 @@ fn index(dashboard: &State<Arc<Mutex<Dashboard>>>) -> Template {
route: "index",
node_ver: &data.node_ver,
proto_ver: &data.proto_ver,
cg_api: &data.cg_api,
cg_api: CONFIG.coingecko_api.clone(),
})
}
@@ -39,7 +40,8 @@ fn index(dashboard: &State<Arc<Mutex<Dashboard>>>) -> Template {
#[get("/block_list")]
fn block_list() -> Template {
Template::render("block_list", context! {
route: "block_list",
route: "block_list",
cg_api: CONFIG.coingecko_api.clone(),
})
}
@@ -60,11 +62,13 @@ async fn block_list_by_height(input_height: &str) -> Template {
if index >= height {
Template::render("block_list", context! {
route: "block_list",
route: "block_list",
cg_api: CONFIG.coingecko_api.clone(),
})
} else {
Template::render("block_list", context! {
route: "block_list_by_height",
route: "block_list_by_height",
cg_api: CONFIG.coingecko_api.clone(),
index,
blocks,
height,
@@ -72,7 +76,8 @@ async fn block_list_by_height(input_height: &str) -> Template {
}
} else {
Template::render("block_list", context! {
route: "block_list",
route: "block_list",
cg_api: CONFIG.coingecko_api.clone(),
})
}
}
@@ -88,14 +93,16 @@ async fn block_details_by_height(height: &str) -> Template {
if block.height.is_empty() == false {
return Template::render("block_details", context! {
route: "block_details",
route: "block_details",
cg_api: CONFIG.coingecko_api.clone(),
block,
});
}
}
Template::render("error", context! {
route: "error",
route: "error",
cg_api: CONFIG.coingecko_api.clone(),
})
}
@@ -114,7 +121,8 @@ async fn block_header_by_hash(hash: &str) -> Either<Template, Redirect> {
}
return Either::Left(Template::render("error", context! {
route: "error",
route: "error",
cg_api: CONFIG.coingecko_api.clone(),
}))
}
@@ -128,13 +136,15 @@ async fn kernel(excess: &str) -> Template {
if kernel.excess.is_empty() == false {
return Template::render("kernel", context! {
route: "kernel",
route: "kernel",
cg_api: CONFIG.coingecko_api.clone(),
kernel,
})
}
return Template::render("error", context! {
route: "error",
route: "error",
cg_api: CONFIG.coingecko_api.clone(),
})
}
@@ -147,7 +157,10 @@ fn search(input: Option<&str>) -> Either<Template, Redirect> {
// Unwrap Option and forward to Search page if no parameters
let input = match input {
Some(value) => value,
None => return Either::Left(Template::render("search", context! { route: "search", })),
None => return Either::Left(Template::render("search", context! {
route: "search",
cg_api: CONFIG.coingecko_api.clone(),
})),
};
// Check for valid chars
@@ -168,7 +181,8 @@ fn search(input: Option<&str>) -> Either<Template, Redirect> {
}
Either::Left(Template::render("error", context! {
route: "error",
route: "error",
cg_api: CONFIG.coingecko_api.clone(),
}))
}