feat: display project version on frontend

This commit is contained in:
2025-09-13 18:58:30 -05:00
parent 8ec2f7d36f
commit 27b0cb877e
5 changed files with 51 additions and 33 deletions

2
Cargo.lock generated
View File

@@ -218,7 +218,7 @@ dependencies = [
[[package]] [[package]]
name = "banner" name = "banner"
version = "0.3.2" version = "0.3.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "banner" name = "banner"
version = "0.3.2" version = "0.3.3"
edition = "2024" edition = "2024"
default-run = "banner" default-run = "banner"

View File

@@ -102,9 +102,8 @@ pub fn create_router(state: BannerState) -> Router {
}; };
// Format latency, status, and code // Format latency, status, and code
let (latency_str, status, code) = ( let (latency_str, status) = (
format!("{latency:.2?}"), format!("{latency:.2?}"),
response.status().as_u16(),
format!( format!(
"{} {}", "{} {}",
response.status().as_u16(), response.status().as_u16(),
@@ -114,19 +113,9 @@ pub fn create_router(state: BannerState) -> Router {
// Log in warn if latency is above threshold, otherwise debug // Log in warn if latency is above threshold, otherwise debug
if latency > latency_threshold { if latency > latency_threshold {
warn!( warn!(latency = latency_str, status = status, "Response");
latency = latency_str,
status = status,
code = code,
"Response"
);
} else { } else {
debug!( debug!(latency = latency_str, status = status, "Response");
latency = latency_str,
status = status,
code = code,
"Response"
);
} }
}, },
) )
@@ -227,6 +216,7 @@ async fn status(State(_state): State<BannerState>) -> Json<Value> {
// For now, return basic status without accessing private fields // For now, return basic status without accessing private fields
Json(json!({ Json(json!({
"status": "operational", "status": "operational",
"version": env!("CARGO_PKG_VERSION"),
"bot": { "bot": {
"status": "running", "status": "running",
"uptime": "TODO: implement uptime tracking" "uptime": "TODO: implement uptime tracking"

View File

@@ -8,6 +8,7 @@ export interface HealthResponse {
export interface StatusResponse { export interface StatusResponse {
status: string; status: string;
version: string;
bot: { bot: {
status: string; status: string;
uptime: string; uptime: string;

View File

@@ -234,27 +234,54 @@ function App() {
</Flex> </Flex>
</Card> </Card>
)} )}
{status?.git?.commit && ( {(status?.git?.commit || status?.version) && (
<Flex justify="center" style={{ marginTop: "12px" }}> <Flex
<Text justify="center"
size="1" style={{ marginTop: "12px" }}
style={{ gap="2"
color: "#8B949E", align="center"
textDecoration: "none", >
}} {status?.version && (
> <Text
<a size="1"
href={`https://github.com/Xevion/banner/commit/${status.git.commit}`}
target="_blank"
rel="noopener noreferrer"
style={{ style={{
color: "inherit", color: "#8B949E",
}}
>
v{status.version}
</Text>
)}
{status?.version && status?.git?.commit && (
<div
style={{
width: "1px",
height: "12px",
backgroundColor: "#8B949E",
opacity: 0.3,
}}
/>
)}
{status?.git?.commit && (
<Text
size="1"
style={{
color: "#8B949E",
textDecoration: "none", textDecoration: "none",
}} }}
> >
GitHub <a
</a> href={`https://github.com/Xevion/banner/commit/${status.git.commit}`}
</Text> target="_blank"
rel="noopener noreferrer"
style={{
color: "inherit",
textDecoration: "none",
}}
>
GitHub
</a>
</Text>
)}
</Flex> </Flex>
)} )}
</Flex> </Flex>