up wrtbwmon 上行 带宽和下行带宽分开设置。

This commit is contained in:
SirPdboy 2023-06-10 10:11:10 +08:00 committed by GitHub
parent dbd5fe4b55
commit 621fecd0c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 23 deletions

View File

@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-wrtbwmon
PKG_VERSION:=1.6.3
PKG_RELEASE:=3
PKG_RELEASE:=4
PKG_LICENSE:=Apache-2.0
PKG_MAINTAINER:=

View File

@ -8,14 +8,25 @@ s = m:section(NamedSection, "general", "wrtbwmon", translate("General settings")
o = s:option(Flag, "enabled", translate("Enabled"))
o.rmempty= true
bandwidth = s:option( Value, "bdw", translate("Default bandwidth"))
bandwidth = s:option( Value, "bdwup", translate("Upload bandwidth"))
bandwidth:value("1M")
bandwidth:value("10M")
bandwidth:value("100M")
bandwidth:value("200M")
bandwidth:value("500M")
bandwidth:value("1000M")
bandwidth.default = '10M'
bandwidth.default = '3M'
bandwidth = s:option( Value, "bdwdown", translate("Download bandwidth"))
bandwidth:value("1M")
bandwidth:value("10M")
bandwidth:value("100M")
bandwidth:value("200M")
bandwidth:value("500M")
bandwidth:value("1000M")
bandwidth:value("2500M")
bandwidth:value("10000M")
bandwidth.default = '100M'
o = s:option(Value, "path", translate("Database Path"),
translate("This box is used to select the Database path, "

View File

@ -16,9 +16,7 @@ local function online_data()
local ln = fd()
if ln == nil then break end
local name,ip,mac,dev = ln:match("^(%S+) (%S+) (%S+) (%S+)")
if ip ~= routeip then
if mac and ip and name and dev then
if mac and ip and name and dev then
rv[#rv+1] = {
hostname = name,
device = dev,
@ -26,7 +24,6 @@ local function online_data()
ipaddr = ip
}
end
end
end
return rv
end

View File

@ -6,7 +6,8 @@
local util = require "luci.util"
local stat = require "luci.tools.status"
local fs = require "nixio.fs"
local bdw = luci.model.uci.cursor():get("wrtbwmon", "general", "bdw")
local bdwup = luci.model.uci.cursor():get("wrtbwmon", "general", "bdwup")
local bdwdown = luci.model.uci.cursor():get("wrtbwmon", "general", "bdwdown")
local dba = luci.model.uci.cursor():get("wrtbwmon", "general", "path")
local SYS = require "luci.sys"
-- Function to generate table from string.
@ -152,8 +153,8 @@
<div class="cbi-map">
<div class="cbi-section">
<div class="tr">
<div class="td left" style="width:5%"><label><%:protocol:%></label></div>
<div class="td left" style="width:15%">
<div class="td left" style="width:10%"><label><%:protocol:%></label></div>
<div class="td left" style="width:20%">
<select id="Select46" style="width:auto">
<option value="ipv4" selected="selected">ipv4</option>
<option value="ipv6">ipv6</option>
@ -161,15 +162,13 @@
</div>
<div class="td left" style="width:10%"><label for="showMore"><%:Show More:%></label></div>
<div class="td left" style="width:10%"><input class="cbi-input-checkbox" type="checkbox" id="showMore"/></div>
<div class="td left" style="width:20%"><input class="cbi-input-checkbox" type="checkbox" id="showMore"/></div>
<div class="td left" style="width:5%"><label><%:bandwidth:%></label></div>
<div class="td left" style="width:15%"><input type="text" id="setBD" value="<%=bdw%>" /></div>
<div class="td left" style="width:10%">
<small><div id="updated" style="display:inline"></div><div id="updating" style="display:inline"></div></small>
</div>
<div class="td left" style="width:20%">
<div class="td right" style="width:30%">
<label for="intervalSelect"><%:Auto update every%></label>
<select id="intervalSelect">
<option value="-1"><%:Disabled%></option>
@ -190,8 +189,8 @@
<legend><%:Online Users%><%:: %><%=luci.sys.exec("sysinfo user")%></legend>
<div class="td"></div>
<div class="table">
<div class="tr"><div class="td left" width="10%"><%:upflow:%></div><div class="td left" style="width:90%"><div id="upflow" class="cbi-progressbar" title="-"><div></div></div></div></div>
<div class="tr"><div class="td left" width="10%"><%:downflow:%></div><div class="td left" style="width:90%"><div id="downflow" class="cbi-progressbar" title="-"><div></div></div></div></div>
<div class="tr"><div class="td left" width="10%"><%:upflow:%><%=bdwup%></div><div class="td left" style="width:90%"><div id="upflow" class="cbi-progressbar" title="-"><div></div></div></div></div>
<div class="tr"><div class="td left" width="10%"><%:downflow:%><%=bdwdown%></div><div class="td left" style="width:90%"><div id="downflow" class="cbi-progressbar" title="-"><div></div></div></div></div>
</div>
<div class="td"></div>
@ -214,6 +213,7 @@
</div>
</div>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
(function () {
@ -250,7 +250,7 @@
}
function displayTable(eltid) {
var tb = $('traffic'), bdw = parseSize($('setBD').value);
var tb = $('traffic'), bdwupx = parseSize("<%=bdwup%>"),bdwdownx = parseSize("<%=bdwdown%>");
var col = setSortColumn(eltid);
cachedData[0].sort(function(x, y) {
@ -263,10 +263,9 @@
// display data
// console.time('update_table');
updateTable(tb, cachedData, '<em><%:Loading...%></em>');
// console.timeEnd('update_table');
progressbar('downflow', cachedData[1][0], bdw, true);
progressbar('upflow', cachedData[1][1], bdw, true);
// console.timeEnd('update_table');
progressbar('downflow', cachedData[1][0], bdwdownx, true);
progressbar('upflow', cachedData[1][1], bdwupx, true);
return
}

View File

@ -59,8 +59,11 @@ msgstr "显示更多:"
msgid "bandwidth:"
msgstr "带宽:"
msgid "Default bandwidth"
msgstr "默认带宽"
msgid "Upload bandwidth"
msgstr "上行带宽"
msgid "Download bandwidth"
msgstr "下行带宽"
msgid "Calculate per host totals"
msgstr "单主机总流量统计"