Skip to content

Commit

Permalink
Add /complete endpoint
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
jjcarstens committed Jan 7, 2020
1 parent 0954601 commit d981460
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions lib/vintage_net_wizard/web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule VintageNetWizard.Web.Router do

alias VintageNetWizard.{
Backend,
Web.Endpoint,
WiFiConfiguration
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion priv/templates/index.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<a class="btn btn-primary" href="/networks">Add a New Network</a>
<%= if length(configs) > 0 do %>
<a class="btn btn-primary" href="/apply">Apply configuration</a>
<a class="btn btn-secondary" href="#" onclick="applyWithoutVerification()">Complete Without Verification</a>
<a class="btn btn-secondary" href="/complete" title="This will apply the configuration without any attempt to verify a successful network connection.">Complete Without Verification</a>
<% end %>
</div>

Expand Down

0 comments on commit d981460

Please sign in to comment.