controller.js
1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
angular.module('focaGestionTerminal')
.controller('gestionTerminalController',
[
'$scope',
'gestionTerminalService',
'netTesting',
function($scope, gestionTerminalesService, netTesting) {
$scope.empresa = {};
$scope.empresas = [];
gestionTerminalesService.getEmpresas().then(function(res) {
$scope.empresas = res.data;
});
$scope.guardar = function() {
netTesting.ping($scope.empresa.url, function() {
if (arguments[1] === 'disconnected') {
$scope.mensaje = "La url indicada no tiene conección";
return;
}
gestionTerminalesService.insertEmpresa(
{ empresa: $scope.empresa}).then(function() {
$scope.mensaje = "Empresa guardada con éxito";
$scope.empresas.push($scope.terminal);
$scope.empresa = {};
$scope.empresaGuardada = true;
}).catch(function() {
$scope.mensaje = "Hubo un error al guardar la empresa";
});
});
};
$scope.eliminarEmpresa = function() {
if (confirm('¿Esta seguro que desa eliminar la empresa?')) {
alert('En desarrollo');
return;
}
};
}]);