From 5a92c0fc089f8af4cdd5c35e94a563526c872ffd Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Wed, 13 Aug 2008 14:09:33 +0000 Subject: [PATCH] libs/cbi: Improved user interface draft #1 --- libs/cbi/htdocs/luci-static/resources/cbi/add.gif | Bin 0 -> 378 bytes .../cbi/htdocs/luci-static/resources/cbi/apply.gif | Bin 0 -> 268 bytes .../htdocs/luci-static/resources/cbi/fieldadd.gif | Bin 0 -> 379 bytes libs/cbi/htdocs/luci-static/resources/cbi/help.gif | Bin 0 -> 266 bytes .../cbi/htdocs/luci-static/resources/cbi/reset.gif | Bin 0 -> 258 bytes libs/cbi/htdocs/luci-static/resources/cbi/save.gif | Bin 0 -> 263 bytes libs/cbi/luasrc/view/cbi/footer.htm | 6 +- libs/cbi/luasrc/view/cbi/full_valuefooter.htm | 1 + libs/cbi/luasrc/view/cbi/nsection.htm | 2 +- libs/cbi/luasrc/view/cbi/tblsection.htm | 28 ++++----- libs/cbi/luasrc/view/cbi/tsection.htm | 4 +- libs/cbi/luasrc/view/cbi/ucisection.htm | 2 +- modules/admin-core/luasrc/tools/webadmin.lua | 12 ++++ .../luasrc/model/cbi/admin_network/network.lua | 40 +++++++++---- .../htdocs/luci-static/openwrt.org/cascade.css | 66 +++++++++++++++++---- 15 files changed, 116 insertions(+), 45 deletions(-) create mode 100644 libs/cbi/htdocs/luci-static/resources/cbi/add.gif create mode 100644 libs/cbi/htdocs/luci-static/resources/cbi/apply.gif create mode 100644 libs/cbi/htdocs/luci-static/resources/cbi/fieldadd.gif create mode 100644 libs/cbi/htdocs/luci-static/resources/cbi/help.gif create mode 100644 libs/cbi/htdocs/luci-static/resources/cbi/reset.gif create mode 100644 libs/cbi/htdocs/luci-static/resources/cbi/save.gif diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/add.gif b/libs/cbi/htdocs/luci-static/resources/cbi/add.gif new file mode 100644 index 0000000000000000000000000000000000000000..0888abf85ed10d3bdadb25b30b49e8c35b8233d9 GIT binary patch literal 378 zcmZ?wbhEHb6krfwxT?YM=;a5`&}?V#n2z-)rk?s^=Nj6%`^~-Q?==mbXC1h9`pm_a zJ=P67ET*3H=saLQ{j_)8HuL@?E|ZSCPdMs&_4bo#r@XE{|4_Brxch*^ymP;U605@t zCcgRjt!Rzz)3;yCrf*qt@%P5-e?EQtb>RNr-FN=3zVdt9tv~<4fPor7@h1x-1A_*G z4#+T&pBUJtADCR=A+xAY{q)Mqma1&c{a=cmxa4~mroT4KS#`QgUof=)~+&T;I{j*sYXaTd%6BpddF%U0!DD^qC5h za!gM1`zFkilw?>wPi9)j8Wt9I))h*%tJiLm*{Loqq9hZ|aDstdhKpl`^aUv?Mn)zk OR#uKC*E=qb4Aua>fQ#$^ literal 0 HcmV?d00001 diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/apply.gif b/libs/cbi/htdocs/luci-static/resources/cbi/apply.gif new file mode 100644 index 0000000000000000000000000000000000000000..82ae7ed821f7524c0356e40f79a0379fc634d535 GIT binary patch literal 268 zcmV+n0rUPxNk%w1VGsZi0K^{vM3g9B!ajxBR(;h{C|4L|#z9W1FZTQNam`88@5?V| z96pC8chOCN)>Mw(T#DRUiQ8Fv(@#mEENRI^ZOca`PZo5~OEz>Nz2>iuw1BeWp~dOA zBTNzi%BC{z2#%%nWDQ(& zkP#APQYdIRbsbb52orn(e?S)(2l8{r~^I{r|G{^@*_mA7}snwCwdU*P=DL|Gypj|E%Km1>^spH~#;&>;M1% z43q)IpDbVlbU-A?PYi4`9Htg{=x~{833+Y}XmD73G1F_0L0j|T!~?dRp1tm=n^ZC5We%>aw-FvmvIpt(dOEPIJ XU%@iXKOm5ik(HI@w%c77M+R#EbrzH@ literal 0 HcmV?d00001 diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/help.gif b/libs/cbi/htdocs/luci-static/resources/cbi/help.gif new file mode 100644 index 0000000000000000000000000000000000000000..9dfa0e196aba9bf0dd70074ccdb980d07de9e903 GIT binary patch literal 266 zcmV+l0rmbzNk%w1VGsZi0K^{vX}bO=Q+JG$m|w5)cDL-S*7{tb+@Z?p4qk8 z_sQn}X|3gLf|Hfa{4HFBMq+vzJXv+X|6!-#{r&xKvgu!?-l)&;*zNvYc8feuU~I4F zQ<~I5R%ieJ|NsC0A^8LW0018VEC2ui01yBW000Gt;3s}wX?kNyLPFa#5UP3^wk(CC zKe9+;gdm|(VMuts4zO}DT@VOK1m)={2pi9Zf$&VC9jdjm*+RV&K$v9RFu0|I!2+1F z6;Q;%BcIpB1z!^u289U*e{2p3gL?-F2^@(e8U&FXn3wsPtC-3SYNk)IzaCG{5wQd4hOTmQRpBi`QrZFzZjOw5(w z;B+Ua|6ri_lZBCiL7qW}0SG{LGO*S^P_K*2tV;HB^Xpa+Tva9QCeXgnd6P%76fc9p zOamsHcy;@YDln|Vuw<0nl$s8=rCxw48uw_56lMa6}$ zEFa1XibC1A+uFH>WUA~WrMhG$PUPgWRp}FBoy96PRn(YYfNQZp@O&*5b=4JX)+#bs F0{{l~XioqD literal 0 HcmV?d00001 diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/save.gif b/libs/cbi/htdocs/luci-static/resources/cbi/save.gif new file mode 100644 index 0000000000000000000000000000000000000000..35e949963e4b7a5f04fd1c8932a980901e3d4385 GIT binary patch literal 263 zcmV+i0r>t$Nk%w1VGsZi0K^{vcEd+Ya4xgmmXXkDk(iA6{P)e~xr@?RgUwTMzeLpS z#Wqhu{H$s5p4O4v<)^3=A2^0_EulhRp%QGjIf`R%Ru$RUj;1k~O1%3=|$g0$`b{ z1p`T8E1%cF0ssJ7eF+Hu(2Z{06R}5X@39! literal 0 HcmV?d00001 diff --git a/libs/cbi/luasrc/view/cbi/footer.htm b/libs/cbi/luasrc/view/cbi/footer.htm index 732389c00..b71905820 100644 --- a/libs/cbi/luasrc/view/cbi/footer.htm +++ b/libs/cbi/luasrc/view/cbi/footer.htm @@ -14,9 +14,9 @@ $Id$ -%>
- - - + + +
diff --git a/libs/cbi/luasrc/view/cbi/full_valuefooter.htm b/libs/cbi/luasrc/view/cbi/full_valuefooter.htm index a7b56e294..8933016d7 100644 --- a/libs/cbi/luasrc/view/cbi/full_valuefooter.htm +++ b/libs/cbi/luasrc/view/cbi/full_valuefooter.htm @@ -14,6 +14,7 @@ $Id$ -%> <% if #self.description > 0 then -%> + <%:help%>
<%=self.description%>
<%- end %> diff --git a/libs/cbi/luasrc/view/cbi/nsection.htm b/libs/cbi/luasrc/view/cbi/nsection.htm index 3f8653109..27db4bfbf 100644 --- a/libs/cbi/luasrc/view/cbi/nsection.htm +++ b/libs/cbi/luasrc/view/cbi/nsection.htm @@ -35,7 +35,7 @@ $Id$ <%=self.title%> <%- end %>
<%=self.description%>
- + <% end %> diff --git a/libs/cbi/luasrc/view/cbi/tblsection.htm b/libs/cbi/luasrc/view/cbi/tblsection.htm index 46f7e5115..cfee09f1c 100644 --- a/libs/cbi/luasrc/view/cbi/tblsection.htm +++ b/libs/cbi/luasrc/view/cbi/tblsection.htm @@ -12,6 +12,13 @@ You may obtain a copy of the License at $Id$ -%> +<%- +local rowcnt = 1 +function rowstyle() + rowcnt = rowcnt + 1 + return (rowcnt % 2) + 1 +end +-%>
@@ -26,9 +33,7 @@ $Id$ <%- end -%> <%- for i, k in pairs(self.children) do -%> <%=k.title%> - <%- count = count + 1; end; if self.extedit then -%> -   - <%- count = count + 1; end; if self.addremove then -%> + <%- count = count + 1; end; if self.extedit or self.addremove then -%>   <%- count = count + 1; end -%> @@ -38,9 +43,7 @@ $Id$ <%- end -%> <%- for i, k in pairs(self.children) do -%> <%=k.description%> - <%- end; if self.extedit then -%> -   - <%- end; if self.addremove then -%> + <%- end; if self.extedit or self.addremove then -%>   <%- end -%> @@ -50,7 +53,7 @@ $Id$ isempty = false scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" } -%> - + <% if not self.anonymous then -%>

<%=k%>

<%- end %> @@ -60,15 +63,10 @@ $Id$ <%- if self.extedit then -%> <%:edit%> <%- end; if self.addremove then %> - + <%- end -%> <%- end -%> - <%- if self.addremove then -%> - - - - <%- end -%> <%- end -%> @@ -84,10 +82,10 @@ $Id$
<% if self.anonymous then %> - + <% else %> - + <% end %> <% if self.err_invalid then %> diff --git a/libs/cbi/luasrc/view/cbi/tsection.htm b/libs/cbi/luasrc/view/cbi/tsection.htm index da44cdc13..a81715b0a 100644 --- a/libs/cbi/luasrc/view/cbi/tsection.htm +++ b/libs/cbi/luasrc/view/cbi/tsection.htm @@ -43,10 +43,10 @@ $Id$ <% if self.addremove then -%>
<% if self.anonymous then -%> - + <%- else -%> - + <%- end %> <% if self.err_invalid then -%> diff --git a/libs/cbi/luasrc/view/cbi/ucisection.htm b/libs/cbi/luasrc/view/cbi/ucisection.htm index e06cb5392..2ae856003 100644 --- a/libs/cbi/luasrc/view/cbi/ucisection.htm +++ b/libs/cbi/luasrc/view/cbi/ucisection.htm @@ -31,6 +31,6 @@ $Id$ <% end %><% end %> <% end %> <% end %> - +
<% end %> diff --git a/modules/admin-core/luasrc/tools/webadmin.lua b/modules/admin-core/luasrc/tools/webadmin.lua index 45bd910ac..b9f18ac40 100644 --- a/modules/admin-core/luasrc/tools/webadmin.lua +++ b/modules/admin-core/luasrc/tools/webadmin.lua @@ -14,6 +14,18 @@ $Id$ ]]-- module("luci.tools.webadmin", package.seeall) +require("luci.model.uci") + +function byte_format(byte) + local suff = {"B", "KB", "MB", "GB", "TB"} + for i=1, 5 do + if byte > 1024 and i < 5 then + byte = byte / 1024 + else + return string.format("%.2f %s", byte, suff[i]) + end + end +end function cbi_add_networks(field) luci.model.uci.foreach("network", "interface", diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua index 75c9f2818..00c001e50 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua @@ -13,6 +13,7 @@ You may obtain a copy of the License at $Id$ ]]-- require("luci.sys") +require("luci.tools.webadmin") m = Map("network", translate("interfaces"), translate("a_n_ifaces1")) @@ -49,11 +50,14 @@ function up.write(self, section, value) os.execute(call .. " " .. section) end -ipaddr = s:option(DummyValue, "ipaddr", translate("ipaddress")) -ipaddr.stateful = true +hwaddr = s:option(DummyValue, "_hwaddr") +function hwaddr.cfgvalue(self, section) + local ix = self.map:stateget(section, "ifname") or "" + return luci.fs.readfile("/sys/class/net/" .. ix .. "/address") or "n/a" +end + -ip6addr = s:option(DummyValue, "ip6addr", translate("ip6address")) -ip6addr.stateful = true +ipaddr = s:option(DummyValue, "ipaddr") function ipaddr.cfgvalue(self, section) local ip = self.map:stateget(section, "ipaddr") @@ -63,20 +67,32 @@ function ipaddr.cfgvalue(self, section) return parsed and parsed:string() or "" end -rx = s:option(DummyValue, "_rx") +txrx = s:option(DummyValue, "_rx", "TX / RX") -function rx.cfgvalue(self, section) +function txrx.cfgvalue(self, section) local ix = self.map:stateget(section, "ifname") - local bt = netstat and netstat[ix] and netstat[ix][1] - return bt and string.format("%.2f MB", tonumber(bt) / 1024 / 1024) + + local rx = netstat and netstat[ix] and netstat[ix][1] + rx = rx and luci.tools.webadmin.byte_format(tonumber(rx)) or "-" + + local tx = netstat and netstat[ix] and netstat[ix][9] + tx = tx and luci.tools.webadmin.byte_format(tonumber(tx)) or "-" + + return string.format("%s / %s", tx, rx) end -tx = s:option(DummyValue, "_tx") +errors = s:option(DummyValue, "_err", "Errors", "TX / RX") -function tx.cfgvalue(self, section) +function errors.cfgvalue(self, section) local ix = self.map:stateget(section, "ifname") - local bt = netstat and netstat[ix] and netstat[ix][9] - return bt and string.format("%.2f MB", tonumber(bt) / 1024 / 1024) + + local rx = netstat and netstat[ix] and netstat[ix][3] + local tx = netstat and netstat[ix] and netstat[ix][11] + + rx = rx and tostring(rx) or "-" + tx = tx and tostring(tx) or "-" + + return string.format("%s / %s", tx, rx) end return m \ No newline at end of file diff --git a/themes/openwrt.org/htdocs/luci-static/openwrt.org/cascade.css b/themes/openwrt.org/htdocs/luci-static/openwrt.org/cascade.css index 218d7674d..ae3e5901d 100644 --- a/themes/openwrt.org/htdocs/luci-static/openwrt.org/cascade.css +++ b/themes/openwrt.org/htdocs/luci-static/openwrt.org/cascade.css @@ -216,20 +216,31 @@ div#content ul { input[type=submit], input[type=reset], +input[type=image], label { cursor: pointer; } + select, input, textarea { background: #eeeeee; color: #000000; - border: 1px solid #000000; + border-width: 1px; + border-color: #000000; +} + +input[type=image] { + border: none; } input:focus, -textarea:focus { +input:hover, +select:focus, +select:hover, +textarea:focus, +textarea:hover { background: #ffffff; } @@ -245,10 +256,40 @@ td input[type=password] { width: 99%; } -button.clean { - cursor: pointer; - border: none; - background-color: inherit; +input.cbi-button { + padding-left: 17px; +} + +input.cbi-button-add { + background: url('../resources/cbi/add.gif') 1px 1px; + background-repeat: no-repeat; +} + +input.cbi-button-fieldadd { + background: url('../resources/cbi/fieldadd.gif') 1px 1px; + background-repeat: no-repeat; +} + +input.cbi-button-reset { + background: url('../resources/cbi/reset.gif') 1px 1px; + background-repeat: no-repeat; +} + +input.cbi-button-save { + background: url('../resources/cbi/save.gif') 1px 1px; + background-repeat: no-repeat; +} + +input.cbi-button-apply { + background: url('../resources/cbi/apply.gif') 1px 1px; + background-repeat: no-repeat; +} + +div.cbi-section-remove input { + background: url('../resources/cbi/remove.gif') 1px 1px; + background-repeat: no-repeat; + padding-left: 17px; + border-bottom: none; } textarea { @@ -290,6 +331,14 @@ table.smalltext tr td { border-left: 1px solid #666666; } +.cbi-rowstyle-1 { + background-color: #eeeeff; +} + +.cbi-rowstyle-2 { + +} + div.cbi-value { clear: left; padding: 0.25em; @@ -344,11 +393,6 @@ div.cbi-section-remove { float: right; } -div.cbi-section-remove input { - border-color: #bbbbbb; - border-bottom: none; -} - .cbi-section-node { clear: both; border: 1px dotted #bbbbbb; -- 2.11.0