| 
									
										
										
										
											2015-11-17 05:14:41 -08:00
										 |  |  | function override_config(event, state, tmp_this) { | 
					
						
							|  |  |  |     event.preventDefault(); | 
					
						
							|  |  |  |     var $this = tmp_this; | 
					
						
							|  |  |  |     var attrib = $this.data('attrib'); | 
					
						
							|  |  |  |     var device_id = $this.data('device_id'); | 
					
						
							|  |  |  |     $.ajax({ | 
					
						
							|  |  |  |         type: 'POST', | 
					
						
							|  |  |  |         url: 'ajax_form.php', | 
					
						
							|  |  |  |         data: { type: 'override-config', device_id: device_id, attrib: attrib, state: state }, | 
					
						
							|  |  |  |         dataType: 'json', | 
					
						
							|  |  |  |         success: function(data) { | 
					
						
							|  |  |  |             if (data.status == 'ok') { | 
					
						
							|  |  |  |                 toastr.success(data.message); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else { | 
					
						
							|  |  |  |                 toastr.error(data.message); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         error: function() { | 
					
						
							|  |  |  |             toastr.error('Could not set this override'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-27 11:58:56 +00:00
										 |  |  | var oldH; | 
					
						
							|  |  |  | var oldW; | 
					
						
							| 
									
										
										
										
											2015-10-10 13:49:09 +00:00
										 |  |  | $(document).ready(function() { | 
					
						
							| 
									
										
										
										
											2015-10-12 21:28:31 +00:00
										 |  |  |     // Device override ajax calls
 | 
					
						
							| 
									
										
										
										
											2015-10-10 13:49:09 +00:00
										 |  |  |     $("[name='override_config']").bootstrapSwitch('offColor','danger'); | 
					
						
							|  |  |  |     $('input[name="override_config"]').on('switchChange.bootstrapSwitch',  function(event, state) { | 
					
						
							| 
									
										
										
										
											2015-11-17 05:14:41 -08:00
										 |  |  |         override_config(event,state,$(this)); | 
					
						
							| 
									
										
										
										
											2015-11-17 00:20:06 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Device override for text inputs
 | 
					
						
							|  |  |  |     $(document).on('blur', 'input[name="override_config_text"]', function(event) { | 
					
						
							|  |  |  |         event.preventDefault(); | 
					
						
							|  |  |  |         var $this = $(this); | 
					
						
							|  |  |  |         var attrib = $this.data('attrib'); | 
					
						
							|  |  |  |         var device_id = $this.data('device_id'); | 
					
						
							|  |  |  |         var value = $this.val(); | 
					
						
							|  |  |  |         $.ajax({ | 
					
						
							|  |  |  |             type: 'POST', | 
					
						
							|  |  |  |             url: 'ajax_form.php', | 
					
						
							|  |  |  |             data: { type: 'override-config', device_id: device_id, attrib: attrib, state: value }, | 
					
						
							|  |  |  |             dataType: 'json', | 
					
						
							|  |  |  |             success: function(data) { | 
					
						
							|  |  |  |                 if (data.status == 'ok') { | 
					
						
							|  |  |  |                     toastr.success(data.message); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 else { | 
					
						
							|  |  |  |                     toastr.error(data.message); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             error: function() { | 
					
						
							|  |  |  |                 toastr.error('Could not set this override'); | 
					
						
							| 
									
										
										
										
											2015-10-10 13:49:09 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2015-10-12 21:28:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Checkbox config ajax calls
 | 
					
						
							|  |  |  |     $("[name='global-config-check']").bootstrapSwitch('offColor','danger'); | 
					
						
							|  |  |  |     $('input[name="global-config-check"]').on('switchChange.bootstrapSwitch',  function(event, state) { | 
					
						
							|  |  |  |         event.preventDefault(); | 
					
						
							|  |  |  |         var $this = $(this); | 
					
						
							|  |  |  |         var config_id = $this.data("config_id"); | 
					
						
							|  |  |  |         $.ajax({ | 
					
						
							|  |  |  |             type: 'POST', | 
					
						
							|  |  |  |             url: 'ajax_form.php', | 
					
						
							|  |  |  |             data: {type: "update-config-item", config_id: config_id, config_value: state}, | 
					
						
							|  |  |  |             dataType: "json", | 
					
						
							|  |  |  |             success: function (data) { | 
					
						
							|  |  |  |                 if (data.status == 'ok') { | 
					
						
							|  |  |  |                     toastr.success('Config updated'); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     toastr.error(data.message); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             error: function () { | 
					
						
							|  |  |  |                 toastr.error(data.message); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Input field config ajax calls
 | 
					
						
							|  |  |  |     $(document).on('blur', 'input[name="global-config-input"]', function(event) { | 
					
						
							|  |  |  |         event.preventDefault(); | 
					
						
							|  |  |  |         var $this = $(this); | 
					
						
							|  |  |  |         var config_id = $this.data("config_id"); | 
					
						
							|  |  |  |         var config_value = $this.val(); | 
					
						
							|  |  |  |         $.ajax({ | 
					
						
							|  |  |  |             type: 'POST', | 
					
						
							|  |  |  |             url: 'ajax_form.php', | 
					
						
							|  |  |  |             data: {type: "update-config-item", config_id: config_id, config_value: config_value}, | 
					
						
							|  |  |  |             dataType: "json", | 
					
						
							|  |  |  |             success: function (data) { | 
					
						
							|  |  |  |                 if (data.status == 'ok') { | 
					
						
							|  |  |  |                     toastr.success('Config updated'); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     toastr.error(data.message); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             error: function () { | 
					
						
							|  |  |  |                 toastr.error(data.message); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Select config ajax calls
 | 
					
						
							|  |  |  |     $( 'select[name="global-config-select"]').change(function(event) { | 
					
						
							|  |  |  |         event.preventDefault(); | 
					
						
							|  |  |  |         var $this = $(this); | 
					
						
							|  |  |  |         var config_id = $this.data("config_id"); | 
					
						
							|  |  |  |         var config_value = $this.val(); | 
					
						
							|  |  |  |         $.ajax({ | 
					
						
							|  |  |  |             type: 'POST', | 
					
						
							|  |  |  |             url: 'ajax_form.php', | 
					
						
							|  |  |  |             data: {type: "update-config-item", config_id: config_id, config_value: config_value}, | 
					
						
							|  |  |  |             dataType: "json", | 
					
						
							|  |  |  |             success: function (data) { | 
					
						
							|  |  |  |                 if (data.status == 'ok') { | 
					
						
							|  |  |  |                     toastr.success('Config updated'); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     toastr.error(data.message); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             error: function () { | 
					
						
							|  |  |  |                 toastr.error(data.message); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2015-11-19 09:54:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-27 11:58:56 +00:00
										 |  |  |     oldW=$(window).width(); | 
					
						
							|  |  |  |     oldH=$(window).height(); | 
					
						
							| 
									
										
										
										
											2015-10-10 13:49:09 +00:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-10-20 21:35:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | function submitCustomRange(frmdata) { | 
					
						
							| 
									
										
										
										
											2015-10-26 19:49:30 +00:00
										 |  |  |     var reto = /to=([0-9a-zA-Z\-])+/g; | 
					
						
							|  |  |  |     var refrom = /from=([0-9a-zA-Z\-])+/g; | 
					
						
							| 
									
										
										
										
											2015-10-20 21:35:08 +00:00
										 |  |  |     var tsto = moment(frmdata.dtpickerto.value).unix(); | 
					
						
							|  |  |  |     var tsfrom = moment(frmdata.dtpickerfrom.value).unix(); | 
					
						
							|  |  |  |     frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto); | 
					
						
							|  |  |  |     frmdata.selfaction.value = frmdata.selfaction.value.replace(refrom, 'from=' + tsfrom); | 
					
						
							|  |  |  |     frmdata.action = frmdata.selfaction.value; | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-30 11:10:35 +00:00
										 |  |  | function updateResolution(refresh) | 
					
						
							| 
									
										
										
										
											2015-11-20 12:02:51 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-11-26 12:14:57 +00:00
										 |  |  |     $.post('ajax_setresolution.php',  | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             width: $(window).width(), | 
					
						
							|  |  |  |             height:$(window).height() | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         function(data) { | 
					
						
							| 
									
										
										
										
											2015-11-30 11:10:35 +00:00
										 |  |  |             if(refresh == true) { | 
					
						
							|  |  |  |                 location.reload(); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2015-11-26 12:14:57 +00:00
										 |  |  |         },'json' | 
					
						
							| 
									
										
										
										
											2015-11-20 12:02:51 +00:00
										 |  |  |     ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-26 12:14:57 +00:00
										 |  |  | var rtime; | 
					
						
							|  |  |  | var timeout = false; | 
					
						
							| 
									
										
										
										
											2015-11-27 11:58:56 +00:00
										 |  |  | var delta = 500; | 
					
						
							| 
									
										
										
										
											2015-11-30 11:10:35 +00:00
										 |  |  | var newH; | 
					
						
							|  |  |  | var newW; | 
					
						
							| 
									
										
										
										
											2015-11-26 12:14:57 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | $(window).on('resize', function(){ | 
					
						
							|  |  |  |     rtime = new Date(); | 
					
						
							|  |  |  |     if (timeout === false) { | 
					
						
							|  |  |  |         timeout = true; | 
					
						
							|  |  |  |         setTimeout(resizeend, delta); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function resizeend() { | 
					
						
							|  |  |  |     if (new Date() - rtime < delta) { | 
					
						
							|  |  |  |         setTimeout(resizeend, delta); | 
					
						
							| 
									
										
										
										
											2015-11-26 17:41:41 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  |     else { | 
					
						
							| 
									
										
										
										
											2015-11-30 11:10:35 +00:00
										 |  |  |         newH=$(window).height(); | 
					
						
							|  |  |  |         newW=$(window).width(); | 
					
						
							| 
									
										
										
										
											2015-11-26 12:14:57 +00:00
										 |  |  |         timeout = false; | 
					
						
							| 
									
										
										
										
											2015-11-30 11:10:35 +00:00
										 |  |  |         if(Math.abs(oldW - newW) >= 200) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             refresh = true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             refresh = false; | 
					
						
							|  |  |  |             resizeGraphs(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         updateResolution(refresh); | 
					
						
							| 
									
										
										
										
											2015-11-26 12:14:57 +00:00
										 |  |  |     }   | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2015-11-20 12:02:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-27 11:58:56 +00:00
										 |  |  | function resizeGraphs() { | 
					
						
							|  |  |  |     ratioW=newW/oldW; | 
					
						
							|  |  |  |     ratioH=newH/oldH; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $('.graphs').each(function (){ | 
					
						
							|  |  |  |         var img = jQuery(this); | 
					
						
							|  |  |  |         img.attr('width',img.width() * ratioW); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |     oldH=newH; | 
					
						
							|  |  |  |     oldW=newW; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-19 09:54:26 +00:00
										 |  |  | $(document).on("click", '.collapse-neighbors', function(event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     var caller = $(this); | 
					
						
							|  |  |  |     var button = caller.find('.neighbors-button'); | 
					
						
							|  |  |  |     var list = caller.find('.neighbors-interface-list'); | 
					
						
							|  |  |  |     var continued = caller.find('.neighbors-list-continued'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-20 12:02:51 +00:00
										 |  |  |     if(button.hasClass("glyphicon-plus")) { | 
					
						
							| 
									
										
										
										
											2015-11-19 12:01:10 +00:00
										 |  |  |         button.addClass('glyphicon-minus').removeClass('glyphicon-plus'); | 
					
						
							| 
									
										
										
										
											2015-11-20 14:47:59 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							| 
									
										
										
										
											2015-11-19 12:01:10 +00:00
										 |  |  |         button.addClass('glyphicon-plus').removeClass('glyphicon-minus'); | 
					
						
							| 
									
										
										
										
											2015-11-19 09:54:26 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     | 
					
						
							|  |  |  |     list.toggle(); | 
					
						
							|  |  |  |     continued.toggle(); | 
					
						
							|  |  |  | }); |