Commit 1c2f4ead34eb9498e869384d1219a3b827b12b12
Exists in
master
Merge branch 'master' into 'master'
reemplazar cookies por localstorage See merge request modulos-npm/foca-configuracion!3
Showing
4 changed files
Show diff stats
package.json
1 | { | 1 | { |
2 | "name": "foca-configuracion", | 2 | "name": "foca-configuracion", |
3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
4 | "description": "", | 4 | "description": "", |
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 | "gulp-pre-commit": "gulp pre-commit", | 8 | "gulp-pre-commit": "gulp pre-commit", |
9 | "postinstall": "gulp uglify", | 9 | "postinstall": "gulp uglify", |
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" | 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" |
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-configuracion.git" | 17 | "url": "https://debo.suite.repo/modulos-npm/foca-configuracion.git" |
18 | }, | 18 | }, |
19 | "author": "Nicolás Guarnieri", | 19 | "author": "Nicolás Guarnieri", |
20 | "license": "ISC", | 20 | "license": "ISC", |
21 | "peerDependencies": { | 21 | "peerDependencies": { |
22 | "angular": "^1.7.5", | 22 | "angular": "^1.7.5", |
23 | "angular-cookies": "^1.7.5", | 23 | "angular-cookies": "^1.7.5", |
24 | "angular-route": "^1.7.5", | 24 | "angular-route": "^1.7.5", |
25 | "gulp": "^3.9.1", | 25 | "gulp": "^3.9.1", |
26 | "gulp-angular-templatecache": "^2.2.3", | 26 | "gulp-angular-templatecache": "^2.2.3", |
27 | "gulp-clean": "^0.4.0", | 27 | "gulp-clean": "^0.4.0", |
28 | "gulp-concat": "^2.6.1", | 28 | "gulp-concat": "^2.6.1", |
29 | "gulp-jshint": "^2.1.0", | 29 | "gulp-jshint": "^2.1.0", |
30 | "gulp-rename": "^1.4.0", | 30 | "gulp-rename": "^1.4.0", |
31 | "gulp-replace": "^1.0.0", | 31 | "gulp-replace": "^1.0.0", |
32 | "gulp-uglify": "^3.0.1", | 32 | "gulp-uglify": "^3.0.1", |
33 | "jquery": "^3.3.1", | 33 | "jquery": "^3.3.1", |
34 | "jshint": "^2.9.6", | 34 | "jshint": "^2.9.6", |
35 | "pre-commit": "^1.2.2", | 35 | "pre-commit": "^1.2.2", |
36 | "pump": "^3.0.0" | 36 | "pump": "^3.0.0" |
37 | }, | 37 | }, |
38 | "devDependencies": { | 38 | "devDependencies": { |
39 | "angular": "^1.7.5", | 39 | "angular": "^1.7.5", |
40 | "angular-cookies": "^1.7.5", | 40 | "angular-cookies": "^1.7.5", |
41 | "angular-route": "^1.7.5", | 41 | "angular-route": "^1.7.5", |
42 | "gulp": "^3.9.1", | 42 | "gulp": "^3.9.1", |
43 | "gulp-angular-templatecache": "^2.2.3", | 43 | "gulp-angular-templatecache": "^2.2.3", |
44 | "gulp-clean": "^0.4.0", | 44 | "gulp-clean": "^0.4.0", |
45 | "gulp-concat": "^2.6.1", | 45 | "gulp-concat": "^2.6.1", |
46 | "gulp-jshint": "^2.1.0", | 46 | "gulp-jshint": "^2.1.0", |
47 | "gulp-rename": "^1.4.0", | 47 | "gulp-rename": "^1.4.0", |
48 | "gulp-replace": "^1.0.0", | 48 | "gulp-replace": "^1.0.0", |
49 | "gulp-uglify": "^3.0.1", | 49 | "gulp-uglify": "^3.0.1", |
50 | "jquery": "^3.3.1", | 50 | "jquery": "^3.3.1", |
51 | "jshint": "^2.9.6", | 51 | "jshint": "^2.9.6", |
52 | "ngstorage": "^0.3.11", | ||
52 | "pre-commit": "^1.2.2", | 53 | "pre-commit": "^1.2.2", |
53 | "pump": "^3.0.0" | 54 | "pump": "^3.0.0" |
54 | } | 55 | } |
55 | } | 56 | } |
56 | 57 |
src/js/app.js
1 | angular.module('focaConfiguracion', []) | 1 | angular.module('focaConfiguracion', ['ngStorage']) |
2 | .run(['$cookies', 'focaConfiguracionService', function($cookies, focaConfiguracionService) { | 2 | .run(['$localStorage', 'focaConfiguracionService', function($localStorage, focaConfiguracionService) { |
3 | if (!$cookies.get("terminalKey")) { | 3 | if (!$localStorage.terminalKey) { |
4 | focaConfiguracionService.getHashTerminal().then(function(res) { | 4 | focaConfiguracionService.getHashTerminal().then(function(res) { |
5 | $cookies.put('terminalKey', res.data); | 5 | $localStorage.terminalKey = res.data; |
6 | }); | 6 | }); |
7 | } | 7 | } |
8 | }]); | 8 | }]); |
src/js/requestHeadersInterceptor.js
1 | angular.module('focaConfiguracion') | 1 | angular.module('focaConfiguracion') |
2 | .factory("RequestHeadersInterceptor", [ | 2 | .factory("RequestHeadersInterceptor", [ |
3 | '$cookies', function($cookies) { | 3 | '$localStorage', function($localStorage) { |
4 | var request = { | 4 | var request = { |
5 | request: function(config) { | 5 | request: function(config) { |
6 | config.headers["X-Terminal-Key"] = $cookies.get("terminalKey"); | 6 | config.headers["X-Terminal-Key"] = $localStorage.terminalKey; |
7 | return config; | 7 | return config; |
8 | } | 8 | } |
9 | } | 9 | } |
10 | 10 | ||
11 | return request; | 11 | return request; |
12 | } | 12 | } |
13 | ]); | 13 | ]); |
src/js/service.js
1 | angular.module('focaConfiguracion') | 1 | angular.module('focaConfiguracion') |
2 | .factory("focaConfiguracionService", [ | 2 | .factory("focaConfiguracionService", [ |
3 | '$http', '$cookies', '$q', 'API_ENDPOINT', | 3 | '$http', 'API_ENDPOINT', |
4 | function($http, $cookies, $q, API_ENDPOINT) { | 4 | function($http, API_ENDPOINT) { |
5 | return { | 5 | return { |
6 | getHashTerminal: function() { | 6 | getHashTerminal: function() { |
7 | return $http.get(API_ENDPOINT.URL + '/config/terminal'); | 7 | return $http.get(API_ENDPOINT.URL + '/config/terminal'); |
8 | } | 8 | } |
9 | } | 9 | } |
10 | } | 10 | } |
11 | ]); | 11 | ]); |