Commit b41ea1a4149098ea59c12006d554b0b83f5f162c
1 parent
bead362d74
Exists in
master
code review
Showing
2 changed files
with
1 additions
and
44 deletions
Show diff stats
src/js/controller.js
| 1 | angular.module('focaGestionTerminal') | 1 | angular.module('focaGestionTerminal') |
| 2 | .controller('gestionTerminalController', | 2 | .controller('gestionTerminalController', |
| 3 | [ | 3 | [ |
| 4 | '$scope', | 4 | '$scope', |
| 5 | 'gestionTerminalService', | 5 | 'gestionTerminalService', |
| 6 | 'netTesting', | 6 | 'netTesting', |
| 7 | function($scope, gestionTerminalesService, netTesting) { | 7 | function($scope, gestionTerminalesService, netTesting) { |
| 8 | $scope.empresa = {}; | 8 | $scope.empresa = {}; |
| 9 | $scope.empresas = []; | 9 | $scope.empresas = []; |
| 10 | 10 | ||
| 11 | gestionTerminalesService.getEmpresas().then(function(res) { | 11 | gestionTerminalesService.getEmpresas().then(function(res) { |
| 12 | 12 | ||
| 13 | $scope.empresas = res.data; | 13 | $scope.empresas = res.data; |
| 14 | }); | 14 | }); |
| 15 | 15 | ||
| 16 | $scope.guardar = function() { | 16 | $scope.guardar = function() { |
| 17 | 17 | ||
| 18 | netTesting.ping($scope.empresa.url, function() { | 18 | netTesting.ping($scope.empresa.url, function() { |
| 19 | 19 | ||
| 20 | if(arguments[1] === 'disconnected') { | 20 | if (arguments[1] === 'disconnected') { |
| 21 | $scope.mensaje = "La url indicada no tiene conección"; | 21 | $scope.mensaje = "La url indicada no tiene conección"; |
| 22 | return; | 22 | return; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | gestionTerminalesService.insertEmpresa( | 25 | gestionTerminalesService.insertEmpresa( |
| 26 | { empresa: $scope.empresa}).then(function() { | 26 | { empresa: $scope.empresa}).then(function() { |
| 27 | 27 | ||
| 28 | $scope.mensaje = "Empresa guardada con éxito"; | 28 | $scope.mensaje = "Empresa guardada con éxito"; |
| 29 | $scope.empresas.push($scope.terminal); | 29 | $scope.empresas.push($scope.terminal); |
| 30 | $scope.empresa = {}; | 30 | $scope.empresa = {}; |
| 31 | $scope.empresaGuardada = true; | 31 | $scope.empresaGuardada = true; |
| 32 | 32 | ||
| 33 | }).catch(function() { | 33 | }).catch(function() { |
| 34 | 34 | ||
| 35 | $scope.mensaje = "Hubo un error al guardar la empresa"; | 35 | $scope.mensaje = "Hubo un error al guardar la empresa"; |
| 36 | }); | 36 | }); |
| 37 | 37 | ||
| 38 | }); | 38 | }); |
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| 41 | }]); | 41 | }]); |
| 42 | 42 |
src/js/service.js
| 1 | angular.module('focaGestionTerminal') | 1 | angular.module('focaGestionTerminal') |
| 2 | .factory('gestionTerminalService', ['endpoint', '$http', function(endpoint, $http) { | 2 | .factory('gestionTerminalService', ['endpoint', '$http', function(endpoint, $http) { |
| 3 | return { | 3 | return { |
| 4 | getTerminalSet: function() { | ||
| 5 | return [ | ||
| 6 | { | ||
| 7 | terminalKey: 'fa651v65aa65d1', | ||
| 8 | urlDireccion: 'debonline.dyndns.com:9900' | ||
| 9 | }, | ||
| 10 | { | ||
| 11 | terminalKey: 'fa651v65aa65d1', | ||
| 12 | urlDireccion: 'debonline.dyndns.com:9900' | ||
| 13 | }, | ||
| 14 | { | ||
| 15 | terminalKey: 'fa651v65aa65d1', | ||
| 16 | urlDireccion: 'debonline.dyndns.com:9900' | ||
| 17 | }, | ||
| 18 | { | ||
| 19 | terminalKey: 'fa651v65aa65d1', | ||
| 20 | urlDireccion: 'debonline.dyndns.com:9900' | ||
| 21 | }, | ||
| 22 | { | ||
| 23 | terminalKey: 'fa651v65aa65d1', | ||
| 24 | urlDireccion: 'debonline.dyndns.com:9900' | ||
| 25 | }, | ||
| 26 | { | ||
| 27 | terminalKey: 'fa651v65aa65d1', | ||
| 28 | urlDireccion: 'debonline.dyndns.com:9900' | ||
| 29 | }, | ||
| 30 | { | ||
| 31 | terminalKey: 'fa651v65aa65d1', | ||
| 32 | urlDireccion: 'debonline.dyndns.com:9900' | ||
| 33 | }, | ||
| 34 | { | ||
| 35 | terminalKey: 'fa651v65aa65d1', | ||
| 36 | urlDireccion: 'debonline.dyndns.com:9900' | ||
| 37 | } | ||
| 38 | ] | ||
| 39 | }, | ||
| 40 | getTerminarRequest: function() { | ||
| 41 | return [ | ||
| 42 | { | ||
| 43 | terminalKey: 'cSB156B6SC51B' | ||
| 44 | } | ||
| 45 | ] | ||
| 46 | }, | ||
| 47 | getEmpresas: function() { | 4 | getEmpresas: function() { |
| 48 | return $http.get(endpoint + '/empresa/listar'); | 5 | return $http.get(endpoint + '/empresa/listar'); |
| 49 | }, | 6 | }, |
| 50 | insertEmpresa: function(empresa) { | 7 | insertEmpresa: function(empresa) { |
| 51 | return $http.post(endpoint + '/empresa/crear', empresa); | 8 | return $http.post(endpoint + '/empresa/crear', empresa); |
| 52 | } | 9 | } |
| 53 | } | 10 | } |
| 54 | }]); | 11 | }]); |
| 55 | 12 |