Skip to content

Commit

Permalink
Better message when applying configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jjcarstens committed Jan 6, 2020
1 parent 6f5fd28 commit 2093278
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
9 changes: 9 additions & 0 deletions lib/vintage_net_wizard/ap_mode.ex
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ defmodule VintageNetWizard.APMode do
}
end

@doc """
Return SSID that is used for AP Mode
"""
@spec ssid() :: String.t()
def ssid() do
get_hostname()
|> sanitize_hostname_for_ssid()
end

defp get_hostname() do
{:ok, hostname} = :inet.gethostname()
hostname_string = to_string(hostname)
Expand Down
2 changes: 1 addition & 1 deletion lib/vintage_net_wizard/web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ defmodule VintageNetWizard.Web.Router do
end

get "/apply" do
render_page(conn, "apply.html")
render_page(conn, "apply.html", ssid: VintageNetWizard.APMode.ssid())
end

forward("/api/v1", to: VintageNetWizard.Web.Api)
Expand Down
16 changes: 13 additions & 3 deletions priv/static/js/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
completeTimer: null,
targetElem: document.querySelector(".content"),
configurationStatus: "not_configured",
completed: false
completed: false,
ssid: document.getElementById("ssid").getAttribute("value")
}

function runGetStatus() {
Expand Down Expand Up @@ -66,10 +67,19 @@
complete();
}

function view({view, dots}) {
function view({view, dots, ssid}) {
switch (view) {
case "trying":
return ["Trying configuration" + dots, runGetStatus];
return [`
<p>Trying Configuration ${dots}</p>
<p>VintageNetWizard has disabled Access Point mode and is attempting to connect
to at least one of the networks in the configuration as verification.</p>
<p>If this page is present for > 15 seconds, check that you have reconnected to
your access point: <b>${ssid}</b></p>
`, runGetStatus
];
case "configurationGood":
return [`
<p>Configuration okay</p>
Expand Down
9 changes: 8 additions & 1 deletion priv/templates/apply.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@
<body class="bg-light h-100 d-flex flex-column">
<div class="container">
<h1 class="text-right mt-2"><a href="/">VintageNet Wizard</a></h1>
<div id="ssid" value="<%= ssid %>" hidden></div>

<div class="content">
Trying configuration...
<p>Trying Configuration</p>

<p>VintageNetWizard has disabled Access Point mode and is attempting to connect
to at least one of the networks in the configuration as verification.</p>

<p>If this page is present for > 15 seconds, check that you have reconnected to
your access point: <b><%= ssid %></b></p>
</div>
</div>
<footer class="py-3 bg-white shadow-sm w-100 text-muted">
Expand Down

0 comments on commit 2093278

Please sign in to comment.