diff --git a/lib/polar_web/live/root_live.ex b/lib/polar_web/live/root_live.ex index 9b549ed..1cba7ca 100644 --- a/lib/polar_web/live/root_live.ex +++ b/lib/polar_web/live/root_live.ex @@ -1,88 +1,91 @@ defmodule PolarWeb.RootLive do use PolarWeb, :live_view + alias Polar.Repo alias Polar.Streams + alias Polar.Streams.Version + + import Ecto.Query, only: [from: 2] def render(assigns) do ~H""" -
-
-

- <%= gettext("Active Images") %> -

-

- <%= gettext("If you need something not available here please create an issue at the") %> - - <%= gettext("opsmaru-images") %> - - <%= gettext("repository.") %> -

+
+
+
+

+ <%= gettext("Active Images") %> +

+

+ <%= gettext("If you need something not available here please create an issue at the") %> + + <%= gettext("opsmaru-images") %> + + <%= gettext("repository.") %> +

+
-
-
-
-
- - - - - - - - - - - <%= for {{os, release}, products} <- @grouped_products do %> - - - - <%= for product <- products do %> +
+
+
+
+
- <%= gettext("Aliases") %> - - <%= gettext("Arch") %> - - <%= gettext("Variant") %> - - <%= gettext("Published At") %> -
- <%= Phoenix.Naming.humanize(os) %> - <%= release %> -
+ - - - - + + + + + - <% end %> - <% end %> - -
- <%= for alias <- product.aliases do %> - - <%= alias %> - - <% end %> - - <%= product.arch %> - - <%= product.variant %> - - <%= Calendar.strftime( - product.latest_version.inserted_at, - "%B %d, %Y %H:%M:%S" - ) %> - + <%= gettext("Aliases") %> + + <%= gettext("Serial") %> + + <%= gettext("OS") %> + + <%= gettext("Arch") %> + + <%= gettext("Published At") %> +
+ + + <%= for version <- @versions do %> + + + <%= for alias <- version.product.aliases do %> + + <%= alias %> + + <% end %> + + + <%= version.serial %> + + + <%= version.product.os %> + + + <%= version.product.arch %> + + + <%= Calendar.strftime( + version.inserted_at, + "%B %d, %Y %H:%M:%S" + ) %> + + + <% end %> + + +
+
@@ -90,13 +93,20 @@ defmodule PolarWeb.RootLive do end def mount(_params, _session, socket) do - products = - Streams.list_products([:active, :with_latest_version]) - |> Enum.group_by(fn p -> {p.os, p.release} end) + versions = + from( + v in Version, + where: v.current_state == ^"active", + join: p in assoc(v, :product), + preload: [{:product, p}], + order_by: [asc: [p.os, p.arch]], + order_by: [desc: :inserted_at] + ) + |> Repo.all() socket = socket - |> assign(:grouped_products, products) + |> assign(:versions, versions) |> assign(:page_title, gettext("OpsMaru Images")) |> assign(:current_path, ~p"/")