add server count and current time to server list page
parent
5ebdbaa225
commit
522cbc5991
|
@ -273,6 +273,9 @@ struct ServerListPage <'a> {
|
||||||
git_version: Option <String>,
|
git_version: Option <String>,
|
||||||
servers: Vec <ServerEntry <'a>>,
|
servers: Vec <ServerEntry <'a>>,
|
||||||
news_url: Option <String>,
|
news_url: Option <String>,
|
||||||
|
connected_server_count: usize,
|
||||||
|
registered_server_count: usize,
|
||||||
|
date_rfc3339: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive (Serialize)]
|
#[derive (Serialize)]
|
||||||
|
@ -311,13 +314,19 @@ async fn handle_server_list_internal (state: &Arc <Relay>)
|
||||||
|
|
||||||
let now = Utc::now ();
|
let now = Utc::now ();
|
||||||
|
|
||||||
|
let registered_server_count = server_list.servers.len ();
|
||||||
|
let mut connected_server_count = 0;
|
||||||
|
|
||||||
let servers = server_list.servers.into_iter ()
|
let servers = server_list.servers.into_iter ()
|
||||||
.map (|x| {
|
.map (|x| {
|
||||||
let last_seen = match x.last_seen {
|
let last_seen = match x.last_seen {
|
||||||
None => "Never".into (),
|
None => "Never".into (),
|
||||||
Some (x) => match pretty_print_last_seen (now, x) {
|
Some (x) => match pretty_print_last_seen (now, x) {
|
||||||
Negative => "Error (negative time)".into (),
|
Negative => "Error (negative time)".into (),
|
||||||
Connected => "Connected".into (),
|
Connected => {
|
||||||
|
connected_server_count += 1;
|
||||||
|
"Connected".into ()
|
||||||
|
},
|
||||||
Description (s) => s.into (),
|
Description (s) => s.into (),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -330,11 +339,16 @@ async fn handle_server_list_internal (state: &Arc <Relay>)
|
||||||
})
|
})
|
||||||
.collect ();
|
.collect ();
|
||||||
|
|
||||||
|
let date_rfc3339 = now.to_rfc3339_opts (SecondsFormat::Secs, true);
|
||||||
|
|
||||||
ServerListPage {
|
ServerListPage {
|
||||||
dev_mode,
|
dev_mode,
|
||||||
git_version,
|
git_version,
|
||||||
servers,
|
servers,
|
||||||
news_url,
|
news_url,
|
||||||
|
connected_server_count,
|
||||||
|
registered_server_count,
|
||||||
|
date_rfc3339,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,14 @@ AIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAA" rel="icon" type="image/x-icon" />
|
||||||
<a href="{{news_url}}">News</a>
|
<a href="{{news_url}}">News</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<div style="padding-top: 1em;">
|
<div>
|
||||||
|
|
||||||
|
<p>Connected servers: {{connected_server_count}}</p>
|
||||||
|
|
||||||
|
<p>Registered servers: {{registered_server_count}}</p>
|
||||||
|
|
||||||
|
<p>{{date_rfc3339}}</p>
|
||||||
|
|
||||||
{{#if servers}}
|
{{#if servers}}
|
||||||
<table class="entry_list">
|
<table class="entry_list">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
Loading…
Reference in New Issue