applications/luci-firewall: fix wrong location of cbi templates
[project/luci.git] / applications / luci-firewall / luasrc / view / firewall / cbi_addrule.htm
1 <%
2 local fw = require "luci.model.firewall".init()
3 local wz = fw:get_zone("wan")
4 local lz = fw:get_zone("lan")
5 %>
6
7 <div class="cbi-section-create cbi-tblsection-create">
8 <% if wz and lz then %>
9 <br />
10 <table class="cbi-section-table" style="margin-left:5px">
11 <tr class="cbi-section-table-titles">
12 <th class="cbi-section-table-cell left" colspan="4"><%:Open ports on router%>:</th>
13 </tr>
14 <tr class="cbi-section-table-descr">
15 <th class="cbi-section-table-cell"><%:Name%></th>
16 <th class="cbi-section-table-cell"><%:Protocol%></th>
17 <th class="cbi-section-table-cell"><%:External port%></th>
18 <th class="cbi-section-table-cell"></th>
19 </tr>
20 <tr class="cbi-section-table-row">
21 <td class="cbi-section-table-cell" style="width:130px">
22 <input type="text" class="cbi-input-text" id="_newopen.name" name="_newopen.name" placeholder="<%:New input rule%>" />
23 </td>
24 <td class="cbi-section-table-cell" style="width:110px">
25 <select class="cbi-input-select" id="_newopen.proto" name="_newopen.proto">
26 <option value="tcp udp">TCP+UDP</option>
27 <option value="tcp">TCP</option>
28 <option value="udp">UDP</option>
29 <option value="other"><%:Other...%></option>
30 </select>
31 </td>
32 <td class="cbi-section-table-cell" style="width:110px">
33 <input type="text" class="cbi-input-text" id="_newopen.extport" name="_newopen.extport" />
34 </td>
35 <td class="cbi-section-table-cell left">
36 <input type="submit" class="cbi-button cbi-button-add" name="_newopen.submit" value="<%:Add%>" />
37 </td>
38 </tr>
39 </table>
40
41 <table class="cbi-section-table" style="margin-left:5px">
42 <tr class="cbi-section-table-titles">
43 <th class="cbi-section-table-cell left" colspan="6"><br /><%:New forward rule%>:</th>
44 </tr>
45 <tr class="cbi-section-table-descr">
46 <th class="cbi-section-table-cell"><%:Name%></th>
47 <th class="cbi-section-table-cell"><%:Source zone%></th>
48 <th class="cbi-section-table-cell"><%:Destination zone%></th>
49 <th class="cbi-section-table-cell"></th>
50 </tr>
51 <tr class="cbi-section-table-row">
52 <td class="cbi-section-table-cell" style="width:130px">
53 <input type="text" class="cbi-input-text" id="_newfwd.name" name="_newfwd.name" placeholder="<%:New forward rule%>" />
54 </td>
55 <td class="cbi-section-table-cell" style="width:110px">
56 <select class="cbi-input-text" id="_newfwd.src" name="_newfwd.src">
57 <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
58 <option<%=ifattr(v:name() == "lan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
59 <%- end %>
60 </select>
61 </td>
62 <td class="cbi-section-table-cell" style="width:110px">
63 <select class="cbi-input-text" id="_newfwd.dest" name="_newfwd.dest">
64 <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
65 <option<%=ifattr(v:name() == "wan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
66 <%- end %>
67 </select>
68 </td>
69 <td class="cbi-section-table-cell left">
70 <input type="submit" class="cbi-button cbi-button-link" name="_newfwd.submit" value="<%:Add and edit...%>" />
71 </td>
72 </tr>
73 </table>
74
75 <script type="text/javascript">//<![CDATA[
76 cbi_validate_field('_newopen.extport', true, 'list(portrange)');
77 cbi_bind(document.getElementById('_newopen.extport'), 'blur',
78 function() {
79 var n = document.getElementById('_newopen.name');
80 var p = document.getElementById('_newopen.proto');
81 var hints = {
82 /* port name 0=both, 1=tcp, 2=udp, 3=other */
83 22: [ 'SSH', 1 ],
84 53: [ 'DNS', 0 ],
85 80: [ 'HTTP', 1 ],
86 443: [ 'HTTPS', 1 ],
87 };
88
89 if (!this.className.match(/invalid/))
90 {
91 var hint = hints[this.value || 0];
92 if (hint)
93 {
94 p.selectedIndex = hint[1];
95
96 if (!n.value)
97 n.value = hint[0];
98 }
99 else if (!n.value && this.value)
100 {
101 n.value = 'Open' + this.value;
102 }
103 }
104 });
105
106
107 cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>', true, 'uciname');
108 //]]></script>
109 <% else %>
110 <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
111 <% end %>
112 </div>