Commit dffb9a67d7c23f64f4680019bc6047b1ebd4ccac
1 parent
0b0782569a
Exists in
master
broadcast
Showing
3 changed files
with
60 additions
and
52 deletions
Show diff stats
package.json
1 | { | 1 | { |
2 | "name": "wrapper-demo", | 2 | "name": "wrapper-demo", |
3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
4 | "description": "", | 4 | "description": "", |
5 | "main": "main.js", | 5 | "main": "main.js", |
6 | "scripts": { | 6 | "scripts": { |
7 | "initdev": "npm install gulp --global && npm install && npm install -g jshint", | 7 | "initdev": "npm install gulp --global && npm install && npm install -g jshint", |
8 | "gulp-pre-commit": "gulp pre-commit", | 8 | "gulp-pre-commit": "gulp pre-commit", |
9 | "compile": "gulp uglify && gulp sass", | 9 | "compile": "gulp uglify && gulp sass", |
10 | "actualizar": "git pull origin master", | 10 | "actualizar": "git pull origin master", |
11 | "install-dev": "gulp pre-install && npm install && gulp post-install" | 11 | "install-dev": "gulp pre-install && npm install && gulp post-install" |
12 | }, | 12 | }, |
13 | "pre-commit": [ | 13 | "pre-commit": [ |
14 | "gulp-pre-commit" | 14 | "gulp-pre-commit" |
15 | ], | 15 | ], |
16 | "repository": { | 16 | "repository": { |
17 | "type": "git", | 17 | "type": "git", |
18 | "url": "git+http://git.focasoftware.com/npm/wrapper-mobile.git" | 18 | "url": "git+http://git.focasoftware.com/npm/wrapper-mobile.git" |
19 | }, | 19 | }, |
20 | "author": "Foca Software", | 20 | "author": "Foca Software", |
21 | "license": "ISC", | 21 | "license": "ISC", |
22 | "dependencies": { | 22 | "dependencies": { |
23 | "angular": "^1.7.8", | 23 | "angular": "^1.7.8", |
24 | "angular-chart.js": "1.1.1", | 24 | "angular-chart.js": "1.1.1", |
25 | "angular-cookies": "^1.7.8", | 25 | "angular-cookies": "^1.7.8", |
26 | "angular-i18n": "^1.7.8", | 26 | "angular-i18n": "^1.7.8", |
27 | "angular-ladda": "^0.4.3", | 27 | "angular-ladda": "^0.4.3", |
28 | "angular-md5": "^0.1.10", | 28 | "angular-md5": "^0.1.10", |
29 | "angular-route": "^1.7.8", | 29 | "angular-route": "^1.7.8", |
30 | "angular-sanitize": "^1.7.8", | 30 | "angular-sanitize": "^1.7.8", |
31 | "angular-ui-swiper": "^2.3.8", | 31 | "angular-ui-swiper": "^2.3.8", |
32 | "bootstrap": "^4.3.1", | 32 | "bootstrap": "^4.3.1", |
33 | "chart.js": "2.7.3", | 33 | "chart.js": "2.7.3", |
34 | "foca-abm-chofer": "git+http://git.focasoftware.com/npm/foca-abm-chofer.git#develop", | 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#develop", | 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#develop", | 36 | "foca-abm-precios-condiciones": "git+http://git.focasoftware.com/npm/foca-abm-precios-condiciones.git", |
37 | "foca-abm-vehiculo": "git+http://git.focasoftware.com/npm/foca-abm-vehiculo.git#develop", | 37 | "foca-abm-vehiculo": "git+http://git.focasoftware.com/npm/foca-abm-vehiculo.git", |
38 | "foca-abm-vendedor-cobrador": "git+http://git.focasoftware.com/npm/foca-abm-vendedor-cobrador.git#develop", | 38 | "foca-abm-vendedor-cobrador": "git+http://git.focasoftware.com/npm/foca-abm-vendedor-cobrador.git", |
39 | "foca-activar-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-activar-hoja-ruta.git#develop", | 39 | "foca-activar-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-activar-hoja-ruta.git", |
40 | "foca-admin-seguimiento": "git+http://git.focasoftware.com/npm/foca-admin-seguimiento.git#develop", | 40 | "foca-admin-seguimiento": "git+http://git.focasoftware.com/npm/foca-admin-seguimiento.git", |
41 | "foca-botonera-facturador": "git+http://git.focasoftware.com/npm/foca-botonera-facturador.git#develop", | 41 | "foca-botonera-facturador": "git+http://git.focasoftware.com/npm/foca-botonera-facturador.git", |
42 | "foca-botonera-lateral": "git+http://git.focasoftware.com/npm/foca-botonera-lateral.git#develop", | 42 | "foca-botonera-lateral": "git+http://git.focasoftware.com/npm/foca-botonera-lateral.git", |
43 | "foca-botonera-principal": "git+http://git.focasoftware.com/npm/foca-botonera-principal.git#develop", | 43 | "foca-botonera-principal": "git+http://git.focasoftware.com/npm/foca-botonera-principal.git", |
44 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git#develop", | 44 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", |
45 | "foca-cabecera-facturador": "git+http://git.focasoftware.com/npm/foca-cabecera-facturador.git#develop", | 45 | "foca-cabecera-facturador": "git+http://git.focasoftware.com/npm/foca-cabecera-facturador.git", |
46 | "foca-configuracion": "git+http://git.focasoftware.com/npm/foca-configuracion.git#develop", | 46 | "foca-configuracion": "git+http://git.focasoftware.com/npm/foca-configuracion.git", |
47 | "foca-crear-cobranza": "git+http://git.focasoftware.com/npm/foca-crear-cobranza.git#develop", | 47 | "foca-crear-cobranza": "git+http://git.focasoftware.com/npm/foca-crear-cobranza.git", |
48 | "foca-crear-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-crear-hoja-ruta.git#develop", | 48 | "foca-crear-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-crear-hoja-ruta.git", |
49 | "foca-crear-login": "git+http://git.focasoftware.com/npm/foca-crear-login.git#develop", | 49 | "foca-crear-login": "git+http://git.focasoftware.com/npm/foca-crear-login.git", |
50 | "foca-crear-nota-pedido": "git+http://git.focasoftware.com/npm/foca-crear-nota-pedido.git#develop", | 50 | "foca-crear-nota-pedido": "git+http://git.focasoftware.com/npm/foca-crear-nota-pedido.git", |
51 | "foca-crear-remito": "git+http://git.focasoftware.com/npm/foca-crear-remito.git#develop", | 51 | "foca-crear-remito": "git+http://git.focasoftware.com/npm/foca-crear-remito.git", |
52 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git#develop", | 52 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
53 | "foca-estado-cisternas": "git+http://git.focasoftware.com/npm/foca-estado-cisternas.git#develop", | 53 | "foca-estado-cisternas": "git+http://git.focasoftware.com/npm/foca-estado-cisternas.git", |
54 | "foca-filtros": "git+http://git.focasoftware.com/npm/foca-filtros.git#develop", | 54 | "foca-filtros": "git+http://git.focasoftware.com/npm/foca-filtros.git", |
55 | "foca-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-hoja-ruta.git#develop", | 55 | "foca-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-hoja-ruta.git", |
56 | "foca-login": "git+http://git.focasoftware.com/npm/foca-login.git#develop", | 56 | "foca-login": "git+http://git.focasoftware.com/npm/foca-login.git", |
57 | "foca-logistica-pedido-ruta": "git+http://git.focasoftware.com/npm/foca-logistica-pedido-ruta.git#develop", | 57 | "foca-logistica-pedido-ruta": "git+http://git.focasoftware.com/npm/foca-logistica-pedido-ruta.git", |
58 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git#develop", | 58 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", |
59 | "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git#develop", | 59 | "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git", |
60 | "foca-modal-cheque": "git+http://git.focasoftware.com/npm/foca-modal-cheque.git#develop", | 60 | "foca-modal-cheque": "git+http://git.focasoftware.com/npm/foca-modal-cheque.git", |
61 | "foca-modal-cobranza": "git+http://git.focasoftware.com/npm/foca-modal-cobranza.git#develop", | 61 | "foca-modal-cobranza": "git+http://git.focasoftware.com/npm/foca-modal-cobranza.git", |
62 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git#develop", | 62 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", |
63 | "foca-modal-detalle-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-modal-detalle-hoja-ruta.git#develop", | 63 | "foca-modal-detalle-hoja-ruta": "git+http://git.focasoftware.com/npm/foca-modal-detalle-hoja-ruta.git", |
64 | "foca-modal-detalles": "git+http://git.focasoftware.com/npm/foca-modal-detalles.git#develop", | 64 | "foca-modal-detalles": "git+http://git.focasoftware.com/npm/foca-modal-detalles.git", |
65 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git#develop", | 65 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", |
66 | "foca-modal-efectivo": "git+http://git.focasoftware.com/npm/foca-modal-efectivo.git#develop", | 66 | "foca-modal-efectivo": "git+http://git.focasoftware.com/npm/foca-modal-efectivo.git", |
67 | "foca-modal-factura": "git+http://git.focasoftware.com/npm/foca-modal-factura.git#develop", | 67 | "foca-modal-factura": "git+http://git.focasoftware.com/npm/foca-modal-factura.git", |
68 | "foca-modal-factura-detalle": "git+http://git.focasoftware.com/npm/foca-modal-factura-detalle.git#develop", | 68 | "foca-modal-factura-detalle": "git+http://git.focasoftware.com/npm/foca-modal-factura-detalle.git", |
69 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git#develop", | 69 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", |
70 | "foca-modal-lista-precio": "git+http://git.focasoftware.com/npm/foca-modal-lista-precio.git#develop", | 70 | "foca-modal-lista-precio": "git+http://git.focasoftware.com/npm/foca-modal-lista-precio.git", |
71 | "foca-modal-login": "git+http://git.focasoftware.com/npm/foca-modal-login.git#develop", | 71 | "foca-modal-login": "git+http://git.focasoftware.com/npm/foca-modal-login.git", |
72 | "foca-modal-nota-pedido": "git+http://git.focasoftware.com/npm/foca-modal-nota-pedido.git#develop", | 72 | "foca-modal-nota-pedido": "git+http://git.focasoftware.com/npm/foca-modal-nota-pedido.git", |
73 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git#develop", | 73 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", |
74 | "foca-modal-punto-descarga": "git+http://git.focasoftware.com/npm/foca-modal-punto-descarga.git#develop", | 74 | "foca-modal-punto-descarga": "git+http://git.focasoftware.com/npm/foca-modal-punto-descarga.git", |
75 | "foca-modal-remito": "git+http://git.focasoftware.com/npm/foca-modal-remito.git#develop", | 75 | "foca-modal-remito": "git+http://git.focasoftware.com/npm/foca-modal-remito.git", |
76 | "foca-modal-resumen-cuenta": "git+http://git.focasoftware.com/npm/foca-modal-resumen-cuenta.git#develop", | 76 | "foca-modal-resumen-cuenta": "git+http://git.focasoftware.com/npm/foca-modal-resumen-cuenta.git", |
77 | "foca-modal-tarifa-flete": "git+http://git.focasoftware.com/npm/foca-modal-tarifa-flete.git#develop", | 77 | "foca-modal-tarifa-flete": "git+http://git.focasoftware.com/npm/foca-modal-tarifa-flete.git", |
78 | "foca-modal-unidad-medida": "git+http://git.focasoftware.com/npm/foca-modal-unidad-medida.git#develop", | 78 | "foca-modal-unidad-medida": "git+http://git.focasoftware.com/npm/foca-modal-unidad-medida.git", |
79 | "foca-nombre-empresa": "git+http://git.focasoftware.com/npm/foca-nombre-empresa.git#develop", | 79 | "foca-nombre-empresa": "git+http://git.focasoftware.com/npm/foca-nombre-empresa.git", |
80 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git#develop", | 80 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git", |
81 | "foca-sqlite": "git+http://git.focasoftware.com/npm/foca-sqlite.git#develop", | 81 | "foca-sqlite": "git+http://git.focasoftware.com/npm/foca-sqlite.git", |
82 | "foca-teclado": "git+http://git.focasoftware.com/npm/foca-teclado.git#develop", | 82 | "foca-teclado": "git+http://git.focasoftware.com/npm/foca-teclado.git", |
83 | "font-awesome": "^4.7.0", | 83 | "font-awesome": "^4.7.0", |
84 | "gulp-angular-templatecache": "^2.2.1", | 84 | "gulp-angular-templatecache": "^2.2.1", |
85 | "gulp-htmlmin": "^5.0.1", | 85 | "gulp-htmlmin": "^5.0.1", |
86 | "gulp-sequence": "^1.0.0", | 86 | "gulp-sequence": "^1.0.0", |
87 | "gulp-uglify-es": "^1.0.4", | 87 | "gulp-uglify-es": "^1.0.4", |
88 | "jquery": "^3.3.1", | 88 | "jquery": "^3.4.0", |
89 | "ladda": "1.0.6", | 89 | "ladda": "1.0.6", |
90 | "leaflet": "1.3.4", | 90 | "leaflet": "1.3.4", |
91 | "moment": "2.23.0", | 91 | "moment": "2.23.0", |
92 | "ngstorage": "^0.3.11", | 92 | "ngstorage": "^0.3.11", |
93 | "node-sass": "^4.10.0", | 93 | "node-sass": "^4.10.0", |
94 | "uglify": "^0.1.5", | 94 | "uglify": "^0.1.5", |
95 | "ui-bootstrap4": "^3.0.6" | 95 | "ui-bootstrap4": "^3.0.6" |
96 | }, | 96 | }, |
97 | "devDependencies": { | 97 | "devDependencies": { |
98 | "gulp": "3.9.1", | 98 | "gulp": "3.9.1", |
99 | "gulp-clean": "^0.4.0", | 99 | "gulp-clean": "^0.4.0", |
100 | "gulp-concat": "^2.6.1", | 100 | "gulp-concat": "^2.6.1", |
101 | "gulp-connect": "^5.6.1", | 101 | "gulp-connect": "^5.6.1", |
102 | "gulp-jshint": "^2.1.0", | 102 | "gulp-jshint": "^2.1.0", |
103 | "gulp-rename": "^1.4.0", | 103 | "gulp-rename": "^1.4.0", |
104 | "gulp-replace": "^1.0.0", | 104 | "gulp-replace": "^1.0.0", |
105 | "gulp-sass": "^4.0.1", | 105 | "gulp-sass": "^4.0.1", |
106 | "gulp-uglify": "^3.0.2", | 106 | "gulp-uglify": "^3.0.2", |
107 | "gulp-watch": "^5.0.1", | 107 | "gulp-watch": "^5.0.1", |
108 | "jasmine-core": "^3.4.0", | 108 | "jasmine-core": "^3.4.0", |
109 | "jshint": "^2.10.2", | 109 | "jshint": "^2.10.2", |
110 | "pre-commit": "^1.2.2", | 110 | "pre-commit": "^1.2.2", |
111 | "pump": "^3.0.0" | 111 | "pump": "^3.0.0" |
112 | } | 112 | } |
113 | } | 113 | } |
114 | 114 |
src/js/interceptor.js
1 | angular.module('focaConfiguracion') | 1 | angular.module('focaConfiguracion') |
2 | .factory("interceptorRequest", [ '$injector', | 2 | .factory("interceptorRequest", [ '$injector', |
3 | function($injector) { | 3 | function($injector) { |
4 | 4 | ||
5 | function reintentarRequest(httpConfig) { | 5 | function reintentarRequest(httpConfig) { |
6 | 6 | ||
7 | var $timeout = $injector.get('$timeout'); | 7 | var $timeout = $injector.get('$timeout'); |
8 | 8 | ||
9 | return $timeout(function() { | 9 | return $timeout(function() { |
10 | 10 | ||
11 | var $http = $injector.get('$http'); | 11 | var $http = $injector.get('$http'); |
12 | return $http(httpConfig.config); | 12 | return $http(httpConfig.config); |
13 | }, 10000); | 13 | }, 10000); |
14 | } | 14 | } |
15 | 15 | ||
16 | function updateDataSqlite(request) { | 16 | function updateDataSqlite(request) { |
17 | 17 | ||
18 | var sqliteService = $injector.get('focaSqliteService'); | 18 | var sqliteService = $injector.get('focaSqliteService'); |
19 | 19 | ||
20 | sqliteService.updateQuery( | 20 | sqliteService.updateQuery( |
21 | request.config.url, | 21 | request.config.url, |
22 | JSON.stringify(request.config.data), | 22 | JSON.stringify(request.config.data), |
23 | request.config.method, | 23 | request.config.method, |
24 | JSON.stringify(request.data)); | 24 | JSON.stringify(request.data)); |
25 | } | 25 | } |
26 | 26 | ||
27 | function getDataSqlite(request) { | 27 | function getDataSqlite(request) { |
28 | 28 | ||
29 | return new Promise(function(resolve) { | 29 | return new Promise(function(resolve) { |
30 | 30 | ||
31 | var sqliteService = $injector.get('focaSqliteService'); | 31 | var sqliteService = $injector.get('focaSqliteService'); |
32 | 32 | ||
33 | sqliteService.getQuery( | 33 | sqliteService.getQuery( |
34 | request.config.url, | 34 | request.config.url, |
35 | JSON.stringify(request.config.data), | 35 | JSON.stringify(request.config.data), |
36 | request.config.method, | 36 | request.config.method, |
37 | respuesta); | 37 | respuesta); |
38 | 38 | ||
39 | function respuesta(config) { | 39 | function respuesta(config) { |
40 | 40 | ||
41 | if (config) { | 41 | if (config) { |
42 | 42 | ||
43 | var request = { | 43 | var request = { |
44 | data: JSON.parse(config.response), | 44 | data: JSON.parse(config.response), |
45 | status: 200 | 45 | status: 200 |
46 | }; | 46 | }; |
47 | 47 | ||
48 | resolve(request); | 48 | resolve(request); |
49 | } else { | 49 | } else { |
50 | resolve(false); | 50 | resolve(false); |
51 | } | 51 | } |
52 | } | 52 | } |
53 | }); | 53 | }); |
54 | } | 54 | } |
55 | 55 | ||
56 | function broadCastRed(status) { | ||
57 | |||
58 | var $rootScope = $injector.get('$rootScope'); | ||
59 | |||
60 | $rootScope.$broadcast('estadoRed', status); | ||
61 | } | ||
62 | |||
56 | var request = { | 63 | var request = { |
57 | responseError: async function(config) { | 64 | responseError: async function(config) { |
58 | 65 | ||
59 | if (config.status === -1) { | 66 | if (config.status === -1) { |
60 | 67 | ||
61 | var data = await getDataSqlite(config); | 68 | broadCastRed(false); |
62 | 69 | ||
70 | var data = await getDataSqlite(config); | ||
63 | if (!data) { | 71 | if (!data) { |
64 | return reintentarRequest(config); | 72 | return reintentarRequest(config); |
65 | } else { | 73 | } else { |
66 | config.data = data.data; | 74 | config.data = data.data; |
67 | return config; | 75 | return config; |
68 | } | 76 | } |
69 | 77 | ||
70 | } else { | 78 | } else { |
71 | return config; | 79 | return config; |
72 | } | 80 | } |
73 | }, | 81 | }, |
74 | response: function(response) { | 82 | response: function(response) { |
75 | 83 | ||
76 | if (typeof response.data !== 'string') { | 84 | if (typeof response.data !== 'string') { |
85 | broadCastRed(true); | ||
77 | updateDataSqlite(response); | 86 | updateDataSqlite(response); |
78 | } | 87 | } |
79 | return response; | 88 | return response; |
80 | } | 89 | } |
81 | } | 90 | } |
82 | 91 | ||
83 | return request; | 92 | return request; |
84 | } | 93 | } |
85 | ]).config(['$httpProvider', function($httpProvider) { | 94 | ]).config(['$httpProvider', function($httpProvider) { |
86 | $httpProvider.interceptors.push('interceptorRequest'); | 95 | $httpProvider.interceptors.push('interceptorRequest'); |
87 | }]); | 96 | }]); |
88 | 97 |
src/js/service.js
1 | angular.module('appWrapperDemo') | 1 | angular.module('appWrapperDemo') |
2 | .factory('API_ENDPOINT', [ | 2 | .factory('API_ENDPOINT', [ |
3 | '$http', | 3 | '$http', |
4 | '$localStorage', | 4 | '$localStorage', |
5 | 'ENDPOINT_BASE', | 5 | 'ENDPOINT_BASE', |
6 | function($http, $localStorage, ENDPOINT_BASE) { | 6 | function($http, $localStorage, ENDPOINT_BASE) { |
7 | return { | 7 | return { |
8 | URL: 'http://10.231.45.189:9900', | ||
9 | ENDPOINT_BASE: ENDPOINT_BASE, | 8 | ENDPOINT_BASE: ENDPOINT_BASE, |
10 | setUrl: function(url) { | 9 | setUrl: function(url) { |
11 | this.URL = url; | 10 | this.URL = url; |
12 | $localStorage.urlEndPoint = url; | 11 | $localStorage.urlEndPoint = url; |
13 | }, | 12 | }, |
14 | getUrl: function() { | 13 | getUrl: function() { |
15 | return $http.get(this.ENDPOINT_BASE + '/terminal/consultar'); | 14 | return $http.get(this.ENDPOINT_BASE + '/terminal/consultar'); |
16 | } | 15 | } |
17 | }; | 16 | }; |
18 | }]); | 17 | }]); |
19 | 18 |