diff --git a/src/pages/directory/domains/display.rs b/src/pages/directory/domains/display.rs index 8ea5a97..be351d8 100644 --- a/src/pages/directory/domains/display.rs +++ b/src/pages/directory/domains/display.rs @@ -3,10 +3,10 @@ * * SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL */ - use leptos::*; use leptos_router::{use_navigate, use_params_map}; use serde::{Deserialize, Serialize}; +use std::ops::Add; use crate::{ components::{ @@ -34,6 +34,46 @@ struct DnsRecord { content: String, } +fn format_zonefile(records: &Vec, domain: &str) -> String { + let formatted_records: Vec<[&str; 3]> = records + .iter() + .filter_map(|record| { + record.name.strip_suffix(domain).map(|name| { + if name.is_empty() { + ["@", &record.typ, &record.content] + } else { + [name, &record.typ, &record.content] + } + }) + }) + .collect(); + + let max_len = formatted_records.iter().fold([0, 0], |acc, x| { + [acc[0].max(x[0].len()), acc[1].max(x[1].len())] + }); + + formatted_records.iter().fold(String::new(), |acc, x| { + let key = format!( + "{}{: impl IntoView { let auth = use_authorization(); @@ -87,6 +127,7 @@ pub fn DomainDisplay() -> impl IntoView { .filter(|r| r.typ == "TXT" && r.content.contains("DKIM")) .count() .to_string(); + let zonefile = format_zonefile(&records, ¶ms.get().get("id").cloned().unwrap_or_default()); Some( view! { @@ -135,6 +176,17 @@ pub fn DomainDisplay() -> impl IntoView { .collect_view()} +
+

+ Zonefile +

+
+