luci-app-mtk: add confirm() for add/remove/disable/reload vifs

This commit is contained in:
hanwckf 2023-08-27 23:27:05 +08:00
parent 01b62ef21d
commit 04296f30f5
2 changed files with 61 additions and 16 deletions

View File

@ -63,7 +63,8 @@ local chipname
</td> </td>
<td style="width:310px;text-align:right"> <td style="width:310px;text-align:right">
<div id="ActionBtns_<%=string.split(dev.devname,".")[1]%>"> <div id="ActionBtns_<%=string.split(dev.devname,".")[1]%>">
<button class="cbi-button cbi-button-edit" onclick="visit_url('<%=string.split(dev.devname,".")[1]%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "chip_cfg_view", dev.devname)%>')"><%:CONFIG%></button> <button class="cbi-button cbi-button-edit" onclick="visit_url('<%=string.split(dev.devname,".")[1]%>',
'<%=luci.dispatcher.build_url("admin", "network", "wifi", "chip_cfg_view", dev.devname)%>')"><%:CONFIG%></button>
</div> </div>
<div id="BusyText_<%=string.split(dev.devname,".")[1]%>" style="display:none"> <div id="BusyText_<%=string.split(dev.devname,".")[1]%>" style="display:none">
<big><strong><%:Processing request.%></strong></big> <big><strong><%:Processing request.%></strong></big>
@ -87,10 +88,13 @@ local chipname
<td style="width:310px;text-align:right"> <td style="width:310px;text-align:right">
<div id="ActionBtns_<%=dev.devname%>"> <div id="ActionBtns_<%=dev.devname%>">
<%if not dev.vifs then%> <%if not dev.vifs then%>
<button class="cbi-button cbi-button-apply" id="reset" onclick="visit_url('<%=dev.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "reset_to_defaults", dev.devname)%>')"><%:Restore Profile to Factory Settings%></button> <button class="cbi-button cbi-button-apply" id="reset" onclick="visit_url('<%=dev.devname%>',
'<%=luci.dispatcher.build_url("admin", "network", "wifi", "reset_to_defaults", dev.devname)%>')"><%:Restore Profile to Factory Settings%></button>
<%else%> <%else%>
<button class="cbi-button cbi-button-reset" onclick="visit_url('<%=dev.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "reload", dev.devname)%>')"><%:RELOAD%></button> <button class="cbi-button cbi-button-reset" onclick="visit_url_confirm('<%:Are you sure to RELOAD%> <%=dev.devname%>?',
<button class="cbi-button cbi-button-edit" onclick="visit_url('<%=dev.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "dev_cfg_view", dev.devname)%>')"><%:CONFIG%></button> '<%=dev.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "reload", dev.devname)%>')"><%:RELOAD%></button>
<button class="cbi-button cbi-button-edit" onclick="visit_url('<%=dev.devname%>',
'<%=luci.dispatcher.build_url("admin", "network", "wifi", "dev_cfg_view", dev.devname)%>')"><%:CONFIG%></button>
<button class="cbi-button cbi-button-add" onclick='add_vif("<%=dev.devname%>","<%=dev.vifs.__prefix%>","<%=dev.maxVif%>")'><%:ADD%></button> <button class="cbi-button cbi-button-add" onclick='add_vif("<%=dev.devname%>","<%=dev.vifs.__prefix%>","<%=dev.maxVif%>")'><%:ADD%></button>
<%end%> <%end%>
</div> </div>
@ -136,12 +140,16 @@ local chipname
<% if not vif.state then %> <% if not vif.state then %>
<button class="cbi-button cbi-button-apply" onclick="alert('Please click on Reload button of ' + '<%=dev.devname%>' + ' device to enable this interface.')"><%:ENABLE%></button> <button class="cbi-button cbi-button-apply" onclick="alert('Please click on Reload button of ' + '<%=dev.devname%>' + ' device to enable this interface.')"><%:ENABLE%></button>
<% elseif vif.state == "up" then %> <% elseif vif.state == "up" then %>
<button class="cbi-button cbi-button-reset" onclick="visit_url('<%=vif.vifname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_disable", vif.vifname)%>')"><%:DISABLE%></button> <button class="cbi-button cbi-button-reset" onclick="visit_url_confirm('<%:Are you sure to DISABLE%> <%=vif.vifname%>?',
'<%=vif.vifname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_disable", vif.vifname)%>')"><%:DISABLE%></button>
<% else %> <% else %>
<button class="cbi-button cbi-button-apply" onclick="visit_url('<%=vif.vifname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_enable", vif.vifname)%>')"><%:ENABLE%></button> <button class="cbi-button cbi-button-apply" onclick="visit_url('<%=vif.vifname%>',
'<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_enable", vif.vifname)%>')"><%:ENABLE%></button>
<% end %> <% end %>
<button class="cbi-button cbi-button-edit" onclick="visit_url('<%=vif.vifname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_cfg_view", dev.devname, vif.vifname)%>')"><%:CONFIG%></button> <button class="cbi-button cbi-button-edit" onclick="visit_url('<%=vif.vifname%>',
<button class="cbi-button cbi-button-remove" onclick="visit_url('<%=vif.vifname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_del", dev.devname, vif.vifname)%>')"><%:REMOVE%></button> '<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_cfg_view", dev.devname, vif.vifname)%>')"><%:CONFIG%></button>
<button class="cbi-button cbi-button-remove" onclick="visit_url_confirm('<%:Are you sure to REMOVE%> <%=vif.vifname%>?',
'<%=vif.vifname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_del", dev.devname, vif.vifname)%>')"><%:REMOVE%></button>
</div> </div>
<div id="BusyText_<%=vif.vifname%>" style="display:none"> <div id="BusyText_<%=vif.vifname%>" style="display:none">
<big><strong><%:Processing request.%></strong></big> <big><strong><%:Processing request.%></strong></big>
@ -176,16 +184,24 @@ local chipname
<div id="ActionBtns_<%=dev.apcli.devname%>"> <div id="ActionBtns_<%=dev.apcli.devname%>">
<% if dev.ApCliEnable ~= "1" then %> <% if dev.ApCliEnable ~= "1" then %>
<% if dev.apcli.state == "up" then %> <% if dev.apcli.state == "up" then %>
<button class="cbi-button cbi-button-reset" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_disable", dev.apcli.vifname)%>')"><%:DISABLE%></button> <button class="cbi-button cbi-button-reset" onclick="visit_url_confirm('<%:Are you sure to DISABLE%> <%=dev.apcli.devname%>?',
<button class="cbi-button cbi-button-reload" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_connect", dev.devname, dev.apcli.vifname)%>')"><%:RECONNECT%></button> '<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_disable", dev.apcli.vifname)%>')"><%:DISABLE%></button>
<button class="cbi-button cbi-button-reload" onclick="visit_url_confirm('<%:Are you sure to RECONNECT%> <%=dev.apcli.devname%>?',
'<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_connect", dev.devname, dev.apcli.vifname)%>')"><%:RECONNECT%></button>
<% end %> <% end %>
<button class="cbi-button cbi-button-edit" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_cfg_view", dev.devname, dev.apcli.vifname)%>')"><%:CONFIG%></button> <button class="cbi-button cbi-button-edit" onclick="visit_url('<%=dev.apcli.devname%>',
'<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_cfg_view", dev.devname, dev.apcli.vifname)%>')"><%:CONFIG%></button>
<% else %> <% else %>
<button class="cbi-button cbi-button-reset" style="display:none" id="ApCliDownBtn_<%=dev.apcli.devname%>" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_disable", dev.apcli.vifname)%>')"><%:DISABLE%></button> <button class="cbi-button cbi-button-reset" style="display:none" id="ApCliDownBtn_<%=dev.apcli.devname%>" onclick="visit_url_confirm('<%:Are you sure to DISABLE%> <%=dev.apcli.devname%>?',
<button class="cbi-button cbi-button-apply" style="display:none" id="ApCliUpBtn_<%=dev.apcli.devname%>" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_enable", dev.apcli.vifname)%>')"><%:ENABLE%></button> '<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_disable", dev.apcli.vifname)%>')"><%:DISABLE%></button>
<button class="cbi-button cbi-button-remove" style="display:none" id="ApCliDisConnBtn_<%=dev.apcli.devname%>" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_disconnect", dev.devname, dev.apcli.vifname)%>')"><%:DISCONNECT%></button> <button class="cbi-button cbi-button-apply" style="display:none" id="ApCliUpBtn_<%=dev.apcli.devname%>" onclick="visit_url('<%=dev.apcli.devname%>',
<button class="cbi-button cbi-button-reload" style="display:none" id="ApCliConnBtn_<%=dev.apcli.devname%>" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_connect", dev.devname, dev.apcli.vifname)%>')"><%:RECONNECT%></button> '<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_enable", dev.apcli.vifname)%>')"><%:ENABLE%></button>
<button class="cbi-button cbi-button-edit" style="display:none" id="ApCliCfgBtn_<%=dev.apcli.devname%>" onclick="visit_url('<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_cfg_view", dev.devname, dev.apcli.vifname)%>')"><%:CONFIG%></button> <button class="cbi-button cbi-button-remove" style="display:none" id="ApCliDisConnBtn_<%=dev.apcli.devname%>" onclick="visit_url_confirm('<%:Are you sure to DISCONNECT%> <%=dev.apcli.devname%>?',
'<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_disconnect", dev.devname, dev.apcli.vifname)%>')"><%:DISCONNECT%></button>
<button class="cbi-button cbi-button-reload" style="display:none" id="ApCliConnBtn_<%=dev.apcli.devname%>" onclick="visit_url_confirm('<%:Are you sure to RECONNECT%> <%=dev.apcli.devname%>?',
'<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_connect", dev.devname, dev.apcli.vifname)%>')"><%:RECONNECT%></button>
<button class="cbi-button cbi-button-edit" style="display:none" id="ApCliCfgBtn_<%=dev.apcli.devname%>" onclick="visit_url('<%=dev.apcli.devname%>',
'<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_cfg_view", dev.devname, dev.apcli.vifname)%>')"><%:CONFIG%></button>
<% end %> <% end %>
</div> </div>
<div id="BusyText_<%=dev.apcli.devname%>" style="display:none"> <div id="BusyText_<%=dev.apcli.devname%>" style="display:none">
@ -320,8 +336,16 @@ local chipname
location.href = to; location.href = to;
} }
function visit_url_confirm(msg, idSuffix, to) {
var i = confirm(msg);
if (i)
visit_url(idSuffix,to);
}
function add_vif(devName, vifPrefix, maxVif) function add_vif(devName, vifPrefix, maxVif)
{ {
if (!confirm('<%:Are you sure to ADD wireless interface?%>'))
return;
disable_all_buttons(); disable_all_buttons();
document.getElementById("ActionBtns_"+devName).style.display = "none"; document.getElementById("ActionBtns_"+devName).style.display = "none";
document.getElementById("BusyText_"+devName).style.display = ""; document.getElementById("BusyText_"+devName).style.display = "";

View File

@ -441,3 +441,24 @@ msgstr "IGMP 侦听"
msgid "Security" msgid "Security"
msgstr "安全性" msgstr "安全性"
msgid "Restore Profile to Factory Settings"
msgstr "恢复无线配置文件为出厂设置"
msgid "Are you sure to RELOAD"
msgstr "你确认要重载"
msgid "Are you sure to DISABLE"
msgstr "你确认要禁用"
msgid "Are you sure to REMOVE"
msgstr "你确认要移除"
msgid "Are you sure to RECONNECT"
msgstr "你确认要重新连接"
msgid "Are you sure to DISCONNECT"
msgstr "你确认要断开"
msgid "Are you sure to ADD wireless interface?"
msgstr "你确认要新增无线interface?"