Commit 499b4ebc60ef161de1f0377a9f73aa387efc5b93

Authored by Jose Pinto
Exists in master

Merge branch 'master' into 'master'

Master(efernandez)

See merge request !2
... ... @@ -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,29 +32,29 @@
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   - "angular": "1.7.5",
39   - "angular-cookies": "1.7.5",
40   - "angular-route": "1.7.5",
41   - "bootstrap": "4.1.3",
42   - "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas",
43   - "font-awesome": "4.7.0",
44   - "gulp": "3.9.1",
45   - "gulp-angular-templatecache": "2.2.5",
46   - "gulp-clean": "0.4.0",
47   - "gulp-connect": "5.6.1",
48   - "gulp-htmlmin": "5.0.1",
49   - "gulp-jshint": "2.1.0",
50   - "gulp-rename": "1.4.0",
51   - "gulp-replace": "1.0.0",
52   - "gulp-sequence": "1.0.0",
53   - "gulp-uglify-es": "1.0.4",
54   - "jasmine-core": "3.3.0",
55   - "jquery": "3.3.1",
56   - "jshint": "2.9.6",
57   - "pre-commit": "1.2.2",
58   - "pump": "3.0.0"
  38 + "angular": "^1.7.5",
  39 + "angular-cookies": "^1.7.5",
  40 + "angular-route": "^1.7.5",
  41 + "bootstrap": "^4.1.3",
  42 + "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git",
  43 + "font-awesome": "^4.7.0",
  44 + "gulp": "^3.9.1",
  45 + "gulp-angular-templatecache": "^2.2.5",
  46 + "gulp-clean": "^0.4.0",
  47 + "gulp-connect": "^5.7.0",
  48 + "gulp-htmlmin": "^5.0.1",
  49 + "gulp-jshint": "^2.1.0",
  50 + "gulp-rename": "^1.4.0",
  51 + "gulp-replace": "^1.0.0",
  52 + "gulp-sequence": "^1.0.0",
  53 + "gulp-uglify-es": "^1.0.4",
  54 + "jasmine-core": "^3.3.0",
  55 + "jquery": "^3.3.1",
  56 + "jshint": "^2.9.7",
  57 + "pre-commit": "^1.2.2",
  58 + "pump": "^3.0.0"
59 59 }
60 60 }
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;
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>