Gprs.js 1.96 KB
Ext.define('App.controller.Gprs', {
    extend : 'Ext.app.Controller',
    
    init : function() {
 
    	this.control({
    		'toolbar  button[action=saveGprs]' : {
                click : this.saveGprs
            },
            
            'toolbar  button[action=loadGprs]' : {
                click : this.loadGprs
            }
            
        });
    
   
    	this.loadGprs();
    },
    
    
    saveGprs:function() {
    	
    	var selected=Ext.getCmp('internetGprs').getValue();
    	
    	var data=Ext.util.JSON.encode(selected);
          
          Ext.Ajax.request({
        	  method: "POST",
              url: 'api/gsm/update',
              headers: {
                  'Accept': 'application/json',
                  'Content-Type': 'application/json'
              },
              params: data,
              success: function(response, opts) {
             	 
            	  var result = Ext.JSON.decode(response.responseText);
        
             	 Ext.Msg.alert(result.type+" "+"Код-"+result.code,result.message);
             	 
              }, failure: function(response, opts) {
             	  Ext.Msg.alert('Ошибка', 'Сервер недоступен');
              }
         });
    	
    	
    },
    
    loadGprs:function() {
    	
    	
    	
    	 Ext.Ajax.request({
        	  method: "GET",
              url: 'api/gsm',
              headers: {
                  'Accept': 'application/json',
                  'Content-Type': 'application/json'
              },
         
              success: function(response, opts) {
             	 
             	var result = Ext.JSON.decode(response.responseText);
             	
             	 Ext.getCmp('internetGprs').setValue(result);
               	 
                 }, failure: function(response, opts) {
                	  Ext.Msg.alert('Ошибка', 'Сервер недоступен');
                 }
         });
    	
    	
    	
    }
    
   
    
    });