Commit 92c3081c2c1cf95be14de7cae86565d834dfbae8

Authored by Nicolás Guarnieri
Exists in master

Merge remote-tracking branch 'origin/master'

... ... @@ -39,7 +39,7 @@ gulp.task('uglify', ['templates'], function() {
39 39 'tmp/views.js'
40 40 ]),
41 41 concat('foca-login.js'),
42   - replace("['ngRoute', 'ngCookies', 'focaDirectivas']",'[]'),
  42 + replace("['ngRoute', 'ngCookies', 'focaDirectivas', 'angular-ladda']",'[]'),
43 43 replace('src/views/', ''),
44 44 gulp.dest(paths.tmp),
45 45 rename('foca-login.min.js'),
... ... @@ -8,7 +8,7 @@
8 8 "compile": "gulp compile",
9 9 "gulp-pre-commit": "gulp pre-commit",
10 10 "postinstall": "npm run compile && gulp clean-post-install",
11   - "install-dev": "npm install -D gulp gulp-connect jasmine-core pre-commit angular angular-route angular-cookies bootstrap font-awesome gulp-angular-templatecache gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-replace jquery jshint pump && npm i -D git+https://debo.suite.repo/modulos-npm/foca-directivas"
  11 + "install-dev": "npm install -D gulp gulp-connect jasmine-core pre-commit angular angular-route angular-cookies bootstrap font-awesome gulp-angular-templatecache gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-replace jquery jshint pump && npm i -D git+http://git.focasoftware.com/npm/foca-directivas.git"
12 12 },
13 13 "pre-commit": [
14 14 "gulp-pre-commit"
... ... @@ -32,28 +32,28 @@
32 32 "gulp-uglify-es": "^1.0.x",
33 33 "jshint": "^2.9.x",
34 34 "pump": "^3.0.x",
35   - "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas"
  35 + "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git"
36 36 },
37 37 "devDependencies": {
38 38 "angular": "^1.7.5",
39 39 "angular-cookies": "^1.7.5",
40 40 "angular-route": "^1.7.5",
41 41 "bootstrap": "^4.1.3",
42   - "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas",
  42 + "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git",
43 43 "font-awesome": "^4.7.0",
44 44 "gulp": "^3.9.1",
45   - "gulp-angular-templatecache": "^2.2.2",
  45 + "gulp-angular-templatecache": "^2.2.5",
46 46 "gulp-clean": "^0.4.0",
47   - "gulp-connect": "^5.6.1",
  47 + "gulp-connect": "^5.7.0",
48 48 "gulp-htmlmin": "^5.0.1",
49 49 "gulp-jshint": "^2.1.0",
50 50 "gulp-rename": "^1.4.0",
51 51 "gulp-replace": "^1.0.0",
52 52 "gulp-sequence": "^1.0.0",
53 53 "gulp-uglify-es": "^1.0.4",
54   - "jasmine-core": "^3.2.1",
  54 + "jasmine-core": "^3.3.0",
55 55 "jquery": "^3.3.1",
56   - "jshint": "^2.9.6",
  56 + "jshint": "^2.9.7",
57 57 "pre-commit": "^1.2.2",
58 58 "pump": "^3.0.0"
59 59 }
1   -angular.module('focaLogin', ['ngRoute', 'ngCookies', 'focaDirectivas'])
  1 +angular.module('focaLogin', ['ngRoute', 'ngCookies', 'focaDirectivas', 'angular-ladda'])
2 2 .run(['$rootScope', '$cookies', '$location', function($rootScope, $cookies, $location) {
3 3 $rootScope.$on('$locationChangeStart', function() {
4 4 var idUsuario = $cookies.get('idUsuario');
src/js/controller.js
1 1 angular.module('focaLogin')
2 2 .controller('focaLoginController', [
3   - '$scope', 'focaLoginService', '$location', '$cookies',
4   - function($scope, focaLoginService, $location, $cookies) {
  3 + '$scope', 'focaLoginService', '$location', '$cookies', 'focaModalService',
  4 + function($scope, focaLoginService, $location, $cookies, focaModalService) {
5 5 $scope.paso = 1;
6 6 $scope.enviar = function() {
7   - focaLoginService.login($scope.usuario).then(function(datos) {
8   - $cookies.put('idUsuario', $scope.usuario.idUsuario);
9   - $cookies.put('token', datos.data.token);
10   - $location.path('/');
11   - $scope.$emit('blur');
12   - });
  7 + $scope.loginLoading = true;
  8 + focaLoginService.login($scope.usuario)
  9 + .then(function(datos) {
  10 + $scope.loginLoading = false;
  11 + $cookies.put('idUsuario', $scope.usuario.idUsuario);
  12 + $cookies.put('token', datos.data.token);
  13 + $location.path('/');
  14 + $scope.$emit('blur');
  15 + })
  16 + .catch(function(error) {
  17 + $scope.loginLoading = false;
  18 + if(error.status === 401) {
  19 + focaModalService.alert('El usuario y/o la contraseña no coinciden');
  20 + return;
  21 + }
  22 + if(error.status === -1) {
  23 + focaModalService.alert('Sin servicio');
  24 + return;
  25 + }
  26 + });
13 27 };
14 28 $scope.irPaso = function(numeroPaso) {
15 29 $scope.paso = numeroPaso;
... ... @@ -21,6 +35,9 @@ angular.module('focaLogin')
21 35 function($cookies, $location) {
22 36 $cookies.remove('idUsuario');
23 37 $cookies.remove('token');
  38 + //Cierra ventana
  39 + window.open('', '_self', ''); //bug fix
  40 + window.close();
24 41 $location.path('/login');
25 42 }
26 43 ]);
src/views/foca-login.html
... ... @@ -10,6 +10,7 @@
10 10 ng-model = "usuario.idUsuario"
11 11 foca-focus = "paso == 1"
12 12 ng-keyup = "$event.keyCode == 13 && irPaso(2)"
  13 + ladda="loginLoading"
13 14 teclado-virtual
14 15 />
15 16 </div>
... ... @@ -20,9 +21,15 @@
20 21 ng-model = "usuario.clave"
21 22 foca-focus = "paso == 2"
22 23 ng-keyup = "$event.keyCode == 13 && enviar()"
  24 + ladda="loginLoading"
23 25 teclado-virtual
24 26 />
25 27 </div>
26   - <button type="button" ng-click="enviar()" class="btn btn-dark mt-3 float-right">Ingresar</button>
  28 + <button
  29 + type="button"
  30 + ng-click="enviar()"
  31 + class="btn btn-dark mt-3 float-right"
  32 + ladda="loginLoading"
  33 + >Ingresar</button>
27 34 </form>
28 35 </div>