mirror of
https://github.com/transatoshi-mw/grin-explorer.git
synced 2025-10-21 13:33:41 +00:00
adjust coingecko option
This commit is contained in:
@@ -35,8 +35,6 @@ pub struct Dashboard {
|
||||
// mempool
|
||||
pub txns: String,
|
||||
pub stem: String,
|
||||
// coingecko api
|
||||
pub cg_api: String,
|
||||
}
|
||||
|
||||
impl Dashboard {
|
||||
@@ -66,7 +64,6 @@ impl Dashboard {
|
||||
breakeven_cost: String::new(),
|
||||
txns: String::new(),
|
||||
stem: String::new(),
|
||||
cg_api: String::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
38
src/main.rs
38
src/main.rs
@@ -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(),
|
||||
}))
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,7 @@ use crate::Kernel;
|
||||
|
||||
// Static explorer config structure
|
||||
lazy_static! {
|
||||
static ref CONFIG: ExplorerConfig = {
|
||||
pub static ref CONFIG: ExplorerConfig = {
|
||||
let mut cfg = ExplorerConfig::new();
|
||||
let settings = Config::builder().add_source(config::File::with_name("Explorer"))
|
||||
.build().unwrap();
|
||||
@@ -94,9 +94,6 @@ pub async fn get_status(dashboard: Arc<Mutex<Dashboard>>) -> Result<(), anyhow::
|
||||
data.proto_ver = resp["result"]["Ok"]["protocol_version"].to_string();
|
||||
}
|
||||
|
||||
// Also set cg_api value
|
||||
data.cg_api = CONFIG.coingecko_api.clone();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@@ -215,15 +215,17 @@
|
||||
<span style="color:grey"><i class="bi bi-github me-1"></i>v.0.1.5</span>
|
||||
</a>
|
||||
<a class="text-decoration-none" href="/search">
|
||||
<span style="color:grey"><i class="bi bi-search me-1"></i>search</span>
|
||||
<span style="color:grey"><i class="bi bi-search me-1"></i>Search</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% if cg_api == "on" %}
|
||||
<div class="row">
|
||||
<div class="col d-flex justify-content-center" style="color:grey">
|
||||
Powered by CoinGecko
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
Reference in New Issue
Block a user