Show loading spinners while enrichment jobs are processing
This commit is contained in:
parent
d207863b15
commit
a3ac8cff8d
1 changed files with 30 additions and 8 deletions
|
|
@ -32,7 +32,7 @@ defmodule MicrowavepropWeb.ContactLive.Show do
|
|||
hrrr = List.first(hrrr_path)
|
||||
{hrrr, hrrr_status} = maybe_enqueue_hrrr(hrrr, contact)
|
||||
terrain = Terrain.get_terrain_profile(contact.id)
|
||||
maybe_enqueue_terrain(terrain, contact)
|
||||
terrain_status = if terrain, do: :loaded, else: maybe_enqueue_terrain(terrain, contact)
|
||||
elevation_profile = compute_elevation_profile(contact, hrrr_path, weather.soundings)
|
||||
propagation_analysis = build_propagation_analysis(contact, hrrr, terrain, elevation_profile, weather.soundings)
|
||||
|
||||
|
|
@ -46,6 +46,7 @@ defmodule MicrowavepropWeb.ContactLive.Show do
|
|||
hrrr: hrrr,
|
||||
hrrr_status: hrrr_status,
|
||||
terrain: terrain,
|
||||
terrain_status: terrain_status,
|
||||
elevation_profile: elevation_profile,
|
||||
propagation_analysis: propagation_analysis,
|
||||
terrain_expanded: false,
|
||||
|
|
@ -124,6 +125,7 @@ defmodule MicrowavepropWeb.ContactLive.Show do
|
|||
{:noreply,
|
||||
assign(socket,
|
||||
terrain: terrain,
|
||||
terrain_status: :loaded,
|
||||
elevation_profile: elevation_profile,
|
||||
propagation_analysis: propagation_analysis
|
||||
)}
|
||||
|
|
@ -223,14 +225,15 @@ defmodule MicrowavepropWeb.ContactLive.Show do
|
|||
end
|
||||
end
|
||||
|
||||
defp maybe_enqueue_terrain(terrain, _contact) when not is_nil(terrain), do: :ok
|
||||
defp maybe_enqueue_terrain(terrain, _contact) when not is_nil(terrain), do: :loaded
|
||||
|
||||
defp maybe_enqueue_terrain(nil, contact) do
|
||||
if contact.pos1 && contact.pos2 do
|
||||
Oban.insert(TerrainProfileWorker.new(%{"qso_id" => contact.id}))
|
||||
:queued
|
||||
else
|
||||
:unavailable
|
||||
end
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
defp maybe_enqueue_hrrr(hrrr, _contact) when not is_nil(hrrr), do: {hrrr, :loaded}
|
||||
|
|
@ -310,6 +313,13 @@ defmodule MicrowavepropWeb.ContactLive.Show do
|
|||
/>
|
||||
<% end %>
|
||||
|
||||
<%= if !@elevation_profile && @terrain_status == :queued do %>
|
||||
<div class="flex items-center gap-2 text-sm text-base-content/50 my-4">
|
||||
<span class="loading loading-spinner loading-sm"></span>
|
||||
Computing elevation profile and terrain analysis...
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= if @elevation_profile do %>
|
||||
<div class="mb-4">
|
||||
<div class="text-sm font-mono mb-2 text-center">
|
||||
|
|
@ -468,7 +478,16 @@ defmodule MicrowavepropWeb.ContactLive.Show do
|
|||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<p class="text-sm text-base-content/50 italic">No terrain profile available.</p>
|
||||
<div class="text-sm text-base-content/50 italic">
|
||||
<%= if @terrain_status == :queued do %>
|
||||
<span class="flex items-center gap-2">
|
||||
<span class="loading loading-spinner loading-sm"></span>
|
||||
Computing terrain profile...
|
||||
</span>
|
||||
<% else %>
|
||||
No terrain profile available.
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="divider" />
|
||||
|
|
@ -622,16 +641,19 @@ defmodule MicrowavepropWeb.ContactLive.Show do
|
|||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<p class="text-sm text-base-content/50 italic">
|
||||
<div class="text-sm text-base-content/50 italic">
|
||||
<%= case @hrrr_status do %>
|
||||
<% :queued -> %>
|
||||
HRRR fetch queued — reload in a few minutes.
|
||||
<span class="flex items-center gap-2">
|
||||
<span class="loading loading-spinner loading-sm"></span>
|
||||
Fetching HRRR atmospheric data...
|
||||
</span>
|
||||
<% :unavailable -> %>
|
||||
HRRR data unavailable for this contact time.
|
||||
<% _ -> %>
|
||||
No HRRR profile available.
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="divider" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue