add version to debug page

This commit is contained in:
soruh 2024-05-31 20:40:57 +02:00
parent 19c334a974
commit dd7b0ca839
5 changed files with 47 additions and 36 deletions

2
Cargo.lock generated
View File

@ -213,7 +213,7 @@ dependencies = [
[[package]] [[package]]
name = "centralex" name = "centralex"
version = "0.1.0" version = "1.0.1"
dependencies = [ dependencies = [
"async-stream", "async-stream",
"bytemuck", "bytemuck",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "centralex" name = "centralex"
version = "0.1.0" version = "1.0.1"
edition = "2021" edition = "2021"
[profile.release] [profile.release]

View File

@ -42,8 +42,15 @@ fn pack_debug_page() -> Result<(), Box<dyn std::error::Error>> {
.split_once("<!--INSERT HEAD CONTENT HERE-->") .split_once("<!--INSERT HEAD CONTENT HERE-->")
.expect("did not find head split point in html"); .expect("did not find head split point in html");
let (body_a, body_b) = body
.split_once("#INSERT VERSION HERE#")
.expect("did not find version split point in html");
let version = env!("CARGO_PKG_VERSION");
let html = minify_html::minify( let html = minify_html::minify(
format!("{head}<style>{css}</style><script>{js}</script>{body}").as_bytes(), format!("{head}<style>{css}</style><script>{js}</script>{body_a}{version}{body_b}")
.as_bytes(),
&minify_html::Cfg::spec_compliant(), &minify_html::Cfg::spec_compliant(),
); );

View File

@ -15,7 +15,7 @@
<div id="header"> <div id="header">
<p id="free_ports" /> <p id="free_ports" />
<div id="connected" class="hidden"><!--INSERT SVG HERE--></div> <div id="connected" class="hidden"><!--INSERT SVG HERE--></div>
<p id="last_ping" /> <p id="last_ping" title="v#INSERT VERSION HERE#" />
</div> </div>
<table id="table"> <table id="table">

View File

@ -149,6 +149,7 @@ window.onload = () => {
table = []; table = [];
for (let number in data.allocated_ports) { for (let number in data.allocated_ports) {
try {
let port = data.allocated_ports[number]; let port = data.allocated_ports[number];
number = +number; number = +number;
@ -183,6 +184,9 @@ window.onload = () => {
} }
table.push({ port, number, status, last_change, rejector, name }); table.push({ port, number, status, last_change, rejector, name });
} catch (error) {
console.error(error);
}
} }
for (let [timestamp, port] of data.errored_ports) { for (let [timestamp, port] of data.errored_ports) {