2024-12-22 21:36:26 +00:00
|
|
|
use axum::extract::{Path, State};
|
2022-04-29 16:04:12 +00:00
|
|
|
use serde_json::{Value, json};
|
2022-04-29 02:29:10 +00:00
|
|
|
|
2024-12-22 21:36:26 +00:00
|
|
|
use crate::AppState;
|
|
|
|
use crate::errors::Error;
|
|
|
|
use crate::ressouces::zone::Zone;
|
2022-04-29 02:29:10 +00:00
|
|
|
use crate::template::Template;
|
|
|
|
|
|
|
|
|
2024-12-22 21:36:26 +00:00
|
|
|
pub async fn get_zone_records_page(
|
|
|
|
Path(zone_name): Path<String>,
|
|
|
|
State(app): State<AppState>,
|
|
|
|
) -> Result<Template<'static, Value>, Error> {
|
|
|
|
let records = Zone::get_records(&zone_name, app.db, app.records).await?;
|
2023-02-22 15:28:12 +00:00
|
|
|
|
2024-12-22 21:36:26 +00:00
|
|
|
//records.0.sort_by_key(|record| (&record.name, record.rdata));
|
2023-02-22 15:28:12 +00:00
|
|
|
|
|
|
|
Ok(Template::new(
|
2024-12-22 21:36:26 +00:00
|
|
|
"pages/records.html",
|
|
|
|
app.template_engine,
|
2023-02-22 15:28:12 +00:00
|
|
|
json!({
|
2024-12-22 21:36:26 +00:00
|
|
|
"current_zone": zone_name,
|
|
|
|
"records": records,
|
2023-02-22 15:28:12 +00:00
|
|
|
})
|
|
|
|
))
|
|
|
|
}
|