Commit 90b17a3ef854534ccd233f3398b6b539615cd16c
1 parent
397c5dae42
Exists in
master
interceptor work with local sqlite
Showing
4 changed files
with
133 additions
and
53 deletions
Show diff stats
gulpfile.js
package.json
... | ... | @@ -15,7 +15,7 @@ |
15 | 15 | ], |
16 | 16 | "repository": { |
17 | 17 | "type": "git", |
18 | - "url": "git@debonline.dyndns.org:npm/wrapper-demo.git" | |
18 | + "url": "git+http://git.focasoftware.com/npm/wrapper-mobile.git" | |
19 | 19 | }, |
20 | 20 | "author": "Foca Software", |
21 | 21 | "license": "ISC", |
... | ... | @@ -31,56 +31,55 @@ |
31 | 31 | "angular-ui-swiper": "^2.3.8", |
32 | 32 | "bootstrap": "^4.3.1", |
33 | 33 | "chart.js": "2.7.3", |
34 | - "foca-abm-chofer": "git+http://git.focasoftware.com/npm/foca-abm-chofer.git", | |
35 | - "foca-abm-plazo-pago": "git+http://git.focasoftware.com/npm/foca-abm-plazo-pago.git", | |
36 | - "foca-abm-precios-condiciones": "git+http://git.focasoftware.com/npm/foca-abm-precios-condiciones.git", | |
37 | - "foca-abm-sectores": "git+http://git.focasoftware.com/npm/foca-abm-sectores.git", | |
38 | - "foca-abm-vehiculo": "git+http://git.focasoftware.com/npm/foca-abm-vehiculo.git", | |
39 | - "foca-abm-vendedor-cobrador": "git+http://git.focasoftware.com/npm/foca-abm-vendedor-cobrador.git", | |
40 | - "foca-activar-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-activar-hoja-ruta.git", | |
41 | - "foca-admin-seguimiento": "git+http://git.focasoftware.com/npm/foca-admin-seguimiento.git", | |
42 | - "foca-botonera-facturador": "git+http://git.focasoftware.com/npm/foca-botonera-facturador.git", | |
43 | - "foca-botonera-lateral": "git+http://git.focasoftware.com/npm/foca-botonera-lateral.git", | |
44 | - "foca-botonera-principal": "git+http://git.focasoftware.com/npm/foca-botonera-principal.git", | |
45 | - "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", | |
46 | - "foca-cabecera-facturador": "git+http://git.focasoftware.com/npm/foca-cabecera-facturador.git", | |
47 | - "foca-configuracion": "git+http://git.focasoftware.com/npm/foca-configuracion.git", | |
48 | - "foca-crear-cobranza": "git+http://git.focasoftware.com/npm/foca-crear-cobranza.git", | |
49 | - "foca-crear-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-crear-hoja-ruta.git", | |
50 | - "foca-crear-login": "git+http://git.focasoftware.com/npm/foca-crear-login.git", | |
34 | + "foca-abm-chofer": "git+http://git.focasoftware.com/npm/foca-abm-chofer.git#develop", | |
35 | + "foca-abm-plazo-pago": "git+http://git.focasoftware.com/npm/foca-abm-plazo-pago.git#develop", | |
36 | + "foca-abm-precios-condiciones": "git+http://git.focasoftware.com/npm/foca-abm-precios-condiciones.git#develop", | |
37 | + "foca-abm-vehiculo": "git+http://git.focasoftware.com/npm/foca-abm-vehiculo.git#develop", | |
38 | + "foca-abm-vendedor-cobrador": "git+http://git.focasoftware.com/npm/foca-abm-vendedor-cobrador.git#develop", | |
39 | + "foca-activar-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-activar-hoja-ruta.git#develop", | |
40 | + "foca-admin-seguimiento": "git+http://git.focasoftware.com/npm/foca-admin-seguimiento.git#develop", | |
41 | + "foca-botonera-facturador": "git+http://git.focasoftware.com/npm/foca-botonera-facturador.git#develop", | |
42 | + "foca-botonera-lateral": "git+http://git.focasoftware.com/npm/foca-botonera-lateral.git#develop", | |
43 | + "foca-botonera-principal": "git+http://git.focasoftware.com/npm/foca-botonera-principal.git#develop", | |
44 | + "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git#develop", | |
45 | + "foca-cabecera-facturador": "git+http://git.focasoftware.com/npm/foca-cabecera-facturador.git#develop", | |
46 | + "foca-configuracion": "git+http://git.focasoftware.com/npm/foca-configuracion.git#develop", | |
47 | + "foca-crear-cobranza": "git+http://git.focasoftware.com/npm/foca-crear-cobranza.git#develop", | |
48 | + "foca-crear-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-crear-hoja-ruta.git#develop", | |
49 | + "foca-crear-login": "git+http://git.focasoftware.com/npm/foca-crear-login.git#develop", | |
51 | 50 | "foca-crear-nota-pedido": "git+http://git.focasoftware.com/npm/foca-crear-nota-pedido.git#develop", |
52 | - "foca-crear-remito": "git+http://git.focasoftware.com/npm/foca-crear-remito.git", | |
53 | - "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | |
54 | - "foca-estado-cisternas": "git+http://git.focasoftware.com/npm/foca-estado-cisternas.git", | |
55 | - "foca-filtros": "git+http://git.focasoftware.com/npm/foca-filtros.git", | |
56 | - "foca-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-hoja-ruta.git", | |
57 | - "foca-login": "git+http://git.focasoftware.com/npm/foca-login.git", | |
58 | - "foca-logistica-pedido-ruta": "git+http://git.focasoftware.com/npm/foca-logistica-pedido-ruta.git", | |
59 | - "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", | |
60 | - "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git", | |
61 | - "foca-modal-cheque": "git+http://git.focasoftware.com/npm/foca-modal-cheque.git", | |
62 | - "foca-modal-cobranza": "git+http://git.focasoftware.com/npm/foca-modal-cobranza.git", | |
63 | - "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", | |
64 | - "foca-modal-detalle-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-modal-detalle-hoja-ruta.git", | |
65 | - "foca-modal-detalles": "git+http://git.focasoftware.com/npm/foca-modal-detalles.git", | |
66 | - "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", | |
67 | - "foca-modal-efectivo": "git+http://git.focasoftware.com/npm/foca-modal-efectivo.git", | |
68 | - "foca-modal-factura": "git+http://git.focasoftware.com/npm/foca-modal-factura.git", | |
69 | - "foca-modal-factura-detalle": "git+http://git.focasoftware.com/npm/foca-modal-factura-detalle.git", | |
70 | - "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", | |
71 | - "foca-modal-lista-precio": "git+http://git.focasoftware.com/npm/foca-modal-lista-precio.git", | |
72 | - "foca-modal-login": "git+http://git.focasoftware.com/npm/foca-modal-login.git", | |
73 | - "foca-modal-nota-pedido": "git+http://git.focasoftware.com/npm/foca-modal-nota-pedido.git", | |
74 | - "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", | |
75 | - "foca-modal-punto-descarga": "git+http://git.focasoftware.com/npm/foca-modal-punto-descarga.git", | |
76 | - "foca-modal-remito": "git+http://git.focasoftware.com/npm/foca-modal-remito.git", | |
77 | - "foca-modal-resumen-cuenta": "git+http://git.focasoftware.com/npm/foca-modal-resumen-cuenta.git", | |
78 | - "foca-modal-tarifa-flete": "git+http://git.focasoftware.com/npm/foca-modal-tarifa-flete.git", | |
79 | - "foca-modal-unidad-medida": "git+http://git.focasoftware.com/npm/foca-modal-unidad-medida.git", | |
80 | - "foca-nombre-empresa": "git+http://git.focasoftware.com/npm/foca-nombre-empresa.git", | |
81 | - "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git", | |
82 | - "foca-sqlite": "git+http://git.focasoftware.com/npm/foca-sqlite.git", | |
83 | - "foca-teclado": "git+http://git.focasoftware.com/npm/foca-teclado.git", | |
51 | + "foca-crear-remito": "git+http://git.focasoftware.com/npm/foca-crear-remito.git#develop", | |
52 | + "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git#develop", | |
53 | + "foca-estado-cisternas": "git+http://git.focasoftware.com/npm/foca-estado-cisternas.git#develop", | |
54 | + "foca-filtros": "git+http://git.focasoftware.com/npm/foca-filtros.git#develop", | |
55 | + "foca-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-hoja-ruta.git#develop", | |
56 | + "foca-login": "git+http://git.focasoftware.com/npm/foca-login.git#develop", | |
57 | + "foca-logistica-pedido-ruta": "git+http://git.focasoftware.com/npm/foca-logistica-pedido-ruta.git#develop", | |
58 | + "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git#develop", | |
59 | + "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git#develop", | |
60 | + "foca-modal-cheque": "git+http://git.focasoftware.com/npm/foca-modal-cheque.git#develop", | |
61 | + "foca-modal-cobranza": "git+http://git.focasoftware.com/npm/foca-modal-cobranza.git#develop", | |
62 | + "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git#develop", | |
63 | + "foca-modal-detalle-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-modal-detalle-hoja-ruta.git#develop", | |
64 | + "foca-modal-detalles": "git+http://git.focasoftware.com/npm/foca-modal-detalles.git#develop", | |
65 | + "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git#develop", | |
66 | + "foca-modal-efectivo": "git+http://git.focasoftware.com/npm/foca-modal-efectivo.git#develop", | |
67 | + "foca-modal-factura": "git+http://git.focasoftware.com/npm/foca-modal-factura.git#develop", | |
68 | + "foca-modal-factura-detalle": "git+http://git.focasoftware.com/npm/foca-modal-factura-detalle.git#develop", | |
69 | + "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git#develop", | |
70 | + "foca-modal-lista-precio": "git+http://git.focasoftware.com/npm/foca-modal-lista-precio.git#develop", | |
71 | + "foca-modal-login": "git+http://git.focasoftware.com/npm/foca-modal-login.git#develop", | |
72 | + "foca-modal-nota-pedido": "git+http://git.focasoftware.com/npm/foca-modal-nota-pedido.git#develop", | |
73 | + "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git#develop", | |
74 | + "foca-modal-punto-descarga": "git+http://git.focasoftware.com/npm/foca-modal-punto-descarga.git#develop", | |
75 | + "foca-modal-remito": "git+http://git.focasoftware.com/npm/foca-modal-remito.git#develop", | |
76 | + "foca-modal-resumen-cuenta": "git+http://git.focasoftware.com/npm/foca-modal-resumen-cuenta.git#develop", | |
77 | + "foca-modal-tarifa-flete": "git+http://git.focasoftware.com/npm/foca-modal-tarifa-flete.git#develop", | |
78 | + "foca-modal-unidad-medida": "git+http://git.focasoftware.com/npm/foca-modal-unidad-medida.git#develop", | |
79 | + "foca-nombre-empresa": "git+http://git.focasoftware.com/npm/foca-nombre-empresa.git#develop", | |
80 | + "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git#develop", | |
81 | + "foca-sqlite": "git+http://git.focasoftware.com/npm/foca-sqlite.git#develop", | |
82 | + "foca-teclado": "git+http://git.focasoftware.com/npm/foca-teclado.git#develop", | |
84 | 83 | "font-awesome": "^4.7.0", |
85 | 84 | "gulp-angular-templatecache": "^2.2.1", |
86 | 85 | "gulp-htmlmin": "^5.0.1", |
... | ... | @@ -106,7 +105,7 @@ |
106 | 105 | "gulp-sass": "^4.0.1", |
107 | 106 | "gulp-uglify": "^3.0.2", |
108 | 107 | "gulp-watch": "^5.0.1", |
109 | - "jasmine-core": "^3.2.1", | |
108 | + "jasmine-core": "^3.4.0", | |
110 | 109 | "jshint": "^2.10.2", |
111 | 110 | "pre-commit": "^1.2.2", |
112 | 111 | "pump": "^3.0.0" |
src/js/interceptor.js
... | ... | @@ -0,0 +1,82 @@ |
1 | +angular.module('focaConfiguracion') | |
2 | + .factory("RequestHeadersInterceptor", [ '$injector', | |
3 | + function($injector) { | |
4 | + | |
5 | + function reintentarRequest(httpConfig) { | |
6 | + | |
7 | + var $timeout = $injector.get('$timeout'); | |
8 | + | |
9 | + $timeout(function() { | |
10 | + | |
11 | + var $http = $injector.get('$http'); | |
12 | + return $http(httpConfig.config); | |
13 | + }, 5000); | |
14 | + | |
15 | + return getDataSqlite(httpConfig); | |
16 | + } | |
17 | + | |
18 | + function updateDataSqlite(request) { | |
19 | + | |
20 | + var sqliteService = $injector.get('focaSqliteService'); | |
21 | + | |
22 | + sqliteService.updateQuery( | |
23 | + request.config.url, | |
24 | + JSON.stringify(request.config.data), | |
25 | + request.config.method, | |
26 | + JSON.stringify(request.data)) | |
27 | + } | |
28 | + | |
29 | + function getDataSqlite(request) { | |
30 | + return new Promise(function(resolve) { | |
31 | + | |
32 | + var sqliteService = $injector.get('focaSqliteService'); | |
33 | + | |
34 | + sqliteService.getQuery( | |
35 | + request.config.url, | |
36 | + JSON.stringify(request.config.data), | |
37 | + request.config.method, | |
38 | + respuesta); | |
39 | + | |
40 | + function respuesta(config) { | |
41 | + | |
42 | + var request = { | |
43 | + data: JSON.parse(config), | |
44 | + status: 200 | |
45 | + }; | |
46 | + | |
47 | + console.log(request); | |
48 | + | |
49 | + if (config) { | |
50 | + resolve(request); | |
51 | + } | |
52 | + } | |
53 | + }); | |
54 | + } | |
55 | + | |
56 | + var request = { | |
57 | + responseError: async function(config) { | |
58 | + | |
59 | + if (config.status === -1) { | |
60 | + | |
61 | + var data = await reintentarRequest(config); | |
62 | + | |
63 | + config.data = data.data; | |
64 | + | |
65 | + return config; | |
66 | + | |
67 | + } else { | |
68 | + return config; | |
69 | + } | |
70 | + }, | |
71 | + response: function(response) { | |
72 | + | |
73 | + if (typeof response.data !== 'string') { | |
74 | + updateDataSqlite(response); | |
75 | + } | |
76 | + return response; | |
77 | + } | |
78 | + } | |
79 | + | |
80 | + return request; | |
81 | + } | |
82 | + ]); |
src/js/service.js
... | ... | @@ -5,7 +5,7 @@ angular.module('appWrapperDemo') |
5 | 5 | 'ENDPOINT_BASE', |
6 | 6 | function($http, $localStorage, ENDPOINT_BASE) { |
7 | 7 | return { |
8 | - URL: 'http://localhost:9900', | |
8 | + URL: 'http://debonline.dyndns.org:9900', | |
9 | 9 | ENDPOINT_BASE: ENDPOINT_BASE, |
10 | 10 | setUrl: function(url) { |
11 | 11 | this.URL = url; |