From 627c51e745569be83ad887051cc5500ad6113ddb Mon Sep 17 00:00:00 2001 From: Astro Date: Mon, 24 Oct 2022 02:43:14 +0200 Subject: [PATCH] pkgs/switch-report: redesign tables --- nix/pkgs/switch-report.nix | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/nix/pkgs/switch-report.nix b/nix/pkgs/switch-report.nix index bc1ccf5..98552ee 100644 --- a/nix/pkgs/switch-report.nix +++ b/nix/pkgs/switch-report.nix @@ -12,13 +12,15 @@ let then # group ports linksByPorts // { - ${lib.concatStringsSep "
" links.${linkName}.ports} = linkName; + ${lib.concatMapStringsSep "
" (port: + "`${port}`" + ) links.${linkName}.ports} = linkName; } else # expand lists of access ports to seperate rows builtins.foldl' (linksByPorts': port: linksByPorts' // { - ${port} = linkName; + "`${port}`" = linkName; } ) linksByPorts links.${linkName}.ports ) {} (builtins.attrNames links); @@ -28,8 +30,8 @@ let `${model}` @ **${location}** - |Name|Ports|Trunk|Networks| - |-:|-:|:-:|:-| + |Ports|Target|Networks| + |-:|:-:|:-| ${lib.concatMapStrings (ports: let linkName = linksByPorts.${ports}; @@ -37,17 +39,19 @@ let in '' |${ lib.optionalString (link.group != null) - "Group ${toString link.group}: " - }**${ + "**Group ${toString link.group}**
" + }${ + ports + }|**${ linkName }**|${ - ports - }|${ - lib.optionalString link.trunk "✓" - }|${ - lib.concatStringsSep "
" ( + if link.trunk + then "**Trunk:** " + else "**Access:** " + }${ + lib.concatStringsSep ", " ( map (net: - "${net} (`${toString config.site.net.${net}.vlan}`)" + "${net} (`${toString config.site.net.${net}.vlan}`)" ) (builtins.sort (a: b: let vlanA = config.site.net.${a}.vlan;