diff options
Diffstat (limited to 'modules/luci-base/luasrc/view')
22 files changed, 171 insertions, 160 deletions
diff --git a/modules/luci-base/luasrc/view/admin_uci/changelog.htm b/modules/luci-base/luasrc/view/admin_uci/changelog.htm index 8a162c88b..9d6267cf3 100644 --- a/modules/luci-base/luasrc/view/admin_uci/changelog.htm +++ b/modules/luci-base/luasrc/view/admin_uci/changelog.htm @@ -19,7 +19,7 @@ local util = luci.util local tpl = { ["add-3"] = "<ins>uci add %0 <strong>%3</strong> # =%2</ins>", - ["set-3"] = "<ins>uci set %0.<strong>%2</strong></ins>=%3", + ["set-3"] = "<ins>uci set %0.<strong>%2</strong>=%3</ins>", ["set-4"] = "<var><ins>uci set %0.%2.%3=<strong>%4</strong></ins></var>", ["remove-2"] = "<del>uci del %0.<strong>%2</strong></del>", ["remove-3"] = "<var><del>uci del %0.%2.<strong>%3</strong></del></var>", diff --git a/modules/luci-base/luasrc/view/cbi/apply_widget.htm b/modules/luci-base/luasrc/view/cbi/apply_widget.htm index ce279edd4..0f9667390 100644 --- a/modules/luci-base/luasrc/view/cbi/apply_widget.htm +++ b/modules/luci-base/luasrc/view/cbi/apply_widget.htm @@ -1,49 +1,4 @@ <% export("cbi_apply_widget", function(redirect_ok, rollback_token) -%> -<style type="text/css"> - #cbi_apply_overlay { - position: absolute; - top: 0; - left: 0; - bottom: 0; - right: 0; - background: rgba(0, 0, 0, 0.7); - display: none; - z-index: 20000; - } - - #cbi_apply_overlay .alert-message { - position: relative; - top: 10%; - width: 60%; - margin: auto; - display: flex; - flex-wrap: wrap; - min-height: 32px; - align-items: center; - } - - #cbi_apply_overlay .alert-message > h4, - #cbi_apply_overlay .alert-message > p, - #cbi_apply_overlay .alert-message > div { - flex-basis: 100%; - } - - #cbi_apply_overlay .alert-message > img { - margin-right: 1em; - flex-basis: 32px; - } - - body.apply-overlay-active { - overflow: hidden; - height: 100vh; - } - - body.apply-overlay-active #cbi_apply_overlay { - display: block; - } -</style> - -<script type="text/javascript" src="<%=resource%>/cbi.js?v=git-18.138.59467-72fe5dd"></script> <script type="text/javascript">//<![CDATA[ var xhr = new XHR(), uci_apply_auth = { sid: '<%=luci.dispatcher.context.authsession%>', token: '<%=token%>' }, @@ -55,28 +10,22 @@ was_xhr_poll_running = false; function uci_status_message(type, content) { - var overlay = document.getElementById('cbi_apply_overlay') || document.body.appendChild(E('<div id="cbi_apply_overlay"><div class="alert-message"></div></div>')), - message = overlay.querySelector('.alert-message'); - - if (message && type) { - if (!message.classList.contains(type)) { - message.classList.remove('notice'); - message.classList.remove('warning'); - message.classList.add(type); - } + if (type) { + var message = showModal('', ''); + + message.classList.add('alert-message'); + DOMTokenList.prototype.add.apply(message.classList, type.split(/\s+/)); if (content) message.innerHTML = content; - document.body.classList.add('apply-overlay-active'); - if (!was_xhr_poll_running) { was_xhr_poll_running = XHR.running(); XHR.halt(); } } else { - document.body.classList.remove('apply-overlay-active'); + hideModal(); if (was_xhr_poll_running) XHR.run(); @@ -85,19 +34,18 @@ function uci_rollback(checked) { if (checked) { - uci_status_message('warning', - '<img src="<%=resource%>/icons/loading.gif" alt="" style="vertical-align:middle" /> ' + - '<%:Failed to confirm apply within %ds, waiting for rollback…%>'.format(uci_apply_rollback)); + uci_status_message('warning spinning', + '<p><%:Failed to confirm apply within %ds, waiting for rollback…%></p>'.format(uci_apply_rollback)); var call = function(r, data, duration) { if (r.status === 204) { uci_status_message('warning', '<h4><%:Configuration has been rolled back!%></h4>' + - '<p><%:The device could not be reached within %d seconds after applying the pending changes, which caused the configuration to be rolled back for safety reasons. If you believe that the configuration changes are correct nonetheless, perform an unchecked configuration apply. Alternatively, you can dismiss this warning and edit changes before attempting to apply again, or revert all pending changes to keep the currently working configuration state.%></p>'.format(uci_apply_rollback) + + '<p><%:The device could not be reached within %d seconds after applying the pending changes, which caused the configuration to be rolled back for safety reasons. If you believe that the configuration changes are correct nonetheless, proceed by applying anyway. Alternatively, you can dismiss this warning and edit changes before attempting to apply again, or revert all pending changes to keep the currently working configuration state.%></p>'.format(uci_apply_rollback) + '<div class="right">' + '<input type="button" class="btn" onclick="uci_status_message(false)" value="<%:Dismiss%>" /> ' + '<input type="button" class="btn cbi-button-action important" onclick="uci_revert()" value="<%:Revert changes%>" /> ' + - '<input type="button" class="btn cbi-button-negative important" onclick="uci_apply(false)" value="<%:Apply unchecked%>" />' + + '<input type="button" class="btn cbi-button-negative important" onclick="uci_apply(false)" value="<%:Apply anyway%>" />' + '</div>'); return; @@ -126,6 +74,7 @@ var call = function(r, data, duration) { if (Date.now() >= deadline) { + window.clearTimeout(tt); uci_rollback(checked); return; } @@ -133,7 +82,7 @@ var indicator = document.querySelector('.uci_change_indicator'); if (indicator) indicator.style.display = 'none'; - uci_status_message('notice', '<%:Configuration has been applied.%>'); + uci_status_message('notice', '<p><%:Configuration has been applied.%></p>'); window.clearTimeout(tt); window.setTimeout(function() { @@ -156,9 +105,8 @@ var tick = function() { var now = Date.now(); - uci_status_message('notice', - '<img src="<%=resource%>/icons/loading.gif" alt="" style="vertical-align:middle" /> ' + - '<%:Waiting for configuration to be applied… %ds%>'.format(Math.max(Math.floor((deadline - Date.now()) / 1000), 0))); + uci_status_message('notice spinning', + '<p><%:Waiting for configuration to be applied… %ds%></p>'.format(Math.max(Math.floor((deadline - Date.now()) / 1000), 0))); if (now >= deadline) return; @@ -174,9 +122,7 @@ } function uci_apply(checked) { - uci_status_message('notice', - '<img src="<%=resource%>/icons/loading.gif" alt="" style="vertical-align:middle" /> ' + - '<%:Starting configuration apply…%>'); + uci_status_message('notice spinning', '<p><%:Starting configuration apply…%></p>'); xhr.post('<%=url("admin/uci")%>/' + (checked ? 'apply_rollback' : 'apply_unchecked'), uci_apply_auth, function(r, tok) { if (r.status === (checked ? 200 : 204)) { @@ -186,7 +132,7 @@ uci_confirm(checked, Date.now() + uci_apply_rollback * 1000); } else if (checked && r.status === 204) { - uci_status_message('notice', '<%:There are no changes to apply.%>'); + uci_status_message('notice', '<p><%:There are no changes to apply.%></p>'); window.setTimeout(function() { <% if redirect_ok then -%> location.href = decodeURIComponent('<%=luci.util.urlencode(redirect_ok)%>'); @@ -196,20 +142,18 @@ }, uci_apply_display * 1000); } else { - uci_status_message('warning', '<%_Apply request failed with status <code>%h</code>%>'.format(r.responseText || r.statusText || r.status)); + uci_status_message('warning', '<p><%_Apply request failed with status <code>%h</code>%></p>'.format(r.responseText || r.statusText || r.status)); window.setTimeout(function() { uci_status_message(false); }, uci_apply_display * 1000); } }); } function uci_revert() { - uci_status_message('notice', - '<img src="<%=resource%>/icons/loading.gif" alt="" style="vertical-align:middle" /> ' + - '<%:Reverting configuration…%>'); + uci_status_message('notice spinning', '<p><%:Reverting configuration…%></p>'); xhr.post('<%=url("admin/uci/revert")%>', uci_apply_auth, function(r) { if (r.status === 200) { - uci_status_message('notice', '<%:Changes have been reverted.%>'); + uci_status_message('notice', '<p><%:Changes have been reverted.%></p>'); window.setTimeout(function() { <% if redirect_ok then -%> location.href = decodeURIComponent('<%=luci.util.urlencode(redirect_ok)%>'); @@ -219,7 +163,7 @@ }, uci_apply_display * 1000); } else { - uci_status_message('warning', '<%_Revert request failed with status <code>%h</code>%>'.format(r.statusText || r.status)); + uci_status_message('warning', '<p><%_Revert request failed with status <code>%h</code>%></p>'.format(r.statusText || r.status)); window.setTimeout(function() { uci_status_message(false); }, uci_apply_display * 1000); } }); diff --git a/modules/luci-base/luasrc/view/cbi/browser.htm b/modules/luci-base/luasrc/view/cbi/browser.htm index 2abc975e8..eb47ffafe 100644 --- a/modules/luci-base/luasrc/view/cbi/browser.htm +++ b/modules/luci-base/luasrc/view/cbi/browser.htm @@ -1,8 +1,10 @@ -<% local v = self:cfgvalue(section) -%> <%+cbi/valueheader%> - <input class="cbi-input-text" type="text"<%= attr("value", v) .. attr("name", cbid) .. attr("id", cbid) %> /> - <script type="text/javascript"> -cbi_init() -cbi_browser_init('<%=cbid%>', '<%=resource%>', '<%=url('admin/filebrowser')%>'<%=self.default_path and ", '"..self.default_path.."'"%>); - </script> + +<input class="cbi-input-text" type="text"<%= + attr("id", cbid) .. + attr("name", cbid) .. + attr("value", self:cfgvalue(section) or self.default) .. + attr("data-browser", self.default_path or "") +%> /> + <%+cbi/valuefooter%> diff --git a/modules/luci-base/luasrc/view/cbi/cell_valueheader.htm b/modules/luci-base/luasrc/view/cbi/cell_valueheader.htm index ea0568f40..cb11d8f61 100644 --- a/modules/luci-base/luasrc/view/cbi/cell_valueheader.htm +++ b/modules/luci-base/luasrc/view/cbi/cell_valueheader.htm @@ -6,7 +6,7 @@ <div class="td cbi-value-field<% if self.error and self.error[section] then %> cbi-value-error<% end %>"<%= attr("data-name", self.option) .. ifattr(ftype and #ftype > 0, "data-type", ftype) .. - ifattr(title and #title > 0, "data-title", title) .. - ifattr(descr and #descr > 0, "data-description", descr) + ifattr(title and #title > 0, "data-title", title, true) .. + ifattr(descr and #descr > 0, "data-description", descr, true) %>> <div id="cbi-<%=self.config.."-"..section.."-"..self.option%>" data-index="<%=self.index%>" data-depends="<%=pcdata(self:deplist2json(section))%>"> diff --git a/modules/luci-base/luasrc/view/cbi/dropdown.htm b/modules/luci-base/luasrc/view/cbi/dropdown.htm index cf8c03d22..6f4b89905 100644 --- a/modules/luci-base/luasrc/view/cbi/dropdown.htm +++ b/modules/luci-base/luasrc/view/cbi/dropdown.htm @@ -30,7 +30,7 @@ <li<%= attr("data-index", i) .. attr("data-depends", self:deplist2json(section, self.deplist[i])) .. - attr("value", key) .. + attr("data-value", key) .. ifattr(selected[key], "selected", "selected") %>> <%=pcdata(self.vallist[i])%> diff --git a/modules/luci-base/luasrc/view/cbi/dynlist.htm b/modules/luci-base/luasrc/view/cbi/dynlist.htm index 4d0b50942..fa7dbdb41 100644 --- a/modules/luci-base/luasrc/view/cbi/dynlist.htm +++ b/modules/luci-base/luasrc/view/cbi/dynlist.htm @@ -6,22 +6,8 @@ self.keylist, self.vallist, self.datatype, self.optional or self.rmempty })) .. - + attr("data-values", luci.util.serialize_json(self:cfgvalue(section))) .. ifattr(self.size, "data-size", self.size) .. ifattr(self.placeholder, "data-placeholder", self.placeholder) -%>> -<% - local vals = self:cfgvalue(section) or {} - for i=1, #vals + 1 do - local val = vals[i] - if (val and #val > 0) or (i == 1) then -%> - <input class="cbi-input-text" value="<%=pcdata(val)%>" data-update="change" type="text"<%= - attr("id", cbid .. "." .. i) .. - attr("name", cbid) .. - ifattr(self.size, "size") .. - ifattr(i == 1 and self.placeholder, "placeholder", self.placeholder) - %> /><br /> -<% end end %> -</div> +%>></div> <%+cbi/valuefooter%> diff --git a/modules/luci-base/luasrc/view/cbi/firewall_zoneforwards.htm b/modules/luci-base/luasrc/view/cbi/firewall_zoneforwards.htm index b38e4b13d..dc251dbd9 100644 --- a/modules/luci-base/luasrc/view/cbi/firewall_zoneforwards.htm +++ b/modules/luci-base/luasrc/view/cbi/firewall_zoneforwards.htm @@ -63,7 +63,7 @@ if empty then %> <label class="zonebadge zonebadge-empty"> - <strong><%=zone:forward():upper()%></strong> + <strong><%=def:forward():upper()%></strong> </label> <% end %> </div> diff --git a/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm b/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm index 3a108020b..7ecec10a8 100644 --- a/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm +++ b/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm @@ -30,7 +30,7 @@ ifattr(self.rmempty or self.optional, "optional", "optional") %>> <script type="item-template"><!-- - <li value="{{value}}"> + <li data-value="{{value}}"> <span class="zonebadge" style="background:repeating-linear-gradient(45deg,rgba(204,204,204,0.5),rgba(204,204,204,0.5) 5px,rgba(255,255,255,0.5) 5px,rgba(255,255,255,0.5) 10px)"> <strong>{{value}}:</strong><em>(<%:create%>)</em> </span> @@ -38,7 +38,7 @@ --></script> <ul> <% if self.allowlocal then %> - <li value=""<%=ifattr(checked[""], "selected", "selected")%>> + <li data-value=""<%=ifattr(checked[""], "selected", "selected")%>> <span style="background-color:<%=fwm.zone.get_color()%>" class="zonebadge"> <strong><%:Device%></strong> <% if self.allowany and self.allowlocal then -%> @@ -48,14 +48,14 @@ </span> </li> <% elseif self.widget ~= "checkbox" and (self.rmempty or self.optional) then %> - <li value=""<%=ifattr(checked[""], "selected", "selected")%>> + <li data-value=""<%=ifattr(checked[""], "selected", "selected")%>> <span class="zonebadge"> <em><%:unspecified%></em> </span> </li> <% end %> <% if self.allowany then %> - <li value="*"<%=ifattr(checked["*"], "selected", "selected")%>> + <li data-value="*"<%=ifattr(checked["*"], "selected", "selected")%>> <span style="background-color:<%=fwm.zone.get_color()%>" class="zonebadge"> <strong><%:Any zone%></strong> <% if self.allowany and self.allowlocal then %>(<%:forward%>)<% end %> @@ -67,7 +67,7 @@ if zone:name() ~= self.exclude then selected = selected or (value == zone:name()) %> - <li<%=attr("value", zone:name()) .. ifattr(checked[zone:name()], "selected", "selected")%>> + <li<%=attr("data-value", zone:name()) .. ifattr(checked[zone:name()], "selected", "selected")%>> <span style="background-color:<%=zone:get_color()%>" class="zonebadge"> <strong><%=zone:name()%>:</strong> <%- @@ -94,11 +94,11 @@ <% end end %> <% if self.widget ~= "checkbox" and not self.nocreate then %> - <li value="-"> + <li data-value="-"> <span class="zonebadge"> <em><%:create%>:</em> <input type="password" style="display:none" /> - <input class="create-item-input" type="text" /> + <input class="create-item-input" type="text" data-type="and(uciname,maxlength(11))" data-optional="true" /> </span> </li> <% end %> diff --git a/modules/luci-base/luasrc/view/cbi/ipaddr.htm b/modules/luci-base/luasrc/view/cbi/ipaddr.htm new file mode 100644 index 000000000..1c924e154 --- /dev/null +++ b/modules/luci-base/luasrc/view/cbi/ipaddr.htm @@ -0,0 +1,27 @@ +<%+cbi/valueheader%> + <script type="text/javascript"> + function switchToCIDRList(ev) { + var input = ev.target.previousElementSibling, + usecidr = document.getElementById(input.id + '_usecidr'); + + ev.preventDefault(); + + usecidr.value = '1'; + cbi_d_update(); + } + </script> + <input data-update="change"<%= + attr("id", cbid) .. + attr("name", cbid) .. + attr("type", "text") .. + attr("class", "cbi-input-text") .. + attr("value", self:cfgvalue(section) or self.default) .. + ifattr(self.size, "size") .. + ifattr(self.placeholder, "placeholder") .. + ifattr(self.datatype, "data-type", self.datatype) .. + ifattr(self.datatype, "data-optional", self.optional or self.rmempty) .. + ifattr(self.combobox_manual, "data-manual", self.combobox_manual) .. + ifattr(#self.keylist > 0, "data-choices", { self.keylist, self.vallist }) + %> /><!-- + --><button class="cbi-button cbi-button-neutral" title="<%:Switch to CIDR list notation%>" aria-label="<%:Switch to CIDR list notation%>" onclick="switchToCIDRList(event)">…</button> +<%+cbi/valuefooter%> diff --git a/modules/luci-base/luasrc/view/cbi/map.htm b/modules/luci-base/luasrc/view/cbi/map.htm index d65a16167..cda4d3530 100644 --- a/modules/luci-base/luasrc/view/cbi/map.htm +++ b/modules/luci-base/luasrc/view/cbi/map.htm @@ -3,25 +3,25 @@ <%- end end -%> <div class="cbi-map" id="cbi-<%=self.config%>"> - <% if self.title and #self.title > 0 then %><h2 name="content"><%=self.title%></h2><% end %> - <% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %> + <% if self.title and #self.title > 0 then %> + <h2 name="content"><%=self.title%></h2> + <% end %> + <% if self.description and #self.description > 0 then %> + <div class="cbi-map-descr"><%=self.description%></div> + <% end %> <% if self.tabbed then %> - <ul class="cbi-tabmenu map"> - <%- self.selected_tab = luci.http.formvalue("tab.m-" .. self.config) %> - <% for i, section in ipairs(self.children) do %> - <%- if not self.selected_tab then self.selected_tab = section.sectiontype end %> - <li id="tab.m-<%=self.config%>.<%=section.section or section.sectiontype%>" class="cbi-tab<%=(section.sectiontype == self.selected_tab) and '' or '-disabled'%>"> - <a onclick="this.blur(); return cbi_t_switch('m-<%=self.config%>', '<%=section.section or section.sectiontype%>')" href="<%=REQUEST_URI%>?tab.m-<%=self.config%>=<%=section.section or section.sectiontype%>"><%=section.title or section.section or section.sectiontype %></a> - <% if section.sectiontype == self.selected_tab then %><input type="hidden" id="tab.m-<%=self.config%>" name="tab.m-<%=self.config%>" value="<%=section.section or section.sectiontype%>" /><% end %> - </li> + <div> + <% for i, section in ipairs(self.children) do + tab = section.section or section.sectiontype %> + <div class="cbi-tabcontainer"<%= + attr("id", "container.m-%s.%s" %{ self.config, tab }) .. + attr("data-tab", tab) .. + attr("data-tab-title", section.title or tab) + %>> + <% section:render() %> + </div> <% end %> - </ul> - <% for i, section in ipairs(self.children) do %> - <div class="cbi-tabcontainer" id="container.m-<%=self.config%>.<%=section.section or section.sectiontype%>"<% if section.sectiontype ~= self.selected_tab then %> style="display:none"<% end %>> - <% section:render() %> - </div> - <script type="text/javascript">cbi_t_add('m-<%=self.config%>', '<%=section.section or section.sectiontype%>')</script> - <% end %> + </div> <% if not self.save then -%> <div class="cbi-section-error"> diff --git a/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm b/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm index a97e9ef6d..f23e51d18 100644 --- a/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm +++ b/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm @@ -41,13 +41,13 @@ <input type="hidden" name="<%=cbeid%>" value="1" /> -<div class="cbi-dropdown" display-items="5" placeholder="<%:-- please select -- %>"<%= +<div class="cbi-dropdown" display-items="10" placeholder="<%:-- please select -- %>"<%= attr("name", cbid) .. ifattr(self.widget == "checkbox", "multiple", "multiple") .. ifattr(self.widget == "checkbox", "optional", "optional") %>> <script type="item-template"><!-- - <li value="{{value}}"> + <li data-value="{{value}}"> <img title="<%:Custom Interface%>: "{{value}}"" src="<%=resource%>/icons/ethernet_disabled.png" /> <span class="hide-open">{{value}}</span> <span class="hide-close"><%:Custom Interface%>: "{{value}}"</span> @@ -61,7 +61,7 @@ iface:name() ~= self.exclude then %> <li<%= - attr("value", iface:name()) .. + attr("data-value", iface:name()) .. ifattr(checked[iface:name()], "selected", "selected") %>> <img<%=attr("title", iface:get_i18n())%> src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" /> @@ -78,7 +78,7 @@ </li> <% end end %> <% if not self.nocreate then %> - <li value=""> + <li data-value=""> <img title="<%:Custom Interface%>" src="<%=resource%>/icons/ethernet_disabled.png" /> <span><%:Custom Interface%>:</span> <input type="password" style="display:none" /> diff --git a/modules/luci-base/luasrc/view/cbi/network_netlist.htm b/modules/luci-base/luasrc/view/cbi/network_netlist.htm index ba6ebb843..3ee4274a3 100644 --- a/modules/luci-base/luasrc/view/cbi/network_netlist.htm +++ b/modules/luci-base/luasrc/view/cbi/network_netlist.htm @@ -20,13 +20,13 @@ end -%> -<div class="cbi-dropdown" display-items="5" placeholder="<%:-- please select -- %>"<%= +<div class="cbi-dropdown" display-items="10" placeholder="<%:-- please select -- %>"<%= attr("name", cbid) .. ifattr(self.widget == "checkbox", "multiple", "multiple") .. ifattr(self.widget == "checkbox", "optional", "optional") %>> <script type="item-template"><!-- - <li value="{{value}}"> + <li data-value="{{value}}"> <span class="ifacebadge" style="background:repeating-linear-gradient(45deg,rgba(204,204,204,0.5),rgba(204,204,204,0.5) 5px,rgba(255,255,255,0.5) 5px,rgba(255,255,255,0.5) 10px)"> {{value}}: <em>(<%:create%>)</em> </span> @@ -34,7 +34,7 @@ --></script> <ul> <% if self.widget ~= "checkbox" then %> - <li value=""<%= ifattr(not value, "selected", "selected") %>> + <li data-value=""<%= ifattr(not value, "selected", "selected") %>> <em><%:unspecified%></em> </li> <% end %> @@ -44,7 +44,7 @@ (net:name() ~= self.exclude) and (not self.novirtual or not net:is_virtual()) then %> - <li<%= attr("value", net:name()) .. ifattr(checked[net:name()], "selected", "selected") %>> + <li<%= attr("data-value", net:name()) .. ifattr(checked[net:name()], "selected", "selected") %>> <span class="ifacebadge"><%=net:name()%>: <% local empty = true @@ -63,7 +63,7 @@ <% end end %> <% if not self.nocreate then %> - <li value="-"<%= ifattr(not value and self.widget ~= "checkbox", "selected", "selected") %>> + <li data-value="-"<%= ifattr(not value and self.widget ~= "checkbox", "selected", "selected") %>> <em> <%- if self.widget == "checkbox" then -%> <%:create:%> diff --git a/modules/luci-base/luasrc/view/cbi/nsection.htm b/modules/luci-base/luasrc/view/cbi/nsection.htm index 63abc5773..14232e3d9 100644 --- a/modules/luci-base/luasrc/view/cbi/nsection.htm +++ b/modules/luci-base/luasrc/view/cbi/nsection.htm @@ -11,7 +11,6 @@ <input type="submit" class="cbi-button" name="cbi.rns.<%=self.config%>.<%=section%>" value="<%:Delete%>" /> </div> <%- end %> - <%+cbi/tabmenu%> <div class="cbi-section-node<% if self.tabs then %> cbi-section-node-tabbed<% end %>" id="cbi-<%=self.config%>-<%=section%>"> <%+cbi/ucisection%> </div> diff --git a/modules/luci-base/luasrc/view/cbi/tabcontainer.htm b/modules/luci-base/luasrc/view/cbi/tabcontainer.htm index 38c435d6a..7fcb83578 100644 --- a/modules/luci-base/luasrc/view/cbi/tabcontainer.htm +++ b/modules/luci-base/luasrc/view/cbi/tabcontainer.htm @@ -1,7 +1,14 @@ -<% for tab, data in pairs(self.tabs) do %> - <div class="cbi-tabcontainer" id="container.<%=self.config%>.<%=section%>.<%=tab%>"<% if tab ~= self.selected_tab then %> style="display:none"<% end %>> - <% if data.description then %><div class="cbi-tab-descr"><%=data.description%></div><% end %> +<% for _, tab in ipairs(self.tab_names) do data = self.tabs[tab] %> + <div class="cbi-tabcontainer"<%= + attr("id", "container.%s.%s.%s" %{ self.config, section, tab }) .. + attr("data-tab", tab) .. + attr("data-tab-title", data.title) .. + attr("data-tab-active", tostring(tab == self.selected_tab)) + %>> + <% if data.description then %> + <div class="cbi-tab-descr"><%=data.description%></div> + <% end %> + <% self:render_tab(tab, section, scope or {}) %> </div> - <script type="text/javascript">cbi_t_add('<%=self.config%>.<%=section%>', '<%=tab%>')</script> <% end %> diff --git a/modules/luci-base/luasrc/view/cbi/tabmenu.htm b/modules/luci-base/luasrc/view/cbi/tabmenu.htm deleted file mode 100644 index 06c1414bf..000000000 --- a/modules/luci-base/luasrc/view/cbi/tabmenu.htm +++ /dev/null @@ -1,12 +0,0 @@ -<%- if self.tabs then %> - <ul class="cbi-tabmenu"> - <%- self.selected_tab = luci.http.formvalue("tab." .. self.config .. "." .. section) %> - <%- for _, tab in ipairs(self.tab_names) do if #self.tabs[tab].childs > 0 then %> - <%- if not self.selected_tab then self.selected_tab = tab end %> - <li id="tab.<%=self.config%>.<%=section%>.<%=tab%>" class="cbi-tab<%=(tab == self.selected_tab) and '' or '-disabled'%>"> - <a onclick="this.blur(); return cbi_t_switch('<%=self.config%>.<%=section%>', '<%=tab%>')" href="<%=REQUEST_URI%>?tab.<%=self.config%>.<%=section%>=<%=tab%>"><%=self.tabs[tab].title%></a> - <% if tab == self.selected_tab then %><input type="hidden" id="tab.<%=self.config%>.<%=section%>" name="tab.<%=self.config%>.<%=section%>" value="<%=tab%>" /><% end %> - </li> - <% end end -%> - </ul> -<% end -%> diff --git a/modules/luci-base/luasrc/view/cbi/tblsection.htm b/modules/luci-base/luasrc/view/cbi/tblsection.htm index 408dfa7fe..11c2206d8 100644 --- a/modules/luci-base/luasrc/view/cbi/tblsection.htm +++ b/modules/luci-base/luasrc/view/cbi/tblsection.htm @@ -127,7 +127,7 @@ end section = k local sectionname = striptags((type(self.sectiontitle) == "function") and self:sectiontitle(section) or k) - local sectiontitle = ifattr(sectionname and (not self.anonymous or self.sectiontitle), "data-title", sectionname) + local sectiontitle = ifattr(sectionname and (not self.anonymous or self.sectiontitle), "data-title", sectionname, true) local colorclass = (self.extedit or self.rowcolors) and rowstyle() or "" local scope = { valueheader = "cbi/cell_valueheader", diff --git a/modules/luci-base/luasrc/view/cbi/tsection.htm b/modules/luci-base/luasrc/view/cbi/tsection.htm index 1a13df0c0..8f3b7f0ff 100644 --- a/modules/luci-base/luasrc/view/cbi/tsection.htm +++ b/modules/luci-base/luasrc/view/cbi/tsection.htm @@ -2,6 +2,11 @@ <% if self.title and #self.title > 0 then -%> <legend><%=self.title%></legend> <%- end %> + <% if self.error_msg and #self.error_msg > 0 then -%> + <div class="cbi-section-error"> + <%=self.error_msg%> + </div> + <%- end %> <% if self.description and #self.description > 0 then -%> <div class="cbi-section-descr"><%=self.description%></div> <%- end %> @@ -18,8 +23,6 @@ <h3><%=section:upper()%></h3> <%- end %> - <%+cbi/tabmenu%> - <div class="cbi-section-node<% if self.tabs then %> cbi-section-node-tabbed<% end %>" id="cbi-<%=self.config%>-<%=section%>"> <%+cbi/ucisection%> </div> diff --git a/modules/luci-base/luasrc/view/cbi/value.htm b/modules/luci-base/luasrc/view/cbi/value.htm index 8eec86534..27f3cb2bd 100644 --- a/modules/luci-base/luasrc/view/cbi/value.htm +++ b/modules/luci-base/luasrc/view/cbi/value.htm @@ -21,6 +21,6 @@ ifattr(#self.keylist > 0, "data-choices", { self.keylist, self.vallist }) %> /> <%- if self.password then -%> - <div class="cbi-button cbi-button-neutral" title="<%:Reveal/hide password%>" onclick="var e = this.previousElementSibling; e.type = (e.type === 'password') ? 'text' : 'password'">∗</div> + <button class="cbi-button cbi-button-neutral" title="<%:Reveal/hide password%>" aria-label="<%:Reveal/hide password%>" onclick="var e = this.previousElementSibling; e.type = (e.type === 'password') ? 'text' : 'password'; event.preventDefault()">∗</button> <% end %> <%+cbi/valuefooter%> diff --git a/modules/luci-base/luasrc/view/cbi/wireless_modefreq.htm b/modules/luci-base/luasrc/view/cbi/wireless_modefreq.htm index ebb02e489..eeb1d5c5c 100644 --- a/modules/luci-base/luasrc/view/cbi/wireless_modefreq.htm +++ b/modules/luci-base/luasrc/view/cbi/wireless_modefreq.htm @@ -4,6 +4,7 @@ var freqlist = <%= luci.http.write_json(self.iwinfo.freqlist) %>; var hwmodes = <%= luci.http.write_json(self.iwinfo.hwmodelist or {}) %>; var htmodes = <%= luci.http.write_json(self.iwinfo.htmodelist) %>; + var acs = <%= luci.http.write_json(self.hostapd_acs or 0) %>; var channels = { '11g': [ @@ -14,6 +15,10 @@ ] }; + if (acs < 1) { + channels[(freqlist[freqlist.length - 1].mhz > 2484) ? '11a' : '11g'].length = 0; + } + for (var i = 0; i < freqlist.length; i++) channels[(freqlist[i].mhz > 2484) ? '11a' : '11g'].push( freqlist[i].channel, diff --git a/modules/luci-base/luasrc/view/header.htm b/modules/luci-base/luasrc/view/header.htm index f6e20c9a4..d68e39f91 100644 --- a/modules/luci-base/luasrc/view/header.htm +++ b/modules/luci-base/luasrc/view/header.htm @@ -10,3 +10,15 @@ luci.dispatcher.context.template_header_sent = true end %> + +<script type="text/javascript" src="<%=resource%>/luci.js"></script> +<script type="text/javascript"> + L = new LuCI(<%= luci.http.write_json({ + token = token, + resource = resource, + scriptname = luci.http.getenv("SCRIPT_NAME"), + pathinfo = luci.http.getenv("PATH_INFO"), + requestpath = luci.dispatcher.context.requestpath, + pollinterval = luci.config.main.pollinterval or 5 + }) %>); +</script> diff --git a/modules/luci-base/luasrc/view/lease_status.htm b/modules/luci-base/luasrc/view/lease_status.htm index 658bcfc1b..bbaf5986b 100644 --- a/modules/luci-base/luasrc/view/lease_status.htm +++ b/modules/luci-base/luasrc/view/lease_status.htm @@ -1,5 +1,5 @@ <script type="text/javascript">//<![CDATA[ - XHR.poll(5, '<%=url('admin/dhcplease_status')%>', null, + XHR.poll(-1, '<%=url('admin/dhcplease_status')%>', null, function(x, st) { var tb = document.getElementById('lease_status_table'); diff --git a/modules/luci-base/luasrc/view/wifi_assoclist.htm b/modules/luci-base/luasrc/view/wifi_assoclist.htm index 700d998ad..f6f66fbbc 100644 --- a/modules/luci-base/luasrc/view/wifi_assoclist.htm +++ b/modules/luci-base/luasrc/view/wifi_assoclist.htm @@ -1,4 +1,21 @@ +<% + local supports_deauth = {} + + local _, v + for _, v in ipairs(luci.util.ubus()) do + local iface = v:match("^hostapd%.(.+)$") + if iface then + local funcs = luci.util.ubus(v) + if type(funcs) == "table" and funcs.del_client then + supports_deauth[iface] = true + end + end + end +%> + <script type="text/javascript">//<![CDATA[ + var supports_deauth = <%= luci.http.write_json(supports_deauth) %>; + function wifirate(bss, rx) { var p = rx ? 'rx_' : 'tx_', s = '%.1f <%:Mbit/s%>, %d<%:MHz%>' @@ -17,7 +34,17 @@ return s; } - XHR.poll(5, '<%=url('admin/wireless_assoclist')%>', null, + function handleDeauth(ev) { + (new XHR()).post('<%=url('admin/wireless_deauth')%>', { + token: '<%=token%>', + iface: ev.target.getAttribute('data-iface'), + bssid: ev.target.getAttribute('data-bssid') + }, function() { + ev.target.disabled = true; + }); + } + + XHR.poll(-1, '<%=url('admin/wireless_assoclist')%>', null, function(x, st) { var tb = document.getElementById('wifi_assoclist_table'); @@ -58,7 +85,15 @@ E('span', wifirate(bss, true)), E('br'), E('span', wifirate(bss, false)) - ]) + ]), + supports_deauth[bss.ifname] ? E('input', { + type: 'button', + class: 'cbi-button cbi-button-remove', + value: '<%:Disconnect%>', + 'data-bssid': bss.bssid, + 'data-iface': bss.ifname, + click: handleDeauth + }) : '-' ]); }); @@ -75,6 +110,9 @@ <div class="th nowrap"><%:Host%></div> <div class="th nowrap"><%:Signal%> / <%:Noise%></div> <div class="th nowrap"><%:RX Rate%> / <%:TX Rate%></div> + <% if next(supports_deauth) then %> + <div class="th right"><%:Disconnect%></div> + <% end %> </div> <div class="tr placeholder"> <div class="td"><em><%:Collecting data...%></em></div> |