PingUtil.js 1.69 KB
Ext.define('App.controller.PingUtil', {
    extend : 'Ext.app.Controller',
    
    init : function() {
 
    	this.control({
    		 '#btnping': {
                 click: this.startPing 
                    
             }
        });
    },
   startPing :function (btn, e, options) {
	   
	   
	 
	   var form = Ext.getCmp('winPing');
	   
	   if (form!=null) {
	   
		   
	   
		   var ipValue=Ext.getCmp('ipaddress').getValue();
		   form.mask("Выполнение ...");
		  
        if (ipValue!="") {
            
            var data=Ext.util.JSON.encode(ipValue);
           
          
            
            Ext.Ajax.request({
          	  method: "POST",
                url: 'api/utils/ping',
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json'
                },
                params: data,
                success: function(response, opts) {
               	
               	var result = Ext.JSON.decode(response.responseText);
               	 
               	var str="";
               	for(var i in result){
               		 
               		 str=str+result[i]+"\n";
               	 } 
               	 
               //	 console.log(str);
               	 
               	 Ext.getCmp('pingResult').setValue(str);
               	 
               	 form.unmask();
               	 
               	 
                }, failure: function(response, opts) {
               	  Ext.Msg.alert('Ошибка', 'Ошибка досупа к серверу');
                }
           });
        }else {
        	//Ext.Msg.alert('Ошибка', 'Введите ');
        	
        }
    
           
	   
		  
	   }
    }
});