prevent double-click on create backup button
Some checks failed
deploy / deploy (push) Failing after 6m10s
Some checks failed
deploy / deploy (push) Failing after 6m10s
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
2af30acb6a
commit
f47a4b90c7
@ -40,6 +40,12 @@ defmodule BerrypodWeb.Admin.Backup do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def handle_event("create_backup", _params, socket) do
|
def handle_event("create_backup", _params, socket) do
|
||||||
|
# Ignore if already creating
|
||||||
|
if socket.assigns.create_backup_status == :saving do
|
||||||
|
{:noreply, socket}
|
||||||
|
else
|
||||||
|
socket = assign(socket, :create_backup_status, :saving)
|
||||||
|
|
||||||
case Backup.create_backup() do
|
case Backup.create_backup() do
|
||||||
{:ok, _path} ->
|
{:ok, _path} ->
|
||||||
{:noreply,
|
{:noreply,
|
||||||
@ -54,6 +60,7 @@ defmodule BerrypodWeb.Admin.Backup do
|
|||||||
|> put_flash(:error, "Failed to create backup: #{inspect(error)}")}
|
|> put_flash(:error, "Failed to create backup: #{inspect(error)}")}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def handle_event("download_history_backup", %{"filename" => filename}, socket) do
|
def handle_event("download_history_backup", %{"filename" => filename}, socket) do
|
||||||
path = Path.join(Backup.backup_dir(), filename)
|
path = Path.join(Backup.backup_dir(), filename)
|
||||||
@ -323,6 +330,7 @@ defmodule BerrypodWeb.Admin.Backup do
|
|||||||
type="button"
|
type="button"
|
||||||
phx-click="create_backup"
|
phx-click="create_backup"
|
||||||
class="admin-btn admin-btn-primary admin-btn-sm"
|
class="admin-btn admin-btn-primary admin-btn-sm"
|
||||||
|
disabled={@create_backup_status == :saving}
|
||||||
>
|
>
|
||||||
<.icon name="hero-plus-mini" class="size-4" /> Create backup
|
<.icon name="hero-plus-mini" class="size-4" /> Create backup
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user