Skip to content

Commit

Permalink
add configuration failed to configurator
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielburnworth committed Feb 18, 2023
1 parent 2efb9f9 commit 30b8f78
Show file tree
Hide file tree
Showing 21 changed files with 235 additions and 160 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

# 15.3.6

* Add new warning element to configurator.

# 15.3.4

* Fix `move_absolute` and `check_position` lua helper bugs.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15.3.4
15.3.6-rc4
11 changes: 10 additions & 1 deletion lib/ext/bootstrap.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,16 @@ defmodule FarmbotOS.Bootstrap do
msg = "Password auth failed! Check again and reconfigurate."
Logger.error(msg)
FarmbotOS.Logger.debug(3, msg)
FarmbotOS.Celery.SysCallGlue.factory_reset("farmbot_os")

FarmbotOS.System.factory_reset("""
FarmBot successfully connected to the web app
servers at #{server} but was not able to login to
the #{email} account. If you have registered an account with this
email, please try again and use the
eye icon to double check you have typed the
password correctly.
""")

FarmbotOS.Time.no_reply(nil, 5000)

er ->
Expand Down
50 changes: 30 additions & 20 deletions lib/os/configurator/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,7 @@ defmodule FarmbotOS.Configurator.Router do
get "/" do
FarmbotTelemetry.event(:configurator, :configuration_start)

case load_last_reset_reason() do
reason when is_binary(reason) ->
if String.contains?(reason, "Factory reset requested") do
redir(conn, "/network")
else
render_page(conn, "index",
version: version(),
last_reset_reason: reason
)
end

nil ->
redir(conn, "/network")
end
redir(conn, "/network")
end

get("/setup", do: redir(conn, "/"))
Expand All @@ -88,7 +75,9 @@ defmodule FarmbotOS.Configurator.Router do
_ ->
render_page(conn, "network",
interfaces: interfaces,
post_action: "select_interface"
post_action: "select_interface",
subtitle: subtitle(),
last_reset_reason: load_last_reset_reason()
)
end
end
Expand Down Expand Up @@ -120,7 +109,8 @@ defmodule FarmbotOS.Configurator.Router do

render_page(conn, "config_wired",
ifname: ifname,
advanced_network: advanced_network()
advanced_network: advanced_network(),
subtitle: subtitle()
)
end

Expand All @@ -130,7 +120,8 @@ defmodule FarmbotOS.Configurator.Router do
render_page(conn, "/config_wireless_step_1",
ifname: ifname,
ssids: scan(ifname),
post_action: "config_wireless_step_1"
post_action: "config_wireless_step_1",
subtitle: subtitle()
)
end

Expand All @@ -145,7 +136,8 @@ defmodule FarmbotOS.Configurator.Router do
ifname: ifname,
security: security,
advanced_network: advanced_network(),
post_action: "config_network"
post_action: "config_network",
subtitle: subtitle()
]

cond do
Expand Down Expand Up @@ -228,7 +220,8 @@ defmodule FarmbotOS.Configurator.Router do
render_page(conn, "credentials",
server: server,
email: email,
password: pass
password: pass,
subtitle: subtitle()
)
end

Expand Down Expand Up @@ -278,7 +271,11 @@ defmodule FarmbotOS.Configurator.Router do
} ->
FarmbotOS.Logger.debug(1, "Configuration success!")
save_config(get_session(conn))
render_page(conn, "finish")

render_page(conn, "finish",
subtitle: subtitle(),
target: target()
)

_ ->
FarmbotOS.Logger.debug(1, "Configuration FAIL")
Expand Down Expand Up @@ -390,4 +387,17 @@ defmodule FarmbotOS.Configurator.Router do
end

defp version, do: FarmbotOS.Project.version()
defp target, do: FarmbotOS.Project.target()

defp subtitle() do
device =
%{
host: "Computer",
rpi4: "Raspberry Pi 4",
rpi3: "Raspberry Pi 3 and Zero 2 W",
rpi: "Raspberry Pi Zero W"
}[target()]

"v#{version()} for #{device}"
end
end
16 changes: 16 additions & 0 deletions platform/target/network.ex
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,22 @@ defmodule FarmbotOS.Platform.Target.Network do
#{minutes} minutes.
""")

first_connect? = is_first_connect?()

if first_connect? do
FarmbotOS.System.set_shutdown_reason("""
FarmBot could not connect to the network. Please double check cable
connectivity using another device and try again. Are you sure it is
spelled correctly, in range, and has Good or Okay signal strength?
If your signal is too weak, consider using a WiFi repeater or an
Ethernet connection. Please try again and use the eye icon to double
check you have typed the password correctly. FarmBot requires ports 80,
443, 3002, and 8883 to communicate with the web app servers.
Please contact your network administrator to ensure all of these ports
are open for the FarmBot.
""")
end

{:noreply, state}
end

Expand Down
10 changes: 10 additions & 0 deletions priv/static/icon_warning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 65 additions & 19 deletions priv/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,26 @@ body {
h1,
h2 {
text-shadow: 0 0 25px rgba(0, 0, 0, 0.1), 0 0 25px rgba(0, 0, 0, 0.1);
margin-bottom: 3rem;
margin-bottom: 2rem;
font-weight: 100;
text-align: center;
color: #fff;
font-weight: 700;
}

h1 {
font-family: Inknut Antiqua;
margin-bottom: 0;
}

h2 {
margin-top: 0.5rem;
font-size: 1.3rem;
}

.button {
text-align: center;
margin-top: 3rem;
margin-top: 1rem;
}

.no-pad {
Expand Down Expand Up @@ -87,14 +98,29 @@ input[type=submit]:hover {
margin-bottom: 3rem;
position: relative;
margin: auto;
margin-bottom: 1.5rem;
max-width: 500px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

.bare {
border-radius: 5px;
font-weight: bold;
}

.bare p {
margin-top: 0.25rem;
font-weight: normal;
font-style: normal;
margin-bottom: 0;
}

.widget-header {
background: #434343;
letter-spacing: .05rem;
padding: .75rem 1rem;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}

h5 {
Expand All @@ -117,6 +143,8 @@ p {
border-color: #ddd;
color: #434343 !important;
padding: 1rem;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}

.widget-content:label {
Expand Down Expand Up @@ -440,34 +468,52 @@ td {
background-color: #999999;
}

.last-shutdown-reason {
background-color: #ccc;
padding: 10px;
.warning {
background-color: #FFDD66;
max-width: 500px;
margin: auto;
margin-bottom: 30px;
overflow-wrap: break-word;
border-radius: 5px;
}

.last-shutdown-reason-header {
text-align: center;
}

.last-shutdown-reason-header h5 {
color: #434343;
.warning-header {
position: relative;
padding: 1rem;
padding-left: 3rem;
padding-bottom: 0.25rem;
text-align: left;
}

.last-shutdown-reason i {
font-weight: bold;
.warning-header img {
position: absolute;
left: 0.75rem;
width: 20px;
height: 20px;
}

.last-shutdown-reason label {
.warning-header h5 {
color: #434343;
margin: 0;
text-transform: none;
}

.last-shutdown-reason hr {
border: 0.4px solid grey;
margin-top: 1.5rem;
#warning-content {
margin-left: 3rem;
padding: 1rem;
padding-top: 0;
padding-left: 0;
color: #434343;
}

.last-shutdown-reason .env-details {
padding-left: 1rem;
#warning-content a {
font-size: 0.75rem;
padding: 0.25rem;
margin-top: 1rem;
display: block;
width: fit-content;
text-align: center;
background: darkgray;
border-color: gray;
color: #434343;
}
4 changes: 3 additions & 1 deletion priv/static/templates/config_wired.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
</head>

<body>
<h1>Configure FarmBot <%= version %> </h1>
<h1>Configure FarmBot</h1>
<h2><%= subtitle %></h2>

<div class="widget">
<div class="widget-header"> <h5>Configure Wired</h5> </div>
<div class="widget-content">
Expand Down
4 changes: 3 additions & 1 deletion priv/static/templates/config_wireless_step_1.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
</head>

<body>
<h1>Configure FarmBot <%= version %> </h1>
<h1>Configure FarmBot</h1>
<h2><%= subtitle %></h2>

<div class="widget">
<div class="widget-header">
<h5>Configure Wireless</h5>
Expand Down
4 changes: 3 additions & 1 deletion priv/static/templates/config_wireless_step_2_EAP.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
</head>

<body>
<h1>Configure FarmBot <%= version %> </h1>
<h1>Configure FarmBot</h1>
<h2><%= subtitle %></h2>

<div class="widget">
<div class="widget-header"> <h5>Configure Wireless</h5> </div>
<div class="widget-content">
Expand Down
4 changes: 3 additions & 1 deletion priv/static/templates/config_wireless_step_2_NONE.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
</head>

<body>
<h1>Configure FarmBot <%= version %> </h1>
<h1>Configure FarmBot</h1>
<h2><%= subtitle %></h2>

<div class="widget">
<div class="widget-header"> <h5>Configure Wireless</h5> </div>
<div class="widget-content">
Expand Down
4 changes: 3 additions & 1 deletion priv/static/templates/config_wireless_step_2_PSK.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
</head>

<body>
<h1>Configure FarmBot <%= version %> </h1>
<h1>Configure FarmBot</h1>
<h2><%= subtitle %></h2>

<div class="widget">
<div class="widget-header"> <h5>Configure Wireless</h5> </div>
<div class="widget-content">
Expand Down
4 changes: 3 additions & 1 deletion priv/static/templates/config_wireless_step_2_custom.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
</head>

<body>
<h1>Configure FarmBot <%= version %> </h1>
<h1>Configure FarmBot</h1>
<h2><%= subtitle %></h2>

<div class="widget">
<div class="widget-header"> <h5>Configure Wireless</h5> </div>
<div class="widget-content">
Expand Down
4 changes: 3 additions & 1 deletion priv/static/templates/config_wireless_step_2_other.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
</head>

<body>
<h1>Configure FarmBot <%= version %> </h1>
<h1>Configure FarmBot</h1>
<h2><%= subtitle %></h2>

<div class="widget">
<div class="widget-header"> <h5>Configure Wireless</h5> </div>
<div class="widget-content">
Expand Down
Loading

0 comments on commit 30b8f78

Please sign in to comment.