1 <%doc>Copyright (C) 2009-2010 HDE, Inc.</%doc>
2 <%inherit file="../include/common.part" />
3 <script type="text/javascript">
6 function firewall_read_event(){
7 $("#init_firewall").one("click", function(){
8 ajax_put("${ctx.homepath}/host/${host_id}/firewall/status.part",
9 {"status" : FIREWALL_READ},
10 function(data, status){},
12 "${ctx.homepath}${ctx.path}"
17 function firewall_start_event(){
18 $("#start_firewall").one("click", function(){
19 ajax_put("${ctx.homepath}/host/${host_id}/firewall/status.part",
20 {"status" : FIREWALL_STAR},
21 function(data, status){},
23 "${ctx.homepath}${ctx.path}"
28 function firewall_stop_event(){
29 $("#stop_firewall").one("click", function(){
30 ajax_put("${ctx.homepath}/host/${host_id}/firewall/status.part",
31 {"status" : FIREWALL_STOP},
32 function(data, status){},
34 "${ctx.homepath}${ctx.path}"
39 function firewall_restart_event(){
40 $("#esc_firewall").one("click", function(){
41 ajax_put("${ctx.homepath}/host/${host_id}/firewall/status.part",
42 {"status" : FIREWALL_RESTART},
43 function(data, status){},
45 "${ctx.homepath}${ctx.path}"
50 function get_target_id(){
52 $("#firewall_tab td").each(function(){
53 if($(this).hasClass("firewall_active") == true){
54 target_id = $(this).attr("id");
60 function bind_add_event(){
61 $("#add_firewall").one("click.once", function() {
63 "${ctx.homepath}${ctx.path}?mode=input",
65 "${ctx.homepath}${ctx.path}");
69 function bind_edit_event(){
70 $("#edit_firewall").one("click.once", function(){
71 var target_id = get_target_id();
72 var val = target_id.split("_");
75 if(val[0] == "policy"){
76 edit_url = "${ctx.homepath}/host/${host_id}/firewall/policy.part?mode=input";
77 } else if(val[0] == "rule"){
78 target_id = selected_row("rule_row");
79 edit_url = "${ctx.homepath}/host/${host_id}/firewall/rule/" + target_id + ".part?mode=input";
81 show_alert_msg("${_('Please select a target.')}", "ERROR");
86 "${_('Firewall Settings')}",
87 "${ctx.homepath}/host/${host_id}/firewall.part");
90 function bind_delete_event(){
91 $("#delete_firewall").click(function(){
92 var target_id = get_target_id();
93 var val = target_id.split("_");
94 var delete_url = null;
96 target_id = selected_row("rule_row");
97 delete_url = "${ctx.homepath}/host/${host_id}/firewall/rule/" + target_id + ".part";
99 delete_dialog("#firewall_dialog", delete_url, param, "${ctx.homepath}${ctx.path}", "#delete_firewall");
101 show_alert_msg("${_('Please select a target.')}", "ERROR");
106 // binding event it only once on each rule page.
107 function bind_rule_row_event(){
108 $("tr[id^='rule_row']").one("click.once", function(){
111 tool_reset("#edit_firewall");
113 tool_reset("#delete_firewall");
115 $("tr[id^='rule_row']").unbind("click.once");
119 function unbind_event(){
120 $("#add_firewall").unbind("click.once");
121 $("#edit_firewall").unbind("click.once");
122 $("#delete_firewall").unbind("click");
125 $(document).ready(function(){
127 tool_invalid("#delete_firewall");
128 tool_invalid("#edit_firewall");
129 tool_invalid("#add_firewall");
131 $("#action>a").hover(
132 function(){tool_over(this);},
133 function(){tool_over(this);}
134 ).mousedown(function(){
135 var id = $(this).attr("id");
140 $("#firewall_tab td").each(function(){
141 $(this).click(function(){
142 var target = $(this).attr("id");
143 var target_val = target.split("_");
146 switch(target_val[0]){
148 ajax_get("#firewall_value",
149 "${ctx.homepath}/host/${host_id}/firewall/policy.part",
151 tool_reset("#edit_firewall");
153 tool_invalid("#add_firewall");
154 tool_invalid("#delete_firewall");
157 ajax_get("#firewall_value",
158 "${ctx.homepath}/host/${host_id}/firewall/rule.part",
161 tool_invalid("#edit_firewall");
162 tool_invalid("#delete_firewall");
163 tool_reset("#add_firewall");
165 bind_rule_row_event();
166 $('#tablesorter_pager img[name="pager_button"]').click(function(){
167 bind_rule_row_event();
171 show_alert_msg("${_('Received an unexpected value.')}", "ERROR");
174 $("#firewall_tab td").each(function(){
175 if($(this).attr("id") != target){
176 $(this).removeClass("firewall_active");
178 $(this).addClass("firewall_active");
184 firewall_read_event();
185 firewall_start_event();
186 firewall_stop_event();
187 firewall_restart_event();
189 renew_main_event("#tool_renew", "${ctx.homepath}${ctx.path}");
194 <div id="firewall_dialog"></div>
196 <div class="left"></div>
197 % if have_config is True:
199 % if iptables.is_running is not True:
200 <a href="#" name="start_firewall" id="start_firewall" class="tool-link">
201 <div class="tool-mid">
202 <div class="tool-left"></div>
203 <div class="tool-img">
204 <img src="${ctx.homepath}/static/images/tool-start.png" alt="" />
206 <div class="tool-right">
207 <div class="tool-text" >${_('Start')}</div>
212 <a href="#" name="stop_firewall" id="stop_firewall" class="tool-link">
213 <div class="tool-mid">
214 <div class="tool-left"></div>
215 <div class="tool-img">
216 <img src="${ctx.homepath}/static/images/tool-stop.png" alt="" />
218 <div class="tool-right">
219 <div class="tool-text" >${_('Stop')}</div>
223 <a href="#" name="esc_firewall" id="esc_firewall" class="tool-link">
224 <div class="tool-mid">
225 <div class="tool-left"></div>
226 <div class="tool-img">
227 <img src="${ctx.homepath}/static/images/tool-restart.png" alt="" />
229 <div class="tool-right">
230 <div class="tool-text" >${_('Restart')}</div>
235 <a href="#" name="add_firewall" id="add_firewall" class="tool-link">
236 <div class="tool-mid">
237 <div class="tool-left"></div>
238 <div class="tool-img">
239 <img src="${ctx.homepath}/static/images/tool-add.png" alt="" />
241 <div class="tool-right">
242 <div class="tool-text" >${_('Add')}</div>
247 <a href="#" name="edit_firewall" id="edit_firewall" class="tool-link">
248 <div class="tool-mid">
249 <div class="tool-left"></div>
250 <div class="tool-img">
251 <img src="${ctx.homepath}/static/images/tool-edit.png" alt="" />
253 <div class="tool-right">
254 <div class="tool-text" >${_('Edit')}</div>
258 <a href="#" name="delete_firewall" id="delete_firewall" class="tool-link">
259 <div class="tool-mid">
260 <div class="tool-left"></div>
261 <div class="tool-img">
262 <img src="${ctx.homepath}/static/images/tool-trash.png" alt="" />
264 <div class="tool-right">
265 <div class="tool-text" >${_('Delete')}</div>
270 <a href="#" name="init_firewall" id="init_firewall" class="tool-link">
271 <div class="tool-mid">
272 <div class="tool-left"></div>
273 <div class="tool-img">
274 <img src="${ctx.homepath}/static/images/tool-refresh.png" alt="" />
276 <div class="tool-right">
277 <div class="tool-text" >${_('Initialize')}</div>
283 <a href="#" class="tool-link" >
284 <div class="tool-mid">
285 <img src="${ctx.homepath}/static/images/reload.gif" alt="renew" id="tool_renew"/>
290 <br style="clear: both;"/>
291 <div class="space"></div>
292 <br style="clear: both;"/>
293 <div class="alert"></div>
295 <div id="result_message"></div>
296 <table width="100%" cellspacing="1" border="0" style="background-color:#bcbcbc;">
298 <td style="background-color:#E4E4DD; padding:0px; text-align:left;" bgcolor="#FFFFFF" width="10%" valign="top">
299 <table id="firewall_tab" width="100%" cellspacing="0" border="0" style="background-color:#e4e4dd;">
301 <td id="policy_" style="font-size:10px;" align="center">
302 <img src="${ctx.homepath}/static/images/firewall-policy.png" alt=""><br />
303 <span class="status">- Policy -</span>
307 <td id="rule_" style="font-size:10px;" align="center">
308 <img src="${ctx.homepath}/static/images/firewall-rule.png" alt=""><br />
309 <span class="status">- Rule -</span>
314 <td bgcolor="#FFFFFF" valign="top" id="firewall_value" width="90%" style="padding:10px;">
315 ${_('Firewall Settings')}
321 <br style="clear: both;"/>