From 58d97b5e271bc0d7507eab5b9bd2902181864e02 Mon Sep 17 00:00:00 2001 From: "Daniel F. Dickinson" Date: Fri, 3 Aug 2018 12:36:51 -0400 Subject: [PATCH] modules: Split luci-mod-full Move some common elements to luci-base, and otherwise make three packages out of status, system, and network. They were mostly separated already, but there were some shared elements between status and network that are now in luci-base. Signed-off-by: Daniel F. Dickinson --- .../luasrc/controller/admin/index.lua | 40 +++++++++++++++++++ .../luasrc/view/cbi/wireless_modefreq.htm | 0 .../luasrc/view}/lease_status.htm | 2 +- .../luasrc/view}/wifi_assoclist.htm | 2 +- modules/luci-mod-admin-full/Makefile | 3 +- modules/luci-mod-network/Makefile | 17 ++++++++ .../luasrc/controller/admin/network.lua | 25 ------------ .../luasrc/model/cbi/admin_network/dhcp.lua | 2 +- .../luasrc/model/cbi/admin_network/hosts.lua | 0 .../model/cbi/admin_network/iface_add.lua | 0 .../luasrc/model/cbi/admin_network/ifaces.lua | 0 .../model/cbi/admin_network/network.lua | 0 .../model/cbi/admin_network/proto_ahcp.lua | 0 .../luasrc/model/cbi/admin_network/routes.lua | 0 .../luasrc/model/cbi/admin_network/vlan.lua | 0 .../luasrc/model/cbi/admin_network/wifi.lua | 0 .../model/cbi/admin_network/wifi_add.lua | 0 .../model/cbi/admin_network/wifi_overview.lua | 2 +- .../luasrc/view/admin_network/diagnostics.htm | 0 .../admin_network/iface_overview_status.htm | 0 .../view/admin_network/iface_status.htm | 0 .../view/admin_network/switch_status.htm | 0 .../luasrc/view/admin_network/wifi_join.htm | 0 .../admin_network/wifi_overview_status.htm | 0 .../luasrc/view/admin_network/wifi_status.htm | 0 .../etc/uci-defaults/50_luci-mod-admin-full | 0 modules/luci-mod-status/Makefile | 18 +++++++++ .../luci-static/resources/bandwidth.svg | 0 .../luci-static/resources/connections.svg | 0 .../htdocs/luci-static/resources/load.svg | 0 .../htdocs/luci-static/resources/wifirate.svg | 0 .../htdocs/luci-static/resources/wireless.svg | 0 .../luasrc/controller/admin/status.lua | 0 .../model/cbi/admin_status/processes.lua | 0 .../luasrc/view/admin_status/bandwidth.htm | 0 .../luasrc/view/admin_status/connections.htm | 0 .../luasrc/view/admin_status/dmesg.htm | 0 .../luasrc/view/admin_status/index.htm | 4 +- .../luasrc/view/admin_status/iptables.htm | 0 .../luasrc/view/admin_status/load.htm | 0 .../luasrc/view/admin_status/routes.htm | 0 .../luasrc/view/admin_status/syslog.htm | 0 .../luasrc/view/admin_status/wireless.htm | 0 .../src/Makefile | 0 .../src/luci-bwc.c | 0 modules/luci-mod-system/Makefile | 17 ++++++++ .../luasrc/controller/admin/system.lua | 0 .../luasrc/model/cbi/admin_system/admin.lua | 0 .../model/cbi/admin_system/backupfiles.lua | 0 .../luasrc/model/cbi/admin_system/crontab.lua | 0 .../luasrc/model/cbi/admin_system/fstab.lua | 0 .../model/cbi/admin_system/fstab/mount.lua | 0 .../model/cbi/admin_system/fstab/swap.lua | 0 .../luasrc/model/cbi/admin_system/ipkg.lua | 0 .../luasrc/model/cbi/admin_system/leds.lua | 0 .../luasrc/model/cbi/admin_system/startup.lua | 0 .../luasrc/model/cbi/admin_system/system.lua | 0 .../luasrc/view/admin_system/applyreboot.htm | 0 .../luasrc/view/admin_system/backupfiles.htm | 0 .../luasrc/view/admin_system/clock_status.htm | 0 .../luasrc/view/admin_system/flashops.htm | 0 .../luasrc/view/admin_system/ipkg.htm | 0 .../luasrc/view/admin_system/packages.htm | 0 .../luasrc/view/admin_system/reboot.htm | 0 .../luasrc/view/admin_system/upgrade.htm | 0 65 files changed, 99 insertions(+), 33 deletions(-) rename modules/{luci-mod-admin-full => luci-base}/luasrc/view/cbi/wireless_modefreq.htm (100%) rename modules/{luci-mod-admin-full/luasrc/view/admin_network => luci-base/luasrc/view}/lease_status.htm (97%) rename modules/{luci-mod-admin-full/luasrc/view/admin_network => luci-base/luasrc/view}/wifi_assoclist.htm (97%) create mode 100644 modules/luci-mod-network/Makefile rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/controller/admin/network.lua (94%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/model/cbi/admin_network/dhcp.lua (99%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/model/cbi/admin_network/hosts.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/model/cbi/admin_network/iface_add.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/model/cbi/admin_network/ifaces.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/model/cbi/admin_network/network.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/model/cbi/admin_network/proto_ahcp.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/model/cbi/admin_network/routes.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/model/cbi/admin_network/vlan.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/model/cbi/admin_network/wifi.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/model/cbi/admin_network/wifi_add.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/model/cbi/admin_network/wifi_overview.lua (99%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/view/admin_network/diagnostics.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/view/admin_network/iface_overview_status.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/view/admin_network/iface_status.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/view/admin_network/switch_status.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/view/admin_network/wifi_join.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/view/admin_network/wifi_overview_status.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/luasrc/view/admin_network/wifi_status.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-network}/root/etc/uci-defaults/50_luci-mod-admin-full (100%) create mode 100644 modules/luci-mod-status/Makefile rename modules/{luci-mod-admin-full => luci-mod-status}/htdocs/luci-static/resources/bandwidth.svg (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/htdocs/luci-static/resources/connections.svg (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/htdocs/luci-static/resources/load.svg (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/htdocs/luci-static/resources/wifirate.svg (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/htdocs/luci-static/resources/wireless.svg (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/luasrc/controller/admin/status.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/luasrc/model/cbi/admin_status/processes.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/luasrc/view/admin_status/bandwidth.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/luasrc/view/admin_status/connections.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/luasrc/view/admin_status/dmesg.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/luasrc/view/admin_status/index.htm (99%) rename modules/{luci-mod-admin-full => luci-mod-status}/luasrc/view/admin_status/iptables.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/luasrc/view/admin_status/load.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/luasrc/view/admin_status/routes.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/luasrc/view/admin_status/syslog.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/luasrc/view/admin_status/wireless.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/src/Makefile (100%) rename modules/{luci-mod-admin-full => luci-mod-status}/src/luci-bwc.c (100%) create mode 100644 modules/luci-mod-system/Makefile rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/controller/admin/system.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/model/cbi/admin_system/admin.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/model/cbi/admin_system/backupfiles.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/model/cbi/admin_system/crontab.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/model/cbi/admin_system/fstab.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/model/cbi/admin_system/fstab/mount.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/model/cbi/admin_system/fstab/swap.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/model/cbi/admin_system/ipkg.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/model/cbi/admin_system/leds.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/model/cbi/admin_system/startup.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/model/cbi/admin_system/system.lua (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/view/admin_system/applyreboot.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/view/admin_system/backupfiles.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/view/admin_system/clock_status.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/view/admin_system/flashops.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/view/admin_system/ipkg.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/view/admin_system/packages.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/view/admin_system/reboot.htm (100%) rename modules/{luci-mod-admin-full => luci-mod-system}/luasrc/view/admin_system/upgrade.htm (100%) diff --git a/modules/luci-base/luasrc/controller/admin/index.lua b/modules/luci-base/luasrc/controller/admin/index.lua index 39e6e573b1..360298b1cd 100644 --- a/modules/luci-base/luasrc/controller/admin/index.lua +++ b/modules/luci-base/luasrc/controller/admin/index.lua @@ -16,6 +16,8 @@ function index() end end + local uci = require("luci.model.uci").cursor() + local root = node() if not root.target then root.target = alias("admin") @@ -23,6 +25,7 @@ function index() end local page = node("admin") + page.title = _("Administration") page.order = 10 page.sysauth = "root" @@ -61,6 +64,24 @@ function index() page.index = true toplevel_page(page, false, false) + if nixio.fs.access("/etc/config/dhcp") then + page = entry({"admin", "dhcplease_status"}, call("lease_status"), nil) + page.leaf = true + end + + local has_wifi = false + + uci:foreach("wireless", "wifi-device", + function(s) + has_wifi = true + return false + end) + + if has_wifi then + page = entry({"admin", "wireless_assoclist"}, call("wifi_assoclist"), nil) + page.leaf = true + end + -- Logout is last entry({"admin", "logout"}, call("action_logout"), _("Logout"), 999) end @@ -80,3 +101,22 @@ function action_logout() luci.http.redirect(dsp.build_url()) end + + +function lease_status() + local s = require "luci.tools.status" + + luci.http.prepare_content("application/json") + luci.http.write('[') + luci.http.write_json(s.dhcp_leases()) + luci.http.write(',') + luci.http.write_json(s.dhcp6_leases()) + luci.http.write(']') +end + +function wifi_assoclist() + local s = require "luci.tools.status" + + luci.http.prepare_content("application/json") + luci.http.write_json(s.wifi_assoclist()) +end diff --git a/modules/luci-mod-admin-full/luasrc/view/cbi/wireless_modefreq.htm b/modules/luci-base/luasrc/view/cbi/wireless_modefreq.htm similarity index 100% rename from modules/luci-mod-admin-full/luasrc/view/cbi/wireless_modefreq.htm rename to modules/luci-base/luasrc/view/cbi/wireless_modefreq.htm diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm b/modules/luci-base/luasrc/view/lease_status.htm similarity index 97% rename from modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm rename to modules/luci-base/luasrc/view/lease_status.htm index 8fbbdc9477..15b6b6908e 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm +++ b/modules/luci-base/luasrc/view/lease_status.htm @@ -1,5 +1,5 @@