mirror of
https://github.com/Xevion/banner.git
synced 2025-12-06 01:14:22 -06:00
feat: display project version on frontend
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -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",
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -234,8 +234,34 @@ function App() {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
{(status?.git?.commit || status?.version) && (
|
||||||
|
<Flex
|
||||||
|
justify="center"
|
||||||
|
style={{ marginTop: "12px" }}
|
||||||
|
gap="2"
|
||||||
|
align="center"
|
||||||
|
>
|
||||||
|
{status?.version && (
|
||||||
|
<Text
|
||||||
|
size="1"
|
||||||
|
style={{
|
||||||
|
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 && (
|
{status?.git?.commit && (
|
||||||
<Flex justify="center" style={{ marginTop: "12px" }}>
|
|
||||||
<Text
|
<Text
|
||||||
size="1"
|
size="1"
|
||||||
style={{
|
style={{
|
||||||
@@ -255,6 +281,7 @@ function App() {
|
|||||||
GitHub
|
GitHub
|
||||||
</a>
|
</a>
|
||||||
</Text>
|
</Text>
|
||||||
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
Reference in New Issue
Block a user