styling and logic updates

pull/507/head
connor rigby 2018-04-30 15:01:41 -07:00
parent 22824574cb
commit 5b632ef750
No known key found for this signature in database
GPG Key ID: 24DC438382965C3B
11 changed files with 91 additions and 62 deletions

View File

@ -26,7 +26,7 @@ defmodule Farmbot.Mixfile do
target: @target,
commit: commit(),
arduino_commit: arduino_commit(),
archives: [nerves_bootstrap: "~> 1.0.0-rc.2"],
archives: [nerves_bootstrap: "~> 1.0.0-rc.4"],
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
deps_path: "deps/#{@target}",
@ -86,8 +86,7 @@ defmodule Farmbot.Mixfile do
defp deps do
[
# {:nerves, "~> 1.0.0-rc.1", runtime: false},
{:nerves, github: "nerves-project/nerves", runtime: false, override: true},
{:nerves, "~> 1.0.0-rc.2", runtime: false},
{:elixir_make, "~> 0.4", runtime: false},
{:gen_stage, "~> 0.12"},

View File

@ -40,7 +40,7 @@
"mime": {:hex, :mime, "1.2.0", "78adaa84832b3680de06f88f0997e3ead3b451a440d183d688085be2d709b534", [:mix], [], "hexpm"},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"},
"mock": {:hex, :mock, "0.2.1", "bfdba786903e77f9c18772dee472d020ceb8ef000783e737725a4c8f54ad28ec", [:mix], [{:meck, "~> 0.8.2", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"},
"nerves": {:hex, :nerves, "1.0.0-rc.1", "7574d0c598074311e86128bea4c4a69ae751b4762a0c5ef817c9f61371091992", [:mix], [{:distillery, "~> 1.4", [hex: :distillery, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"},
"nerves": {:hex, :nerves, "1.0.0-rc.2", "927baad8eab2eb5c3c77fe6bd870ba95d2444a454854f6970bf96abe14936a43", [:mix], [{:distillery, "~> 1.4", [hex: :distillery, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"},
"nerves_leds": {:hex, :nerves_leds, "0.8.0", "193692767dca1a201b09113d242648493b9be0087bab83ebee99c3b0a254f5e1", [:mix], [], "hexpm"},
"nerves_uart": {:hex, :nerves_uart, "1.1.1", "2ba6282b45513268249e78880cd84bc37c5758ee7db9c6d92f442be21fcacc35", [:mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm"},
"plug": {:hex, :plug, "1.4.5", "7b13869283fff6b8b21b84b8735326cc012c5eef8607095dc6ee24bd0a273d8e", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"},

View File

@ -33,7 +33,7 @@
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
"mime": {:hex, :mime, "1.2.0", "78adaa84832b3680de06f88f0997e3ead3b451a440d183d688085be2d709b534", [:mix], [], "hexpm"},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"},
"nerves": {:git, "https://github.com/nerves-project/nerves.git", "364a07e8f7e27898b0dfef9cd7d6fd07b841f6a1", []},
"nerves": {:hex, :nerves, "1.0.0-rc.2", "927baad8eab2eb5c3c77fe6bd870ba95d2444a454854f6970bf96abe14936a43", [:mix], [{:distillery, "~> 1.4", [hex: :distillery, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"},
"nerves_firmware": {:hex, :nerves_firmware, "0.4.0", "ac2fed915a7ca4bb69f567d9b742d77cffc3a6a56420ce65e870c8c34119b935", [:mix], [], "hexpm"},
"nerves_firmware_ssh": {:hex, :nerves_firmware_ssh, "0.3.1", "e8b1967fa0aff255230be539c68ec868d33884193a385caff957ebad7d6aa8af", [:mix], [{:nerves_runtime, "~> 0.4", [hex: :nerves_runtime, repo: "hexpm", optional: false]}], "hexpm"},
"nerves_init_gadget": {:hex, :nerves_init_gadget, "0.3.0", "4c8fdd6af9f9ad82763d7e93ab1a3f380f64d4b2804cf70acad907261b7b16be", [:mix], [{:mdns, "~> 1.0", [hex: :mdns, repo: "hexpm", optional: false]}, {:nerves_firmware_ssh, "~> 0.2", [hex: :nerves_firmware_ssh, repo: "hexpm", optional: false]}, {:nerves_network, "~> 0.3", [hex: :nerves_network, repo: "hexpm", optional: false]}, {:nerves_runtime, "~> 0.3", [hex: :nerves_runtime, repo: "hexpm", optional: false]}, {:ring_logger, "~> 0.4", [hex: :ring_logger, repo: "hexpm", optional: false]}], "hexpm"},

View File

@ -23,12 +23,12 @@ defmodule Farmbot.Target.Bootstrap.Configurator.Router do
get "/network" do
interfaces = [:eth0, :wlan0]
render_page(conn, "network", [interfaces: interfaces])
render_page(conn, "network", [interfaces: interfaces, post_action: "select_interface"])
end
post "select_interface" do
{:ok, _, conn} = read_body(conn)
interface = conn.body_params["interface"]
interface = conn.body_params["interface"] |> remove_empty_string()
case interface do
nil -> redir(conn, "/network")
<<"w", _ ::binary >> = wireless -> redir(conn, "/config_wireless?ifname=#{wireless}")
@ -58,15 +58,16 @@ defmodule Farmbot.Target.Bootstrap.Configurator.Router do
post "config_wiresless_step_1" do
try do
ifname = conn.params["ifname"] || raise(MissingField, field: "ifname", message: "ifname not provided", redir: "/network")
ssid = conn.params["ssid"] || raise(MissingField, field: "ssid", message: "ssid not provided", redir: "/config_wireless?ifname=#{ifname}")
security = conn.params["security"] || raise(MissingField, field: "security", message: "security not provided", redir: "/config_wireless?ifname=#{ifname}")
manualssid = conn.params["manualssid"]
ifname = conn.params["ifname"] |> remove_empty_string() || raise(MissingField, field: "ifname", message: "ifname not provided", redir: "/network")
ssid = conn.params["ssid"] |> remove_empty_string()
security = conn.params["security"] |> remove_empty_string()
manualssid = conn.params["manualssid"] |> remove_empty_string()
opts = [ssid: ssid, ifname: ifname, security: security, advanced_network: advanced_network(), post_action: "config_network"]
cond do
manualssid != "" -> render_page(conn, "/config_wiresless_step_2_custom", opts)
manualssid != nil -> render_page(conn, "/config_wiresless_step_2_custom", Keyword.put(opts, :ssid, manualssid))
ssid == nil -> raise(MissingField, field: "ssid", message: "ssid not provided", redir: "/config_wireless?ifname=#{ifname}")
security == nil -> raise(MissingField, field: "security", message: "security not provided", redir: "/config_wireless?ifname=#{ifname}")
security == "WPA-PSK" -> render_page(conn, "/config_wiresless_step_2_PSK", opts)
security == "WPA2-PSK" -> render_page(conn, "/config_wiresless_step_2_PSK", opts)
security == "NONE" -> render_page(conn, "/config_wiresless_step_2_NONE", opts)
true -> render_page(conn, "/config_wiresless_step_2_other", opts)
end
@ -80,15 +81,15 @@ defmodule Farmbot.Target.Bootstrap.Configurator.Router do
post "/config_network" do
try do
ifname = conn.params["ifname"] || raise(MissingField, field: "ifname", message: "ifname not provided", redir: "/network")
ssid = conn.params["ssid"]
security = conn.params["security"]
psk = conn.params["psk"]
ssid = conn.params["ssid"] |> remove_empty_string()
security = conn.params["security"] |> remove_empty_string()
psk = conn.params["psk"] |> remove_empty_string()
domain = conn.params["domain"] |> remove_empty_string()
name_servers = conn.params["name_servers"] |> remove_empty_string()
ipv4_method = conn.params["ipv4_method"]
ipv4_address = conn.params["ipv4_address"]
ipv4_gateway = conn.params["ipv4_gateway"]
ipv4_subnet_mask = conn.params["ipv4_subnet_mask"]
ipv4_method = conn.params["ipv4_method"] |> remove_empty_string()
ipv4_address = conn.params["ipv4_address"] |> remove_empty_string()
ipv4_gateway = conn.params["ipv4_gateway"] |> remove_empty_string()
ipv4_subnet_mask = conn.params["ipv4_subnet_mask"] |> remove_empty_string()
ConfigStorage.input_network_config!(%{
name: ifname,
ssid: ssid, security: security, psk: psk,

View File

@ -42,12 +42,12 @@ defmodule Farmbot.Target.Bootstrap.Configurator.Router do
#NETWORKCONFIG
get "/network" do
interfaces = Farmbot.Target.Network.get_interfaces()
render_page(conn, "network", [interfaces: interfaces])
render_page(conn, "network", [interfaces: interfaces, post_action: "select_interface"])
end
post "select_interface" do
{:ok, _, conn} = read_body(conn)
interface = conn.body_params["interface"]
interface = conn.body_params["interface"] |> remove_empty_string()
case interface do
nil -> redir(conn, "/network")
<<"w", _ ::binary >> = wireless -> redir(conn, "/config_wireless?ifname=#{wireless}")
@ -78,15 +78,16 @@ defmodule Farmbot.Target.Bootstrap.Configurator.Router do
post "config_wiresless_step_1" do
try do
ifname = conn.params["ifname"] || raise(MissingField, field: "ifname", message: "ifname not provided", redir: "/network")
ssid = conn.params["ssid"] || raise(MissingField, field: "ssid", message: "ssid not provided", redir: "/config_wireless?ifname=#{ifname}")
security = conn.params["security"] || raise(MissingField, field: "security", message: "security not provided", redir: "/config_wireless?ifname=#{ifname}")
manualssid = conn.params["manualssid"]
ifname = conn.params["ifname"] |> remove_empty_string() || raise(MissingField, field: "ifname", message: "ifname not provided", redir: "/network")
ssid = conn.params["ssid"] |> remove_empty_string()
security = conn.params["security"] |> remove_empty_string()
manualssid = conn.params["manualssid"] |> remove_empty_string()
opts = [ssid: ssid, ifname: ifname, security: security, advanced_network: advanced_network(), post_action: "config_network"]
cond do
manualssid != "" -> render_page(conn, "/config_wiresless_step_2_custom", opts)
manualssid != nil -> render_page(conn, "/config_wiresless_step_2_custom", Keyword.put(opts, :ssid, manualssid))
ssid == nil -> raise(MissingField, field: "ssid", message: "ssid not provided", redir: "/config_wireless?ifname=#{ifname}")
security == nil -> raise(MissingField, field: "security", message: "security not provided", redir: "/config_wireless?ifname=#{ifname}")
security == "WPA-PSK" -> render_page(conn, "/config_wiresless_step_2_PSK", opts)
security == "WPA2-PSK" -> render_page(conn, "/config_wiresless_step_2_PSK", opts)
security == "NONE" -> render_page(conn, "/config_wiresless_step_2_NONE", opts)
true -> render_page(conn, "/config_wiresless_step_2_other", opts)
end
@ -100,15 +101,15 @@ defmodule Farmbot.Target.Bootstrap.Configurator.Router do
post "/config_network" do
try do
ifname = conn.params["ifname"] || raise(MissingField, field: "ifname", message: "ifname not provided", redir: "/network")
ssid = conn.params["ssid"]
security = conn.params["security"]
psk = conn.params["psk"]
ssid = conn.params["ssid"] |> remove_empty_string()
security = conn.params["security"] |> remove_empty_string()
psk = conn.params["psk"] |> remove_empty_string()
domain = conn.params["domain"] |> remove_empty_string()
name_servers = conn.params["name_servers"] |> remove_empty_string()
ipv4_method = conn.params["ipv4_method"]
ipv4_address = conn.params["ipv4_address"]
ipv4_gateway = conn.params["ipv4_gateway"]
ipv4_subnet_mask = conn.params["ipv4_subnet_mask"]
name_servers = conn.params["name_servers"] |> remove_empty_string()
ipv4_method = conn.params["ipv4_method"] |> remove_empty_string()
ipv4_address = conn.params["ipv4_address"] |> remove_empty_string()
ipv4_gateway = conn.params["ipv4_gateway"] |> remove_empty_string()
ipv4_subnet_mask = conn.params["ipv4_subnet_mask"] |> remove_empty_string()
ConfigStorage.input_network_config!(%{
name: ifname,
ssid: ssid, security: security, psk: psk,

View File

@ -30,6 +30,7 @@ defmodule Farmbot.Target.Network do
@doc "Scan on an interface. "
def do_scan(iface) do
Nerves.Network.scan(iface)
|> Enum.reject(&String.contains?(&1.ssid, "\\x00"))
|> ScanResult.decode()
|> ScanResult.sort_results()
|> ScanResult.decode_security()

View File

@ -184,6 +184,10 @@ th {
color: black;
}
.highlight {
background-color: yellow;
}
.ssid_quality,
.ssid_security {
color: #434343;

View File

@ -8,11 +8,15 @@
<script src="signal_table.js"></script>
<script type="text/javascript">
function selectSsid(ssid, security) {
function selectSsid(ssid, bssid, security) {
console.log("you selected "+ ssid);
document.getElementById("hiddenssidinput").value = ssid;
document.getElementById("hiddensecurityinput").value = security;
document.getElementById("ssid_select_form").submit();
var derp = document.getElementsByName("ssisSelector");
document.getElementById("manualssid").value = "";
for(var i = 0; i < derp.length; i++) derp[i].classList.remove("highlight");
document.getElementById(ssid + "." + bssid).classList.add("highlight");
}
function enableSsidInput() {
@ -39,19 +43,21 @@
<th class="centered"><label>Security</label></th>
</tr>
<%= for ssid_result <- ssids do %>
<tr class="ssid_result" onclick="selectSsid('<%= ssid_result.ssid %>', '<%= ssid_result.security %>')">
<td class="ssid_name"> <%= ssid_result.ssid || "hidden network" %> </td>
<td class="ssid_quality"> <script> document.write(signal_table[<%= ssid_result.level %>]) </script> </td>
<td class="ssid_security"> <%= ssid_result.security %> </td>
</tr>
<%= if ssid_result.ssid && String.printable?(ssid_result.ssid) do %>
<tr id="<%= ssid_result.ssid %>.<%= ssid_result.bssid %>" name="ssisSelector" class="ssid_result" onclick="selectSsid('<%= ssid_result.ssid %>', '<%= ssid_result.bssid %>', '<%= ssid_result.security %>')">
<td class="ssid_name"> <%= ssid_result.ssid || "hidden network" %> </td>
<td class="ssid_quality"> <script> document.write(signal_table[<%= ssid_result.level %>]) </script> </td>
<td class="ssid_security"> <%= ssid_result.security %> </td>
</tr>
<% end %>
<% end %>
</table>
<label class="customSsidInput" onclick="enableSsidInput()">Manual Input</label>
<input name="security" id="hiddensecurityinput" hidden=true />
<input name="ifname", hidden=true value="<%= ifname %>" />
<input name="ssid" id="hiddenssidinput" hidden/>
<label for="manualssid" class="customSsidInput" onclick="enableSsidInput()">Manual Input</label>
<input type="text" name="manualssid" id="manualssid"/>
<input name="security" id="hiddensecurityinput" hidden/>
<input name="ssid" id="hiddenssidinput" hidden/>
<input name="ifname" id="ifname" value="<%= ifname %>" hidden/>
</fieldset>
<div class="button"> <input type=submit value="next"> </div>

View File

@ -15,7 +15,7 @@
<form action=<%= post_action %> method="post">
<fieldset>
<label>Network Name</label>
<input name="ssid" type="text" disabled value="<%= ssid %>">
<input name="ssid" type="text" value="<%= ssid %>" disabled >
<input name="security" hidden=true value="<%= security %>" />
<input name="ifname", hidden=true value="<%= ifname %>" />

View File

@ -14,12 +14,25 @@
<form action=<%= post_action %> method="post" id="ssid_select_form">
<fieldset>
<label>Network Name</label>
<input name="ssid" type="text" disabled value="<%= ssid %>">
<input name="ssid_fake" type="text" value="<%= ssid %>" disabled>
<input name="ssid" type="text" value="<%= ssid %>" hidden>
<input name="security" hidden=true value="<%= security %>">
<input name="ifname", hidden=true value="<%= ifname %>">
<input name="ifname", hidden=true value="<%= ifname %>">
<label for="psk"> PASSWORD </label>
<input type="password" name="psk" id="psk">
<input type="checkbox" onclick="showPassword()">Show Password
<script>
function showPassword() {
var x = document.getElementById("psk");
if (x.type === "password") {
x.type = "text";
} else {
x.type = "password";
}
}
</script>
</fieldset>

View File

@ -5,8 +5,16 @@
<title> Configure Farmbot's Network </title>
<link rel="stylesheet" href="/styles.css">
<script src="signal_table.js"></script>
<script type="text/javascript">
function select_interface() {
var selected = document.getElementsByName("interfaceRadio");
for(var i = 0; i < selected.length; i++) {
if(selected[i].checked) {
document.getElementById("interface").value = selected[i].id;
document.getElementById("interfaceSelectForm").submit();
}
}
}
</script>
</head>
@ -16,20 +24,16 @@
<div class="widget">
<div class="widget-header"> <h5>Network</h5> </div>
<div class="widget-content">
<form action="select_interface" method="post">
<form action="<%= post_action %>" id="interfaceSelectForm" method="post">
<input id="interface" name="interface" value="" hidden/>
<% # Main form stuff %>
<fieldset>
<label>Select your interface</label>
<select id="interface", name="interface">
<%= for ifname <- interfaces do %>
<option> <%= ifname %> </option>
<% end %>
</select>
</fieldset>
<%= for ifname <- interfaces do %>
<label for='<%= ifname %>'> <%= ifname %> </label>
<input type="radio" id='<%= ifname %>' name="interfaceRadio" value=""/>
<% end %>
<% #/Main form stuff %>
<div class="button"> <input type=submit value="next"> </div>
<div class="button"> <input type=submit value="next" onclick="select_interface()"> </div>
</form>
</div>
</div>