Commit 02fd79ca0f98aa82e1db908a8f9942779e9ece51
Exists in
master
Merge branch 'master' into 'develop'
Master(efernandez) See merge request !3
Showing
3 changed files
Show diff stats
package.json
1 | { | 1 | { |
2 | "name": "foca-configurar-terminal", | 2 | "name": "foca-configurar-terminal", |
3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
4 | "description": "foca-configurar-terminal", | 4 | "description": "foca-configurar-terminal", |
5 | "main": "index.js", | 5 | "main": "index.js", |
6 | "scripts": { | 6 | "scripts": { |
7 | "test": "echo \"Error: no test specified\" && exit 1", | 7 | "test": "echo \"Error: no test specified\" && exit 1", |
8 | "compile": "gulp uglify", | 8 | "compile": "gulp uglify", |
9 | "gulp-pre-commit": "gulp pre-commit", | 9 | "gulp-pre-commit": "gulp pre-commit", |
10 | "postinstall": "npm run compile && gulp clean-post-install", | 10 | "postinstall": "npm run compile && gulp clean-post-install", |
11 | "install-dev": "npm install angular bootstrap font-awesome jquery gulp gulp-connect jasmine-core pre-commit gulp-angular-templatecache gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es jshint pump" | 11 | "install-dev": "npm install angular bootstrap font-awesome jquery gulp gulp-connect jasmine-core pre-commit gulp-angular-templatecache gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es jshint pump" |
12 | }, | 12 | }, |
13 | "repository": { | 13 | "repository": { |
14 | "type": "git", | 14 | "type": "git", |
15 | "url": "git@git.focasoftware.com:npm/foca-configurar-terminal.git" | 15 | "url": "git@git.focasoftware.com:npm/foca-configurar-terminal.git" |
16 | }, | 16 | }, |
17 | "author": "", | 17 | "author": "", |
18 | "license": "ISC", | 18 | "license": "ISC", |
19 | "devDependencies": { | 19 | "devDependencies": { |
20 | "angular": "^1.7.5", | 20 | "angular": "^1.7.7", |
21 | "angular-route": "^1.7.5", | 21 | "angular-route": "^1.7.5", |
22 | "bootstrap": "^4.2.1", | 22 | "bootstrap": "^4.3.1", |
23 | "gulp": "^3.9.1", | 23 | "gulp": "^3.9.1", |
24 | "gulp-angular-templatecache": "^2.2.6", | 24 | "gulp-angular-templatecache": "^2.2.6", |
25 | "gulp-clean": "^0.4.0", | 25 | "gulp-clean": "^0.4.0", |
26 | "gulp-connect": "^5.7.0", | 26 | "gulp-connect": "^5.7.0", |
27 | "gulp-htmlmin": "^5.0.1", | 27 | "gulp-htmlmin": "^5.0.1", |
28 | "gulp-jshint": "^2.1.0", | 28 | "gulp-jshint": "^2.1.0", |
29 | "gulp-rename": "^1.4.0", | 29 | "gulp-rename": "^1.4.0", |
30 | "gulp-replace": "^1.0.0", | 30 | "gulp-replace": "^1.0.0", |
31 | "gulp-uglify": "^3.0.1", | 31 | "gulp-uglify": "^3.0.1", |
32 | "gulp-uglify-es": "^1.0.4", | 32 | "gulp-uglify-es": "^1.0.4", |
33 | "jasmine-core": "^3.3.0", | 33 | "jasmine-core": "^3.3.0", |
34 | "jquery": "^3.3.1", | 34 | "jquery": "^3.3.1", |
35 | "jshint": "^2.9.7", | 35 | "jshint": "^2.10.1", |
36 | "pre-commit": "^1.2.2", | 36 | "pre-commit": "^1.2.2", |
37 | "pump": "^3.0.0" | 37 | "pump": "^3.0.0" |
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 |
src/js/controller.js
1 | angular.module('focaConfigurarTerminal') | 1 | angular.module('focaConfigurarTerminal') |
2 | .controller('focaConfigurarTerminalController', [ | 2 | .controller('focaConfigurarTerminalController', [ |
3 | '$scope', | 3 | '$scope', |
4 | '$timeout', | 4 | '$timeout', |
5 | '$location', | 5 | '$location', |
6 | 'focaConfigurarTerminalService', | 6 | 'focaConfigurarTerminalService', |
7 | 'focaBotoneraLateralService', | 7 | 'focaBotoneraLateralService', |
8 | 'focaModalService', | ||
8 | function( | 9 | function( |
9 | $scope, | 10 | $scope, |
10 | $timeout, | 11 | $timeout, |
11 | $location, | 12 | $location, |
12 | focaConfigurarTerminalService, | 13 | focaConfigurarTerminalService, |
13 | focaBotoneraLateralService) { | 14 | focaBotoneraLateralService, |
15 | focaModalService) { | ||
16 | |||
14 | $scope.now = new Date(); | 17 | $scope.now = new Date(); |
15 | $scope.focused = 1; | 18 | $scope.focused = 1; |
16 | $scope.terminal = { | 19 | $scope.terminal = { |
17 | variable: 'terminalId' | 20 | variable: 'terminalId' |
18 | }; | 21 | }; |
19 | 22 | ||
20 | $timeout(function() { | 23 | $timeout(function() { |
21 | focaBotoneraLateralService.showSalir(true); | 24 | focaBotoneraLateralService.showSalir(true); |
22 | focaBotoneraLateralService.showPausar(false); | 25 | focaBotoneraLateralService.showPausar(false); |
23 | focaBotoneraLateralService.showCancelar(false); | 26 | focaBotoneraLateralService.showCancelar(false); |
24 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); | 27 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); |
25 | }); | 28 | }); |
26 | 29 | ||
27 | $scope.guardar = function() { | 30 | $scope.guardar = function() { |
31 | |||
28 | focaConfigurarTerminalService | 32 | focaConfigurarTerminalService |
29 | .configTerminal($scope.terminal) | 33 | .nombreEmpresa() |
30 | .then(function() { | 34 | .then(function(res) { |
31 | $location.path('/'); | 35 | |
36 | var json = { | ||
37 | terminal: $scope.terminal, | ||
38 | empresa: res.data.NOM, | ||
39 | idEmpresa: res.data.idEmpresa | ||
40 | }; | ||
41 | |||
42 | focaConfigurarTerminalService | ||
43 | .guardarTerminalBase(json) | ||
44 | .then(terminalLocal) | ||
45 | .catch(function(err) { | ||
46 | |||
47 | if(err.status === 404) { | ||
48 | focaModalService.alert('Empresa no configurada'); | ||
49 | return; | ||
50 | } | ||
51 | |||
52 | focaModalService | ||
53 | .alert('Hubo un error al dar de alta esta terminal'); | ||
54 | }); | ||
55 | |||
32 | }); | 56 | }); |
33 | }; | 57 | }; |
34 | 58 | ||
35 | $scope.next = function(key) { | 59 | $scope.next = function(key) { |
60 | |||
36 | if(key === 13) $scope.focused ++; | 61 | if(key === 13) $scope.focused ++; |
37 | }; | 62 | }; |
63 | |||
64 | function terminalLocal() { | ||
65 | focaConfigurarTerminalService.configTerminal($scope.terminal).then(terminar); | ||
66 | } | ||
67 | |||
68 | function terminar() { | ||
69 | |||
70 | $location.path('/'); | ||
71 | } | ||
38 | } | 72 | } |
39 | ]); | 73 | ]); |
40 | 74 |
src/js/service.js
1 | angular.module('focaConfigurarTerminal') | 1 | angular.module('focaConfigurarTerminal') |
2 | .factory('focaConfigurarTerminalService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 2 | .factory('focaConfigurarTerminalService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { |
3 | return { | 3 | return { |
4 | configTerminal: function(terminal) { | 4 | configTerminal: function(terminal) { |
5 | return $http.post(API_ENDPOINT.URL + '/config/terminal', terminal); | 5 | return $http.post(API_ENDPOINT.URL + '/config/terminal', terminal); |
6 | }, | ||
7 | nombreEmpresa: function() { | ||
8 | return $http.get(API_ENDPOINT.URL + '/empresa/obtener/primera'); | ||
9 | }, | ||
10 | guardarTerminalBase: function(json) { | ||
11 | return $http.post(API_ENDPOINT.ENDPOINT_BASE + '/terminal/agregar', json); | ||
6 | } | 12 | } |
7 | }; | 13 | }; |
8 | }]); | 14 | }]); |
9 | 15 |