UX improvements v1 (#39)
* Removed collection_type user input instead inferring from yt-dlp response * Updated docs * Added delete buttons for source; Refactored the way deletion methods work * Update source to always run an initial index * Added deletion to the last models * Improved clarity around deletion operation * Improved task fetching and deletion methods * More tests
This commit is contained in:
@@ -12,19 +12,17 @@ defmodule PinchflatWeb.MediaItems.MediaItemController do
|
||||
def delete(conn, %{"id" => id} = params) do
|
||||
delete_files = Map.get(params, "delete_files", false)
|
||||
media_item = Media.get_media_item!(id)
|
||||
{:ok, _} = Media.delete_media_item(media_item, delete_files: delete_files)
|
||||
|
||||
if delete_files do
|
||||
{:ok, _} = Media.delete_media_item_and_attachments(media_item)
|
||||
flash_message =
|
||||
if delete_files do
|
||||
"Record and files deleted successfully."
|
||||
else
|
||||
"Record deleted successfully. Files were not deleted."
|
||||
end
|
||||
|
||||
conn
|
||||
|> put_flash(:info, "Record and files deleted successfully.")
|
||||
|> redirect(to: ~p"/sources/#{media_item.source_id}")
|
||||
else
|
||||
{:ok, _} = Media.delete_media_item(media_item)
|
||||
|
||||
conn
|
||||
|> put_flash(:info, "Record deleted successfully. Files were not deleted.")
|
||||
|> redirect(to: ~p"/sources/#{media_item.source_id}")
|
||||
end
|
||||
conn
|
||||
|> put_flash(:info, flash_message)
|
||||
|> redirect(to: ~p"/sources/#{media_item.source_id}")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,17 +7,6 @@
|
||||
Media Item #<%= @media_item.id %>
|
||||
</h2>
|
||||
</div>
|
||||
<nav>
|
||||
<.link
|
||||
href={~p"/sources/#{@media_item.source_id}/media/#{@media_item}?delete_files=true"}
|
||||
method="delete"
|
||||
data-confirm="Are you sure?"
|
||||
>
|
||||
<.button color="bg-meta-1" rounding="rounded-full">
|
||||
Delete Record and Files
|
||||
</.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">
|
||||
@@ -25,5 +14,17 @@
|
||||
<h3 class="font-bold text-xl">Attributes</h3>
|
||||
<.list_items_from_map map={Map.from_struct(@media_item)} />
|
||||
</div>
|
||||
|
||||
<section class="flex justify-center my-10">
|
||||
<.link
|
||||
href={~p"/sources/#{@media_item.source_id}/media/#{@media_item}?delete_files=true"}
|
||||
method="delete"
|
||||
data-confirm="Are you sure you want to delete this record and all associated files on disk? This cannot be undone."
|
||||
>
|
||||
<.button color="bg-meta-1" rounding="rounded-full">
|
||||
Delete Files
|
||||
</.button>
|
||||
</.link>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -46,6 +46,7 @@ defmodule PinchflatWeb.MediaProfiles.MediaProfileController do
|
||||
def edit(conn, %{"id" => id}) do
|
||||
media_profile = Profiles.get_media_profile!(id)
|
||||
changeset = Profiles.change_media_profile(media_profile)
|
||||
|
||||
render(conn, :edit, media_profile: media_profile, changeset: changeset)
|
||||
end
|
||||
|
||||
@@ -63,12 +64,20 @@ defmodule PinchflatWeb.MediaProfiles.MediaProfileController do
|
||||
end
|
||||
end
|
||||
|
||||
def delete(conn, %{"id" => id}) do
|
||||
def delete(conn, %{"id" => id} = params) do
|
||||
delete_files = Map.get(params, "delete_files", false)
|
||||
media_profile = Profiles.get_media_profile!(id)
|
||||
{:ok, _media_profile} = Profiles.delete_media_profile(media_profile)
|
||||
{:ok, _media_profile} = Profiles.delete_media_profile(media_profile, delete_files: delete_files)
|
||||
|
||||
flash_message =
|
||||
if delete_files do
|
||||
"Media profile, its sources, and its files deleted successfully."
|
||||
else
|
||||
"Media profile and its sources deleted successfully. Files were not deleted."
|
||||
end
|
||||
|
||||
conn
|
||||
|> put_flash(:info, "Media profile deleted successfully.")
|
||||
|> put_flash(:info, flash_message)
|
||||
|> redirect(to: ~p"/media_profiles")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,5 +22,27 @@
|
||||
<h3 class="font-bold text-xl">Attributes</h3>
|
||||
<.list_items_from_map map={Map.from_struct(@media_profile)} />
|
||||
</div>
|
||||
|
||||
<section class="flex flex-col md:flex-row items-center md:justify-around my-10">
|
||||
<.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
|
||||
</.button>
|
||||
</.link>
|
||||
<.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
|
||||
</.button>
|
||||
</.link>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -87,12 +87,20 @@ defmodule PinchflatWeb.Sources.SourceController do
|
||||
end
|
||||
end
|
||||
|
||||
def delete(conn, %{"id" => id}) do
|
||||
def delete(conn, %{"id" => id} = params) do
|
||||
delete_files = Map.get(params, "delete_files", false)
|
||||
source = Sources.get_source!(id)
|
||||
{:ok, _source} = Sources.delete_source(source)
|
||||
{:ok, _source} = Sources.delete_source(source, delete_files: delete_files)
|
||||
|
||||
flash_message =
|
||||
if delete_files do
|
||||
"Source and files deleted successfully."
|
||||
else
|
||||
"Source deleted successfully. Files were not deleted."
|
||||
end
|
||||
|
||||
conn
|
||||
|> put_flash(:info, "Source deleted successfully.")
|
||||
|> put_flash(:info, flash_message)
|
||||
|> redirect(to: ~p"/sources")
|
||||
end
|
||||
|
||||
|
||||
@@ -24,11 +24,4 @@ defmodule PinchflatWeb.Sources.SourceHTML do
|
||||
{"Monthly", 30 * 24 * 60}
|
||||
]
|
||||
end
|
||||
|
||||
def friendly_collection_types do
|
||||
[
|
||||
{"Channel", "channel"},
|
||||
{"Playlist", "playlist"}
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -72,5 +72,27 @@
|
||||
<p class="text-black dark:text-white">Nothing Here!</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<section class="flex flex-col md:flex-row items-center md:justify-around mt-10">
|
||||
<.link
|
||||
href={~p"/sources/#{@source}"}
|
||||
method="delete"
|
||||
data-confirm="Are you sure you want to delete this source (leaving files in place)? This cannot be undone."
|
||||
>
|
||||
<.button color="bg-meta-1" rounding="rounded-full">
|
||||
Delete Source
|
||||
</.button>
|
||||
</.link>
|
||||
<.link
|
||||
href={~p"/sources/#{@source}?delete_files=true"}
|
||||
method="delete"
|
||||
data-confirm="Are you sure you want to delete this source and it's files on disk? This cannot be undone."
|
||||
class="mt-5 md:mt-0"
|
||||
>
|
||||
<.button color="bg-meta-1" rounding="rounded-full">
|
||||
Delete Source and Files
|
||||
</.button>
|
||||
</.link>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -19,14 +19,12 @@
|
||||
label="Media Profile"
|
||||
/>
|
||||
|
||||
<.input field={f[:collection_type]} options={friendly_collection_types()} type="select" label="Source Type" />
|
||||
|
||||
<.input
|
||||
field={f[:index_frequency_minutes]}
|
||||
options={friendly_index_frequencies()}
|
||||
type="select"
|
||||
label="Index Frequency"
|
||||
help="The time between one index of this source finishing and the next one starting"
|
||||
help="Time between one index of this source finishing and the next one starting. Setting to 'Never' will still run an initial index but no subsequent ones"
|
||||
/>
|
||||
|
||||
<.input
|
||||
|
||||
Reference in New Issue
Block a user