Commit 24c5a8e8a9920b2fdcee16db532fa2793ba14651
1 parent
6b3f3e7da5
Exists in
master
ok focus en modal alert
Showing
2 changed files
with
7 additions
and
3 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaLogin') | 1 | angular.module('focaLogin') |
2 | .controller('focaLoginController', [ | 2 | .controller('focaLoginController', [ |
3 | '$scope', 'focaLoginService', '$location', '$cookies', 'focaModalService', 'md5', | 3 | '$scope', 'focaLoginService', '$location', '$cookies', 'focaModalService', 'md5', |
4 | function($scope, focaLoginService, $location, $cookies, focaModalService, md5) { | 4 | function($scope, focaLoginService, $location, $cookies, focaModalService, md5) { |
5 | $scope.paso = 1; | 5 | $scope.paso = 1; |
6 | $scope.enviar = function() { | 6 | $scope.enviar = function() { |
7 | angular.element('#password').blur(); | ||
7 | focaLoginService.login({ | 8 | focaLoginService.login({ |
8 | idUsuario: $scope.usuario.idUsuario, | 9 | idUsuario: $scope.usuario.idUsuario, |
9 | clave: md5.createHash($scope.usuario.clave) | 10 | clave: md5.createHash($scope.usuario.clave) |
10 | }).then(function(datos) { | 11 | }).then(function(datos) { |
11 | if (datos.data.chofer && datos.data.chofer.id) { | 12 | if (datos.data.chofer && datos.data.chofer.id) { |
12 | $cookies.put('chofer', datos.data.chofer.id); | 13 | $cookies.put('chofer', datos.data.chofer.id); |
13 | $cookies.put('nombreUsuario', datos.data.chofer.nombre); | 14 | $cookies.put('nombreUsuario', datos.data.chofer.nombre); |
14 | } else if (datos.data.vendedorCobrador && datos.data.vendedorCobrador.id) { | 15 | } else if (datos.data.vendedorCobrador && datos.data.vendedorCobrador.id) { |
15 | $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.id); | 16 | $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.id); |
16 | $cookies.put('nombreUsuario', datos.data.vendedorCobrador.NOM); | 17 | $cookies.put('nombreUsuario', datos.data.vendedorCobrador.NOM); |
17 | } else { | 18 | } else { |
18 | focaModalService.alert('Existe un error con el usuario ingresado'); | 19 | focaModalService.alert('Existe un error con el usuario ingresado'); |
19 | return; | 20 | return; |
20 | } | 21 | } |
21 | 22 | ||
22 | console.info(datos.data); | 23 | console.info(datos.data); |
23 | $cookies.put('token', datos.data.token); | 24 | $cookies.put('token', datos.data.token); |
24 | $location.path('/'); | 25 | $location.path('/'); |
25 | $scope.$emit('blur'); | 26 | $scope.$emit('blur'); |
26 | }, function(error) { | 27 | }, function(error) { |
27 | if (error.status === 401) { | 28 | if (error.status === 401) { |
28 | focaModalService.alert('El usuario o la contraseña han sido mal introducidos'); | 29 | focaModalService |
30 | .alert('El usuario o la contraseña han sido mal introducidos'); | ||
29 | } | 31 | } |
30 | 32 | ||
31 | if(error.status === -1) { | 33 | if(error.status === -1) { |
32 | focaModalService.alert('Sin servicio'); | 34 | focaModalService.alert('Sin servicio'); |
33 | return; | 35 | return; |
34 | } | 36 | } |
35 | }); | 37 | }); |
36 | }; | 38 | }; |
37 | $scope.irPaso = function(numeroPaso) { | 39 | $scope.irPaso = function(numeroPaso) { |
38 | $scope.paso = numeroPaso; | 40 | $scope.paso = numeroPaso; |
39 | }; | 41 | }; |
40 | } | 42 | } |
41 | ]) | 43 | ]) |
42 | .controller('focaLogoutController', [ | 44 | .controller('focaLogoutController', [ |
43 | '$cookies', '$location', | 45 | '$cookies', '$location', |
44 | function($cookies, $location) { | 46 | function($cookies, $location) { |
45 | $cookies.remove('chofer'); | 47 | $cookies.remove('chofer'); |
46 | $cookies.remove('vendedorCobrador'); | 48 | $cookies.remove('vendedorCobrador'); |
47 | $cookies.remove('nombreUsuario'); | 49 | $cookies.remove('nombreUsuario'); |
48 | $cookies.remove('token'); | 50 | $cookies.remove('token'); |
49 | //Cierra ventana | 51 | //Cierra ventana |
50 | window.open('', '_self', ''); //bug fix | 52 | window.open('', '_self', ''); //bug fix |
51 | window.close(); | 53 | window.close(); |
52 | $location.path('/login'); | 54 | $location.path('/login'); |
53 | } | 55 | } |
54 | ]); | 56 | ]); |
55 | 57 |
src/views/foca-login.html
1 | <div class="login"> | 1 | <div class="login"> |
2 | <form name="login"> | 2 | <form name="login"> |
3 | <div class="login-titulo"> | 3 | <div class="login-titulo"> |
4 | <span>Ingreso de usuario</span> | 4 | <span>Ingreso de usuario</span> |
5 | </div> | 5 | </div> |
6 | <div class="login-campo"> | 6 | <div class="login-campo"> |
7 | <label>Usuario</label> | 7 | <label>Usuario</label> |
8 | <input | 8 | <input |
9 | type = "text" | 9 | type = "text" |
10 | ng-model = "usuario.idUsuario" | 10 | ng-model = "usuario.idUsuario" |
11 | ng-focus = "paso = 1" | ||
11 | foca-focus = "paso == 1" | 12 | foca-focus = "paso == 1" |
12 | ng-keyup = "$event.keyCode == 13 && irPaso(2)" | 13 | ng-keyup = "$event.keyCode == 13 && irPaso(2)" |
13 | ladda="loginLoading" | 14 | ladda = "loginLoading" |
14 | teclado-virtual | 15 | teclado-virtual |
15 | /> | 16 | /> |
16 | </div> | 17 | </div> |
17 | <div class="login-campo"> | 18 | <div class="login-campo"> |
18 | <label>Contraseña</label> | 19 | <label>Contraseña</label> |
19 | <input | 20 | <input |
21 | id = "password" | ||
20 | type = "password" | 22 | type = "password" |
21 | ng-model = "usuario.clave" | 23 | ng-model = "usuario.clave" |
22 | foca-focus = "paso == 2" | 24 | foca-focus = "paso == 2" |
23 | ng-keyup = "$event.keyCode == 13 && enviar()" | 25 | ng-keyup = "$event.keyCode == 13 && enviar()" |
24 | ladda="loginLoading" | 26 | ladda = "loginLoading" |
25 | teclado-virtual | 27 | teclado-virtual |
26 | /> | 28 | /> |
27 | </div> | 29 | </div> |
28 | <button | 30 | <button |
29 | type="button" | 31 | type="button" |
30 | ng-click="enviar()" | 32 | ng-click="enviar()" |
31 | class="btn btn-dark mt-3 float-right" | 33 | class="btn btn-dark mt-3 float-right" |
32 | ladda="loginLoading" | 34 | ladda="loginLoading" |
33 | >Ingresar</button> | 35 | >Ingresar</button> |
34 | </form> | 36 | </form> |
35 | </div> | 37 | </div> |
36 | 38 |