Commit 34508b29f1753182ff4082b4ca7140aebd4f1620
Exists in
master
Merge branch 'develop' of git.focasoftware.com:npm/foca-login
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", | ||
7 | "test": "echo \"Error: no test specified\" && exit 1", | 8 | "test": "echo \"Error: no test specified\" && exit 1", |
8 | "gulp-pre-commit": "gulp pre-commit", | 9 | "gulp-pre-commit": "gulp pre-commit", |
9 | "postinstall": "gulp uglify && gulp clean-post-install", | 10 | "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" | 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 gulp-replace jquery jshint pump && npm i -D git+https://debo.suite.repo/modulos-npm/foca-directivas" |
11 | }, | 12 | }, |
12 | "pre-commit": [ | 13 | "pre-commit": [ |
13 | "gulp-pre-commit" | 14 | "gulp-pre-commit" |
14 | ], | 15 | ], |
15 | "repository": { | 16 | "repository": { |
16 | "type": "git", | 17 | "type": "git", |
17 | "url": "https://debo.suite.repo/modulos-npm/foca-login.git" | 18 | "url": "https://debo.suite.repo/modulos-npm/foca-login.git" |
18 | }, | 19 | }, |
19 | "author": "Foca Software", | 20 | "author": "Foca Software", |
20 | "license": "ISC", | 21 | "license": "ISC", |
21 | "peerDependencies": { | 22 | "peerDependencies": { |
22 | "angular": "^1.7.x", | 23 | "angular": "^1.7.x", |
23 | "bootstrap": "^4.1.x", | 24 | "bootstrap": "^4.1.x", |
24 | "jquery": "^3.3.x", | 25 | "jquery": "^3.3.x", |
25 | "font-awesome": "^4.7.x", | 26 | "font-awesome": "^4.7.x", |
26 | "gulp": "^3.9.x", | 27 | "gulp": "^3.9.x", |
27 | "gulp-concat": "2.6.x", | 28 | "gulp-concat": "2.6.x", |
28 | "gulp-jshint": "^2.1.x", | 29 | "gulp-jshint": "^2.1.x", |
29 | "gulp-rename": "^1.4.x", | 30 | "gulp-rename": "^1.4.x", |
30 | "gulp-replace": "^1.0.x", | 31 | "gulp-replace": "^1.0.x", |
31 | "gulp-uglify-es": "^1.0.x", | 32 | "gulp-uglify-es": "^1.0.x", |
32 | "jshint": "^2.9.x", | 33 | "jshint": "^2.9.x", |
33 | "pump": "^3.0.x", | 34 | "pump": "^3.0.x", |
34 | "foca-directivas": "git+ssh://git@debonline.dyndns.org:npm/foca-directivas.git" | 35 | "foca-directivas": "git+ssh://git@debonline.dyndns.org:npm/foca-directivas.git" |
35 | }, | 36 | }, |
36 | "devDependencies": { | 37 | "devDependencies": { |
37 | "angular": "^1.7.5", | 38 | "angular": "^1.7.5", |
38 | "angular-cookies": "^1.7.5", | 39 | "angular-cookies": "^1.7.5", |
39 | "angular-route": "^1.7.5", | 40 | "angular-route": "^1.7.5", |
40 | "bootstrap": "^4.1.3", | 41 | "bootstrap": "^4.1.3", |
41 | "foca-directivas": "git+ssh://git@debonline.dyndns.org:npm/foca-directivas.git", | 42 | "foca-directivas": "git+ssh://git@debonline.dyndns.org:npm/foca-directivas.git", |
42 | "font-awesome": "^4.7.0", | 43 | "font-awesome": "^4.7.0", |
43 | "gulp": "^3.9.1", | 44 | "gulp": "^3.9.1", |
44 | "gulp-angular-templatecache": "^2.2.2", | 45 | "gulp-angular-templatecache": "^2.2.2", |
45 | "gulp-clean": "^0.4.0", | 46 | "gulp-clean": "^0.4.0", |
46 | "gulp-connect": "^5.7.0", | 47 | "gulp-connect": "^5.7.0", |
47 | "gulp-htmlmin": "^5.0.1", | 48 | "gulp-htmlmin": "^5.0.1", |
48 | "gulp-jshint": "^2.1.0", | 49 | "gulp-jshint": "^2.1.0", |
49 | "gulp-rename": "^1.4.0", | 50 | "gulp-rename": "^1.4.0", |
50 | "gulp-replace": "^1.0.0", | 51 | "gulp-replace": "^1.0.0", |
51 | "gulp-sequence": "^1.0.0", | 52 | "gulp-sequence": "^1.0.0", |
52 | "gulp-uglify": "^3.0.1", | 53 | "gulp-uglify": "^3.0.1", |
53 | "jasmine-core": "^3.3.0", | 54 | "jasmine-core": "^3.3.0", |
54 | "jquery": "^3.3.1", | 55 | "jquery": "^3.3.1", |
55 | "jshint": "^2.9.7", | 56 | "jshint": "^2.9.7", |
56 | "pre-commit": "^1.2.2", | 57 | "pre-commit": "^1.2.2", |
57 | "pump": "^3.0.0" | 58 | "pump": "^3.0.0" |
58 | } | 59 | } |
59 | } | 60 | } |
60 | 61 |
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', 'APP', |
4 | function($scope, focaLoginService, $location, $cookies, focaModalService, md5) { | 4 | function ($scope, focaLoginService, $location, $cookies, focaModalService, md5, APP) { |
5 | $scope.paso = 1; | 5 | $scope.paso = 1; |
6 | $scope.enviar = function() { | 6 | $scope.hidePassword = true; |
7 | $scope.enviar = function () { | ||
7 | angular.element('#password').blur(); | 8 | angular.element('#password').blur(); |
8 | focaLoginService.login({ | 9 | focaLoginService.login({ |
9 | idUsuario: $scope.usuario.idUsuario, | 10 | idUsuario: $scope.usuario.idUsuario, |
10 | clave: md5.createHash($scope.usuario.clave) | 11 | clave: APP != 'facturador' ? md5.createHash($scope.usuario.clave) : |
11 | }).then(function(datos) { | 12 | $scope.usuario.clave |
13 | }).then(function (datos) { | ||
12 | if (datos.data.chofer && datos.data.chofer.id) { | 14 | if (datos.data.chofer && datos.data.chofer.id) { |
13 | $cookies.put('chofer', datos.data.chofer.id); | 15 | $cookies.put('chofer', datos.data.chofer.id); |
14 | $cookies.put('nombreUsuario', datos.data.chofer.nombre); | 16 | $cookies.put('nombreUsuario', datos.data.chofer.nombre); |
15 | } else if (datos.data.vendedorCobrador && datos.data.vendedorCobrador.id) { | 17 | } else if (datos.data.vendedorCobrador && datos.data.vendedorCobrador.id) { |
16 | $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.id); | 18 | $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.id); |
17 | $cookies.put('nombreUsuario', datos.data.vendedorCobrador.NOM); | 19 | $cookies.put('nombreUsuario', datos.data.vendedorCobrador.NOM); |
20 | } else if (datos.data.vendedorPlaya) { | ||
21 | $cookies.put('vendedorPlaya', datos.data.vendedorPlaya.CodVen); | ||
22 | $cookies.put('nombreUsuario', datos.data.vendedorPlaya.NomVen.trim()); | ||
18 | } else { | 23 | } else { |
19 | focaModalService.alert('Existe un error con el usuario ingresado'); | 24 | focaModalService.alert('Existe un error con el usuario ingresado'); |
20 | return; | 25 | return; |
21 | } | 26 | } |
22 | 27 | ||
23 | console.info(datos.data); | 28 | console.info(datos.data); |
24 | $cookies.put('token', datos.data.token); | 29 | $cookies.put('token', datos.data.token); |
25 | $location.path('/'); | 30 | $location.path('/'); |
26 | $scope.$emit('blur'); | 31 | $scope.$emit('blur'); |
27 | }, function(error) { | 32 | }, function (error) { |
28 | if (error.status === 401) { | 33 | if (error.status === 401) { |
29 | focaModalService | 34 | focaModalService |
30 | .alert('El usuario o la contraseña han sido mal introducidos'); | 35 | .alert('El usuario o la contraseña han sido mal introducidos'); |
31 | } | 36 | } |
32 | 37 | ||
33 | if(error.status === -1) { | 38 | if (error.status === -1) { |
34 | focaModalService.alert('Sin servicio'); | 39 | focaModalService.alert('Sin servicio'); |
35 | return; | 40 | return; |
36 | } | 41 | } |
37 | }); | 42 | }); |
38 | }; | 43 | }; |
39 | $scope.irPaso = function(numeroPaso) { | 44 | $scope.irPaso = function (numeroPaso) { |
40 | $scope.paso = numeroPaso; | 45 | $scope.paso = numeroPaso; |
41 | }; | 46 | }; |
42 | } | 47 | } |
43 | ]) | 48 | ]) |
44 | .controller('focaLogoutController', [ | 49 | .controller('focaLogoutController', [ |
45 | '$cookies', '$location', | 50 | '$cookies', '$location', |
46 | function($cookies, $location) { | 51 | function ($cookies, $location) { |
47 | $cookies.remove('chofer'); | 52 | $cookies.remove('chofer'); |
48 | $cookies.remove('vendedorCobrador'); | 53 | $cookies.remove('vendedorCobrador'); |
54 | $cookies.remove('vendedorPlaya'); | ||
49 | $cookies.remove('nombreUsuario'); | 55 | $cookies.remove('nombreUsuario'); |
50 | $cookies.remove('token'); | 56 | $cookies.remove('token'); |
51 | //Cierra ventana | 57 | //Cierra ventana |
52 | window.open('', '_self', ''); //bug fix | 58 | window.open('', '_self', ''); //bug fix |
53 | window.close(); | 59 | window.close(); |
54 | $location.path('/login'); | 60 | $location.path('/login'); |
55 | } | 61 | } |
56 | ]); | 62 | ]); |
57 | 63 |
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 | }; | 28 | }; |
25 | } | 29 | } |
26 | ]); | 30 | ]); |
27 | 31 |
src/views/foca-login.html
1 | <div class="login"> | 1 | <div class="row justify-content-center align-items-center"> |
2 | <form name="login"> | 2 | <div class="col-12 my-2"> |
3 | <div class="login-titulo"> | 3 | <img src="img/logo.png" class="img-login mx-auto d-block"> |
4 | <span>Ingreso de usuario</span> | 4 | </div> |
5 | <div class="col-8 col-sm-6 col-md-4 col-lg-3 my-2 align-self-stretch"> | ||
6 | <div class="bg-gradient-login border-0 rounded shadow-sm text-center"> | ||
7 | <form class="p-3 m-0" name="login"> | ||
8 | <div class="pt-3 pb-2 mb-3 border-bottom border-white"> | ||
9 | <span>Ingreso de usuario</span> | ||
10 | </div> | ||
11 | <!-- USUARIO --> | ||
12 | <label | ||
13 | for="user" | ||
14 | class="login-small-text m-0"> | ||
15 | Usuario | ||
16 | </label> | ||
17 | <div class="input-group mb-2"> | ||
18 | <input | ||
19 | class="form-control form-control-sm rounded-pill text-transform-none" | ||
20 | type="text" | ||
21 | id="user" | ||
22 | ng-model="usuario.idUsuario" | ||
23 | ng-focus="paso = 1" | ||
24 | foca-focus="paso === 1" | ||
25 | ng-keyup="$event.keyCode == 13 && irPaso(2)" | ||
26 | ladda="loginLoading" | ||
27 | teclado-virtual | ||
28 | /> | ||
29 | </div> | ||
30 | <!-- CONTRASEÑA --> | ||
31 | <label | ||
32 | for="password" | ||
33 | class="login-small-text m-0"> | ||
34 | Contraseña | ||
35 | </label> | ||
36 | <div class="input-group mb-2"> | ||
37 | <input | ||
38 | class="form-control form-control-sm rounded-pill text-transform-none pr-5" | ||
39 | id="password" | ||
40 | type="{{hidePassword ? 'password' : 'text'}}" | ||
41 | ng-model="usuario.clave" | ||
42 | foca-focus="paso == 2" | ||
43 | ng-keyup="$event.keyCode == 13 && enviar()" | ||
44 | ladda="loginLoading" | ||
45 | teclado-virtual | ||
46 | /> | ||
47 | <div class="input-icon px-3"> | ||
48 | <div ng-show="!hidePassword" ng-click="hidePassword = !hidePassword"> | ||
49 | <i class="fade-in fa fa-eye"></i> | ||
50 | </div> | ||
51 | <div ng-show="hidePassword" ng-click="hidePassword = !hidePassword"> | ||
52 | <i class="fade-in fa fa-eye-slash"></i> | ||
53 | </div> | ||
54 | </div> | ||
55 | </div> | ||
56 | <button | ||
57 | type="button" | ||
58 | ng-click="enviar()" | ||
59 | class="btn btn-primary btn-block my-3" | ||
60 | ladda="loginLoading"> | ||
61 | Ingresar | ||
62 | </button> | ||
63 | <img | ||
64 | src="img/logo-foca.png" | ||
65 | class="w-50 rounded mx-auto py-2 d-block"> | ||
66 | </form> | ||
5 | </div> | 67 | </div> |
6 | <div class="login-campo"> | 68 | </div> |
7 | <label>Usuario</label> | ||
8 | <input |