Refactor URL paths for modem configuration

This commit is contained in:
fujr 2024-10-24 16:44:15 +08:00
parent 52694e98d1
commit 9d32aff0d0
15 changed files with 46 additions and 46 deletions

View File

@ -4,9 +4,9 @@ local fs = require "nixio.fs"
local json = require("luci.jsonc") local json = require("luci.jsonc")
function index() function index()
--sim卡配置 --sim卡配置
entry({"admin", "network", "qmodem", "modem_sim"}, cbi("qmodem_hc/modem_sim"), luci.i18n.translate("SIM Config"), 23).leaf = true entry({"admin", "modem", "qmodem", "modem_sim"}, cbi("qmodem_hc/modem_sim"), luci.i18n.translate("SIM Config"), 23).leaf = true
entry({"admin", "network", "qmodem", "set_sim"}, call("setSIM"), nil).leaf = true entry({"admin", "modem", "qmodem", "set_sim"}, call("setSIM"), nil).leaf = true
entry({"admin", "network", "qmodem", "get_sim"}, call("getSIM"), nil).leaf = true entry({"admin", "modem", "qmodem", "get_sim"}, call("getSIM"), nil).leaf = true
end end
function getSimSlot(sim_path) function getSimSlot(sim_path)

View File

@ -12,7 +12,7 @@
function set_sim(){ function set_sim(){
select = document.getElementById("sim_slot_select"); select = document.getElementById("sim_slot_select");
slot = select.value; slot = select.value;
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "set_sim")%>', {"slot": slot }, XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "set_sim")%>', {"slot": slot },
function (x, data) { function (x, data) {
set_sim_view(data); set_sim_view(data);
} }
@ -20,7 +20,7 @@
} }
window.onload=function(){ window.onload=function(){
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "get_sim")%>', null, XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "get_sim")%>', null,
function (x, data) { function (x, data) {
set_sim_view(data); set_sim_view(data);
} }

View File

@ -5,5 +5,5 @@ function index()
return return
end end
--mwan配置 --mwan配置
entry({"admin", "network", "qmodem", "mwan_config"}, cbi("qmodem/mwan_config"), luci.i18n.translate("Mwan Config"), 21).leaf = true entry({"admin", "modem", "qmodem", "mwan_config"}, cbi("qmodem/mwan_config"), luci.i18n.translate("Mwan Config"), 21).leaf = true
end end

View File

@ -26,7 +26,7 @@ s.addremove = true
s.template = "cbi/tblsection" s.template = "cbi/tblsection"
member_interface = s:option(DynamicList, "member_interface", translate("Interface")) member_interface = s:option(DynamicList, "member_interface", translate("Interface"))
member_interface.rmempty = true member_interface.rmempty = true
member_interface.datatype = "network" member_interface.datatype = "modem"
member_interface.template = "cbi/network_netlist" member_interface.template = "cbi/network_netlist"
member_interface.widget = "select" member_interface.widget = "select"
member_interface.description = translate("Priority determines the order of member selection, while weight determines the traffic distribution ratio among members with the same priority.") member_interface.description = translate("Priority determines the order of member selection, while weight determines the traffic distribution ratio among members with the same priority.")

View File

@ -13,10 +13,10 @@ end
function index() function index()
--sim卡配置 --sim卡配置
entry({"admin", "network", "qmodem", "modem_sms"},template("modem_sms/modem_sms"), luci.i18n.translate("SMS"), 11).leaf = true entry({"admin", "modem", "qmodem", "modem_sms"},template("modem_sms/modem_sms"), luci.i18n.translate("SMS"), 11).leaf = true
entry({"admin", "network", "qmodem", "send_sms"}, call("sendSMS"), nil).leaf = true entry({"admin", "modem", "qmodem", "send_sms"}, call("sendSMS"), nil).leaf = true
entry({"admin", "network", "qmodem", "get_sms"}, call("getSMS"), nil).leaf = true entry({"admin", "modem", "qmodem", "get_sms"}, call("getSMS"), nil).leaf = true
entry({"admin", "network", "qmodem", "delete_sms"}, call("delSMS"), nil).leaf = true entry({"admin", "modem", "qmodem", "delete_sms"}, call("delSMS"), nil).leaf = true
end end
function getSMS() function getSMS()

View File

@ -609,7 +609,7 @@ class ModemSMS {
send_gsm(){ send_gsm(){
var phone_number = this.phone_number.value; var phone_number = this.phone_number.value;
var message_content = this.message_content.value; var message_content = this.message_content.value;
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "send_sms")%>',{ XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "send_sms")%>',{
"cfg": this.cfg_id, "cfg": this.cfg_id,
"phone_number": phone_number, "phone_number": phone_number,
"message_content": message_content, "message_content": message_content,
@ -631,7 +631,7 @@ class ModemSMS {
if (Array.isArray(pdu)) { if (Array.isArray(pdu)) {
pdu = pdu[0]; pdu = pdu[0];
} }
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "send_sms")%>',{ XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "send_sms")%>',{
"cfg": this.cfg_id, "cfg": this.cfg_id,
"pdu": pdu, "pdu": pdu,
},(x,data)=>{ },(x,data)=>{
@ -695,7 +695,7 @@ class ModemSMS {
if (this.cfg_id == null){ if (this.cfg_id == null){
return; return;
} }
XHR.poll(10,'<%=luci.dispatcher.build_url("admin", "network", "qmodem", "get_sms")%>',{ XHR.poll(10,'<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "get_sms")%>',{
"cfg": this.cfg_id, "cfg": this.cfg_id,
}, (x,data) => { }, (x,data) => {
@ -704,7 +704,7 @@ class ModemSMS {
} }
update(){ update(){
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "get_sms")%>',{ XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "get_sms")%>',{
"cfg": this.cfg_id, "cfg": this.cfg_id,
}, (x,data) => { }, (x,data) => {
this.combine_messages(data); this.combine_messages(data);
@ -712,7 +712,7 @@ class ModemSMS {
} }
update_modem_cfg_list(){ update_modem_cfg_list(){
XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "network", "qmodem", "get_modem_cfg")%>',{},(x,data)=>{ XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "get_modem_cfg")%>',{},(x,data)=>{
var new_cfg_list = []; var new_cfg_list = [];
var cfgs = data.cfgs; var cfgs = data.cfgs;
for (let i = 0; i < cfgs.length; i++) { for (let i = 0; i < cfgs.length; i++) {
@ -853,7 +853,7 @@ class ModemSMS {
delete_btn.value = "<%:Delete%>"; delete_btn.value = "<%:Delete%>";
delete_btn.addEventListener('click',()=>{ delete_btn.addEventListener('click',()=>{
this.lock(); this.lock();
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "delete_sms")%>',{ XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "delete_sms")%>',{
"cfg": this.cfg_id, "cfg": this.cfg_id,
"index": index.sort((a,b)=>{return b-a}).join(" "), "index": index.sort((a,b)=>{return b-a}).join(" "),
},(x,data)=>{ },(x,data)=>{

View File

@ -4,5 +4,5 @@ function index()
if not nixio.fs.access("/etc/config/qmodem_ttl") then if not nixio.fs.access("/etc/config/qmodem_ttl") then
return return
end end
entry({"admin", "network", "qmodem", "modem_ttl"}, cbi("qmodem/modem_ttl"), luci.i18n.translate("TTL Config"), 22).leaf = true entry({"admin", "modem", "qmodem", "modem_ttl"}, cbi("qmodem/modem_ttl"), luci.i18n.translate("TTL Config"), 22).leaf = true
end end

View File

@ -13,23 +13,23 @@ function index()
if not nixio.fs.access("/etc/config/qmodem") then if not nixio.fs.access("/etc/config/qmodem") then
return return
end end
entry({"admin", "modem"}, firstchild(), luci.i18n.translate("Modem"), 50).dependent = true
entry({"admin", "network", "qmodem"}, alias("admin", "network", "qmodem", "modem_info"), luci.i18n.translate("QModem"), 100).dependent = true entry({"admin", "modem", "qmodem"}, alias("admin", "modem", "qmodem", "modem_info"), luci.i18n.translate("QModem"), 100).dependent = true
--模块信息 --模块信息
entry({"admin", "network", "qmodem", "modem_info"}, template("qmodem/modem_info"), luci.i18n.translate("QModem Information"),2).leaf = true entry({"admin", "modem", "qmodem", "modem_info"}, template("qmodem/modem_info"), luci.i18n.translate("QModem Information"),2).leaf = true
entry({"admin", "network", "qmodem", "get_modem_cfg"}, call("getModemCFG"), nil).leaf = true entry({"admin", "modem", "qmodem", "get_modem_cfg"}, call("getModemCFG"), nil).leaf = true
entry({"admin", "network", "qmodem", "modem_ctrl"}, call("modemCtrl")).leaf = true entry({"admin", "modem", "qmodem", "modem_ctrl"}, call("modemCtrl")).leaf = true
--拨号配置 --拨号配置
entry({"admin", "network", "qmodem", "dial_overview"},cbi("qmodem/dial_overview"),luci.i18n.translate("Dial Overview"),3).leaf = true entry({"admin", "modem", "qmodem", "dial_overview"},cbi("qmodem/dial_overview"),luci.i18n.translate("Dial Overview"),3).leaf = true
entry({"admin", "network", "qmodem", "dial_config"}, cbi("qmodem/dial_config")).leaf = true entry({"admin", "modem", "qmodem", "dial_config"}, cbi("qmodem/dial_config")).leaf = true
entry({"admin", "network", "qmodem", "modems_dial_overview"}, call("getOverviews"), nil).leaf = true entry({"admin", "modem", "qmodem", "modems_dial_overview"}, call("getOverviews"), nil).leaf = true
--模块调试 --模块调试
entry({"admin", "network", "qmodem", "modem_debug"},template("qmodem/modem_debug"),luci.i18n.translate("Advance Modem Settings"),4).leaf = true entry({"admin", "modem", "qmodem", "modem_debug"},template("qmodem/modem_debug"),luci.i18n.translate("Advance Modem Settings"),4).leaf = true
entry({"admin", "network", "qmodem", "send_at_command"}, call("sendATCommand"), nil).leaf = true entry({"admin", "modem", "qmodem", "send_at_command"}, call("sendATCommand"), nil).leaf = true
--Qmodem设置 --Qmodem设置
entry({"admin", "network", "qmodem", "settings"}, cbi("qmodem/settings"), luci.i18n.translate("QModem Settings"),100).leaf = true entry({"admin", "modem", "qmodem", "settings"}, cbi("qmodem/settings"), luci.i18n.translate("QModem Settings"),100).leaf = true
entry({"admin", "network", "qmodem", "slot_config"}, cbi("qmodem/slot_config")).leaf = true entry({"admin", "modem", "qmodem", "slot_config"}, cbi("qmodem/slot_config")).leaf = true
end end
--[[ --[[
@ -174,7 +174,7 @@ function getModemCFG()
return return
end end
--获取模组的备注 --获取模组的备注
local network=modem_device["network"] local network=modem_device["modem"]
local alias=modem_device["alias"] local alias=modem_device["alias"]
local config_name=modem_device[".name"] local config_name=modem_device[".name"]
--设置模组AT串口 --设置模组AT串口

View File

@ -3,7 +3,7 @@ local uci = require "luci.model.uci".cursor()
local http = require "luci.http" local http = require "luci.http"
m = Map("qmodem", translate("Modem Configuration")) m = Map("qmodem", translate("Modem Configuration"))
m.redirect = dispatcher.build_url("admin", "network", "qmodem","dial_overview") m.redirect = dispatcher.build_url("admin", "modem", "qmodem","dial_overview")
s = m:section(NamedSection, arg[1], "modem-device", "") s = m:section(NamedSection, arg[1], "modem-device", "")
s.addremove = false s.addremove = false

View File

@ -17,13 +17,13 @@ o = s:option(Button, "reload_dial", translate("Restart Dial Service"))
o.inputstyle = "apply" o.inputstyle = "apply"
o.write = function() o.write = function()
sys.call("/etc/init.d/qmodem_network reload > /dev/null 2>&1") sys.call("/etc/init.d/qmodem_network reload > /dev/null 2>&1")
luci.http.redirect(d.build_url("admin", "network", "qmodem", "dial_overview")) luci.http.redirect(d.build_url("admin", "modem", "qmodem", "dial_overview"))
end end
s = m:section(TypedSection, "modem-device", translate("Config List")) s = m:section(TypedSection, "modem-device", translate("Config List"))
s.addremove = ture s.addremove = ture
s.template = "cbi/tblsection" s.template = "cbi/tblsection"
s.extedit = d.build_url("admin", "network", "qmodem", "dial_config", "%s") s.extedit = d.build_url("admin", "modem", "qmodem", "dial_config", "%s")
o = s:option(Flag, "enable_dial", translate("Enable Dial")) o = s:option(Flag, "enable_dial", translate("Enable Dial"))
o.width = "5%" o.width = "5%"
@ -76,7 +76,7 @@ function remove_btn.write(self, section)
shell="/usr/share/qmodem/modem_scan.sh remove "..section shell="/usr/share/qmodem/modem_scan.sh remove "..section
luci.sys.call(shell) luci.sys.call(shell)
--refresh the page --refresh the page
luci.http.redirect(d.build_url("admin", "network", "qmodem", "dial_overview")) luci.http.redirect(d.build_url("admin", "modem", "qmodem", "dial_overview"))
end end
-- 添加模块拨号日志 -- 添加模块拨号日志
m:append(Template("qmodem/dial_overview")) m:append(Template("qmodem/dial_overview"))

View File

@ -3,7 +3,7 @@ local d = require "luci.dispatcher"
m = Map("qmodem") m = Map("qmodem")
m.title = translate("QModem Setting") m.title = translate("QModem Setting")
this_page = d.build_url("admin", "network", "qmodem", "settings") this_page = d.build_url("admin", "modem", "qmodem", "settings")
s = m:section(NamedSection, "main", "main", translate("Modem Probe setting")) s = m:section(NamedSection, "main", "main", translate("Modem Probe setting"))
block_auto_probe = s:option(Flag, "block_auto_probe", translate("Block Auto Probe/Remove")) block_auto_probe = s:option(Flag, "block_auto_probe", translate("Block Auto Probe/Remove"))
block_auto_probe.description = translate("If enabled, the modem auto scan will be blocked.") block_auto_probe.description = translate("If enabled, the modem auto scan will be blocked.")
@ -45,7 +45,7 @@ end
s = m:section(TypedSection, "modem-slot", translate("Modem Slot Config List")) s = m:section(TypedSection, "modem-slot", translate("Modem Slot Config List"))
s.addremove = true s.addremove = true
s.template = "cbi/tblsection" s.template = "cbi/tblsection"
s.extedit = d.build_url("admin", "network", "qmodem", "slot_config", "%s") s.extedit = d.build_url("admin", "modem", "qmodem", "slot_config", "%s")
s.sectionhead = translate("Config Name") s.sectionhead = translate("Config Name")
slot_type = s:option(DummyValue, "type", translate("Slot Type")) slot_type = s:option(DummyValue, "type", translate("Slot Type"))
slot_type.cfgvalue = function(t, n) slot_type.cfgvalue = function(t, n)

View File

@ -1,5 +1,5 @@
m = Map("qmodem", translate("Slot Configuration")) m = Map("qmodem", translate("Slot Configuration"))
m.redirect = luci.dispatcher.build_url("admin", "network", "qmodem","settings") m.redirect = luci.dispatcher.build_url("admin", "modem", "qmodem","settings")
s = m:section(NamedSection, arg[1], "modem-device", "") s = m:section(NamedSection, arg[1], "modem-device", "")

View File

@ -170,7 +170,7 @@
} }
clear(){ clear(){
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "modem_ctrl")%>', {"action":"clear_dial_log","cfg":this.section_name}, XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "modem_ctrl")%>', {"action":"clear_dial_log","cfg":this.section_name},
function(x, data) function(x, data)
{ {
var state = data.result.state; var state = data.result.state;
@ -235,7 +235,7 @@
poll() poll()
{ {
XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "network", "qmodem", "modems_dial_overview")%>',{}, XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "modems_dial_overview")%>',{},
(x,data)=>{ (x,data)=>{
this.update_modems_state(data.modems); this.update_modems_state(data.modems);
this.update_modems_log(data.logs); this.update_modems_log(data.logs);

View File

@ -18,7 +18,7 @@
} }
get_config(){ get_config(){
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "modem_ctrl")%>', XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "modem_ctrl")%>',
{ {
"cfg": this.cfg_id, "cfg": this.cfg_id,
"action": this.get_action "action": this.get_action
@ -33,7 +33,7 @@
} }
set_config(config){ set_config(config){
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "modem_ctrl")%>', XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "modem_ctrl")%>',
{ {
"cfg": this.cfg_id, "cfg": this.cfg_id,
"action": this.set_action, "action": this.set_action,
@ -852,7 +852,7 @@
} }
update_modem_cfg_list() { update_modem_cfg_list() {
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "qmodem", "get_modem_cfg")%>', {}, (x, data) => { XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "get_modem_cfg")%>', {}, (x, data) => {
var new_cfg_list = []; var new_cfg_list = [];
var cfgs = data.cfgs; var cfgs = data.cfgs;
for (let i = 0; i < cfgs.length; i++) { for (let i = 0; i < cfgs.length; i++) {

View File

@ -260,7 +260,7 @@ class ModemInfo {
if (this.cfg_id == null){ if (this.cfg_id == null){
return; return;
} }
XHR.poll(10,'<%=luci.dispatcher.build_url("admin", "network", "qmodem", "modem_ctrl")%>',{ XHR.poll(10,'<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "modem_ctrl")%>',{
"cfg": this.cfg_id, "cfg": this.cfg_id,
"action": "info", "action": "info",
"translate": "1" "translate": "1"
@ -270,7 +270,7 @@ class ModemInfo {
} }
update(){ update(){
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "qmodem", "modem_ctrl")%>',{ XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "modem_ctrl")%>',{
"cfg": this.cfg_id, "cfg": this.cfg_id,
"action": "info", "action": "info",
"translate": "1" "translate": "1"
@ -280,7 +280,7 @@ class ModemInfo {
} }
update_modem_cfg_list(){ update_modem_cfg_list(){
XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "network", "qmodem", "get_modem_cfg")%>',{},(x,data)=>{ XHR.poll(5,'<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "get_modem_cfg")%>',{},(x,data)=>{
var new_cfg_list = []; var new_cfg_list = [];
var cfgs = data.cfgs; var cfgs = data.cfgs;
for (let i = 0; i < cfgs.length; i++) { for (let i = 0; i < cfgs.length; i++) {