mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
rc_society dashboard display (#131)
### Description Closes #130 ### Please confirm - [x] I am the legal owner or represent the legal owner of all work submitted (including LLM-generated code, if any) - [x] I consent to my changes being added to this FOSS project - [x] I have confirmed that this does not add new errors or warnings with `utils/clippy.sh` - [ ] This PR used LLMs to generate some or all of the code changes Reviewed-on: https://git.ngram.ca/OpenJam/rc-servers/pulls/131
This commit is contained in:
@@ -9,6 +9,7 @@ struct RenderData {
|
||||
is_logged_in: bool,
|
||||
display_name: Option<String>,
|
||||
server: ServerDetails,
|
||||
links: LinkDetails,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
@@ -16,6 +17,7 @@ struct ServerDetails {
|
||||
domain: String,
|
||||
cdn: String,
|
||||
auth: String,
|
||||
factory: String,
|
||||
min_version: i32,
|
||||
server_version: String,
|
||||
start_time_iso: String,
|
||||
@@ -32,6 +34,7 @@ fn server_details(conf: &oj_rc_core::persist::config::ServerConfig) -> ServerDet
|
||||
domain: conf.domain.clone(),
|
||||
cdn: conf.cdn_url.clone(),
|
||||
auth: conf.auth_url.clone(),
|
||||
factory: conf.factory_url.clone(),
|
||||
min_version: conf.minimum_version,
|
||||
server_version,
|
||||
start_time_unix,
|
||||
@@ -39,9 +42,25 @@ fn server_details(conf: &oj_rc_core::persist::config::ServerConfig) -> ServerDet
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct LinkDetails {
|
||||
feedback: String,
|
||||
support: String,
|
||||
wiki: String,
|
||||
}
|
||||
|
||||
fn links_details(links: &oj_rc_core::persist::config::LinksConfig) -> LinkDetails {
|
||||
LinkDetails {
|
||||
feedback: links.feedback_url.clone(),
|
||||
support: links.support_url.clone(),
|
||||
wiki: links.wiki_url.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
pub async fn get(handlebars_ref: Data<handlebars::Handlebars<'_>>, auth: Data<Box<oj_rc_core::UserImpl>>, server_config: Data<oj_rc_core::persist::config::ServerConfig>, user_opt: Option<Identity>, req: HttpRequest) -> Result<impl Responder, actix_web::error::Error> {
|
||||
pub async fn get(handlebars_ref: Data<handlebars::Handlebars<'_>>, auth: Data<Box<oj_rc_core::UserImpl>>, server_config: Data<oj_rc_core::persist::config::ServerConfig>, server_links: Data<oj_rc_core::persist::config::LinksConfig>, user_opt: Option<Identity>, req: HttpRequest) -> Result<impl Responder, actix_web::error::Error> {
|
||||
let server_info = server_details(server_config.as_ref());
|
||||
let links_info = links_details(server_links.as_ref());
|
||||
if let Some(user) = user_opt {
|
||||
match super::try_auth_user(Some(user), auth.as_ref(), &req).await? {
|
||||
super::LoginReturn::AuthFail(resp) => Ok(resp),
|
||||
@@ -51,6 +70,7 @@ pub async fn get(handlebars_ref: Data<handlebars::Handlebars<'_>>, auth: Data<Bo
|
||||
is_logged_in: true,
|
||||
display_name: Some(user.display_name().to_owned()),
|
||||
server: server_info,
|
||||
links: links_info,
|
||||
},
|
||||
handlebars_ref.as_ref(),
|
||||
FORM_NAME,
|
||||
@@ -66,6 +86,7 @@ pub async fn get(handlebars_ref: Data<handlebars::Handlebars<'_>>, auth: Data<Bo
|
||||
is_logged_in: false,
|
||||
display_name: None,
|
||||
server: server_info,
|
||||
links: links_info,
|
||||
},
|
||||
handlebars_ref.as_ref(),
|
||||
FORM_NAME,
|
||||
|
||||
Reference in New Issue
Block a user