Adds new UI to media profiles page

This commit is contained in:
Kieran Eglin 2024-02-08 10:28:32 -08:00
parent fcc40dfa8d
commit 8acf30ca71
No known key found for this signature in database
GPG key ID: 193984967FCF432D
8 changed files with 147 additions and 70 deletions

View file

@ -27,7 +27,8 @@ defmodule Pinchflat.Profiles.MediaProfile do
schema "media_profiles" do
field :name, :string
field :output_path_template, :string
field :output_path_template, :string, default: "/{{ uploader }}/{{ title }}.{{ ext }}"
field :download_subs, :boolean, default: true
field :download_auto_subs, :boolean, default: true

View file

@ -1,5 +1,5 @@
<header class="sticky top-0 z-999 flex w-full bg-white drop-shadow-1 dark:bg-boxdark dark:drop-shadow-none">
<div class="flex flex-grow items-center justify-between px-4 py-4 shadow-2 md:px-6 2xl:px-11">
<div class="flex flex-grow items-center justify-end px-4 py-4 shadow-2 md:px-6 2xl:px-11">
<div class="flex items-center gap-2 sm:gap-4 lg:hidden">
<button
class="z-99999 block rounded-sm border border-stroke bg-white p-1.5 shadow-sm dark:border-strokedark dark:bg-boxdark lg:hidden"
@ -11,10 +11,10 @@
<h2 class="text-title-md2 font-bold text-white">Pinchflat</h2>
</a>
</div>
<div class="hidden sm:block">
<div class="hidden sm:block bg-meta-4 rounded-md">
<%!-- Aspirational (for now) --%>
<div class="relative">
<span class="absolute left-0 top-1/2 -translate-y-1/2">
<span class="absolute left-2 top-1/2 -translate-y-1/2 flex">
<.icon name="hero-magnifying-glass" />
</span>
@ -25,18 +25,5 @@
/>
</div>
</div>
<div class="flex items-center gap-3 2xsm:gap-7">
<ul class="flex items-center gap-2 2xsm:gap-4">
<li class="relative">
<%!-- Aspirational (for now) --%>
<a
class="relative flex h-8.5 w-8.5 items-center justify-center rounded-full border-[0.5px] border-stroke bg-gray hover:text-primary dark:border-strokedark dark:bg-meta-4 dark:text-white"
href="#"
>
<.icon name="hero-cog-8-tooth" />
</a>
</li>
</ul>
</div>
</div>
</header>

View file

@ -1,8 +1,14 @@
<.old_header>
Edit Media profile <%= @media_profile.id %>
<:subtitle>Use this form to manage media_profile records in your database.</:subtitle>
</.old_header>
<div class="mb-6 flex gap-3 flex-row items-center">
<.link navigate={~p"/media_profiles"}>
<.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" />
</.link>
<h2 class="text-title-md2 font-bold text-black dark:text-white ml-4">Edit Media Profile</h2>
</div>
<.media_profile_form changeset={@changeset} action={~p"/media_profiles/#{@media_profile}"} />
<.back navigate={~p"/media_profiles"}>Back to media_profiles</.back>
<div class="rounded-sm border border-stroke bg-white px-5 pb-2.5 pt-6 shadow-default dark:border-strokedark dark:bg-boxdark sm:px-7.5 xl:pb-1">
<div class="max-w-full overflow-x-auto">
<div class="flex flex-col gap-10">
<.media_profile_form changeset={@changeset} action={~p"/media_profiles/#{@media_profile}"} />
</div>
</div>
</div>

View file

@ -1,8 +1,39 @@
<.old_header>
Listing Media profiles
<:actions>
<.link href={~p"/media_profiles/new"}>
<.button>New Media profile</.button>
<div class="mb-6 flex gap-3 flex-row items-center justify-between">
<h2 class="text-title-md2 font-bold text-black dark:text-white">All Media Profiles</h2>
<nav>
<.link navigate={~p"/media_profiles/new"}>
<.button color="bg-primary" rounding="rounded-full">
<span class="font-bold mx-2">+</span> New Media Profile
</.button>
</.link>
</:actions>
</.old_header>
</nav>
</div>
<div class="rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
<div class="max-w-full overflow-x-auto">
<div class="flex flex-col gap-10">
<.table rows={@media_profiles} table_class="text-black dark:text-white">
<:col :let={media_profile} label="Name">
<%= media_profile.name %>
</:col>
<:col :let={media_profile} label="Output Template">
<code class="text-sm"><%= media_profile.output_path_template %></code>
</:col>
<:col :let={media_profile} label="" class="flex place-content-evenly">
<.link
navigate={~p"/media_profiles/#{media_profile.id}"}
class="hover:text-secondary duration-200 ease-in-out mx-0.5"
>
<.icon name="hero-eye" />
</.link>
<.link
navigate={~p"/media_profiles/#{media_profile.id}/edit"}
class="hover:text-secondary duration-200 ease-in-out mx-0.5"
>
<.icon name="hero-pencil-square" />
</.link>
</:col>
</.table>
</div>
</div>
</div>

View file

@ -2,29 +2,62 @@
<.error :if={@changeset.action}>
Oops, something went wrong! Please check the errors below.
</.error>
<.input field={f[:name]} type="text" label="Name" />
<.input field={f[:output_path_template]} type="text" label="Output path template" />
<h3 class="my-4 text-2xl text-black dark:text-white">
General Options
</h3>
<.input field={f[:name]} type="text" label="Name" placeholder="New Profile" help="(required)" />
<.input
field={f[:output_path_template]}
type="text"
label="Output path template"
help="TODO: provide docs (required)"
/>
<h3>Subtitle Options</h3>
<.input field={f[:download_subs]} type="checkbox" label="Download Subs" />
<.input field={f[:download_auto_subs]} type="checkbox" label="Download Autogenerated Subs" />
<.input field={f[:embed_subs]} type="checkbox" label="Embed Subs" />
<.input field={f[:sub_langs]} type="text" label="Sub Langs" />
<h3 class="mb-4 mt-8 text-2xl text-black dark:text-white">
Subtitle Options
</h3>
<.input field={f[:download_subs]} type="toggle" label="Download Subtitles" />
<.input
field={f[:download_auto_subs]}
type="toggle"
label="Download Autogenerated Subtitles"
help="Prefers normal subs but will download autogenerated if needed"
/>
<.input
field={f[:embed_subs]}
type="toggle"
label="Embed Subtitles"
help="Embeds subtitles in the video file itself, if supported"
/>
<.input
field={f[:sub_langs]}
type="text"
label="Subtitle Languages"
help="Use commas for multiple languages (eg: en,de)"
/>
<h3>Thumbnail Options</h3>
<.input field={f[:download_thumbnail]} type="checkbox" label="Download Thumbnail" />
<.input field={f[:embed_thumbnail]} type="checkbox" label="Embed Thumbnail" />
<h3 class="mb-4 mt-8 text-2xl text-black dark:text-white">
Thumbnail Options
</h3>
<.input field={f[:download_thumbnail]} type="toggle" label="Download Thumbnail" />
<.input field={f[:embed_thumbnail]} type="toggle" label="Embed Thumbnail" />
<h3>Metadata Options</h3>
<.input field={f[:download_metadata]} type="checkbox" label="Download Metadata" />
<.input field={f[:embed_metadata]} type="checkbox" label="Embed Metadata" />
<h3 class="mb-4 mt-8 text-2xl text-black dark:text-white">
Metadata Options
</h3>
<.input field={f[:download_metadata]} type="toggle" label="Download Metadata" />
<.input field={f[:embed_metadata]} type="toggle" label="Embed Metadata" />
<h3 class="mb-4 mt-8 text-2xl text-black dark:text-white">
Release Format Options
</h3>
<h3>Release Format Options</h3>
<.input
field={f[:shorts_behaviour]}
options={friendly_format_type_options()}
type="select"
label="Include Shorts?"
help="Experimental"
/>
<.input
field={f[:livestream_behaviour]}
@ -34,6 +67,6 @@
/>
<:actions>
<.button>Save Media profile</.button>
<.button class="mt-15 mb-5 sm:mb-7.5">Save Media profile</.button>
</:actions>
</.simple_form>

View file

@ -1,8 +1,14 @@
<.old_header>
New Media profile
<:subtitle>Use this form to manage media_profile records in your database.</:subtitle>
</.old_header>
<div class="mb-6 flex gap-3 flex-row items-center">
<.link navigate={~p"/media_profiles"}>
<.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" />
</.link>
<h2 class="text-title-md2 font-bold text-black dark:text-white ml-4">New Media Profile</h2>
</div>
<.media_profile_form changeset={@changeset} action={~p"/media_profiles"} />
<.back navigate={~p"/media_profiles"}>Back to media_profiles</.back>
<div class="rounded-sm border border-stroke bg-white px-5 pb-2.5 pt-6 shadow-default dark:border-strokedark dark:bg-boxdark sm:px-7.5 xl:pb-1">
<div class="max-w-full overflow-x-auto">
<div class="flex flex-col gap-10">
<.media_profile_form changeset={@changeset} action={~p"/media_profiles"} />
</div>
</div>
</div>

View file

@ -1,13 +1,26 @@
<.old_header>
Media profile <%= @media_profile.id %>
<:subtitle>This is a media_profile record from your database.</:subtitle>
<:actions>
<.link href={~p"/media_profiles/#{@media_profile}/edit"}>
<.button>Edit media_profile</.button>
<div class="mb-6 flex gap-3 flex-row items-center justify-between">
<div class="flex gap-3 items-center">
<.link navigate={~p"/media_profiles"}>
<.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" />
</.link>
</:actions>
</.old_header>
<h2 class="text-title-md2 font-bold text-black dark:text-white ml-4">
Media Profile #<%= @media_profile.id %>
</h2>
</div>
<.list_items_from_map map={Map.from_struct(@media_profile)} />
<.back navigate={~p"/media_profiles"}>Back to media_profiles</.back>
<nav>
<.link navigate={~p"/media_profiles/#{@media_profile}/edit"}>
<.button color="bg-primary" rounding="rounded-full">
<.icon name="hero-pencil-square" class="mr-2" /> Edit Media Profile
</.button>
</.link>
</nav>
</div>
<div class="rounded-sm border border-stroke bg-white px-5 pb-2.5 pt-6 shadow-default dark:border-strokedark dark:bg-boxdark sm:px-7.5 xl:pb-1">
<div class="max-w-full overflow-x-auto">
<div class="flex flex-col gap-10 dark:text-white">
<h3 class="font-bold text-xl">Attributes</h3>
<.list_items_from_map map={Map.from_struct(@media_profile)} />
</div>
</div>
</div>

View file

@ -13,14 +13,14 @@ defmodule PinchflatWeb.MediaProfileControllerTest do
describe "index" do
test "lists all media_profiles", %{conn: conn} do
conn = get(conn, ~p"/media_profiles")
assert html_response(conn, 200) =~ "Listing Media profiles"
assert html_response(conn, 200) =~ "All Media Profiles"
end
end
describe "new media_profile" do
test "renders form", %{conn: conn} do
conn = get(conn, ~p"/media_profiles/new")
assert html_response(conn, 200) =~ "New Media profile"
assert html_response(conn, 200) =~ "New Media Profile"
end
end
@ -32,12 +32,12 @@ defmodule PinchflatWeb.MediaProfileControllerTest do
assert redirected_to(conn) == ~p"/media_profiles/#{id}"
conn = get(conn, ~p"/media_profiles/#{id}")
assert html_response(conn, 200) =~ "Media profile #{id}"
assert html_response(conn, 200) =~ "Media Profile ##{id}"
end
test "renders errors when data is invalid", %{conn: conn} do
conn = post(conn, ~p"/media_profiles", media_profile: @invalid_attrs)
assert html_response(conn, 200) =~ "New Media profile"
assert html_response(conn, 200) =~ "New Media Profile"
end
end
@ -49,7 +49,7 @@ defmodule PinchflatWeb.MediaProfileControllerTest do
media_profile: media_profile
} do
conn = get(conn, ~p"/media_profiles/#{media_profile}/edit")
assert html_response(conn, 200) =~ "Edit Media profile"
assert html_response(conn, 200) =~ "Edit Media Profile"
end
end
@ -66,7 +66,7 @@ defmodule PinchflatWeb.MediaProfileControllerTest do
test "renders errors when data is invalid", %{conn: conn, media_profile: media_profile} do
conn = put(conn, ~p"/media_profiles/#{media_profile}", media_profile: @invalid_attrs)
assert html_response(conn, 200) =~ "Edit Media profile"
assert html_response(conn, 200) =~ "Edit Media Profile"
end
end