Compare View
Commits (10)
-
Master(efernandez) See merge request !17
-
Master(efernandez) See merge request !18
-
Facturador(mpuebla) See merge request !19
-
Master(brodriguez) See merge request !20
Showing
4 changed files
Show diff stats
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 | "refresh": "gulp uglify && cp tmp/foca-login.js ../wrapper-demo/node_modules/foca-login/dist/foca-login.min.js", | ||
8 | "frefresh": "gulp uglify && cp tmp/foca-login.js ../wrapper-facturador/node_modules/foca-login/dist/foca-login.min.js", | ||
7 | "test": "echo \"Error: no test specified\" && exit 1", | 9 | "test": "echo \"Error: no test specified\" && exit 1", |
8 | "gulp-pre-commit": "gulp pre-commit", | 10 | "gulp-pre-commit": "gulp pre-commit", |
9 | "postinstall": "gulp uglify && gulp clean-post-install", | 11 | "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" | 12 | "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 | }, | 13 | }, |
12 | "pre-commit": [ | 14 | "pre-commit": [ |
13 | "gulp-pre-commit" | 15 | "gulp-pre-commit" |
14 | ], | 16 | ], |
15 | "repository": { | 17 | "repository": { |
16 | "type": "git", | 18 | "type": "git", |
17 | "url": "https://debo.suite.repo/modulos-npm/foca-login.git" | 19 | "url": "https://debo.suite.repo/modulos-npm/foca-login.git" |
18 | }, | 20 | }, |
19 | "author": "Foca Software", | 21 | "author": "Foca Software", |
20 | "license": "ISC", | 22 | "license": "ISC", |
21 | "peerDependencies": { | 23 | "peerDependencies": { |
22 | "angular": "^1.7.x", | 24 | "angular": "^1.7.x", |
23 | "bootstrap": "^4.1.x", | 25 | "bootstrap": "^4.1.x", |
24 | "jquery": "^3.3.x", | 26 | "jquery": "^3.3.x", |
25 | "font-awesome": "^4.7.x", | 27 | "font-awesome": "^4.7.x", |
26 | "gulp": "^3.9.x", | 28 | "gulp": "^3.9.x", |
27 | "gulp-concat": "2.6.x", | 29 | "gulp-concat": "2.6.x", |
28 | "gulp-jshint": "^2.1.x", | 30 | "gulp-jshint": "^2.1.x", |
29 | "gulp-rename": "^1.4.x", | 31 | "gulp-rename": "^1.4.x", |
30 | "gulp-replace": "^1.0.x", | 32 | "gulp-replace": "^1.0.x", |
31 | "gulp-uglify-es": "^1.0.x", | 33 | "gulp-uglify-es": "^1.0.x", |
32 | "jshint": "^2.9.x", | 34 | "jshint": "^2.9.x", |
33 | "pump": "^3.0.x", | 35 | "pump": "^3.0.x", |
34 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git" | 36 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git" |
35 | }, | 37 | }, |
36 | "devDependencies": { | 38 | "devDependencies": { |
37 | "angular": "^1.7.5", | 39 | "angular": "^1.7.5", |
38 | "angular-cookies": "^1.7.5", | 40 | "angular-cookies": "^1.7.5", |
39 | "angular-route": "^1.7.5", | 41 | "angular-route": "^1.7.5", |
40 | "bootstrap": "^4.1.3", | 42 | "bootstrap": "^4.1.3", |
41 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 43 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
42 | "font-awesome": "^4.7.0", | 44 | "font-awesome": "^4.7.0", |
43 | "gulp": "^3.9.1", | 45 | "gulp": "^3.9.1", |
44 | "gulp-angular-templatecache": "^2.2.2", | 46 | "gulp-angular-templatecache": "^2.2.2", |
45 | "gulp-clean": "^0.4.0", | 47 | "gulp-clean": "^0.4.0", |
46 | "gulp-connect": "^5.7.0", | 48 | "gulp-connect": "^5.7.0", |
47 | "gulp-htmlmin": "^5.0.1", | 49 | "gulp-htmlmin": "^5.0.1", |
48 | "gulp-jshint": "^2.1.0", | 50 | "gulp-jshint": "^2.1.0", |
49 | "gulp-rename": "^1.4.0", | 51 | "gulp-rename": "^1.4.0", |
50 | "gulp-replace": "^1.0.0", | 52 | "gulp-replace": "^1.0.0", |
51 | "gulp-sequence": "^1.0.0", | 53 | "gulp-sequence": "^1.0.0", |
52 | "gulp-uglify": "^3.0.1", | 54 | "gulp-uglify": "^3.0.1", |
53 | "jasmine-core": "^3.3.0", | 55 | "jasmine-core": "^3.3.0", |
54 | "jquery": "^3.3.1", | 56 | "jquery": "^3.3.1", |
55 | "jshint": "^2.9.7", | 57 | "jshint": "^2.9.7", |
56 | "pre-commit": "^1.2.2", | 58 | "pre-commit": "^1.2.2", |
57 | "pump": "^3.0.0" | 59 | "pump": "^3.0.0" |
58 | } | 60 | } |
59 | } | 61 | } |
60 | 62 |
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', 'APP', | 3 | '$scope', 'focaLoginService', '$location', '$cookies', 'focaModalService', 'md5', 'APP', |
4 | function($scope, focaLoginService, $location, $cookies, focaModalService, md5, APP) { | 4 | function($scope, focaLoginService, $location, $cookies, focaModalService, md5, APP) { |
5 | $scope.paso = 1; | 5 | $scope.paso = 1; |
6 | $scope.enviar = function() { | 6 | $scope.enviar = function() { |
7 | angular.element('#password').blur(); | 7 | angular.element('#password').blur(); |
8 | focaLoginService.login({ | 8 | focaLoginService.login({ |
9 | idUsuario: $scope.usuario.idUsuario, | 9 | idUsuario: $scope.usuario.idUsuario, |
10 | clave: APP != 'facturador' ? md5.createHash($scope.usuario.clave) : | 10 | clave: APP != 'facturador' ? md5.createHash($scope.usuario.clave) : |
11 | $scope.usuario.clave | ||
11 | $scope.usuario.clave | 12 | }).then(function(datos) { |
12 | }).then(function(datos) { | 13 | if (datos.data.chofer && datos.data.chofer.id) { |
13 | if (datos.data.chofer && datos.data.chofer.id) { | 14 | $cookies.put('chofer', datos.data.chofer.id); |
14 | $cookies.put('chofer', datos.data.chofer.id); | 15 | $cookies.put('nombreUsuario', datos.data.chofer.nombre); |
15 | $cookies.put('nombreUsuario', datos.data.chofer.nombre); | 16 | } else if (datos.data.vendedorCobrador && datos.data.vendedorCobrador.id) { |
16 | } else if (datos.data.vendedorCobrador && datos.data.vendedorCobrador.id) { | 17 | $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.id); |
17 | $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.id); | 18 | $cookies.put('nombreUsuario', datos.data.vendedorCobrador.NOM); |
19 | } else if (datos.data.vendedorPlaya) { | ||
20 | $cookies.put('vendedorPlaya', datos.data.vendedorPlaya.CodVen); | ||
21 | $cookies.put('nombreUsuario', datos.data.vendedorPlaya.NomVen.trim()); | ||
18 | $cookies.put('nombreUsuario', datos.data.vendedorCobrador.NOM); | 22 | } else { |
19 | } else if (datos.data.vendedorPlaya) { | 23 | focaModalService.alert('Existe un error con el usuario ingresado'); |
20 | $cookies.put('vendedorPlaya', datos.data.vendedorPlaya.CodVen); | 24 | return; |
21 | $cookies.put('nombreUsuario', datos.data.vendedorPlaya.NomVen.trim()); | 25 | } |
22 | } else { | 26 | |
23 | focaModalService.alert('Existe un error con el usuario ingresado'); | 27 | console.info(datos.data); |
24 | return; | 28 | $cookies.put('token', datos.data.token); |
25 | } | 29 | $location.path('/'); |
26 | 30 | $scope.$emit('blur'); | |
27 | console.info(datos.data); | 31 | }, function(error) { |
28 | $cookies.put('token', datos.data.token); | 32 | if (error.status === 401) { |
29 | $location.path('/'); | 33 | focaModalService |
30 | $scope.$emit('blur'); | 34 | .alert('El usuario o la contraseña han sido mal introducidos'); |
31 | }, function(error) { | 35 | } |
32 | if (error.status === 401) { | 36 | |
33 | focaModalService | 37 | if(error.status === -1) { |
34 | .alert('El usuario o la contraseña han sido mal introducidos'); | 38 | focaModalService.alert('Sin servicio'); |
35 | } | 39 | return; |
36 | 40 | } | |
37 | if(error.status === -1) { | 41 | }); |
38 | focaModalService.alert('Sin servicio'); | 42 | }; |
39 | return; | 43 | $scope.irPaso = function(numeroPaso) { |
40 | } | 44 | $scope.paso = numeroPaso; |
41 | }); | 45 | }; |
42 | }; | 46 | } |
43 | $scope.irPaso = function(numeroPaso) { | 47 | ]) |
44 | $scope.paso = numeroPaso; | 48 | .controller('focaLogoutController', [ |
45 | }; | 49 | '$cookies', '$location', |
46 | } | 50 | function($cookies, $location) { |
47 | ]) | 51 | $cookies.remove('chofer'); |
48 | .controller('focaLogoutController', [ | 52 | $cookies.remove('vendedorCobrador'); |
53 | $cookies.remove('vendedorPlaya'); | ||
49 | '$cookies', '$location', | 54 | $cookies.remove('nombreUsuario'); |
50 | function($cookies, $location) { | 55 | $cookies.remove('token'); |
51 | $cookies.remove('chofer'); | 56 | //Cierra ventana |
52 | $cookies.remove('vendedorCobrador'); | 57 | window.open('', '_self', ''); //bug fix |
53 | $cookies.remove('vendedorPlaya'); | 58 | window.close(); |
54 | $cookies.remove('nombreUsuario'); | 59 | $location.path('/login'); |
55 | $cookies.remove('token'); | 60 | } |
56 | //Cierra ventana | 61 | ]); |
57 | window.open('', '_self', ''); //bug fix | 62 |
src/js/service.js
1 | angular.module('focaLogin') | 1 | angular.module('focaLogin') |
2 | .factory('focaLoginService', [ | 2 | .factory('focaLoginService', [ |
3 | '$http', 'API_ENDPOINT', 'APP', '$cookies', | 3 | '$http', 'API_ENDPOINT', 'APP', '$cookies', |
4 | function($http, API_ENDPOINT, APP, $cookies) { | 4 | function($http, API_ENDPOINT, APP, $cookies) { |
5 | return { | 5 | return { |
6 | login: function(usuario) { | 6 | login: function(usuario) { |
7 | var param = ''; | 7 | var param = ''; |
8 | 8 | ||
9 | if (APP) { | 9 | if (APP) { |
10 | param = '/' + APP; | 10 | param = '/' + APP; |
11 | } | 11 | } |
12 | 12 | ||
13 | return $http.post(API_ENDPOINT.URL + '/usuario/login' + param , usuario); | 13 | return $http.post(API_ENDPOINT.URL + '/usuario/login' + param , usuario); |
14 | }, | 14 | }, |
15 | getLoginData: function() { | 15 | getLoginData: function() { |
16 | if ($cookies.get('chofer')) { | 16 | if ($cookies.get('chofer')) { |
17 | return {chofer: $cookies.get('chofer')}; | 17 | return {chofer: $cookies.get('chofer')}; |
18 | } | 18 | } |
19 | 19 | ||
20 | if ($cookies.get('vendedorCobrador')) { | 20 | if ($cookies.get('vendedorCobrador')) { |
21 | return {vendedorCobrador: $cookies.get('vendedorCobrador')}; | 21 | return {vendedorCobrador: $cookies.get('vendedorCobrador')}; |
22 | } | 22 | } |
23 | |||
24 | if ($cookies.get('vendedorPlaya')) { | ||
25 | return {vendedorPlaya: $cookies.get('vendedorPlaya')}; | ||
26 | } | ||
23 | 27 | } | |
24 | if ($cookies.get('vendedorPlaya')) { | 28 | }; |
25 | return {vendedorPlaya: $cookies.get('vendedorPlaya')}; | 29 | } |
26 | } | 30 | ]); |
27 | } | 31 |
src/views/foca-login.html
1 | <img src="img/logo.png" class="w-25 rounded mx-auto d-block"> | 1 | <img src="img/logo.png" class="w-25 rounded mx-auto d-block"> |
2 | <div class="login mt-5 p-3 border-0"> | ||
2 | <div class="login mt-5 p-3 border-0"> | 3 | <form name="login"> |
3 | <form name="login"> | 4 | |
5 | <div class="login-titulo"> | ||
4 | 6 | <span>Ingreso de usuario</span> | |
5 | <div class="login-titulo"> | 7 | </div> |
6 | <span>Ingreso de usuario</span> | 8 | |
7 | </div> | 9 | <div class="row justify-content-center m-5"> |
8 | <div class="login-campo"> | 10 | <div class="col col-sm-10 col-md-5 col-lg-4 bg-gray-gradient shadow rounded-2"> |
9 | <label>Usuario</label> | 11 | <form name="login"> |
10 | <input | 12 | <div class="row my-2 justify-content-center"> |
11 | type = "text" | 13 | <div class="col border-bottom border-white"> |
12 | ng-model = "usuario.idUsuario" | 14 | <p class="mb-2 text-center">Ingreso de usuario</p> |
13 | ng-focus = "paso = 1" | 15 | </div> |
14 | foca-focus = "paso == 1" | 16 | </div> |
15 | ng-keyup = "$event.keyCode == 13 && irPaso(2)" | 17 | <div class="row mb-2"> |
16 | ladda = "loginLoading" | 18 | <div class="col px-4"> |
19 | <p class="mb-0 text-center">Usuario</p> | ||
20 | <input | ||
21 | class="form-control form-control-sm" | ||
22 | type="text" | ||
23 | ng-model="usuario.idUsuario" | ||
24 | ng-focus="paso = 1" | ||
25 | foca-focus="paso == 1" | ||
26 | ng-keyup="$event.keyCode == 13 && irPaso(2)" | ||
27 | ladda="loginLoading" | ||
28 | teclado-virtual | ||
29 | /> | ||
30 | </div> | ||
31 | </div> | ||
32 | <div class="row mb-3"> | ||
33 | <div class="col px-4"> | ||
34 | <p class="mb-0 text-center">Contraseña</p> | ||
35 | <input | ||
36 | class="form-control form-control-sm" | ||
37 | id="password" | ||
38 | type="password" | ||
39 | ng-model="usuario.clave" | ||
40 | foca-focus="paso == 2" | ||
41 | ng-keyup="$event.keyCode == 13 && enviar()" | ||
42 | ladda="loginLoading" | ||
43 | teclado-virtual | ||
44 | /> | ||
45 | </div> | ||
46 | </div> | ||
47 | <div class="row mb-5"> | ||
48 | <div class="col px-4"> | ||
49 | <button | ||
50 | type="button" | ||
51 | ng-click="enviar()" | ||
52 | class="btn btn-primary btn-block" | ||
53 | ladda="loginLoading"> | ||
54 | Ingresar | ||
55 | </button> | ||
56 | </div> | ||
57 | </div> | ||
58 | </form> | ||
59 | </div> | ||
17 | teclado-virtual | 60 | </div> |
61 | <<<<<<< HEAD | ||
18 | /> | 62 | <div class="login-campo"> |
19 | </div> | 63 | <label>Contraseña</label> |
20 | <div class="login-campo"> | 64 | <input |
21 | <label>Contraseña</label> | 65 | id = "password" |
22 | <input | 66 | type = "password" |
23 | id = "password" | 67 | ng-model = "usuario.clave" |
24 | type = "password" | 68 | foca-focus = "paso == 2" |
25 | ng-model = "usuario.clave" | 69 | ng-keyup = "$event.keyCode == 13 && enviar()" |
26 | foca-focus = "paso == 2" | 70 | ladda = "loginLoading" |
27 | ng-keyup = "$event.keyCode == 13 && enviar()" | 71 | teclado-virtual |
28 | ladda = "loginLoading" | 72 | /> |
29 | teclado-virtual | 73 | </div> |
30 | /> | 74 | <button |
31 | </div> | 75 | type="button" |
32 | <button | 76 | ng-click="enviar()" |
33 | type="button" | 77 | class="login-button btn mt-3 btn-login" |
34 | ng-click="enviar()" | 78 | ladda="loginLoading" |
35 | class="login-button btn mt-3 btn-login" | 79 | >Ingresar</button> |
36 | ladda="loginLoading" | 80 | </form> |
81 | <img src="img/logo-foca.png" class="w-50 rounded mx-auto d-block"> | ||
82 | ======= | ||
83 | </div> | ||
84 | >>>>>>> ac450d6b074c59434f538a88b6166436bff55510 | ||
37 | >Ingresar</button> | 85 | </div> |
38 | </form> | 86 |