feat: resolve linter warnings, optimize tables scroll behavior with top scroll sync, and extract reusable table macros

This commit is contained in:
2026-05-31 06:03:54 +05:00
parent 478d5f3c17
commit 58c929dd38
15 changed files with 718 additions and 325 deletions
+1
View File
@@ -23,6 +23,7 @@ where
}
/// Lower-level helper function to write audit log entries directly to the database.
#[allow(clippy::too_many_arguments)]
pub async fn log_action(
db: &mongodb::Database,
user_opt: Option<&AuthenticatedUser>,
+14 -18
View File
@@ -57,10 +57,8 @@ impl MongoAuditRepository {
if let Some(ent_id_str) = entity_id {
let trimmed = ent_id_str.trim();
if !trimmed.is_empty() {
if let Ok(oid) = ObjectId::parse_str(trimmed) {
filter.insert("entity_id", oid);
}
if let Ok(oid) = ObjectId::parse_str(trimmed) {
filter.insert("entity_id", oid);
}
}
@@ -69,25 +67,23 @@ impl MongoAuditRepository {
if let Some(start) = start_date {
let trimmed = start.trim();
if !trimmed.is_empty() {
if let Ok(naive_date) = chrono::NaiveDate::parse_from_str(trimmed, "%Y-%m-%d") {
if let Some(naive_datetime) = naive_date.and_hms_opt(0, 0, 0) {
let dt = chrono::DateTime::<chrono::Utc>::from_naive_utc_and_offset(naive_datetime, chrono::Utc);
date_query.insert("$gte", mongodb::bson::DateTime::from_chrono(dt));
}
}
if let Some(naive_datetime) = chrono::NaiveDate::parse_from_str(trimmed, "%Y-%m-%d")
.ok()
.and_then(|d| d.and_hms_opt(0, 0, 0))
{
let dt = chrono::DateTime::<chrono::Utc>::from_naive_utc_and_offset(naive_datetime, chrono::Utc);
date_query.insert("$gte", mongodb::bson::DateTime::from_chrono(dt));
}
}
if let Some(end) = end_date {
let trimmed = end.trim();
if !trimmed.is_empty() {
if let Ok(naive_date) = chrono::NaiveDate::parse_from_str(trimmed, "%Y-%m-%d") {
if let Some(naive_datetime) = naive_date.and_hms_opt(23, 59, 59) {
let dt = chrono::DateTime::<chrono::Utc>::from_naive_utc_and_offset(naive_datetime, chrono::Utc);
date_query.insert("$lte", mongodb::bson::DateTime::from_chrono(dt));
}
}
if let Some(naive_datetime) = chrono::NaiveDate::parse_from_str(trimmed, "%Y-%m-%d")
.ok()
.and_then(|d| d.and_hms_opt(23, 59, 59))
{
let dt = chrono::DateTime::<chrono::Utc>::from_naive_utc_and_offset(naive_datetime, chrono::Utc);
date_query.insert("$lte", mongodb::bson::DateTime::from_chrono(dt));
}
}
+14
View File
@@ -121,6 +121,13 @@ pub struct LoggingTemplate {
pub authenticated: bool,
}
#[derive(Template)]
#[template(path = "docs/tables.html")]
pub struct TablesTemplate {
pub username: String,
pub authenticated: bool,
}
// Define individual handlers
pub async fn index_handler(
user_opt: Option<AuthenticatedUser>,
@@ -221,3 +228,10 @@ pub async fn logging_handler(
let (authenticated, username) = get_session_info(user_opt);
Ok(HtmlTemplate(LoggingTemplate { username, authenticated }))
}
pub async fn tables_handler(
user_opt: Option<AuthenticatedUser>,
) -> Result<impl IntoResponse, AppError> {
let (authenticated, username) = get_session_info(user_opt);
Ok(HtmlTemplate(TablesTemplate { username, authenticated }))
}
+2 -1
View File
@@ -5,7 +5,7 @@ use self::handlers::{
index_handler, buttons_handler, inputs_handler, date_time_handler,
combobox_handler, toggles_handler, modals_handler, sheets_handler,
tabs_accordion_handler, visuals_handler, scrollbars_handler, feedback_handler,
logging_handler,
logging_handler, tables_handler,
};
pub fn router<S>() -> Router<S>
@@ -29,4 +29,5 @@ where
.route("/docs/scrollbars", get(scrollbars_handler))
.route("/docs/feedback", get(feedback_handler))
.route("/docs/logging", get(logging_handler))
.route("/docs/tables", get(tables_handler))
}
+7 -7
View File
@@ -76,12 +76,12 @@ html, body {
/* Custom Scrollbars */
* {
scrollbar-width: thin;
scrollbar-color: hsl(var(--border)) transparent;
scrollbar-color: rgba(100, 116, 139, 0.5) rgba(15, 23, 42, 0.4);
}
::-webkit-scrollbar {
width: 6px;
height: 6px;
width: 8px;
height: 8px;
}
::-webkit-scrollbar-button {
@@ -89,19 +89,19 @@ html, body {
}
::-webkit-scrollbar-track {
background: transparent;
background: rgba(15, 23, 42, 0.4);
border-radius: 9999px;
}
::-webkit-scrollbar-thumb {
background: hsl(var(--border));
background: rgba(100, 116, 139, 0.5);
border-radius: 9999px;
border: 1px solid transparent;
background-clip: padding-box;
transition: background-color 0.2s ease;
}
::-webkit-scrollbar-thumb:hover {
background: hsl(var(--muted-foreground));
background: rgba(148, 163, 184, 0.8);
}
/* Custom Date/Time Inputs */