| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  | <div class="row"> | 
					
						
							|  |  |  |     <div class="col-sm-12"> | 
					
						
							|  |  |  |         <span id="message"></span> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  | </div> | 
					
						
							| 
									
										
										
										
											2015-03-30 01:05:57 +01:00
										 |  |  | <div class="table-responsive"> | 
					
						
							|  |  |  |     <table id="alerts" class="table table-hover table-condensed alerts"> | 
					
						
							|  |  |  |         <thead> | 
					
						
							|  |  |  |             <tr> | 
					
						
							| 
									
										
										
										
											2015-03-31 18:47:10 +01:00
										 |  |  |                 <th data-column-id="status" data-formatter="status" data-sortable="false">Status</th> | 
					
						
							| 
									
										
										
										
											2015-03-30 01:05:57 +01:00
										 |  |  |                 <th data-column-id="rule">Rule</th> | 
					
						
							| 
									
										
										
										
											2015-04-23 15:07:55 +00:00
										 |  |  |                 <th data-column-id="details" data-sortable="false"> </th> | 
					
						
							| 
									
										
										
										
											2015-03-30 01:05:57 +01:00
										 |  |  |                 <th data-column-id="hostname">Hostname</th> | 
					
						
							|  |  |  |                 <th data-column-id="timestamp">Timestamp</th> | 
					
						
							|  |  |  |                 <th data-column-id="severity">Severity</th> | 
					
						
							|  |  |  |                 <th data-column-id="ack" data-formatter="ack" data-sortable="false">Acknowledge</th> | 
					
						
							|  |  |  |             </tr> | 
					
						
							|  |  |  |         </thead> | 
					
						
							|  |  |  |     </table> | 
					
						
							|  |  |  | </div> | 
					
						
							|  |  |  | <script> | 
					
						
							|  |  |  | var grid = $("#alerts").bootgrid({ | 
					
						
							|  |  |  |     ajax: true, | 
					
						
							|  |  |  |     post: function () | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return { | 
					
						
							|  |  |  |             id: "alerts", | 
					
						
							| 
									
										
										
										
											2015-04-23 15:07:55 +00:00
										 |  |  |             device_id: '<?php echo $device['device_id']; ?>' | 
					
						
							| 
									
										
										
										
											2015-03-30 01:05:57 +01:00
										 |  |  |         }; | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     url: "/ajax_table.php", | 
					
						
							|  |  |  |     formatters: { | 
					
						
							| 
									
										
										
										
											2015-03-31 18:47:10 +01:00
										 |  |  |         "status": function(column,row) { | 
					
						
							| 
									
										
										
										
											2015-04-29 01:31:52 +01:00
										 |  |  |             return "<h4><span class='label label-"+row.extra+" threeqtr-width'>" + row.msg + "</span></h4>"; | 
					
						
							| 
									
										
										
										
											2015-03-31 18:47:10 +01:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2015-03-30 01:05:57 +01:00
										 |  |  |         "ack": function(column,row) { | 
					
						
							|  |  |  |             return "<button type='button' class='btn btn-"+row.ack_col+" btn-sm command-ack-alert' data-target='#ack-alert' data-state='"+row.state+"' data-alert_id='"+row.alert_id+"' name='ack-alert' id='ack-alert' data-extra='"+row.extra+"'><span class='glyphicon glyphicon-"+row.ack_ico+"'aria-hidden='true'></span></button>"; | 
					
						
							| 
									
										
										
										
											2015-01-26 22:07:42 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-04-19 23:19:13 +01:00
										 |  |  |     }, | 
					
						
							|  |  |  |     templates: { | 
					
						
							| 
									
										
										
										
											2015-03-30 01:05:57 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | }).on("loaded.rs.jquery.bootgrid", function() { | 
					
						
							| 
									
										
										
										
											2015-04-23 16:36:42 +00:00
										 |  |  |     grid.find(".incident-toggle").each( function() { | 
					
						
							|  |  |  |       $(this).parent().addClass('incident-toggle-td'); | 
					
						
							|  |  |  |     }).on("click", function(e) { | 
					
						
							|  |  |  |       var target = $(this).data("target"); | 
					
						
							|  |  |  |       $(target).collapse('toggle'); | 
					
						
							|  |  |  |       $(this).toggleClass('glyphicon-plus glyphicon-minus'); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2015-04-23 15:07:55 +00:00
										 |  |  |     grid.find(".incident").each( function() { | 
					
						
							| 
									
										
										
										
											2015-05-14 20:05:47 +01:00
										 |  |  |       $(this).parent().addClass('col-lg-4 col-md-4 col-sm-4 col-xs-4'); | 
					
						
							| 
									
										
										
										
											2015-04-23 15:07:55 +00:00
										 |  |  |       $(this).parent().parent().on("mouseenter", function() { | 
					
						
							|  |  |  |         $(this).find(".incident-toggle").fadeIn(200); | 
					
						
							|  |  |  |       }).on("mouseleave", function() { | 
					
						
							|  |  |  |         $(this).find(".incident-toggle").fadeOut(200); | 
					
						
							| 
									
										
										
										
											2015-04-23 16:36:42 +00:00
										 |  |  |       }).on("click", "td:not(.incident-toggle-td)", function() { | 
					
						
							|  |  |  |         var target = $(this).parent().find(".incident-toggle").data("target"); | 
					
						
							|  |  |  |         if( $(this).parent().find(".incident-toggle").hasClass('glyphicon-plus') ) { | 
					
						
							|  |  |  |           $(this).parent().find(".incident-toggle").toggleClass('glyphicon-plus glyphicon-minus'); | 
					
						
							|  |  |  |           $(target).collapse('toggle'); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-04-23 15:07:55 +00:00
										 |  |  |       }); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2015-03-30 01:05:57 +01:00
										 |  |  |     grid.find(".command-ack-alert").on("click", function(e) { | 
					
						
							|  |  |  |         e.preventDefault(); | 
					
						
							|  |  |  |         var alert_id = $(this).data("alert_id"); | 
					
						
							|  |  |  |         var state = $(this).data("state"); | 
					
						
							|  |  |  |         $.ajax({ | 
					
						
							|  |  |  |             type: "POST", | 
					
						
							|  |  |  |             url: "/ajax_form.php", | 
					
						
							|  |  |  |             data: { type: "ack-alert", alert_id: alert_id, state: state }, | 
					
						
							|  |  |  |             success: function(msg){ | 
					
						
							|  |  |  |                 $("#message").html('<div class="alert alert-info">'+msg+'</div>'); | 
					
						
							|  |  |  |                 if(msg.indexOf("ERROR:") <= -1) { | 
					
						
							|  |  |  |                     location.reload(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             error: function(){ | 
					
						
							|  |  |  |                  $("#message").html('<div class="alert alert-info">An error occurred acking this alert.</div>'); | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2015-03-30 01:05:57 +01:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | </script> |