Add enrichment status badge column to contacts table
This commit is contained in:
parent
915e8bdccf
commit
72b272cf5c
1 changed files with 27 additions and 1 deletions
|
|
@ -72,6 +72,29 @@ defmodule MicrowavepropWeb.ContactLive.Index do
|
||||||
defp validate_sort_order(order) when order in ~w(asc desc), do: order
|
defp validate_sort_order(order) when order in ~w(asc desc), do: order
|
||||||
defp validate_sort_order(_), do: @default_sort_order
|
defp validate_sort_order(_), do: @default_sort_order
|
||||||
|
|
||||||
|
@enrichment_fields [:hrrr_status, :weather_status, :terrain_status, :iemre_status]
|
||||||
|
@done_statuses [:complete, :unavailable]
|
||||||
|
|
||||||
|
defp enrichment_badge(contact) do
|
||||||
|
statuses = Enum.map(@enrichment_fields, &Map.get(contact, &1))
|
||||||
|
done = Enum.count(statuses, &(&1 in @done_statuses))
|
||||||
|
failed = Enum.count(statuses, &(&1 == :failed))
|
||||||
|
|
||||||
|
{label, class} =
|
||||||
|
cond do
|
||||||
|
done == 4 -> {"Complete", "badge-success"}
|
||||||
|
failed > 0 -> {"Failed", "badge-error"}
|
||||||
|
done > 0 -> {"Partial", "badge-warning"}
|
||||||
|
true -> {"Pending", "badge-ghost"}
|
||||||
|
end
|
||||||
|
|
||||||
|
assigns = %{label: label, class: class}
|
||||||
|
|
||||||
|
~H"""
|
||||||
|
<span class={["badge badge-xs", @class]}>{@label}</span>
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
|
|
@ -111,6 +134,7 @@ defmodule MicrowavepropWeb.ContactLive.Index do
|
||||||
<th>Band</th>
|
<th>Band</th>
|
||||||
<th>Mode</th>
|
<th>Mode</th>
|
||||||
<th>Distance (km)</th>
|
<th>Distance (km)</th>
|
||||||
|
<th>Enriched</th>
|
||||||
<th>Submitted</th>
|
<th>Submitted</th>
|
||||||
<th>Timestamp (UTC)</th>
|
<th>Timestamp (UTC)</th>
|
||||||
<th>Added (UTC)</th>
|
<th>Added (UTC)</th>
|
||||||
|
|
@ -119,7 +143,7 @@ defmodule MicrowavepropWeb.ContactLive.Index do
|
||||||
<tbody>
|
<tbody>
|
||||||
<%= for {primary, reciprocals} <- @grouped_contacts do %>
|
<%= for {primary, reciprocals} <- @grouped_contacts do %>
|
||||||
<tr class="h-1">
|
<tr class="h-1">
|
||||||
<td colspan="11"></td>
|
<td colspan="12"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr
|
<tr
|
||||||
class={[
|
class={[
|
||||||
|
|
@ -145,6 +169,7 @@ defmodule MicrowavepropWeb.ContactLive.Index do
|
||||||
<td>{primary.mode}</td>
|
<td>{primary.mode}</td>
|
||||||
<td>{primary.distance_km}</td>
|
<td>{primary.distance_km}</td>
|
||||||
<td>{if primary.user_submitted, do: "Yes", else: "—"}</td>
|
<td>{if primary.user_submitted, do: "Yes", else: "—"}</td>
|
||||||
|
<td>{enrichment_badge(primary)}</td>
|
||||||
<td>{Calendar.strftime(primary.qso_timestamp, "%Y-%m-%d %H:%M")}</td>
|
<td>{Calendar.strftime(primary.qso_timestamp, "%Y-%m-%d %H:%M")}</td>
|
||||||
<td>{Calendar.strftime(primary.inserted_at, "%Y-%m-%d %H:%M")}</td>
|
<td>{Calendar.strftime(primary.inserted_at, "%Y-%m-%d %H:%M")}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -162,6 +187,7 @@ defmodule MicrowavepropWeb.ContactLive.Index do
|
||||||
<td>{recip.mode}</td>
|
<td>{recip.mode}</td>
|
||||||
<td>{recip.distance_km}</td>
|
<td>{recip.distance_km}</td>
|
||||||
<td>{if recip.user_submitted, do: "Yes", else: "—"}</td>
|
<td>{if recip.user_submitted, do: "Yes", else: "—"}</td>
|
||||||
|
<td>{enrichment_badge(recip)}</td>
|
||||||
<td>{Calendar.strftime(recip.qso_timestamp, "%Y-%m-%d %H:%M")}</td>
|
<td>{Calendar.strftime(recip.qso_timestamp, "%Y-%m-%d %H:%M")}</td>
|
||||||
<td>{Calendar.strftime(recip.inserted_at, "%Y-%m-%d %H:%M")}</td>
|
<td>{Calendar.strftime(recip.inserted_at, "%Y-%m-%d %H:%M")}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue