Inline templates inside LV modules

This commit is contained in:
Claudio Ortolina
2026-02-24 17:20:21 +00:00
parent d55e957eea
commit e9b9717b08
32 changed files with 3583 additions and 3501 deletions
@@ -12,6 +12,142 @@ defmodule MusicLibraryWeb.MaintenanceLive.Index do
@poll_interval 2_000
@impl true
def render(assigns) do
~H"""
<Layouts.app flash={@flash} current_section={@current_section} socket={@socket}>
<div>
<h1 class="mt-2 text-base lg:text-2xl text-zinc-900 dark:text-zinc-200 font-semibold">
{gettext("Maintenance")}
</h1>
<h3 class="mt-4 text-base font-semibold text-zinc-900 dark:text-white">
{gettext("Records")}
</h3>
<p class="mt-2 max-w-4xl text-sm text-zinc-500 dark:text-zinc-400">
{gettext(
"Run operations on the entire record database. Monitor execution via the Oban dashboard."
)}
</p>
<ul class="mt-4">
<li class="space-y-4">
<.button_group>
<.button
type="button"
phx-click="refresh_records_musicbrainz_data"
disabled={@refresh_records_musicbrainz_jobs > 0}
data-confirm={
gettext(
"Are you sure you want to refresh MusicBrainz data for all records? This operation can take a long time to complete."
)
}
>
<.loading :if={@refresh_records_musicbrainz_jobs > 0} class="size-4" />
{gettext("Refresh MusicBrainz data")}
</.button>
<.button
type="button"
phx-click="generate_record_embeddings"
disabled={@generate_record_embeddings_jobs > 0}
data-confirm={
gettext(
"Are you sure you want to regenerate embeddings for all records? This operation can take a long time to complete."
)
}
>
<.loading :if={@generate_record_embeddings_jobs > 0} class="size-4" />
{gettext("Regenerate record embeddings")}
</.button>
</.button_group>
</li>
</ul>
<h3 class="mt-4 text-base font-semibold text-zinc-900 dark:text-white">
{gettext("Artists")}
</h3>
<p class="mt-2 max-w-4xl text-sm text-zinc-500 dark:text-zinc-400">
{gettext(
"Run operations on the entire artist database. Monitor execution via the Oban dashboard."
)}
</p>
<ul class="mt-4">
<li class="space-y-4">
<.button_group>
<.button
type="button"
phx-click="refresh_artists_musicbrainz_data"
disabled={@refresh_artists_musicbrainz_jobs > 0}
data-confirm={
gettext(
"Are you sure you want to refresh MusicBrainz data for all artists? This operation can take a long time to complete."
)
}
>
<.loading :if={@refresh_artists_musicbrainz_jobs > 0} class="size-4" />
{gettext("Refresh MusicBrainz data")}
</.button>
<.button
type="button"
phx-click="refresh_artists_discogs_data"
disabled={@refresh_artists_discogs_jobs > 0}
data-confirm={
gettext(
"Are you sure you want to refresh Discogs data for all artists? This operation can take a long time to complete."
)
}
>
<.loading :if={@refresh_artists_discogs_jobs > 0} class="size-4" />
{gettext("Refresh Discogs data")}
</.button>
<.button
type="button"
phx-click="refresh_artists_wikipedia_data"
disabled={@refresh_artists_wikipedia_jobs > 0}
data-confirm={
gettext(
"Are you sure you want to refresh Wikipedia data for all artists? This operation can take a long time to complete."
)
}
>
<.loading :if={@refresh_artists_wikipedia_jobs > 0} class="size-4" />
{gettext("Refresh Wikipedia data")}
</.button>
</.button_group>
</li>
</ul>
<h3 class="mt-4 text-base font-semibold text-zinc-900 dark:text-white">
{gettext("Database")}
</h3>
<p class="mt-2 max-w-4xl text-sm text-zinc-500 dark:text-zinc-400">
{gettext("Run lower-level operations on the database")}
</p>
<ul class="mt-4">
<li class="space-y-4">
<.button_group>
<.button
type="button"
phx-click="db_vacuum"
phx-disable-with={gettext("Running vacuum...")}
>
{gettext("Vacuum")}
</.button>
<.button
type="button"
phx-click="db_optimize"
phx-disable-with={gettext("Running optimize...")}
>
{gettext("Optimize")}
</.button>
<.button href={~p"/backup"}>
{gettext("Backup")}
</.button>
</.button_group>
</li>
</ul>
</div>
</Layouts.app>
"""
end
@impl true
def mount(_params, _session, socket) do
if connected?(socket) do
Process.send_after(self(), :update_job_counts, @poll_interval)
@@ -26,6 +162,7 @@ defmodule MusicLibraryWeb.MaintenanceLive.Index do
|> assign_job_counts()}
end
@impl true
def handle_info(:update_job_counts, socket) do
Process.send_after(self(), :update_job_counts, @poll_interval)
@@ -66,6 +203,7 @@ defmodule MusicLibraryWeb.MaintenanceLive.Index do
BackgroundRepo.one(query)
end
@impl true
def handle_event("refresh_records_musicbrainz_data", _params, socket) do
Records.Batch.refresh_musicbrainz_data()