Add current fire rating to dashboard
This commit is contained in:
parent
8b1cb60ef1
commit
e3e7e4442b
|
|
@ -63,6 +63,7 @@ struct DashboardTemplate {
|
|||
logged_in: bool,
|
||||
user: UserData,
|
||||
user_roles: Vec<crate::user::UserRolesDisplay>,
|
||||
fire_rating: String,
|
||||
}
|
||||
|
||||
pub async fn index(
|
||||
|
|
@ -83,7 +84,10 @@ pub async fn index(
|
|||
HtmlTemplate(template).into_response()
|
||||
}
|
||||
} else {
|
||||
let template = IndexTemplate { logged_in, user: UserData::default() };
|
||||
let template = IndexTemplate {
|
||||
logged_in,
|
||||
user: UserData::default(),
|
||||
};
|
||||
HtmlTemplate(template).into_response()
|
||||
}
|
||||
}
|
||||
|
|
@ -104,10 +108,13 @@ pub async fn dashboard(
|
|||
// Get user roles
|
||||
let user_roles = get_user_roles_display(userid, &db_pool.clone()).await;
|
||||
|
||||
let fire_rating = get_seguin_fire_rating().await;
|
||||
|
||||
let template = DashboardTemplate {
|
||||
logged_in,
|
||||
user,
|
||||
user_roles,
|
||||
fire_rating,
|
||||
};
|
||||
HtmlTemplate(template).into_response()
|
||||
} else {
|
||||
|
|
@ -223,7 +230,6 @@ pub async fn useradmin(
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
|
||||
if is_authorized("/useradmin", user_data, db_pool.clone()).await {
|
||||
// Get user roles
|
||||
let user_roles = get_user_roles_display(userid, &db_pool.clone()).await;
|
||||
|
|
@ -308,3 +314,29 @@ pub async fn contact(Extension(user_data): Extension<Option<UserData>>) -> impl
|
|||
let template = ContactTemplate { logged_in, user };
|
||||
HtmlTemplate(template)
|
||||
}
|
||||
|
||||
pub async fn get_seguin_fire_rating() -> String {
|
||||
let response = reqwest::get("https://www.seguin.ca/en/explore-play/firerating.aspx")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let fire_rating: String;
|
||||
|
||||
let body = response.text().await.unwrap();
|
||||
|
||||
let result = body.find(r#"<img title="#);
|
||||
if let Some(result) = result {
|
||||
let link = body[result..].to_string();
|
||||
let link_end = link.find(r#">"#);
|
||||
if let Some(link_end) = link_end {
|
||||
fire_rating = link[..link_end +1].to_string();
|
||||
} else {
|
||||
println!("not found");
|
||||
fire_rating = "0".to_string();
|
||||
}
|
||||
} else {
|
||||
fire_rating = "0".to_string();
|
||||
}
|
||||
|
||||
fire_rating
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,21 @@
|
|||
{% extends "authorized.html" %}
|
||||
{% block center %}
|
||||
<div class="row align-items-stretch">
|
||||
<div class="col-md-6">
|
||||
<h2>Points of Interest</h2>
|
||||
<a href="https://www.tlccreations.ca" target="_blank" rel="noopener noreferrer"><img title="TLC Creations"
|
||||
src="https://www.tlccreations.ca/assets/images/banner.png" class="img-fluid" alt="TLC Creations"></a>
|
||||
<a href="https://www.seguin.ca" target="_blank" rel="noopener noreferrer"><img title="Seguin"
|
||||
src="https://www.seguin.ca/en/images/structure/badge.svg" class="img-fluid" alt="Seguin Township"></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-stretch" id="firerating">
|
||||
<a href="https://www.seguin.ca/en/explore-play/firerating.aspx" target="_blank" rel="noopener noreferrer"><img
|
||||
title="Fire Rating: MODERATE" src="https://www.seguin.ca/en/resources/firemodseguin.jpg"
|
||||
class="img-fluid" alt="Fire Rating: MODERATE"></a>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Web links</h2>
|
||||
<h3>TLC Creations</h3>
|
||||
<ul>
|
||||
<li><a href="https://www.tlccreations.ca" target="_blank" rel="noopener noreferrer">TLC Creations</a></li>
|
||||
</ul>
|
||||
<h3>Fonts</h3>
|
||||
<ul>
|
||||
<li><a href="https://fonts.google.com" target="_blank" rel="noopener noreferrer">Google fonts</a></li>
|
||||
|
|
@ -15,7 +25,8 @@
|
|||
<ul>
|
||||
<li><a href="https://www.ancestry.ca" target="_blank" rel="noopener noreferrer">Ancestry</a></li>
|
||||
<li><a href="https://www.geni.com" target="_blank" rel="noopener noreferrer">Geni</a></li>
|
||||
<li><a href="http://www.tracingroots.ca/" target="_blank" rel="noopener noreferrer">Tracing Roots - Forth Family Tree</a></li>
|
||||
<li><a href="http://www.tracingroots.ca/" target="_blank" rel="noopener noreferrer">Tracing Roots - Forth Family
|
||||
Tree</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock center %}
|
||||
Loading…
Reference in New Issue