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>,
|
||||
servers: Vec <ServerEntry <'a>>,
|
||||
news_url: Option <String>,
|
||||
connected_server_count: usize,
|
||||
registered_server_count: usize,
|
||||
date_rfc3339: String,
|
||||
}
|
||||
|
||||
#[derive (Serialize)]
|
||||
|
@ -311,13 +314,19 @@ async fn handle_server_list_internal (state: &Arc <Relay>)
|
|||
|
||||
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 ()
|
||||
.map (|x| {
|
||||
let last_seen = match x.last_seen {
|
||||
None => "Never".into (),
|
||||
Some (x) => match pretty_print_last_seen (now, x) {
|
||||
Negative => "Error (negative time)".into (),
|
||||
Connected => "Connected".into (),
|
||||
Connected => {
|
||||
connected_server_count += 1;
|
||||
"Connected".into ()
|
||||
},
|
||||
Description (s) => s.into (),
|
||||
},
|
||||
};
|
||||
|
@ -330,11 +339,16 @@ async fn handle_server_list_internal (state: &Arc <Relay>)
|
|||
})
|
||||
.collect ();
|
||||
|
||||
let date_rfc3339 = now.to_rfc3339_opts (SecondsFormat::Secs, true);
|
||||
|
||||
ServerListPage {
|
||||
dev_mode,
|
||||
git_version,
|
||||
servers,
|
||||
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>
|
||||
{{/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}}
|
||||
<table class="entry_list">
|
||||
<thead>
|
||||
|
|
Loading…
Reference in New Issue