Commit 92c3081c2c1cf95be14de7cae86565d834dfbae8
Exists in
master
Merge remote-tracking branch 'origin/master'
Showing
5 changed files
Show diff stats
gulpfile.js
1 | const clean = require('gulp-clean'); | 1 | const clean = require('gulp-clean'); |
2 | const concat = require('gulp-concat'); | 2 | const concat = require('gulp-concat'); |
3 | const connect = require('gulp-connect'); | 3 | const connect = require('gulp-connect'); |
4 | const gulp = require('gulp'); | 4 | const gulp = require('gulp'); |
5 | const htmlmin = require('gulp-htmlmin'); | 5 | const htmlmin = require('gulp-htmlmin'); |
6 | const jshint = require('gulp-jshint'); | 6 | const jshint = require('gulp-jshint'); |
7 | const pump = require('pump'); | 7 | const pump = require('pump'); |
8 | const rename = require('gulp-rename'); | 8 | const rename = require('gulp-rename'); |
9 | const replace = require('gulp-replace'); | 9 | const replace = require('gulp-replace'); |
10 | const templateCache = require('gulp-angular-templatecache'); | 10 | const templateCache = require('gulp-angular-templatecache'); |
11 | const uglify = require('gulp-uglify'); | 11 | const uglify = require('gulp-uglify'); |
12 | 12 | ||
13 | var paths = { | 13 | var paths = { |
14 | srcJS: 'src/js/*.js', | 14 | srcJS: 'src/js/*.js', |
15 | srcViews: 'src/views/*.html', | 15 | srcViews: 'src/views/*.html', |
16 | tmp: 'tmp', | 16 | tmp: 'tmp', |
17 | dist: 'dist/' | 17 | dist: 'dist/' |
18 | }; | 18 | }; |
19 | 19 | ||
20 | gulp.task('templates', ['clean'], function() { | 20 | gulp.task('templates', ['clean'], function() { |
21 | return pump( | 21 | return pump( |
22 | [ | 22 | [ |
23 | gulp.src(paths.srcViews), | 23 | gulp.src(paths.srcViews), |
24 | htmlmin(), | 24 | htmlmin(), |
25 | templateCache('views.js', { | 25 | templateCache('views.js', { |
26 | module: 'focaLogin', | 26 | module: 'focaLogin', |
27 | root: '' | 27 | root: '' |
28 | }), | 28 | }), |
29 | gulp.dest(paths.tmp) | 29 | gulp.dest(paths.tmp) |
30 | ] | 30 | ] |
31 | ); | 31 | ); |
32 | }); | 32 | }); |
33 | 33 | ||
34 | gulp.task('uglify', ['templates'], function() { | 34 | gulp.task('uglify', ['templates'], function() { |
35 | return pump( | 35 | return pump( |
36 | [ | 36 | [ |
37 | gulp.src([ | 37 | gulp.src([ |
38 | paths.srcJS, | 38 | paths.srcJS, |
39 | 'tmp/views.js' | 39 | 'tmp/views.js' |
40 | ]), | 40 | ]), |
41 | concat('foca-login.js'), | 41 | concat('foca-login.js'), |
42 | replace("['ngRoute', 'ngCookies', 'focaDirectivas']",'[]'), | 42 | replace("['ngRoute', 'ngCookies', 'focaDirectivas', 'angular-ladda']",'[]'), |
43 | replace('src/views/', ''), | 43 | replace('src/views/', ''), |
44 | gulp.dest(paths.tmp), | 44 | gulp.dest(paths.tmp), |
45 | rename('foca-login.min.js'), | 45 | rename('foca-login.min.js'), |
46 | uglify(), | 46 | uglify(), |
47 | gulp.dest(paths.dist) | 47 | gulp.dest(paths.dist) |
48 | ] | 48 | ] |
49 | ); | 49 | ); |
50 | }); | 50 | }); |
51 | 51 | ||
52 | gulp.task('clean', function() { | 52 | gulp.task('clean', function() { |
53 | return gulp.src(['tmp', 'dist'], {read: false}) | 53 | return gulp.src(['tmp', 'dist'], {read: false}) |
54 | .pipe(clean()); | 54 | .pipe(clean()); |
55 | }); | 55 | }); |
56 | 56 | ||
57 | gulp.task('pre-commit', function() { | 57 | gulp.task('pre-commit', function() { |
58 | pump( | 58 | pump( |
59 | [ | 59 | [ |
60 | gulp.src(paths.srcJS), | 60 | gulp.src(paths.srcJS), |
61 | jshint('.jshintrc'), | 61 | jshint('.jshintrc'), |
62 | jshint.reporter('default'), | 62 | jshint.reporter('default'), |
63 | jshint.reporter('fail') | 63 | jshint.reporter('fail') |
64 | ] | 64 | ] |
65 | ); | 65 | ); |
66 | }); | 66 | }); |
67 | 67 | ||
68 | gulp.task('clean-post-install', function() { | 68 | gulp.task('clean-post-install', function() { |
69 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 69 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
70 | 'index.html'], {read: false}) | 70 | 'index.html'], {read: false}) |
71 | .pipe(clean()); | 71 | .pipe(clean()); |
72 | }); | 72 | }); |
73 | 73 | ||
74 | gulp.task('webserver', function() { | 74 | gulp.task('webserver', function() { |
75 | pump [ | 75 | pump [ |
76 | connect.server({port: 3000}) | 76 | connect.server({port: 3000}) |
77 | ] | 77 | ] |
78 | }); | 78 | }); |
79 | 79 | ||
80 | gulp.task('default', ['webserver']); | 80 | gulp.task('default', ['webserver']); |
81 | 81 | ||
82 | gulp.task('watch', function() { | 82 | gulp.task('watch', function() { |
83 | return gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | 83 | return gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); |
84 | }); | 84 | }); |
85 | 85 |
package.json
1 | { | 1 | { |
2 | "name": "foca-login", | 2 | "name": "foca-login", |
3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
4 | "description": "Login", | 4 | "description": "Login", |
5 | "main": "dist/foca-login.js", | 5 | "main": "dist/foca-login.js", |
6 | "scripts": { | 6 | "scripts": { |
7 | "test": "echo \"Error: no test specified\" && exit 1", | 7 | "test": "echo \"Error: no test specified\" && exit 1", |
8 | "gulp-pre-commit": "gulp pre-commit", | 8 | "gulp-pre-commit": "gulp pre-commit", |
9 | "postinstall": "gulp uglify && gulp clean-post-install", | 9 | "postinstall": "gulp uglify && gulp clean-post-install", |
10 | "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 gulp-replace jquery jshint pump && npm i -D git+https://debo.suite.repo/modulos-npm/foca-directivas" | 10 | "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 gulp-replace jquery jshint pump && npm i -D git+https://debo.suite.repo/modulos-npm/foca-directivas" |
11 | }, | 11 | }, |
12 | "pre-commit": [ | 12 | "pre-commit": [ |
13 | "gulp-pre-commit" | 13 | "gulp-pre-commit" |
14 | ], | 14 | ], |
15 | "repository": { | 15 | "repository": { |
16 | "type": "git", | 16 | "type": "git", |
17 | "url": "https://debo.suite.repo/modulos-npm/foca-login.git" | 17 | "url": "https://debo.suite.repo/modulos-npm/foca-login.git" |
18 | }, | 18 | }, |
19 | "author": "Foca Software", | 19 | "author": "Foca Software", |
20 | "license": "ISC", | 20 | "license": "ISC", |
21 | "peerDependencies": { | 21 | "peerDependencies": { |
22 | "angular": "^1.7.x", | 22 | "angular": "^1.7.x", |
23 | "bootstrap": "^4.1.x", | 23 | "bootstrap": "^4.1.x", |
24 | "jquery": "^3.3.x", | 24 | "jquery": "^3.3.x", |
25 | "font-awesome": "^4.7.x", | 25 | "font-awesome": "^4.7.x", |
26 | "gulp": "^3.9.x", | 26 | "gulp": "^3.9.x", |
27 | "gulp-concat": "2.6.x", | 27 | "gulp-concat": "2.6.x", |
28 | "gulp-jshint": "^2.1.x", | 28 | "gulp-jshint": "^2.1.x", |
29 | "gulp-rename": "^1.4.x", | 29 | "gulp-rename": "^1.4.x", |
30 | "gulp-replace": "^1.0.x", | 30 | "gulp-replace": "^1.0.x", |
31 | "gulp-uglify-es": "^1.0.x", | 31 | "gulp-uglify-es": "^1.0.x", |
32 | "jshint": "^2.9.x", | 32 | "jshint": "^2.9.x", |
33 | "pump": "^3.0.x", | 33 | "pump": "^3.0.x", |
34 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas" | 34 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git" |
35 | }, | 35 | }, |
36 | "devDependencies": { | 36 | "devDependencies": { |
37 | "angular": "^1.7.5", | 37 | "angular": "^1.7.5", |
38 | "angular-cookies": "^1.7.5", | 38 | "angular-cookies": "^1.7.5", |
39 | "angular-route": "^1.7.5", | 39 | "angular-route": "^1.7.5", |
40 | "bootstrap": "^4.1.3", | 40 | "bootstrap": "^4.1.3", |
41 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas", | 41 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
42 | "font-awesome": "^4.7.0", | 42 | "font-awesome": "^4.7.0", |
43 | "gulp": "^3.9.1", | 43 | "gulp": "^3.9.1", |
44 | "gulp-angular-templatecache": "^2.2.3", | 44 | "gulp-angular-templatecache": "^2.2.2", |
45 | "gulp-clean": "^0.4.0", | 45 | "gulp-clean": "^0.4.0", |
46 | "gulp-connect": "^5.6.1", | 46 | "gulp-connect": "^5.7.0", |
47 | "gulp-htmlmin": "^5.0.1", | 47 | "gulp-htmlmin": "^5.0.1", |
48 | "gulp-jshint": "^2.1.0", | 48 | "gulp-jshint": "^2.1.0", |
49 | "gulp-rename": "^1.4.0", | 49 | "gulp-rename": "^1.4.0", |
50 | "gulp-replace": "^1.0.0", | 50 | "gulp-replace": "^1.0.0", |
51 | "gulp-sequence": "^1.0.0", | 51 | "gulp-sequence": "^1.0.0", |
52 | "gulp-uglify": "^3.0.1", | 52 | "gulp-uglify": "^3.0.1", |
53 | "jasmine-core": "^3.3.0", | 53 | "jasmine-core": "^3.3.0", |
54 | "jquery": "^3.3.1", | 54 | "jquery": "^3.3.1", |
55 | "jshint": "^2.9.6", | 55 | "jshint": "^2.9.7", |
56 | "pre-commit": "^1.2.2", | 56 | "pre-commit": "^1.2.2", |
57 | "pump": "^3.0.0" | 57 | "pump": "^3.0.0" |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 |
src/js/app.js
1 | angular.module('focaLogin', ['ngRoute', 'ngCookies', 'focaDirectivas']) | 1 | angular.module('focaLogin', ['ngRoute', 'ngCookies', 'focaDirectivas', 'angular-ladda']) |
2 | .run(['$rootScope', '$cookies', '$location', function($rootScope, $cookies, $location) { | 2 | .run(['$rootScope', '$cookies', '$location', function($rootScope, $cookies, $location) { |
3 | $rootScope.$on('$locationChangeStart', function() { | 3 | $rootScope.$on('$locationChangeStart', function() { |
4 | if(!$cookies.get('token')) { | 4 | if(!$cookies.get('token')) { |
5 | if($location.path() !== '/login') { | 5 | if($location.path() !== '/login') { |
6 | $location.path('/login'); | 6 | $location.path('/login'); |
7 | } | 7 | } |
8 | } | 8 | } |
9 | }); | 9 | }); |
10 | }]); | 10 | }]); |
11 | 11 |
src/js/controller.js
1 | angular.module('focaLogin') | 1 | angular.module('focaLogin') |
2 | .controller('focaLoginController', [ | 2 | .controller('focaLoginController', [ |
3 | '$scope', 'focaLoginService', '$location', '$cookies', | 3 | '$scope', 'focaLoginService', '$location', '$cookies', 'focaModalService', |
4 | function($scope, focaLoginService, $location, $cookies) { | 4 | function($scope, focaLoginService, $location, $cookies, focaModalService) { |
5 | $scope.paso = 1; | 5 | $scope.paso = 1; |
6 | $scope.enviar = function() { | 6 | $scope.enviar = function() { |
7 | focaLoginService.login($scope.usuario).then(function(datos) { | 7 | focaLoginService.login($scope.usuario).then(function(datos) { |
8 | $cookies.put('token', datos.data.token); | 8 | $cookies.put('token', datos.data.token); |
9 | 9 | ||
10 | if (datos.data.chofer) { | 10 | if (datos.data.chofer) { |
11 | $cookies.put('chofer', datos.data.chofer.id); | 11 | $cookies.put('chofer', datos.data.chofer.id); |
12 | } else if (datos.data.vendedorCobrador) { | 12 | } else if (datos.data.vendedorCobrador) { |
13 | $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.CodVen); | ||
14 | } | ||
15 | |||
16 | $location.path('/'); | ||
17 | $scope.$emit('blur'); | ||
18 | }, function(error) { | ||
19 | if (error.status === 401) { | ||
20 | focaModalService.alert('El usuario o la contraseña han sido mal introducidos'); | ||
21 | } | ||
22 | |||
23 | if(error.status === -1) { | ||
24 | focaModalService.alert('Sin servicio'); | ||
25 | return; | ||
26 | } | ||
13 | $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.CodVen); | 27 | }); |
14 | } | 28 | }; |
15 | 29 | $scope.irPaso = function(numeroPaso) { | |
16 | $location.path('/'); | 30 | $scope.paso = numeroPaso; |
17 | $scope.$emit('blur'); | 31 | }; |
18 | }, function(error) { | 32 | } |
19 | if (error.status === 401) { | 33 | ]) |
20 | alert('El usuario o la contraseña han sido mal introducidos'); | 34 | .controller('focaLogoutController', [ |
21 | } | 35 | '$cookies', '$location', |
22 | }); | 36 | function($cookies, $location) { |
23 | }; | 37 | $cookies.remove('chofer'); |
38 | $cookies.remove('vendedorCobrador'); | ||
39 | $cookies.remove('token'); | ||
40 | //Cierra ventana | ||
24 | $scope.irPaso = function(numeroPaso) { | 41 | window.open('', '_self', ''); //bug fix |
25 | $scope.paso = numeroPaso; | 42 | window.close(); |
26 | }; | 43 | $location.path('/login'); |
27 | } | 44 | } |
28 | ]) | 45 | ]); |
29 | .controller('focaLogoutController', [ | 46 |
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 | foca-focus = "paso == 1" | 11 | foca-focus = "paso == 1" |
12 | ng-keyup = "$event.keyCode == 13 && irPaso(2)" | 12 | ng-keyup = "$event.keyCode == 13 && irPaso(2)" |
13 | ladda="loginLoading" | ||
13 | teclado-virtual | 14 | teclado-virtual |
14 | /> | 15 | /> |
15 | </div> | 16 | </div> |
16 | <div class="login-campo"> | 17 | <div class="login-campo"> |
17 | <label>Contraseña</label> | 18 | <label>Contraseña</label> |
18 | <input | 19 | <input |
19 | type = "password" | 20 | type = "password" |
20 | ng-model = "usuario.clave" | 21 | ng-model = "usuario.clave" |
21 | foca-focus = "paso == 2" | 22 | foca-focus = "paso == 2" |
22 | ng-keyup = "$event.keyCode == 13 && enviar()" | 23 | ng-keyup = "$event.keyCode == 13 && enviar()" |
24 | ladda="loginLoading" | ||
23 | teclado-virtual | 25 | teclado-virtual |
24 | /> | 26 | /> |
25 | </div> | 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 | </form> | 34 | </form> |
28 | </div> | 35 | </div> |
29 | 36 |