luci/applications/luci-app-firewall/luasrc/view/firewall/cbi_addrule.htm
Jo-Philipp Wich 067d7dc9f7 treewide: convert HTML tables to div
Mostly convert HTML tables to div based markup to allow for easier styling
in the future. Also change JS accessor code accordingly.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-28 15:18:45 +02:00

116 lines
4.4 KiB
HTML

<%
local fw = require "luci.model.firewall".init()
local wz = fw:get_zone("wan")
local lz = fw:get_zone("lan")
local zones = fw:get_zones()
%>
<div class="cbi-section-create cbi-tblsection-create">
<% if wz then %>
<br />
<div class="table cbi-section-table" style="margin-left:5px">
<div class="tr cbi-section-table-titles">
<div class="th cbi-section-table-cell left" colspan="4"><%:Open ports on router%>:</div>
</div>
<div class="tr cbi-section-table-descr">
<div class="th cbi-section-table-cell"><%:Name%></div>
<div class="th cbi-section-table-cell"><%:Protocol%></div>
<div class="th cbi-section-table-cell"><%:External port%></div>
<div class="th cbi-section-table-cell"></div>
</div>
<div class="tr cbi-section-table-row">
<div class="td cbi-section-table-cell" style="width:130px">
<input type="text" class="cbi-input-text" id="_newopen.name" name="_newopen.name" placeholder="<%:New input rule%>" />
</div>
<div class="td cbi-section-table-cell" style="width:110px">
<select class="cbi-input-select" id="_newopen.proto" name="_newopen.proto">
<option value="tcp udp">TCP+UDP</option>
<option value="tcp">TCP</option>
<option value="udp">UDP</option>
<option value="other"><%:Other...%></option>
</select>
</div>
<div class="td cbi-section-table-cell" style="width:110px">
<input type="text" class="cbi-input-text" id="_newopen.extport" name="_newopen.extport" />
</div>
<div class="td cbi-section-table-cell left">
<input type="submit" class="cbi-button cbi-button-add" name="_newopen.submit" value="<%:Add%>" />
</div>
</div>
</div>
<% end %>
<% if #zones > 1 then %>
<div class="table cbi-section-table" style="margin-left:5px">
<div class="tr cbi-section-table-titles">
<div class="th cbi-section-table-cell left" colspan="6"><br /><%:New forward rule%>:</div>
</div>
<div class="tr cbi-section-table-descr">
<div class="th cbi-section-table-cell"><%:Name%></div>
<div class="th cbi-section-table-cell"><%:Source zone%></div>
<div class="th cbi-section-table-cell"><%:Destination zone%></div>
<div class="th cbi-section-table-cell"></div>
</div>
<div class="tr cbi-section-table-row">
<div class="td cbi-section-table-cell" style="width:130px">
<input type="text" class="cbi-input-text" id="_newfwd.name" name="_newfwd.name" placeholder="<%:New forward rule%>" />
</div>
<div class="td cbi-section-table-cell" style="width:110px">
<select class="cbi-input-text" id="_newfwd.src" name="_newfwd.src">
<% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
<option<%=ifattr(v:name() == "wan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
<%- end %>
</select>
</div>
<div class="td cbi-section-table-cell" style="width:110px">
<select class="cbi-input-text" id="_newfwd.dest" name="_newfwd.dest">
<% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
<option<%=ifattr(v:name() == "lan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
<%- end %>
</select>
</div>
<div class="td cbi-section-table-cell left">
<input type="submit" class="cbi-button cbi-button-link" name="_newfwd.submit" value="<%:Add and edit...%>" />
</div>
</div>
</div>
<% else %>
<input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
<% end %>
<% if wz then %>
<script type="text/javascript">//<![CDATA[
cbi_validate_field('_newopen.extport', true, 'list(neg(portrange))');
cbi_bind(document.getElementById('_newopen.extport'), 'blur',
function() {
var n = document.getElementById('_newopen.name');
var p = document.getElementById('_newopen.proto');
var hints = {
/* port name 0=both, 1=tcp, 2=udp, 3=other */
22: [ 'SSH', 1 ],
53: [ 'DNS', 0 ],
80: [ 'HTTP', 1 ],
443: [ 'HTTPS', 1 ],
};
if (!this.className.match(/invalid/))
{
var hint = hints[this.value || 0];
if (hint)
{
p.selectedIndex = hint[1];
if (!n.value)
n.value = hint[0];
}
else if (!n.value && this.value)
{
n.value = 'Open' + this.value;
}
}
});
cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>', true, 'uciname');
//]]></script>
<% end %>
</div>