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 = List.first(hrrr_path)
|
||||||
{hrrr, hrrr_status} = maybe_enqueue_hrrr(hrrr, contact)
|
{hrrr, hrrr_status} = maybe_enqueue_hrrr(hrrr, contact)
|
||||||
terrain = Terrain.get_terrain_profile(contact.id)
|
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)
|
elevation_profile = compute_elevation_profile(contact, hrrr_path, weather.soundings)
|
||||||
propagation_analysis = build_propagation_analysis(contact, hrrr, terrain, elevation_profile, 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: hrrr,
|
||||||
hrrr_status: hrrr_status,
|
hrrr_status: hrrr_status,
|
||||||
terrain: terrain,
|
terrain: terrain,
|
||||||
|
terrain_status: terrain_status,
|
||||||
elevation_profile: elevation_profile,
|
elevation_profile: elevation_profile,
|
||||||
propagation_analysis: propagation_analysis,
|
propagation_analysis: propagation_analysis,
|
||||||
terrain_expanded: false,
|
terrain_expanded: false,
|
||||||
|
|
@ -124,6 +125,7 @@ defmodule MicrowavepropWeb.ContactLive.Show do
|
||||||
{:noreply,
|
{:noreply,
|
||||||
assign(socket,
|
assign(socket,
|
||||||
terrain: terrain,
|
terrain: terrain,
|
||||||
|
terrain_status: :loaded,
|
||||||
elevation_profile: elevation_profile,
|
elevation_profile: elevation_profile,
|
||||||
propagation_analysis: propagation_analysis
|
propagation_analysis: propagation_analysis
|
||||||
)}
|
)}
|
||||||
|
|
@ -223,14 +225,15 @@ defmodule MicrowavepropWeb.ContactLive.Show do
|
||||||
end
|
end
|
||||||
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
|
defp maybe_enqueue_terrain(nil, contact) do
|
||||||
if contact.pos1 && contact.pos2 do
|
if contact.pos1 && contact.pos2 do
|
||||||
Oban.insert(TerrainProfileWorker.new(%{"qso_id" => contact.id}))
|
Oban.insert(TerrainProfileWorker.new(%{"qso_id" => contact.id}))
|
||||||
|
:queued
|
||||||
|
else
|
||||||
|
:unavailable
|
||||||
end
|
end
|
||||||
|
|
||||||
:ok
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_enqueue_hrrr(hrrr, _contact) when not is_nil(hrrr), do: {hrrr, :loaded}
|
defp maybe_enqueue_hrrr(hrrr, _contact) when not is_nil(hrrr), do: {hrrr, :loaded}
|
||||||
|
|
@ -310,6 +313,13 @@ defmodule MicrowavepropWeb.ContactLive.Show do
|
||||||
/>
|
/>
|
||||||
<% end %>
|
<% 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 %>
|
<%= if @elevation_profile do %>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<div class="text-sm font-mono mb-2 text-center">
|
<div class="text-sm font-mono mb-2 text-center">
|
||||||
|
|
@ -468,7 +478,16 @@ defmodule MicrowavepropWeb.ContactLive.Show do
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% 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 %>
|
<% end %>
|
||||||
|
|
||||||
<div class="divider" />
|
<div class="divider" />
|
||||||
|
|
@ -622,16 +641,19 @@ defmodule MicrowavepropWeb.ContactLive.Show do
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<p class="text-sm text-base-content/50 italic">
|
<div class="text-sm text-base-content/50 italic">
|
||||||
<%= case @hrrr_status do %>
|
<%= case @hrrr_status do %>
|
||||||
<% :queued -> %>
|
<% :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 -> %>
|
<% :unavailable -> %>
|
||||||
HRRR data unavailable for this contact time.
|
HRRR data unavailable for this contact time.
|
||||||
<% _ -> %>
|
<% _ -> %>
|
||||||
No HRRR profile available.
|
No HRRR profile available.
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="divider" />
|
<div class="divider" />
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue