From bbf096c79eca2e8407d15fe2acfde70c8d08e9c4 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 19 Jun 2018 17:17:04 +0200 Subject: [PATCH] luci-mod-admin-full: cleanup markup Globally cleanup template markup to support responsive design changes in OpenWrt theme. Rework handling of dynamic status tables, consolidate hand-written markup, fix small render bugs in various places and annotate tables where needed. Signed-off-by: Jo-Philipp Wich --- .../luasrc/view/admin_network/diagnostics.htm | 85 ++++---- .../view/admin_network/iface_overview.htm | 71 +++--- .../view/admin_network/iface_status.htm | 55 ++--- .../view/admin_network/lease_status.htm | 38 ++-- .../view/admin_network/switch_status.htm | 32 ++- .../luasrc/view/admin_network/wifi_join.htm | 48 ++-- .../view/admin_network/wifi_overview.htm | 74 +++---- .../luasrc/view/admin_status/index.htm | 205 +++++++++--------- .../luasrc/view/admin_status/iptables.htm | 110 +++++----- .../luasrc/view/admin_status/routes.htm | 113 +++++----- .../luasrc/view/admin_system/flashops.htm | 136 ++++++------ .../luasrc/view/admin_system/packages.htm | 150 ++++++------- .../luasrc/view/admin_system/reboot.htm | 3 +- .../luasrc/view/admin_uci/changelog.htm | 10 +- .../luasrc/view/admin_uci/changes.htm | 22 +- 15 files changed, 577 insertions(+), 575 deletions(-) diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/diagnostics.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/diagnostics.htm index f4adb2606..5607e59df 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_network/diagnostics.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/diagnostics.htm @@ -61,55 +61,54 @@ local route_host = luci.config.diag and luci.config.diag.route or "dev.openwrt.o

<%:Diagnostics%>

-
+
<%:Network Utilities%> -
- -
-
- <% if has_ping6 then %> - - - <% else %> - - <% end %> +
+
+
+
+ <% if has_ping6 then %> + + + <% else %> + + <% end %> +
+ +
+
+ <% if has_traceroute6 then %> + + + <% else %> + + <% end %> + <% if not has_traceroute6 then %> +

 

+

<%:Install iputils-traceroute6 for IPv6 traceroute%>

+ <% end %> +
+ +
+
+ +
+
- -
-
- <% if has_traceroute6 then %> - - - <% else %> - - <% end %> - <% if not has_traceroute6 then %> -

 

-

<%:Install iputils-traceroute6 for IPv6 traceroute%>

- <% end %> -
- -
-
- -
- -

- -
+
- + <%+footer%> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview.htm index 420e5879f..473e2275c 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview.htm @@ -67,7 +67,7 @@ } function iface_delete(id) { - if (!confirm(<%=luci.http.write_json(translate('Really delete this interface? The deletion cannot be undone! You might lose access to this device if you are connected via this interface.'))%>)) + if (!confirm(<%=luci.http.write_json(translate('Really delete this interface? The deletion cannot be undone! You might lose access to this device if you are connected via this interface'))%>)) return; (new XHR()).post('<%=url('admin/network/iface_delete')%>/' + id, { token: '<%=token%>' }, @@ -141,8 +141,8 @@ } html += String.format( - '<%:RX%>: %.2mB (%d <%:Pkts.%>)
' + - '<%:TX%>: %.2mB (%d <%:Pkts.%>)
', + '<%:RX%>: %.2mB (%d <%:Pkts.%>)
' + + '<%:TX%>: %.2mB (%d <%:Pkts.%>)
', ifc.rx_bytes, ifc.rx_packets, ifc.tx_bytes, ifc.tx_packets ); @@ -209,46 +209,43 @@
-
+
<%:Interface Overview%> -
-
-
<%:Network%>
-
<%:Status%>
-
<%:Actions%>
-
- <% - for i, net in ipairs(netlist) do - local z = net[3] - local c = z and z:get_color() or "#EEEEEE" - local t = z and translate("Part of zone %q" % z:name()) or translate("No zone assigned") - %> -
-
-
-
- <%=net[1]:upper()%> -
-
-
- ? +
+
+ <% + for i, net in ipairs(netlist) do + local z = net[3] + local c = z and z:get_color() or "#EEEEEE" + local t = z and translate("Part of zone %q" % z:name()) or translate("No zone assigned") + %> +
+
+
+
+ <%=net[1]:upper()%> +
+
+
+ ? +
+
+ <%:Collecting data...%> +
+
+ + + '" title="<%:Edit this interface%>" value="<%:Edit%>" id="<%=net[1]%>-ifc-edit" /> + +
-
- <%:Collecting data...%> -
-
- - - '" title="<%:Edit this interface%>" value="<%:Edit%>" id="<%=net[1]%>-ifc-edit" /> - -
-
- <% end %> + <% end %> +
'" /> -
+
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_status.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_status.htm index 58f5400da..9c5173dae 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_status.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_status.htm @@ -6,29 +6,18 @@ { if (ifc && (ifc = ifc[0])) { - var html = ''; + var s = document.getElementById('<%=self.option%>-ifc-status'), + img = s.querySelector('img'), + info = s.querySelector('span'), + html = '<%:Device%>: %h
'.format(ifc.ifname); - var s = document.getElementById('<%=self.option%>-ifc-signal'); - if (s) - s.innerHTML = String.format( - '' + - '
%s', - ifc.type, ifc.is_up ? '' : '_disabled', - ifc.name - ); - - var d = document.getElementById('<%=self.option%>-ifc-description'); - if (d && ifc.ifname) + if (ifc.ifname) { if (ifc.is_up) - { html += String.format('<%:Uptime%>: %t
', ifc.uptime); - } if (ifc.macaddr) - { html += String.format('<%:MAC-Address%>: %s
', ifc.macaddr); - } html += String.format( '<%:RX%>: %.2mB (%d <%:Pkts.%>)
' + @@ -38,50 +27,40 @@ ); if (ifc.ipaddrs && ifc.ipaddrs.length) - { for (var i = 0; i < ifc.ipaddrs.length; i++) html += String.format( '<%:IPv4%>: %s
', ifc.ipaddrs[i] ); - } if (ifc.ip6addrs && ifc.ip6addrs.length) - { for (var i = 0; i < ifc.ip6addrs.length; i++) html += String.format( '<%:IPv6%>: %s
', ifc.ip6addrs[i] ); - } - + if (ifc.ip6prefix) - { html += String.format('<%:IPv6-PD%>: %s
', ifc.ip6prefix); - } - d.innerHTML = html; + info.innerHTML = html; } - else if (d) + else { - d.innerHTML = '<%:Interface not present or not connected yet.%>'; + info.innerHTML = '<%:Interface not present or not connected yet.%>'; } + + img.src = '<%=resource%>/icons/%s%s.png'.format(ifc.type, ifc.is_up ? '' : '_disabled'); } } ); //]]> -
-
-
-
-
- ? -
-
- <%:Collecting data...%> -
-
-
+ + + + <%:Collecting data...%> + + <%+cbi/valuefooter%> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm index 9005279a4..a1b2c8454 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm @@ -34,7 +34,7 @@ else timestr = String.format('%t', st[0][i].expires); - tb.appendChild(E('
'.format((i % 2) + 1), [ + tb.appendChild(E('
'.format((i % 2) + 1), [ E('
', st[0][i].hostname || '?'), E('
', st[0][i].ipaddr), E('
', st[0][i].macaddr), @@ -43,7 +43,7 @@ } if (tb.firstElementChild === tb.lastElementChild) - tb.appendChild(E('

<%:There are no active leases.%>
')); + tb.appendChild(E('

<%:There are no active leases.%>
')); } var tb6 = document.getElementById('lease6_status_table'); @@ -79,8 +79,8 @@ hint = host.name; } - tb6.appendChild(E('
'.format((i % 2) + 1), [ - E('
', hint ? '
%h (%h)
'.format(name || '?', hint) : (name || '?')), + tb6.appendChild(E('
'.format((i % 2) + 1), [ + E('
', hint ? '%h (%h)'.format(name || '?', hint) : (name || '?')), E('
', st[1][i].ip6addr), E('
', st[1][i].duid), E('
', timestr) @@ -88,7 +88,7 @@ } if (tb6.firstElementChild === tb6.lastElementChild) - tb6.appendChild(E('

<%:There are no active leases.%>
')); + tb6.appendChild(E('

<%:There are no active leases.%>
')); } } ); @@ -96,14 +96,14 @@
<%:Active DHCP Leases%> -
-
-
<%:Hostname%>
-
<%:IPv4-Address%>
-
<%:MAC-Address%>
-
<%:Leasetime remaining%>
+
+
+
<%:Hostname%>
+
<%:IPv4-Address%>
+
<%:MAC-Address%>
+
<%:Leasetime remaining%>
-
+

<%:Collecting data...%>
@@ -111,14 +111,14 @@
-
+
<%:IPv6 Neighbours%> -
-
-
-
<%:IPv6-Address%>
-
<%:MAC-Address%>
-
<%:Interface%>
+
+
+
<%:IPv6-Address%>
+
<%:MAC-Address%>
+
<%:Interface%>
<% for _, v in ipairs(ip.neighbors({ family = 6 })) do if v.dest and not v.dest:is6linklocal() and v.mac then %> -
-
<%=v.dest%>
-
<%=v.mac%>
-
<%=luci.tools.webadmin.iface_get_network(v.dev) or '(' .. v.dev .. ')'%>
+
+
<%=v.dest%>
+
<%=v.mac%>
+
<%=luci.tools.webadmin.iface_get_network(v.dev) or '(' .. v.dev .. ')'%>
<% style = not style @@ -154,8 +150,7 @@ %>
-
-
+
<% end %>
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm b/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm index b32ef7826..9eec01254 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm @@ -13,84 +13,78 @@
  • <%:Configuration%>
  • -
    - -
    - <%:Backup / Restore%> -
    <%:Click "Generate archive" to download a tar archive of the current configuration files. To reset the firmware to its initial state, click "Perform reset" (only possible with squashfs images).%>
    -
    -
    - -
    - -
    - -
    -
    -
    - <% if reset_avail then %> -
    - -
    - -
    - -
    -
    -
    - <% end %> -
    -
    -
    <%:To restore configuration files, you can upload a previously generated backup archive here.%>
    -
    -
    -
    - -
    - - - -
    +
    + <%:Backup / Restore%> +
    <%:Click "Generate archive" to download a tar archive of the current configuration files. To reset the firmware to its initial state, click "Perform reset" (only possible with squashfs images).%>
    +
    + + +
    + +
    +
    - -
    +
    + <% if reset_avail then %> -
    <%:Custom files (certificates, scripts) may remain on the system. To prevent this, perform a factory-reset first.%>
    +
    + +
    + +
    + +
    +
    +
    <% end %> -
    - +

    +
    <%:To restore configuration files, you can upload a previously generated backup archive here.%>
    +
    +
    +
    + +
    + + + +
    +
    +
    +
    + <% if reset_avail then %> +
    <%:Custom files (certificates, scripts) may remain on the system. To prevent this, perform a factory-reset first.%>
    + <% end %> +
    -
    - <%:Flash new firmware image%> - <% if upgrade_avail then %> -
    - -
    <%:Upload a sysupgrade-compatible image here to replace the running firmware. Check "Keep settings" to retain the current configuration (requires a compatible firmware image).%>
    -
    -
    - -
    - -
    +
    + <%:Flash new firmware image%> + <% if upgrade_avail then %> + + +
    <%:Upload a sysupgrade-compatible image here to replace the running firmware. Check "Keep settings" to retain the current configuration (requires a compatible firmware image).%>
    +
    +
    + +
    +
    -
    - -
    - - -
    +
    +
    + +
    + +
    - <% if image_invalid then %> -
    <%:The uploaded image file does not contain a supported format. Make sure that you choose the generic image format for your platform. %>
    - <% end %> - - <% else %> -
    <%:Sorry, there is no sysupgrade support present; a new firmware image must be flashed manually. Please refer to the wiki for device specific install instructions.%>
    - <% end %> -
    - - +
    + <% if image_invalid then %> +
    <%:The uploaded image file does not contain a supported format. Make sure that you choose the generic image format for your platform. %>
    + <% end %> + + <% else %> +
    <%:Sorry, there is no sysupgrade support present; a new firmware image must be flashed manually. Please refer to the wiki for device specific install instructions.%>
    + <% end %> +
    <%+footer%> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_system/packages.htm b/modules/luci-mod-admin-full/luasrc/view/admin_system/packages.htm index 4944a232b..ef13a9167 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_system/packages.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_system/packages.htm @@ -44,6 +44,8 @@ end <%+header%> + +

    <%:Software%>

    @@ -57,8 +59,8 @@ end -
    -
    +
    +
    <% if (install and next(install)) or (remove and next(remove)) or update or upgrade then %>
    <% if #stdout > 0 then %>
    <%=pcdata(stdout)%>
    <% end %> @@ -91,18 +93,18 @@ end
     
    -
    +

    -
    +
    - +
    @@ -110,11 +112,11 @@ end
    - +
    -
    - +
    +
    @@ -122,90 +124,90 @@ end <% if display ~= "available" then %> -
    -
    -
    -
     
    -
    <%:Package name%>
    -
    <%:Version%>
    -
    - <% local empty = true; luci.model.ipkg.list_installed(querypat, function(n, v, s, d) empty = false; filter[n] = true %> -
    -
    -
    - - - - <%:Remove%> -
    +
    +
    +
    +
    +
    <%:Package name%>
    +
    <%:Version%>
    +
     
    -
    <%=luci.util.pcdata(n)%>
    -
    <%=luci.util.pcdata(v)%>
    -
    - <% end) %> - <% if empty then %> -
    -
     
    -
    <%:none%>
    -
    <%:none%>
    + <% local empty = true; luci.model.ipkg.list_installed(querypat, function(n, v, s, d) empty = false; filter[n] = true %> +
    +
    <%=luci.util.pcdata(n)%>
    +
    <%=luci.util.pcdata(v)%>
    +
    +
    + + + + +
    +
    +
    + <% end) %> + <% if empty then %> +
    +
     
    +
    <%:none%>
    +
    <%:none%>
    +
    + <% end %>
    - <% end %>
    -
    +
    <% else %> -
    +
    <% if not querypat then %> -
      + -
      <% end %> -
      -
      -
       
      -
      <%:Package name%>
      -
      <%:Version%>
      -
      <%:Size (.ipk)%>
      -
      <%:Description%>
      -
      - <% local empty = true; opkg_list(querypat or letterpat, function(n, v, s, d) if filter[n] then return end; empty = false %> -
      -
      -
      - - - - <%:Install%> -
      +
      +
      +
      +
      <%:Package name%>
      +
      <%:Version%>
      +
      <%:Size (.ipk)%>
      +
      <%:Description%>
      +
       
      -
      <%=luci.util.pcdata(n)%>
      -
      <%=luci.util.pcdata(v)%>
      -
      <%=luci.util.pcdata(s)%>
      -
      <%=luci.util.pcdata(d)%>
      -
      - <% end) %> - <% if empty then %> -
      -
       
      -
      <%:none%>
      -
      <%:none%>
      -
      <%:none%>
      -
      <%:none%>
      + <% local empty = true; opkg_list(querypat or letterpat, function(n, v, s, d) if filter[n] then return end; empty = false %> +
      +
      <%=luci.util.pcdata(n)%>
      +
      <%=luci.util.pcdata(v)%>
      +
      <%=luci.util.pcdata(s)%>
      +
      <%=luci.util.pcdata(d)%>
      +
      +
      + + + + +
      +
      +
      + <% end) %> + <% if empty then %> +
      +
       
      +
      <%:none%>
      +
      <%:none%>
      +
      <%:none%>
      +
      <%:none%>
      +
      + <% end %>
      - <% end %>
      - <% if not querypat then %> -
      - <% end %> -
    +
    <% end %>
    diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_system/reboot.htm b/modules/luci-mod-admin-full/luasrc/view/admin_system/reboot.htm index c9551804d..6ec2b310d 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_system/reboot.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_system/reboot.htm @@ -7,7 +7,6 @@ <%+header%>

    <%:Reboot%>

    -

    <%:Reboots the operating system of your device%>

    @@ -49,7 +48,7 @@ } //]]> - +
    +
    <%:Legend:%>
      <%:Section added%>
    @@ -32,9 +32,11 @@ ret[#ret+1] = "
    %s.%s.%s+=%s" %{ r, s, o, util.pcdata(v[i]) } end - else + elseif v ~= "" then ret[#ret+1] = "
    %s.%s.%s=%s" %{ r, s, o, util.pcdata(v) } + else + ret[#ret+1] = "
    %s.%s.%s" %{ r, s, o } end end end @@ -57,7 +59,7 @@ ret[#ret+1] = "%s.%s.%s+=%s
    " %{ r, s, o, util.pcdata(v[i]) } end - + else ret[#ret+1] = "%s.%s.%s=%s
    " %{ r, s, o, util.pcdata(v) } @@ -75,5 +77,5 @@ write(table.concat(ret)) %>
    -
    +
    <%- end) %> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_uci/changes.htm b/modules/luci-mod-admin-full/luasrc/view/admin_uci/changes.htm index c69ec1215..628224475 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_uci/changes.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_uci/changes.htm @@ -27,21 +27,17 @@
    <% if redir_url then %> -
    -
    - -
    -
    +
    + +
    <% end %> -
    - -
    "> - - " /> - -
    -
    + +
    "> + + " /> + +
    <%+footer%> -- 2.25.1