diff --git a/lib/pinchflat_web.ex b/lib/pinchflat_web.ex index e0a512d..6f301ff 100644 --- a/lib/pinchflat_web.ex +++ b/lib/pinchflat_web.ex @@ -88,6 +88,7 @@ defmodule PinchflatWeb do # Core UI components and translation import PinchflatWeb.Gettext import PinchflatWeb.CoreComponents + import PinchflatWeb.CustomComponents.TabComponents import PinchflatWeb.CustomComponents.TextComponents import PinchflatWeb.CustomComponents.TableComponents import PinchflatWeb.CustomComponents.ButtonComponents diff --git a/lib/pinchflat_web/components/core_components.ex b/lib/pinchflat_web/components/core_components.ex index f9477df..09d842c 100644 --- a/lib/pinchflat_web/components/core_components.ex +++ b/lib/pinchflat_web/components/core_components.ex @@ -587,6 +587,7 @@ defmodule PinchflatWeb.CoreComponents do attrs = Enum.filter(assigns.map, fn {_, %{__struct__: _}} -> false + {_, [%{__meta__: _} | _]} -> false _ -> true end) diff --git a/lib/pinchflat_web/components/custom_components/tab_components.ex b/lib/pinchflat_web/components/custom_components/tab_components.ex new file mode 100644 index 0000000..1b0ae22 --- /dev/null +++ b/lib/pinchflat_web/components/custom_components/tab_components.ex @@ -0,0 +1,37 @@ +defmodule PinchflatWeb.CustomComponents.TabComponents do + @moduledoc false + use Phoenix.Component + + @doc """ + Takes a list of tabs and renders them in a tabbed layout. + """ + slot :tab, required: true do + attr :title, :string, required: true + end + + def tabbed_layout(assigns) do + ~H""" +
+
+ + <%= tab.title %> + +
+
+
+ <%= render_slot(tab) %> +
+
+
+ """ + end +end diff --git a/lib/pinchflat_web/controllers/media_profiles/media_profile_controller.ex b/lib/pinchflat_web/controllers/media_profiles/media_profile_controller.ex index 246f6e3..f0d78d9 100644 --- a/lib/pinchflat_web/controllers/media_profiles/media_profile_controller.ex +++ b/lib/pinchflat_web/controllers/media_profiles/media_profile_controller.ex @@ -1,6 +1,7 @@ defmodule PinchflatWeb.MediaProfiles.MediaProfileController do use PinchflatWeb, :controller + alias Pinchflat.Repo alias Pinchflat.Profiles alias Pinchflat.Profiles.MediaProfile @@ -39,7 +40,11 @@ defmodule PinchflatWeb.MediaProfiles.MediaProfileController do end def show(conn, %{"id" => id}) do - media_profile = Profiles.get_media_profile!(id) + media_profile = + id + |> Profiles.get_media_profile!() + |> Repo.preload(:sources) + render(conn, :show, media_profile: media_profile) end diff --git a/lib/pinchflat_web/controllers/media_profiles/media_profile_html/show.html.heex b/lib/pinchflat_web/controllers/media_profiles/media_profile_html/show.html.heex index a7833b1..7cdb2df 100644 --- a/lib/pinchflat_web/controllers/media_profiles/media_profile_html/show.html.heex +++ b/lib/pinchflat_web/controllers/media_profiles/media_profile_html/show.html.heex @@ -18,31 +18,50 @@
-
-

Attributes for "<%= @media_profile.name %>"

- <.list_items_from_map map={Map.from_struct(@media_profile)} /> -
+ <.tabbed_layout> + <:tab title="Attributes"> +
+

Attributes for "<%= @media_profile.name %>"

+ <.list_items_from_map map={Map.from_struct(@media_profile)} /> +
-
- <.link - href={~p"/media_profiles/#{@media_profile}"} - method="delete" - data-confirm="Are you sure you want to delete this profile and all its sources (leaving files in place)? This cannot be undone." - > - <.button color="bg-meta-1" rounding="rounded-full"> - Delete Profile and its Sources - - - <.link - href={~p"/media_profiles/#{@media_profile}?delete_files=true"} - method="delete" - data-confirm="Are you sure you want to delete this profile, all its sources, and its files on disk? This cannot be undone." - class="mt-5 md:mt-0" - > - <.button color="bg-meta-1" rounding="rounded-full"> - Delete Profile, Sources, and Files - - -
+
+ <.link + href={~p"/media_profiles/#{@media_profile}"} + method="delete" + data-confirm="Are you sure you want to delete this profile and all its sources (leaving files in place)? This cannot be undone." + > + <.button color="bg-meta-1" rounding="rounded-full"> + Delete Profile and its Sources + + + <.link + href={~p"/media_profiles/#{@media_profile}?delete_files=true"} + method="delete" + data-confirm="Are you sure you want to delete this profile, all its sources, and its files on disk? This cannot be undone." + class="mt-5 md:mt-0" + > + <.button color="bg-meta-1" rounding="rounded-full"> + Delete Profile, Sources, and Files + + +
+ + <:tab title="Sources"> + <.table rows={@media_profile.sources} table_class="text-black dark:text-white"> + <:col :let={source} label="Name"> + <%= source.friendly_name || source.collection_name %> + + <:col :let={source} label="Type"><%= source.collection_type %> + <:col :let={source} label="Should Download?"> + <.icon name={if source.download_media, do: "hero-check", else: "hero-x-mark"} /> + + <:col :let={source} label="" class="flex place-content-evenly"> + <.icon_link href={~p"/sources/#{source.id}"} icon="hero-eye" class="mx-1" /> + <.icon_link href={~p"/sources/#{source.id}/edit"} icon="hero-pencil-square" class="mx-1" /> + + + +