From c4bd6fb7b9915cdf32bf08c93e64bd091c793bd5 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 19 Jun 2018 17:09:36 +0200 Subject: [PATCH 01/11] luci-base: cbi.js: add tooltip handling and responsive table helper code - make findParent() globally available - add code for initializing rich cbi tooltips - introduce cbi_update_table() helper to auto-assign responsive attributes to table markup Signed-off-by: Jo-Philipp Wich --- .../htdocs/luci-static/resources/cbi.js | 129 ++++++++++++++---- 1 file changed, 105 insertions(+), 24 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index a7f999d876..6a487366f8 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -620,7 +620,11 @@ function cbi_init() { } document.querySelectorAll('.cbi-dropdown').forEach(function(s) { - cbi_dropdown_init(s); + cbi_dropdown_init(s); + }); + + document.querySelectorAll('.cbi-tooltip:not(:empty)').forEach(function(s) { + s.parentNode.classList.add('cbi-tooltip-container'); }); cbi_d_update(); @@ -1232,14 +1236,13 @@ function cbi_validate_field(cbid, optional, type) function cbi_row_swap(elem, up, store) { - var tr = elem.parentNode; - - while (tr && !tr.classList.contains('cbi-section-table-row')) - tr = tr.parentNode; + var tr = findParent(elem.parentNode, '.cbi-section-table-row'); if (!tr) return false; + tr.classList.remove('flash'); + if (up) { var prev = tr.previousElementSibling; @@ -1277,6 +1280,9 @@ function cbi_row_swap(elem, up, store) if (input) input.value = ids.join(' '); + window.scrollTo(0, tr.offsetTop); + window.setTimeout(function() { tr.classList.add('flash'); }, 1); + return false; } @@ -1522,6 +1528,19 @@ function toElem(s) return elem || null; } +function findParent(node, selector) +{ + while (node) + if (node.msMatchesSelector && node.msMatchesSelector(selector)) + return node; + else if (node.matches && node.matches(selector)) + return node; + else + node = node.parentNode; + + return null; +} + function E() { var html = arguments[0], @@ -1541,7 +1560,7 @@ function E() if (attr) for (var key in attr) - if (attr.hasOwnProperty(key)) + if (attr.hasOwnProperty(key) && attr[key] !== null && attr[key] !== undefined) elem.setAttribute(key, attr[key]); if (typeof(data) === 'function') @@ -1818,18 +1837,6 @@ CBIDropdown = { document.querySelectorAll('.cbi-dropdown[open]').forEach(function(s) { s.dispatchEvent(new CustomEvent('cbi-dropdown-close', {})); }); - }, - - findParent: function(node, selector) { - while (node) - if (node.msMatchesSelector && node.msMatchesSelector(selector)) - return node; - else if (node.matches && node.matches(selector)) - return node; - else - node = node.parentNode; - - return null; } }; @@ -1908,7 +1915,7 @@ function cbi_dropdown_init(sb) { sbox.openDropdown(this); } else { - var li = sbox.findParent(ev.target, 'li'); + var li = findParent(ev.target, 'li'); if (li && li.parentNode.classList.contains('dropdown')) sbox.toggleItem(this, li); } @@ -1933,7 +1940,7 @@ function cbi_dropdown_init(sb) { } else { - var active = sbox.findParent(document.activeElement, 'li'); + var active = findParent(document.activeElement, 'li'); switch (ev.keyCode) { case 27: @@ -1986,7 +1993,7 @@ function cbi_dropdown_init(sb) { if (!this.hasAttribute('open')) return; - var li = sbox.findParent(ev.target, 'li'); + var li = findParent(ev.target, 'li'); if (li) { if (li.parentNode.classList.contains('dropdown')) sbox.setFocus(this, li); @@ -2023,18 +2030,18 @@ function cbi_dropdown_init(sb) { }); create.addEventListener('focus', function(ev) { - var cbox = sbox.findParent(this, 'li').querySelector('input[type="checkbox"]'); + var cbox = findParent(this, 'li').querySelector('input[type="checkbox"]'); if (cbox) cbox.checked = true; sb.setAttribute('locked-in', ''); }); create.addEventListener('blur', function(ev) { - var cbox = sbox.findParent(this, 'li').querySelector('input[type="checkbox"]'); + var cbox = findParent(this, 'li').querySelector('input[type="checkbox"]'); if (cbox) cbox.checked = false; sb.removeAttribute('locked-in'); }); - var li = sbox.findParent(create, 'li'); + var li = findParent(create, 'li'); li.setAttribute('unselectable', ''); li.addEventListener('click', function(ev) { @@ -2044,3 +2051,77 @@ function cbi_dropdown_init(sb) { } cbi_dropdown_init.prototype = CBIDropdown; + +function cbi_update_table(table, data, placeholder) { + target = isElem(table) ? table : document.querySelector(table); + + if (!isElem(target)) + return; + + target.querySelectorAll('.tr.table-titles, .cbi-section-table-titles').forEach(function(thead) { + var titles = []; + + thead.querySelectorAll('.th').forEach(function(th) { + titles.push(th); + }); + + if (Array.isArray(data)) { + var n = 0, rows = target.querySelectorAll('.tr'); + + data.forEach(function(row) { + var trow = E('div', { 'class': 'tr' }); + + for (var i = 0; i < titles.length; i++) { + var text = titles[i].innerText; + var td = trow.appendChild(E('div', { + 'class': titles[i].className, + 'data-title': text ? text.trim() : null + }, row[i] || '')); + + td.classList.remove('th'); + td.classList.add('td'); + } + + trow.classList.add('cbi-rowstyle-%d'.format((n++ % 2) ? 2 : 1)); + + if (rows[n]) + target.replaceChild(trow, rows[n]); + else + target.appendChild(trow); + }); + + while (rows[++n]) + target.removeChild(rows[n]); + + if (placeholder && target.firstElementChild === target.lastElementChild) { + var trow = target.appendChild(E('div', { 'class': 'tr placeholder' })); + var td = trow.appendChild(E('div', { 'class': titles[0].className }, placeholder)); + + td.classList.remove('th'); + td.classList.add('td'); + } + } + else { + thead.parentNode.style.display = 'none'; + + thead.parentNode.querySelectorAll('.tr, .cbi-section-table-row').forEach(function(trow) { + if (trow !== thead) { + var n = 0; + trow.querySelectorAll('.th, .td').forEach(function(td) { + if (n < titles.length) { + var text = (titles[n++].innerText || '').trim(); + if (text !== '') + td.setAttribute('data-title', text); + } + }); + } + }); + + thead.parentNode.style.display = ''; + } + }); +} + +document.addEventListener('DOMContentLoaded', function() { + document.querySelectorAll('.table').forEach(cbi_update_table); +}); From d0b91bcca266a6d386f9ebeef695e1cef34ad9cf Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 19 Jun 2018 17:10:38 +0200 Subject: [PATCH 02/11] luci-base: globally cleanup markup - add responsive attributes to partial cbi templates - unify and fix button style classes - fix styling of sysauth dialog - rework firewall_zoneforwards widget Signed-off-by: Jo-Philipp Wich --- .../luasrc/view/cbi/apply_widget.htm | 2 +- modules/luci-base/luasrc/view/cbi/button.htm | 2 +- .../luasrc/view/cbi/cell_valueheader.htm | 10 +- .../luci-base/luasrc/view/cbi/dropdown.htm | 12 ++ .../luasrc/view/cbi/firewall_zoneforwards.htm | 79 ++++--- modules/luci-base/luasrc/view/cbi/footer.htm | 2 - .../luasrc/view/cbi/full_valuefooter.htm | 1 - modules/luci-base/luasrc/view/cbi/map.htm | 3 - .../luci-base/luasrc/view/cbi/nsection.htm | 9 +- .../luci-base/luasrc/view/cbi/nullsection.htm | 5 +- .../luci-base/luasrc/view/cbi/simpleform.htm | 15 +- .../luci-base/luasrc/view/cbi/tblsection.htm | 203 ++++++++---------- .../luci-base/luasrc/view/cbi/tsection.htm | 18 +- modules/luci-base/luasrc/view/cbi/upload.htm | 2 +- modules/luci-base/luasrc/view/sysauth.htm | 10 +- 15 files changed, 189 insertions(+), 184 deletions(-) diff --git a/modules/luci-base/luasrc/view/cbi/apply_widget.htm b/modules/luci-base/luasrc/view/cbi/apply_widget.htm index 702512f495..e3090da656 100644 --- a/modules/luci-base/luasrc/view/cbi/apply_widget.htm +++ b/modules/luci-base/luasrc/view/cbi/apply_widget.htm @@ -47,7 +47,7 @@ } - + + <%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI @@ -161,11 +235,15 @@
-
+
+
+ <% if category then render_tabmenu(category, cattree) 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 420e5879fa..473e2275ce 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 58f5400da7..9c5173dae2 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; + if (ifc.ip6prefix) + html += String.format('<%:IPv6-PD%>: %s
', ifc.ip6prefix); + + 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 9005279a4e..a1b2c8454d 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 b32ef78263..9eec012547 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).%>
    -
    -
    - -
    - -
    - -
    +
    + <%: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.%>
    -
    -
    -
    - -
    - - - -
    -
    -
    -
    +
    + <% 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 4944a232b2..ef13a91672 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)%>
    + <% 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) %> - <% if empty then %> -
    -
     
    -
    <%:none%>
    -
    <%:none%>
    -
    - <% 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)%>
      + <% 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 empty then %> -
      -
       
      -
      <%:none%>
      -
      <%:none%>
      -
      <%:none%>
      -
      <%:none%>
      -
      - <% 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 c9551804d2..6ec2b310d2 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 c69ec1215a..6282244757 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%> From e097d3f734d25b31fe511a0d344d913a6d411c87 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 19 Jun 2018 16:58:39 +0200 Subject: [PATCH 07/11] luci-app-firewall: cleanup template markup Rework the cbi section add template markup to properly render with the latest responsive design changes. Signed-off-by: Jo-Philipp Wich --- .../luasrc/view/firewall/cbi_addforward.htm | 170 ++++++++-------- .../luasrc/view/firewall/cbi_addrule.htm | 181 +++++++++--------- .../luasrc/view/firewall/cbi_addsnat.htm | 87 ++++----- 3 files changed, 211 insertions(+), 227 deletions(-) diff --git a/applications/luci-app-firewall/luasrc/view/firewall/cbi_addforward.htm b/applications/luci-app-firewall/luasrc/view/firewall/cbi_addforward.htm index 279b6e06d6..f48599b505 100644 --- a/applications/luci-app-firewall/luasrc/view/firewall/cbi_addforward.htm +++ b/applications/luci-app-firewall/luasrc/view/firewall/cbi_addforward.htm @@ -18,95 +18,91 @@ vals[#vals+1] = '%s (%s)' %{ ip, name } end) -%> -
    -
    -
    -
    -
    <%:New port forward%>:
    + +

    <%:New port forward%>

    +
    +
    +
    <%:Name%>
    +
    <%:Protocol%>
    +
    <%:External zone%>
    +
    <%:External port%>
    +
    <%:Internal zone%>
    +
    <%:Internal IP address%>
    +
    <%:Internal port%>
    +
    +
    +
    +
    +
    -
    -
    <%:Name%>
    -
    <%:Protocol%>
    -
    <%:External zone%>
    -
    <%:External port%>
    -
    <%:Internal zone%>
    -
    <%:Internal IP address%>
    -
    <%:Internal port%>
    -
    +
    +
    -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    -
    - 0, "data-choices", {keys, vals}) - %>/> -
    -
    - -
    -
    - -
    +
    + +
    +
    + +
    +
    + +
    +
    + 0, "data-choices", {keys, vals}) + %>/> +
    +
    + +
    +
    +
    - -
    + + diff --git a/applications/luci-app-firewall/luasrc/view/firewall/cbi_addrule.htm b/applications/luci-app-firewall/luasrc/view/firewall/cbi_addrule.htm index c99ecaca37..273675cd30 100644 --- a/applications/luci-app-firewall/luasrc/view/firewall/cbi_addrule.htm +++ b/applications/luci-app-firewall/luasrc/view/firewall/cbi_addrule.htm @@ -5,112 +5,105 @@ local zones = fw:get_zones() %> -
    - <% if wz then %> -
    -
    -
    -
    <%:Open ports on router%>:
    +<% if wz then %> +

    <%:Open ports on router%>

    +
    +
    +
    <%:Name%>
    +
    <%:Protocol%>
    +
    <%:External port%>
    +
    +
    +
    +
    +
    -
    -
    <%:Name%>
    -
    <%:Protocol%>
    -
    <%:External port%>
    -
    +
    +
    -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    +
    + +
    +
    +
    - <% end %> - <% if #zones > 1 then %> -
    -
    -

    <%:New forward rule%>:
    +
    +<% end %> +<% if #zones > 1 then %> +

    <%:New forward rule%>

    +
    +
    +
    <%:Name%>
    +
    <%:Source zone%>
    +
    <%:Destination zone%>
    +
    +
    +
    +
    +
    -
    -
    <%:Name%>
    -
    <%:Source zone%>
    -
    <%:Destination zone%>
    -
    +
    +
    -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    +
    + +
    +
    +
    - <% else %> - - <% end %> +
    +<% else %> + +<% end %> - <% if wz then %> - - <% end %> -
    + cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>', true, 'uciname'); + //]]> +<% end %> diff --git a/applications/luci-app-firewall/luasrc/view/firewall/cbi_addsnat.htm b/applications/luci-app-firewall/luasrc/view/firewall/cbi_addsnat.htm index b2775cf694..0b4774ccc0 100644 --- a/applications/luci-app-firewall/luasrc/view/firewall/cbi_addsnat.htm +++ b/applications/luci-app-firewall/luasrc/view/firewall/cbi_addsnat.htm @@ -12,53 +12,48 @@ end %> -
    - <% if #zones > 1 then %> -
    -
    -
    -
    <%:New source NAT%>:
    +<% if #zones > 1 then %> +

    <%:New source NAT%>

    +
    +
    +
    <%:Name%>
    +
    <%:Source zone%>
    +
    <%:Destination zone%>
    +
    <%:To source IP%>
    +
    <%:To source port%>
    +
    +
    +
    +
    +
    -
    -
    <%:Name%>
    -
    <%:Source zone%>
    -
    <%:Destination zone%>
    -
    <%:To source IP%>
    -
    <%:To source port%>
    -
    +
    +
    -
    -
    - -
    -
    - -
    -
    - -
    -
    - 0, "data-choices", { keys, vals }) - %> /> -
    -
    - -
    -
    - -
    +
    + +
    +
    + 0, "data-choices", { keys, vals }) + %> /> +
    +
    + +
    +
    +
    - <% else %> - - <% end %> -
    +
    +<% else %> + +<% end %> From ce8101ae75fa8767bf84f692c5424e2cf3441f34 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 19 Jun 2018 17:18:02 +0200 Subject: [PATCH 08/11] luci-app-upnp: rework lease status indicator Turn the dynamic lease status table into responsive table by using the cbi_update_table() helper in conjunction with title annotation attributes. Signed-off-by: Jo-Philipp Wich --- .../luci-app-upnp/luasrc/view/upnp_status.htm | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/applications/luci-app-upnp/luasrc/view/upnp_status.htm b/applications/luci-app-upnp/luasrc/view/upnp_status.htm index 1e09225793..459c63c1d7 100644 --- a/applications/luci-app-upnp/luasrc/view/upnp_status.htm +++ b/applications/luci-app-upnp/luasrc/view/upnp_status.htm @@ -16,40 +16,39 @@ var tb = document.getElementById('upnp_status_table'); if (st && tb) { - /* clear all rows */ - while (tb.firstElementChild !== tb.lastElementChild) - tb.removeChild(tb.lastElementChild); + var rows = []; for (var i = 0; i < st.length; i++) - tb.appendChild(E('
    '.format((i % 2) + 1), [ - E('
    ', st[i].proto), - E('
    ', st[i].extport), - E('
    ', st[i].intaddr), - E('
    ', st[i].intport), - E('
    ', st[i].descr), - E(''.format(st[i].num)) - ])); + rows.push([ + st[i].proto, + st[i].extport, + st[i].intaddr, + st[i].intport, + st[i].descr, + E(''.format(st[i].num)) + ]); - if (tb.firstElementChild === tb.lastElementChild) - tb.appendChild(E('

    <%:There are no active redirects.%>
    ')); + cbi_update_table(tb, rows, '<%:There are no active redirects.%>'); } } ); //]]> -
    +
    <%:Active UPnP Redirects%> -
    -
    -
    <%:Protocol%>
    -
    <%:External Port%>
    -
    <%:Client Address%>
    -
    <%:Client Port%>
    -
    <%:Description%>
    -
     
    -
    -
    -

    <%:Collecting data...%>
    +
    +
    +
    +
    <%:Protocol%>
    +
    <%:External Port%>
    +
    <%:Client Address%>
    +
    <%:Client Port%>
    +
    <%:Description%>
    +
     
    +
    +
    +
    <%:Collecting data...%>
    +
    -
    +
    From db4139b1491a0ca7ba7897208d49be126c368ae9 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 19 Jun 2018 17:18:36 +0200 Subject: [PATCH 09/11] luci-app-travelmate: consolidate markup Rework the various application view templates to properly render with the latest responsive design changes. Signed-off-by: Jo-Philipp Wich --- .../luasrc/view/travelmate/logread.htm | 4 +-- .../luasrc/view/travelmate/stations.htm | 28 ++++++++-------- .../luasrc/view/travelmate/wifi_scan.htm | 32 ++++++++++--------- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/logread.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/logread.htm index 6cbeaffde6..c40bdeeb59 100644 --- a/applications/luci-app-travelmate/luasrc/view/travelmate/logread.htm +++ b/applications/luci-app-travelmate/luasrc/view/travelmate/logread.htm @@ -6,10 +6,10 @@ This is free software, licensed under the Apache License, Version 2.0 <%+header%>
    -
    +
    <%:This form shows the syslog output, pre-filtered for travelmate related messages only.%>
    -
    +
    +
    <%=translatef("Provides an overview of all configured uplinks for the travelmate interface (%s). You can edit, delete or re-order existing uplinks or scan for a new one. The currently used uplink is emphasized in blue.", trmiface)%>
    -
    -
    +
    +
    -
    <%:Device%>
    -
    <%:SSID%>
    -
    <%:BSSID%>
    -
    <%:Encryption%>
    -
    <%:Actions%>
    +
    <%:Device%>
    +
    <%:SSID%>
    +
    <%:BSSID%>
    +
    <%:Encryption%>
    +
     
    <% uci:foreach("wireless", "wifi-iface", function(s) @@ -45,11 +47,9 @@ This is free software, licensed under the Apache License, Version 2.0
    <%=ssid%>
    <%=bssid%>
    <%=encryption%>
    -
    - - -
    -
    +
    + +
    @@ -59,7 +59,7 @@ This is free software, licensed under the Apache License, Version 2.0 end) %>
    -
    +
    <% uci:foreach("wireless", "wifi-device", function(s) @@ -68,7 +68,7 @@ This is free software, licensed under the Apache License, Version 2.0
    - +
    <% end) diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm index 81182b99b4..57efd97376 100644 --- a/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm +++ b/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm @@ -39,31 +39,33 @@ This is free software, licensed under the Apache License, Version 2.0 <%+header%> + +

    <%:Wireless Scan%>

    -
    -
    +
    +
    -
    <%:Uplink SSID%>
    -
    <%:Uplink BSSID%>
    -
    <%:Encryption%>
    -
    <%:Signal strength%>
    +
    <%:Uplink SSID%>
    +
    <%:Uplink BSSID%>
    +
    <%:Encryption%>
    +
    <%:Signal strength%>
    <% for i, net in ipairs(iw.scanlist or { }) do %>
    -
    +
    <%=net.ssid and utl.pcdata(net.ssid) or "%s" % translate("hidden")%>
    -
    +
    <%=net.bssid and utl.pcdata(net.bssid)%>
    -
    +
    <%=format_wifi_encryption(net.encryption)%>
    -
    +
    <%=percent_wifi_signal(net)%> %
    -
    +
    @@ -80,16 +82,16 @@ This is free software, licensed under the Apache License, Version 2.0
    <% end %>
    -
    +
    + + +
    -
    - -
    From b4d78d20427a782fa0d405f9d69c378bf3349ca5 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 19 Jun 2018 17:57:08 +0200 Subject: [PATCH 10/11] luci-mod-admin-full: packages: display available packages by default Signed-off-by: Jo-Philipp Wich --- modules/luci-mod-admin-full/luasrc/controller/admin/system.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua b/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua index 6fcd66f441..0c19893cf8 100644 --- a/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua +++ b/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua @@ -74,7 +74,7 @@ function action_packages() local out, err -- Display - local display = luci.http.formvalue("display") or "installed" + local display = luci.http.formvalue("display") or "available" -- Letter local letter = string.byte(luci.http.formvalue("letter") or "A", 1) From c7ee1ffcf114e11a81f2fdb707c705b5cb5064e3 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 20 Jun 2018 14:00:00 +0200 Subject: [PATCH 11/11] luci-app-shadowsocks-libev: cleanup section add markup Signed-off-by: Jo-Philipp Wich --- .../view/shadowsocks-libev/add_instance.htm | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/applications/luci-app-shadowsocks-libev/luasrc/view/shadowsocks-libev/add_instance.htm b/applications/luci-app-shadowsocks-libev/luasrc/view/shadowsocks-libev/add_instance.htm index 80b95564dd..f016dd47e6 100644 --- a/applications/luci-app-shadowsocks-libev/luasrc/view/shadowsocks-libev/add_instance.htm +++ b/applications/luci-app-shadowsocks-libev/luasrc/view/shadowsocks-libev/add_instance.htm @@ -1,24 +1,17 @@
    -
    -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    +
    +
    +
    + +
    +