report work

This commit is contained in:
Mitchell Marino 2023-04-14 20:12:37 -05:00
parent f4ffe71556
commit 9c10def7d2
2 changed files with 40 additions and 9 deletions

View File

@ -77,7 +77,7 @@ pub async fn get_report(
} }
}; };
// render report // render report to html.
let mut context = Context::new(); let mut context = Context::new();
context.insert("grade", &report_query.grade); context.insert("grade", &report_query.grade);
context.insert("date", &Local::now().format("%Y-%m-%d").to_string()); context.insert("date", &Local::now().format("%Y-%m-%d").to_string());
@ -88,12 +88,15 @@ pub async fn get_report(
return ( return (
StatusCode::BAD_REQUEST, StatusCode::BAD_REQUEST,
Json(json!({ Json(json!({
"error": format!("Unknown error creating event: {}", err) "error": format!("Unknown error creating event: {:?}", err)
})), })),
) )
.into_response() .into_response()
} }
}; };
todo!() // render html to pdf
println!("{}", report);
(StatusCode::OK, "").into_response()
} }

View File

@ -3,29 +3,57 @@
<head> <head>
<title>Student Point Report Grade {{ grade }}</title> <title>Student Point Report Grade {{ grade }}</title>
<style> <style>
/* color theme */
:root {
--primary-color: #9aedf4;
--secondary-color: #f2f2f2;
--text-color: #333;
}
/* zebra striping */ /* zebra striping */
tr:nth-child(even) { tr:nth-child(even) {
background-color: #f2f2f2; background-color: var(--secondary-color);
} }
/* table styling */ /* table styling */
table { table {
border-collapse: collapse; border-collapse: collapse;
width: 100%; width: 100%;
margin: 20px 0;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
font-family: Arial, sans-serif;
color: var(--text-color);
} }
th, td { th, td {
text-align: left; text-align: left;
padding: 8px; padding: 12px;
border: 1px solid #ddd; border: 1px solid #ddd;
} }
th { th {
background-color: #4CAF50; background-color: var(--primary-color);
color: white; color: white;
font-weight: normal;
}
/* header styling */
header {
background-color: var(--primary-color);
color: white;
padding: 30px 20px;
display: flex;
justify-content: space-between;
align-items: center;
font-family: Arial, sans-serif;
}
h1 {
margin: 0;
font-size: 32px;
font-weight: normal;
} }
</style> </style>
</head> </head>
<body> <body>
<header>
<h1>Student Point Report Grade {{ grade }}</h1> <h1>Student Point Report Grade {{ grade }}</h1>
<p>Date: {{ date }}</p> <p style="margin: 0;">{{ date }}</p>
</header>
<table> <table>
<thead> <thead>
<tr> <tr>
@ -36,7 +64,7 @@
<tbody> <tbody>
{% for user in users %} {% for user in users %}
<tr> <tr>
<td>{{ user.name }}</td> <td>{{ user.username }}</td>
<td>{{ user.points }}</td> <td>{{ user.points }}</td>
</tr> </tr>
{% endfor %} {% endfor %}