mirror of
https://github.com/transatoshi-mw/grin-explorer.git
synced 2025-10-21 21:43:40 +00:00
adjust coingecko option
This commit is contained in:
@@ -35,8 +35,6 @@ pub struct Dashboard {
|
|||||||
// mempool
|
// mempool
|
||||||
pub txns: String,
|
pub txns: String,
|
||||||
pub stem: String,
|
pub stem: String,
|
||||||
// coingecko api
|
|
||||||
pub cg_api: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Dashboard {
|
impl Dashboard {
|
||||||
@@ -66,7 +64,6 @@ impl Dashboard {
|
|||||||
breakeven_cost: String::new(),
|
breakeven_cost: String::new(),
|
||||||
txns: String::new(),
|
txns: String::new(),
|
||||||
stem: 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::Block;
|
||||||
use crate::data::Transactions;
|
use crate::data::Transactions;
|
||||||
use crate::data::Kernel;
|
use crate::data::Kernel;
|
||||||
|
use crate::requests::CONFIG;
|
||||||
|
|
||||||
|
|
||||||
// Rendering main (Dashboard) page.
|
// Rendering main (Dashboard) page.
|
||||||
@@ -30,7 +31,7 @@ fn index(dashboard: &State<Arc<Mutex<Dashboard>>>) -> Template {
|
|||||||
route: "index",
|
route: "index",
|
||||||
node_ver: &data.node_ver,
|
node_ver: &data.node_ver,
|
||||||
proto_ver: &data.proto_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")]
|
#[get("/block_list")]
|
||||||
fn block_list() -> Template {
|
fn block_list() -> Template {
|
||||||
Template::render("block_list", context! {
|
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 {
|
if index >= height {
|
||||||
Template::render("block_list", context! {
|
Template::render("block_list", context! {
|
||||||
route: "block_list",
|
route: "block_list",
|
||||||
|
cg_api: CONFIG.coingecko_api.clone(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Template::render("block_list", context! {
|
Template::render("block_list", context! {
|
||||||
route: "block_list_by_height",
|
route: "block_list_by_height",
|
||||||
|
cg_api: CONFIG.coingecko_api.clone(),
|
||||||
index,
|
index,
|
||||||
blocks,
|
blocks,
|
||||||
height,
|
height,
|
||||||
@@ -72,7 +76,8 @@ async fn block_list_by_height(input_height: &str) -> Template {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Template::render("block_list", context! {
|
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 {
|
if block.height.is_empty() == false {
|
||||||
return Template::render("block_details", context! {
|
return Template::render("block_details", context! {
|
||||||
route: "block_details",
|
route: "block_details",
|
||||||
|
cg_api: CONFIG.coingecko_api.clone(),
|
||||||
block,
|
block,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Template::render("error", context! {
|
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! {
|
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 {
|
if kernel.excess.is_empty() == false {
|
||||||
return Template::render("kernel", context! {
|
return Template::render("kernel", context! {
|
||||||
route: "kernel",
|
route: "kernel",
|
||||||
|
cg_api: CONFIG.coingecko_api.clone(),
|
||||||
kernel,
|
kernel,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return Template::render("error", context! {
|
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
|
// Unwrap Option and forward to Search page if no parameters
|
||||||
let input = match input {
|
let input = match input {
|
||||||
Some(value) => value,
|
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
|
// Check for valid chars
|
||||||
@@ -168,7 +181,8 @@ fn search(input: Option<&str>) -> Either<Template, Redirect> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Either::Left(Template::render("error", context! {
|
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
|
// Static explorer config structure
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref CONFIG: ExplorerConfig = {
|
pub static ref CONFIG: ExplorerConfig = {
|
||||||
let mut cfg = ExplorerConfig::new();
|
let mut cfg = ExplorerConfig::new();
|
||||||
let settings = Config::builder().add_source(config::File::with_name("Explorer"))
|
let settings = Config::builder().add_source(config::File::with_name("Explorer"))
|
||||||
.build().unwrap();
|
.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();
|
data.proto_ver = resp["result"]["Ok"]["protocol_version"].to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also set cg_api value
|
|
||||||
data.cg_api = CONFIG.coingecko_api.clone();
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -215,15 +215,17 @@
|
|||||||
<span style="color:grey"><i class="bi bi-github me-1"></i>v.0.1.5</span>
|
<span style="color:grey"><i class="bi bi-github me-1"></i>v.0.1.5</span>
|
||||||
</a>
|
</a>
|
||||||
<a class="text-decoration-none" href="/search">
|
<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>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% if cg_api == "on" %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col d-flex justify-content-center" style="color:grey">
|
<div class="col d-flex justify-content-center" style="color:grey">
|
||||||
Powered by CoinGecko
|
Powered by CoinGecko
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
Reference in New Issue
Block a user