mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-02 19:13:56 +08:00
update 2026-08-13 13:36:07
This commit is contained in:
1 parent
db1b718d36
commit
13e1596e66
6 files changed
+67
-143
No files matched your search
@@ -87,7 +87,6 @@ function index()
|
|||||||
entry({"admin", "services", appname, "delete_select_nodes"}, call("delete_select_nodes")).leaf = true
|
entry({"admin", "services", appname, "delete_select_nodes"}, call("delete_select_nodes")).leaf = true
|
||||||
entry({"admin", "services", appname, "reassign_group"}, call("reassign_group")).leaf = true
|
entry({"admin", "services", appname, "reassign_group"}, call("reassign_group")).leaf = true
|
||||||
entry({"admin", "services", appname, "get_node"}, call("get_node")).leaf = true
|
entry({"admin", "services", appname, "get_node"}, call("get_node")).leaf = true
|
||||||
entry({"admin", "services", appname, "save_node_order"}, call("save_node_order")).leaf = true
|
|
||||||
entry({"admin", "services", appname, "save_node_list_opt"}, call("save_node_list_opt")).leaf = true
|
entry({"admin", "services", appname, "save_node_list_opt"}, call("save_node_list_opt")).leaf = true
|
||||||
entry({"admin", "services", appname, "update_rules"}, call("update_rules")).leaf = true
|
entry({"admin", "services", appname, "update_rules"}, call("update_rules")).leaf = true
|
||||||
entry({"admin", "services", appname, "rollback_rules"}, call("rollback_rules")).leaf = true
|
entry({"admin", "services", appname, "rollback_rules"}, call("rollback_rules")).leaf = true
|
||||||
@@ -99,7 +98,6 @@ function index()
|
|||||||
entry({"admin", "services", appname, "get_shunt_rules"}, call("get_shunt_rules")).leaf = true
|
entry({"admin", "services", appname, "get_shunt_rules"}, call("get_shunt_rules")).leaf = true
|
||||||
entry({"admin", "services", appname, "add_shunt_rule"}, call("add_shunt_rule")).leaf = true
|
entry({"admin", "services", appname, "add_shunt_rule"}, call("add_shunt_rule")).leaf = true
|
||||||
entry({"admin", "services", appname, "delete_select_shunt_rules"}, call("delete_select_shunt_rules")).leaf = true
|
entry({"admin", "services", appname, "delete_select_shunt_rules"}, call("delete_select_shunt_rules")).leaf = true
|
||||||
entry({"admin", "services", appname, "save_shunt_rule_order"}, call("save_shunt_rule_order")).leaf = true
|
|
||||||
|
|
||||||
--[[rule_list]]
|
--[[rule_list]]
|
||||||
entry({"admin", "services", appname, "read_rulelist"}, call("read_rulelist")).leaf = true
|
entry({"admin", "services", appname, "read_rulelist"}, call("read_rulelist")).leaf = true
|
||||||
@@ -720,19 +718,6 @@ function get_node()
|
|||||||
http_write_json(result)
|
http_write_json(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
function save_node_order()
|
|
||||||
local ids = http.formvalue("ids") or ""
|
|
||||||
local new_order = {}
|
|
||||||
for id in ids:gmatch("([^,]+)") do
|
|
||||||
new_order[#new_order + 1] = id
|
|
||||||
end
|
|
||||||
for idx, name in ipairs(new_order) do
|
|
||||||
luci.sys.call(string.format("uci -q reorder %s.%s=%d", appname, name, idx - 1))
|
|
||||||
end
|
|
||||||
api.sh_uci_commit(appname)
|
|
||||||
http_write_json({ status = "ok" })
|
|
||||||
end
|
|
||||||
|
|
||||||
function reassign_group()
|
function reassign_group()
|
||||||
local ids = http.formvalue("ids") or ""
|
local ids = http.formvalue("ids") or ""
|
||||||
local group = http.formvalue("group") or "default"
|
local group = http.formvalue("group") or "default"
|
||||||
@@ -1209,16 +1194,3 @@ function delete_select_shunt_rules()
|
|||||||
api.uci_save(uci, appname, true, true)
|
api.uci_save(uci, appname, true, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function save_shunt_rule_order()
|
|
||||||
local ids = http.formvalue("ids") or ""
|
|
||||||
local new_order = {}
|
|
||||||
for id in ids:gmatch("([^,]+)") do
|
|
||||||
new_order[#new_order + 1] = id
|
|
||||||
end
|
|
||||||
for idx, name in ipairs(new_order) do
|
|
||||||
luci.sys.call(string.format("uci -q reorder %s.%s=%d", appname, name, idx - 1))
|
|
||||||
end
|
|
||||||
api.sh_uci_commit(appname)
|
|
||||||
http_write_json({ status = "ok" })
|
|
||||||
end
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
local api = require "luci.passwall.api"
|
local api = require "luci.passwall.api"
|
||||||
local appname = "passwall"
|
local appname = "passwall"
|
||||||
local sys = api.sys
|
|
||||||
local datatypes = api.datatypes
|
|
||||||
|
|
||||||
api.set_default_cbi()
|
api.set_default_cbi()
|
||||||
|
|
||||||
@@ -30,6 +28,29 @@ o:value("https://connectivitycheck.platform.hicloud.com/generate_204", "HiCloud
|
|||||||
o:value("https://wifi.vivo.com.cn/generate_204", "VIVO (CN)")
|
o:value("https://wifi.vivo.com.cn/generate_204", "VIVO (CN)")
|
||||||
o.default = o.keylist[3]
|
o.default = o.keylist[3]
|
||||||
|
|
||||||
m:append(Template(appname .. "/node_list/node_list"))
|
if true then
|
||||||
|
local o = Template(appname .. "/node_list/node_list")
|
||||||
|
o.map = m
|
||||||
|
o.api = api
|
||||||
|
m:append(o)
|
||||||
|
|
||||||
|
if luci.http.formvalue("cbi.submit") == "1" then
|
||||||
|
local group_order = {}
|
||||||
|
group_order = luci.http.formvaluetable("group.order")
|
||||||
|
if group_order then
|
||||||
|
for k, v in pairs(group_order) do
|
||||||
|
if v and v~= "" then
|
||||||
|
local new_order = {}
|
||||||
|
string.gsub(v, "[^" .. " " .. "]+", function(w)
|
||||||
|
new_order[#new_order + 1] = w
|
||||||
|
end)
|
||||||
|
for idx, name in ipairs(new_order) do
|
||||||
|
m.uci:reorder(appname, name, idx - 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return api.return_map(m)
|
return api.return_map(m)
|
||||||
@@ -146,7 +146,26 @@ end
|
|||||||
s:append(Template(appname .. "/rule/rule_version"))
|
s:append(Template(appname .. "/rule/rule_version"))
|
||||||
|
|
||||||
if has_xray or has_singbox then
|
if has_xray or has_singbox then
|
||||||
m:append(Template(appname .. "/rule/shunt_rule_list"))
|
local o = Template(appname .. "/rule/shunt_rule_list")
|
||||||
|
o.api = api
|
||||||
|
m:append(o)
|
||||||
|
|
||||||
|
if luci.http.formvalue("cbi.submit") == "1" then
|
||||||
|
local group_order = luci.http.formvaluetable("group.order")
|
||||||
|
if group_order then
|
||||||
|
for k, v in pairs(group_order) do
|
||||||
|
if v and v~= "" then
|
||||||
|
local new_order = {}
|
||||||
|
string.gsub(v, "[^" .. " " .. "]+", function(w)
|
||||||
|
new_order[#new_order + 1] = w
|
||||||
|
end)
|
||||||
|
for idx, name in ipairs(new_order) do
|
||||||
|
m.uci:reorder(appname, name, idx - 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return api.return_map(m)
|
return api.return_map(m)
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<%
|
<%
|
||||||
local api = require "luci.passwall.api"
|
local api = self.api
|
||||||
local appname = api.appname
|
local appname = api.appname
|
||||||
|
local map = self.map
|
||||||
local is_js_luci = api.is_js_luci()
|
local is_js_luci = api.is_js_luci()
|
||||||
local section_tag = is_js_luci and "div" or "fieldset"
|
local section_tag = is_js_luci and "div" or "fieldset"
|
||||||
-%>
|
-%>
|
||||||
@@ -500,15 +501,7 @@ table td, .table .td {
|
|||||||
let firstDataRow = parent.querySelector("tr:not(.cbi-section-table-titles)");
|
let firstDataRow = parent.querySelector("tr:not(.cbi-section-table-titles)");
|
||||||
if (firstDataRow && firstDataRow !== row) {
|
if (firstDataRow && firstDataRow !== row) {
|
||||||
parent.insertBefore(row, firstDataRow);
|
parent.insertBefore(row, firstDataRow);
|
||||||
let save_order_btn = document.getElementById("save_order_btn_" + group);
|
set_order(group);
|
||||||
if (save_order_btn) {
|
|
||||||
const new_order = get_node_order(group);
|
|
||||||
if (!arraysEqual(new_order, origin_group_node_order[group])) {
|
|
||||||
save_order_btn.style.display = null;
|
|
||||||
} else {
|
|
||||||
save_order_btn.style.display = "none";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "del_all":
|
case "del_all":
|
||||||
@@ -652,48 +645,24 @@ table td, .table .td {
|
|||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_current_page_order(group) {
|
function set_order(group) {
|
||||||
var table = document.getElementById("cbi-<%=appname%>-nodes-" + group + "-table");
|
let table = document.getElementById("cbi-<%=appname%>-nodes-" + group + "-table");
|
||||||
if (!table) {
|
if (!table) {
|
||||||
alert("<%:No table!%>");
|
alert("<%:No table!%>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var rows = table.querySelectorAll("tr.cbi-section-table-row");
|
let rows = table.querySelectorAll("tr.cbi-section-table-row");
|
||||||
if (!rows || rows.length === 0) {
|
if (!rows || rows.length === 0) {
|
||||||
alert("<%:No nodes!%>");
|
alert("<%:No nodes!%>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var btn = document.getElementById("save_order_btn_" + group);
|
let ids = [];
|
||||||
if (btn) {
|
|
||||||
btn.style.display = "none";
|
|
||||||
btn.disabled = true;
|
|
||||||
}
|
|
||||||
var ids = [];
|
|
||||||
rows.forEach(function(row) {
|
rows.forEach(function(row) {
|
||||||
var id = row.id.replace("cbi-<%=appname%>-", "");
|
let id = row.id.replace("cbi-<%=appname%>-", "");
|
||||||
ids.push(id);
|
ids.push(id);
|
||||||
});
|
});
|
||||||
ajax.abortAll();
|
const input_order = document.getElementsByName(`group.order.${group}`)[0];
|
||||||
XHR.get('<%=api.url("save_node_order")%>', {
|
input_order.value = ids.join(" ");
|
||||||
group: group,
|
|
||||||
ids: ids.join(",")
|
|
||||||
},
|
|
||||||
function(x, result) {
|
|
||||||
if (btn) {
|
|
||||||
btn.style.display = null;
|
|
||||||
btn.disabled = false;
|
|
||||||
}
|
|
||||||
if (x && x.status === 200) {
|
|
||||||
origin_group_node_order[group] = get_node_order(group);
|
|
||||||
alert("<%:Saved current page order successfully.%>");
|
|
||||||
if (btn) {
|
|
||||||
btn.style.display = "none";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
alert("<%:Save failed!%>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取当前使用的节点
|
//获取当前使用的节点
|
||||||
@@ -947,16 +916,7 @@ table td, .table .td {
|
|||||||
forceFallback: false,
|
forceFallback: false,
|
||||||
swapThreshold: 0.65,
|
swapThreshold: 0.65,
|
||||||
onEnd: function (evt) {
|
onEnd: function (evt) {
|
||||||
//save_current_page_order(group); // 自动提交保存
|
set_order(group);
|
||||||
let save_order_btn = document.getElementById("save_order_btn_" + group);
|
|
||||||
if (save_order_btn) {
|
|
||||||
const new_order = get_node_order(group);
|
|
||||||
if (!arraysEqual(new_order, origin_group_node_order[group])) {
|
|
||||||
save_order_btn.style.display = null;
|
|
||||||
} else {
|
|
||||||
save_order_btn.style.display = "none";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
@@ -1302,9 +1262,9 @@ table td, .table .td {
|
|||||||
</tr>
|
</tr>
|
||||||
{{node-tr}}
|
{{node-tr}}
|
||||||
</table>
|
</table>
|
||||||
|
<input type="hidden" name="group.order.{{group}}">
|
||||||
<div class="cbi-section-create cbi-tblsection-create">
|
<div class="cbi-section-create cbi-tblsection-create">
|
||||||
<input class="cbi-button cbi-button-add" type="button" value="<%:Add%>" onclick="node_action('add')">
|
<input class="cbi-button cbi-button-add" type="button" value="<%:Add%>" onclick="node_action('add')">
|
||||||
<input class="cbi-button cbi-button-apply" style="display: none" type="button" id="save_order_btn_{{group}}" value="<%:Save Order%>" onclick="save_current_page_order('{{group}}')">
|
|
||||||
</div>
|
</div>
|
||||||
</<%=section_tag%>>
|
</<%=section_tag%>>
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<%
|
<%
|
||||||
local api = require "luci.passwall.api"
|
local api = self.api
|
||||||
local appname = api.appname
|
local appname = api.appname
|
||||||
local uci = api.uci
|
|
||||||
local is_js_luci = api.is_js_luci()
|
local is_js_luci = api.is_js_luci()
|
||||||
local section_tag = is_js_luci and "div" or "fieldset"
|
local section_tag = is_js_luci and "div" or "fieldset"
|
||||||
local title_tag = is_js_luci and "h3" or "legend"
|
local title_tag = is_js_luci and "h3" or "legend"
|
||||||
@@ -185,15 +184,7 @@ table td, .table .td {
|
|||||||
let firstDataRow = parent.querySelector("tr:not(.cbi-section-table-titles)");
|
let firstDataRow = parent.querySelector("tr:not(.cbi-section-table-titles)");
|
||||||
if (firstDataRow && firstDataRow !== row) {
|
if (firstDataRow && firstDataRow !== row) {
|
||||||
parent.insertBefore(row, firstDataRow);
|
parent.insertBefore(row, firstDataRow);
|
||||||
let save_order_btn = document.getElementById("save_order_btn_" + group);
|
set_order(group);
|
||||||
if (save_order_btn) {
|
|
||||||
const new_order = get_shunt_rule_order(group);
|
|
||||||
if (!arraysEqual(new_order, origin_group_shunt_rule_order[group])) {
|
|
||||||
save_order_btn.style.display = null;
|
|
||||||
} else {
|
|
||||||
save_order_btn.style.display = "none";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,48 +205,24 @@ table td, .table .td {
|
|||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_current_page_order(group) {
|
function set_order(group) {
|
||||||
var table = document.getElementById("cbi-<%=appname%>-shunt_rules-" + group + "-table");
|
let table = document.getElementById("cbi-<%=appname%>-shunt_rules-" + group + "-table");
|
||||||
if (!table) {
|
if (!table) {
|
||||||
alert("<%:No table!%>");
|
alert("<%:No table!%>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var rows = table.querySelectorAll("tr.cbi-section-table-row");
|
let rows = table.querySelectorAll("tr.cbi-section-table-row");
|
||||||
if (!rows || rows.length === 0) {
|
if (!rows || rows.length === 0) {
|
||||||
alert("<%:No shunt_rules!%>");
|
alert("<%:No shunt_rules!%>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var btn = document.getElementById("save_order_btn_" + group);
|
let ids = [];
|
||||||
if (btn) {
|
|
||||||
btn.style.display = "none";
|
|
||||||
btn.disabled = true;
|
|
||||||
}
|
|
||||||
var ids = [];
|
|
||||||
rows.forEach(function(row) {
|
rows.forEach(function(row) {
|
||||||
var id = row.id.replace("cbi-<%=appname%>-", "");
|
let id = row.id.replace("cbi-<%=appname%>-", "");
|
||||||
ids.push(id);
|
ids.push(id);
|
||||||
});
|
});
|
||||||
XHR.get('<%=api.url("save_shunt_rule_order")%>', {
|
const input_order = document.getElementsByName(`group.order.${group}`)[0];
|
||||||
group: group,
|
input_order.value = ids.join(" ");
|
||||||
ids: ids.join(",")
|
|
||||||
},
|
|
||||||
function(x, result) {
|
|
||||||
if (btn) {
|
|
||||||
btn.style.display = null;
|
|
||||||
btn.disabled = false;
|
|
||||||
}
|
|
||||||
if (x && x.status === 200) {
|
|
||||||
// origin_group_shunt_rule_order[group] = get_shunt_rule_order(group);
|
|
||||||
alert("<%:Saved current page order successfully.%>");
|
|
||||||
// if (btn) {
|
|
||||||
// btn.style.display = "none";
|
|
||||||
// }
|
|
||||||
window.location.reload();
|
|
||||||
} else {
|
|
||||||
alert("<%:Save failed!%>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List drag and rearrange
|
// List drag and rearrange
|
||||||
@@ -274,16 +241,7 @@ table td, .table .td {
|
|||||||
forceFallback: false,
|
forceFallback: false,
|
||||||
swapThreshold: 0.65,
|
swapThreshold: 0.65,
|
||||||
onEnd: function (evt) {
|
onEnd: function (evt) {
|
||||||
//save_current_page_order(group); // Auto save
|
set_order(group);
|
||||||
let save_order_btn = document.getElementById("save_order_btn_" + group);
|
|
||||||
if (save_order_btn) {
|
|
||||||
const new_order = get_shunt_rule_order(group);
|
|
||||||
if (!arraysEqual(new_order, origin_group_shunt_rule_order[group])) {
|
|
||||||
save_order_btn.style.display = null;
|
|
||||||
} else {
|
|
||||||
save_order_btn.style.display = "none";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
@@ -339,10 +297,10 @@ table td, .table .td {
|
|||||||
</tr>
|
</tr>
|
||||||
{{shunt_rule-tr}}
|
{{shunt_rule-tr}}
|
||||||
</table>
|
</table>
|
||||||
|
<input type="hidden" name="group.order.{{group}}">
|
||||||
<div class="cbi-section-create cbi-tblsection-create">
|
<div class="cbi-section-create cbi-tblsection-create">
|
||||||
<input type="text" id="add_name_{{group}}">
|
<input type="text" id="add_name_{{group}}">
|
||||||
<input class="cbi-button cbi-button-add" type="button" value="<%:Add%>" onclick="toPage('add')">
|
<input class="cbi-button cbi-button-add" type="button" value="<%:Add%>" onclick="toPage('add')">
|
||||||
<input class="cbi-button cbi-button-apply" style="display: none" type="button" id="save_order_btn_{{group}}" value="<%:Save Order%>" onclick="save_current_page_order('{{group}}')">
|
|
||||||
</div>
|
</div>
|
||||||
</<%=section_tag%>>
|
</<%=section_tag%>>
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -448,12 +448,6 @@ msgstr "节点备注"
|
|||||||
msgid "Add Mode"
|
msgid "Add Mode"
|
||||||
msgstr "添加方式"
|
msgstr "添加方式"
|
||||||
|
|
||||||
msgid "Save Order"
|
|
||||||
msgstr "保存当前顺序"
|
|
||||||
|
|
||||||
msgid "Saved current page order successfully."
|
|
||||||
msgstr "保存当前页面顺序成功。"
|
|
||||||
|
|
||||||
msgid "Drag to reorder"
|
msgid "Drag to reorder"
|
||||||
msgstr "拖动以重排"
|
msgstr "拖动以重排"
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user