From d9814601eb093f1cac5c57c9dd2392fdbb0956fc Mon Sep 17 00:00:00 2001 From: Jon Carstens Date: Tue, 7 Jan 2020 10:23:20 -0700 Subject: [PATCH] Add /complete endpoint Also change the `Complete without verification` to use `/complete` endpoint and remove the JS confirm dialog to fix cases that the JS may not be working (especially in captive portal) --- lib/vintage_net_wizard/web/router.ex | 15 +++++++++++++++ priv/templates/index.html.eex | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/vintage_net_wizard/web/router.ex b/lib/vintage_net_wizard/web/router.ex index e8687832..306b9589 100644 --- a/lib/vintage_net_wizard/web/router.ex +++ b/lib/vintage_net_wizard/web/router.ex @@ -6,6 +6,7 @@ defmodule VintageNetWizard.Web.Router do alias VintageNetWizard.{ Backend, + Web.Endpoint, WiFiConfiguration } @@ -112,6 +113,20 @@ defmodule VintageNetWizard.Web.Router do render_page(conn, "apply.html", ssid: VintageNetWizard.APMode.ssid()) end + get "/complete" do + :ok = Backend.complete() + + _ = + Task.Supervisor.start_child(VintageNetWizard.TaskSupervisor, fn -> + # We don't want to stop the server before we + # send the response back. + :timer.sleep(3000) + Endpoint.stop_server() + end) + + render_page(conn, "complete.html") + end + forward("/api/v1", to: VintageNetWizard.Web.Api) match _ do diff --git a/priv/templates/index.html.eex b/priv/templates/index.html.eex index 90e8240a..c123b7b6 100644 --- a/priv/templates/index.html.eex +++ b/priv/templates/index.html.eex @@ -62,7 +62,7 @@ Add a New Network <%= if length(configs) > 0 do %> Apply configuration - Complete Without Verification + Complete Without Verification <% end %>