diff --git a/files/usr/lib/lua/aredn/html.lua b/files/usr/lib/lua/aredn/html.lua index ff54d618..340245df 100644 --- a/files/usr/lib/lua/aredn/html.lua +++ b/files/usr/lib/lua/aredn/html.lua @@ -88,6 +88,67 @@ function html.msg_banner() html.print("") end +function html.navbar_user(selected, config_mode) + local order = {} + local navs = {} + if config_mode then + _G.config_mode = config_mode + end + for file in nixio.fs.dir("/usr/lib/lua/aredn/nav/user") + do + order[#order + 1] = file + navs[file] = require("aredn.nav.user." .. file:match("^(.*)%.lua$")) + end + table.sort(order) + html.print("") + html.print("Help") + html.print("  ") + for _, key in ipairs(order) + do + local nav = navs[key] + if type(nav) == "table" then + html.print("  ") + end + end + html.print("  ") + html.print("") +end + +function html.navbar_admin(selected) + local order = {} + local navs = {} + for file in nixio.fs.dir("/usr/lib/lua/aredn/nav/admin") + do + order[#order + 1] = file + navs[file] = require("aredn.nav.admin." .. file:match("^(.*)%.lua$")) + end + table.sort(order) + html.print("") + local width = math.floor(100 / #order) .. "%" + for _, key in ipairs(order) + do + local nav = navs[key] + if type(nav) == "table" then + html.print("") + else + html.print("" .. nav.display .. "") + end + end + end + html.print("


") +end + function html.print(line) -- html output is defined in aredn.http -- this is a bit icky at the moment :-() diff --git a/files/usr/lib/lua/aredn/nav/admin/10status.lua b/files/usr/lib/lua/aredn/nav/admin/10status.lua new file mode 100644 index 00000000..8a7e4e12 --- /dev/null +++ b/files/usr/lib/lua/aredn/nav/admin/10status.lua @@ -0,0 +1 @@ +return { href = "status", display = "Node Status" } diff --git a/files/usr/lib/lua/aredn/nav/admin/20setup.lua b/files/usr/lib/lua/aredn/nav/admin/20setup.lua new file mode 100644 index 00000000..55d85fd1 --- /dev/null +++ b/files/usr/lib/lua/aredn/nav/admin/20setup.lua @@ -0,0 +1 @@ +return { href = "setup", display = "Basic Setup" } diff --git a/files/usr/lib/lua/aredn/nav/admin/30ports.lua b/files/usr/lib/lua/aredn/nav/admin/30ports.lua new file mode 100644 index 00000000..45c9aba1 --- /dev/null +++ b/files/usr/lib/lua/aredn/nav/admin/30ports.lua @@ -0,0 +1 @@ +return { href = "ports", display = "Port Forwarding,
DHCP, and Services" } diff --git a/files/usr/lib/lua/aredn/nav/admin/40vpn.lua b/files/usr/lib/lua/aredn/nav/admin/40vpn.lua new file mode 100644 index 00000000..e6ab568e --- /dev/null +++ b/files/usr/lib/lua/aredn/nav/admin/40vpn.lua @@ -0,0 +1 @@ +return { href = "vpn", display = "Tunnel
Server", enable = nixio.fs.stat("/usr/sbin/vtund") ~= nil } diff --git a/files/usr/lib/lua/aredn/nav/admin/50vpnc.lua b/files/usr/lib/lua/aredn/nav/admin/50vpnc.lua new file mode 100644 index 00000000..3a1ec998 --- /dev/null +++ b/files/usr/lib/lua/aredn/nav/admin/50vpnc.lua @@ -0,0 +1 @@ +return { href = "vpnc", display = "Tunnel
Client", enable = nixio.fs.stat("/usr/sbin/vtund") ~= nil } diff --git a/files/usr/lib/lua/aredn/nav/admin/60admin.lua b/files/usr/lib/lua/aredn/nav/admin/60admin.lua new file mode 100644 index 00000000..e2fd326e --- /dev/null +++ b/files/usr/lib/lua/aredn/nav/admin/60admin.lua @@ -0,0 +1 @@ +return { href = "admin", display = "Administration" } diff --git a/files/usr/lib/lua/aredn/nav/admin/70advancedconfig.lua b/files/usr/lib/lua/aredn/nav/admin/70advancedconfig.lua new file mode 100644 index 00000000..7ccf9e27 --- /dev/null +++ b/files/usr/lib/lua/aredn/nav/admin/70advancedconfig.lua @@ -0,0 +1 @@ +return { href = "advancedconfig", display = "Advanced
Configuration" } diff --git a/files/usr/lib/lua/aredn/nav/user/10mesh.lua b/files/usr/lib/lua/aredn/nav/user/10mesh.lua new file mode 100644 index 00000000..8a78c9bd --- /dev/null +++ b/files/usr/lib/lua/aredn/nav/user/10mesh.lua @@ -0,0 +1 @@ +return { href = "mesh", display = "Mesh Status", hint = "See what is on the mesh", enable = not config_mode } diff --git a/files/usr/lib/lua/aredn/nav/user/20lqm.lua b/files/usr/lib/lua/aredn/nav/user/20lqm.lua new file mode 100644 index 00000000..cc9042a4 --- /dev/null +++ b/files/usr/lib/lua/aredn/nav/user/20lqm.lua @@ -0,0 +1,3 @@ +if uci.cursor():get("aredn", "@lqm[0]", "enable") == "1" then + return { href = "lqm", display = "Neighbor Status", hint = "See the link status to our neighbors", enable = not config_mode } +end diff --git a/files/usr/lib/lua/aredn/nav/user/30scan.lua b/files/usr/lib/lua/aredn/nav/user/30scan.lua new file mode 100644 index 00000000..fb623097 --- /dev/null +++ b/files/usr/lib/lua/aredn/nav/user/30scan.lua @@ -0,0 +1,3 @@ +if aredn.hardware.get_iface_name("wifi"):match("wlan(%d+)") then + return { href = "scan", display = "WiFi Scan", hint = "See what wireless networks are nearby", enable = not config_mode } +end diff --git a/files/usr/lib/lua/aredn/nav/user/40setup.lua b/files/usr/lib/lua/aredn/nav/user/40setup.lua new file mode 100644 index 00000000..c885f2d4 --- /dev/null +++ b/files/usr/lib/lua/aredn/nav/user/40setup.lua @@ -0,0 +1 @@ +return { href = "setup", display = "Setup", hint = "Configure this node", enable = not config_mode or config_mode ~= "ram" } diff --git a/files/www/cgi-bin/admin b/files/www/cgi-bin/admin index 54c4c68a..adc8e1e1 100755 --- a/files/www/cgi-bin/admin +++ b/files/www/cgi-bin/admin @@ -811,18 +811,10 @@ http_header() html.header(node .. " administration", true) html.print("
") html.alert_banner() -html.print("
") +html.navbar_admin("admin") +html.print("
") +html.print("") -- nav -html.print("
") -html.print("") -html.print("") -html.print("") -html.print("") -html.print("") -html.print("") -html.print("") -html.print("
Node StatusBasic SetupPort Forwarding,
DHCP, and Services
Tunnel
Server
Tunnel
Client
Advanced
Configuration

") -html.print("
") html.print("
Help  ") html.print("") diff --git a/files/www/cgi-bin/advancedconfig b/files/www/cgi-bin/advancedconfig index a77265cc..c9b2ed8b 100755 --- a/files/www/cgi-bin/advancedconfig +++ b/files/www/cgi-bin/advancedconfig @@ -850,21 +850,10 @@ function toggleDefault(fname, defval) { html.print("
") html.alert_banner(); -html.print("
") -html.print("WARNING: Changing advanced settings can be harmful to the stability, security, and performance of this node and potentially the entire mesh network.
You should only continue if you are sure of what you are doing.
") html.print("") -- navbar -html.print("
") -html.print("") -html.print("") -html.print("") -html.print("") -html.print("") -html.print("") -html.print("") -html.print("") -html.print("
Node StatusBasic SetupPort Forwarding,
DHCP, and Services
Tunnel
Server
Tunnel
Client
AdministrationAdvanced
Configuration

") +html.navbar_admin("advancedconfig") -- help link and buttons table html.print("
") @@ -873,6 +862,9 @@ html.print("    ") html.print("
") +html.print("
") +html.print("WARNING: Changing advanced settings can be harmful to the stability, security, and performance of this node and potentially the entire mesh network.
You should only continue if you are sure of what you are doing.
") + -- messages table html.print("") if nixio.fs.stat("/tmp/reboot-required") then diff --git a/files/www/cgi-bin/ports b/files/www/cgi-bin/ports index 9931028d..dab0097b 100755 --- a/files/www/cgi-bin/ports +++ b/files/www/cgi-bin/ports @@ -73,19 +73,6 @@ if os.getenv("REQUEST_METHOD") == "POST" then parms = request:formvalue() end -function navbar() - html.print("
") - html.print("
") - html.print("") - html.print("") - html.print("") - html.print("") - html.print("") - html.print("") - html.print("") - html.print("
Node StatusBasic SetupTunnel
Server
Tunnel
Client
AdministrationAdvanced
Configuration

") -end - function validate_service_name(name) if not name or name == "" or name:match("[:-\"|<>]") then return false @@ -147,10 +134,10 @@ local macs = {} if config ~= "mesh" or nixio.fs.stat("/tmp/reboot-required") then http_header() html.header(node .. " setup", true) - html.print("
") + html.print("
") html.alert_banner() - navbar() - html.print("

") + html.navbar_admin("ports") + html.print("

") if config == "" then html.print("This page is not available until the configuration has been set.") else @@ -852,10 +839,8 @@ html.header(node .. " setup", true) html.print("
") html.alert_banner() html.print("") +html.navbar_admin("ports") html.print("") -html.print("") -- control buttons html.print([[
") -navbar() -html.print("
diff --git a/files/www/cgi-bin/setup b/files/www/cgi-bin/setup index 4db24083..e14256a0 100755 --- a/files/www/cgi-bin/setup +++ b/files/www/cgi-bin/setup @@ -961,19 +961,9 @@ html.print("
") html.alert_banner() html.print("\n") -html.print("") -html.print("") +html.navbar_admin("setup") +html.print("
") -- navbar -html.print("
") -html.print("") -html.print("") -html.print("") -html.print("") -html.print("") -html.print("") -html.print("") -html.print("
Node StatusPort Forwarding,
DHCP, and Services
Tunnel
Server
Tunnel
Client
AdministrationAdvanced
Configuration

") -html.print("
") -- control buttons html.print([[
Help diff --git a/files/www/cgi-bin/status b/files/www/cgi-bin/status index b7927821..c3f76c6c 100755 --- a/files/www/cgi-bin/status +++ b/files/www/cgi-bin/status @@ -141,17 +141,6 @@ function get_wifi_signal(wifiif) end end -function css_options() - html.print("") - for file in nixio.fs.glob("/www/*.css") - do - if file ~= "/www/style.css" then - file = file:match("/www/(.*).css") - html.print("") - end - end -end - -- helpers end local node = aredn_info.get_nvram("node") @@ -264,48 +253,33 @@ if node_desc then end html.print("
") --- nav buttons -html.print("") -html.print("Help") -html.print("  ") -html.print("") -if config == "mesh" then - html.print("  ") - html.print("") - if cursor:get("aredn", "@lqm[0]", "enable") == "1" then - html.print("  ") - html.print("") - end - if not wifi_disabled then - html.print("  ") - html.print("") - end -end -html.print("  ") -html.print("") -html.print("  ") -html.print("") -html.print("") - -html.print("") - +-- Work out what config mode we're in. We use this to better instruct the +-- user about the next steps +local config_mode = nil if config == "not set" then - html.print("

This node is not yet configured.
") - local overlay = false + config_mode = "ram" for line in io.lines("/proc/mounts") do if line:match("overlay") then - overlay = true + config_mode = "setup" break end end - if overlay then +end + +-- nav buttons +html.navbar_user("status", config_mode) + +html.print("") + +if config_mode then + html.print("

This node is not yet configured.
") + if config_mode == "setup" then html.print("Go to the setup page and set your node name and password.
") html.print("Click Save Changes, even if you didn't make any changes, then the node will reboot.
") else - html.print("Go the the administration page and upload new firmware.
") + html.print("
*** WARNING ***

AREDN is currently running a temporary image.
All configuration changes will be lost if you reboot.

") + html.print("Before doing anything else, please go
to the administration page and upload firmware.
") end html.print("

") html.print("
") diff --git a/files/www/cgi-bin/vpn b/files/www/cgi-bin/vpn index 09fc3862..bf88a751 100755 --- a/files/www/cgi-bin/vpn +++ b/files/www/cgi-bin/vpn @@ -86,19 +86,6 @@ function hide(inp) hidden[#hidden + 1] = inp end -function navbar() - html.print("
") - html.print("
") - html.print("") - html.print("") - html.print("") - html.print("") - html.print("") - html.print("") - html.print("") - html.print("
Node StatusBasic SetupPort Forwarding,
DHCP, and Services
Tunnel
Client
AdministrationAdvanced
Configuration

") -end - function get_active_tun() local tuns = {} local f = io.popen("ps -w | grep vtun | grep ' tun '") @@ -176,9 +163,9 @@ if config == "" or nixio.fs.stat("/tmp/reboot-required") then html.header(node .. " setup", true); html.print("
") html.alert_banner() + html.navbar_admin("vpn") html.print("
") - navbar(); - html.print("

") + html.print("

") if config == "" then html.print("This page is not available until the configuration has been set.") else @@ -377,12 +364,11 @@ html.header(node .. " setup", true) html.print("
") html.alert_banner() html.print("") -html.print("") -html.print("") -- navigation bar -navbar() -html.print("") +html.navbar_admin("vpn") + +html.print("
") -- control buttons html.print("
") diff --git a/files/www/cgi-bin/vpnc b/files/www/cgi-bin/vpnc index 116fb99b..2dde25d4 100755 --- a/files/www/cgi-bin/vpnc +++ b/files/www/cgi-bin/vpnc @@ -90,19 +90,6 @@ function err2(msg) errors[#errors + 1] = msg end -function navbar() - html.print("
") - html.print("
") - html.print("") - html.print("") - html.print("") - html.print("") - html.print("") - html.print("") - html.print("") - html.print("
Node StatusBasic SetupPort Forwarding,
DHCP, and Services
Tunnel
Server
AdministrationAdvanced
Configuration

") -end - function get_active_tun() local tuns = {} local f = io.popen("ps -w | grep vtun | grep ' tun '") @@ -160,9 +147,9 @@ if config == "" or nixio.fs.stat("/tmp/reboot-required") then html.header(node .. " setup", true); html.print("
") html.alert_banner() + html.navbar_admin("vpnc") html.print("") - navbar(); - html.print("

") + html.print("

") if config == "" then html.print("This page is not available until the configuration has been set.") else @@ -353,15 +340,13 @@ html.header(node .. " setup", true) html.print("
") html.alert_banner() -html.print("") +html.print("") -- nav bar -html.print("") +html.navbar_admin("vpnc") -- control buttons -html.print("
") -navbar() -html.print("
") +html.print("
") html.print("Help") html.print("   ") html.print(" ")