diff --git a/lib/towerops_web/live/insights_live/index.ex b/lib/towerops_web/live/insights_live/index.ex index a21b876b..904691cb 100644 --- a/lib/towerops_web/live/insights_live/index.ex +++ b/lib/towerops_web/live/insights_live/index.ex @@ -144,6 +144,17 @@ defmodule ToweropsWeb.InsightsLive.Index do def source_classes("system"), do: "bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300" def source_classes(_), do: "bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400" + @doc """ + Display label for a source. Acronyms render uppercase; everything else + capitalises the first letter so the badge reads "Preseem" rather than + "preseem". Picked over CSS `capitalize` because that produces "Snmp" + and "Ai" instead of "SNMP" and "AI". + """ + def source_label("ai"), do: "AI" + def source_label("snmp"), do: "SNMP" + def source_label(other) when is_binary(other), do: String.capitalize(other) + def source_label(other), do: other + @doc false def build_filter_params(base, overrides) do base diff --git a/lib/towerops_web/live/insights_live/index.html.heex b/lib/towerops_web/live/insights_live/index.html.heex index 0292cef9..fa336345 100644 --- a/lib/towerops_web/live/insights_live/index.html.heex +++ b/lib/towerops_web/live/insights_live/index.html.heex @@ -75,14 +75,14 @@ ~p"/insights?#{build_filter_params(%{status: @filter_status, urgency: @filter_urgency}, %{source: source})}" } class={[ - "rounded-md px-2 py-1 text-xs font-medium capitalize", + "rounded-md px-2 py-1 text-xs font-medium", if(@filter_source == source, do: "bg-gray-200 text-gray-800 dark:bg-white/20 dark:text-white", else: "text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-white/10" ) ]} > - {source} + {source_label(source)} @@ -252,10 +252,10 @@ <%!-- Source badge --%> - {insight.source} + {source_label(insight.source)} <%!-- AI badge — present on any LLM-enriched insight --%>