Commit fa99ca01c90e0994e5abb8878fd3437251d88451
1 parent
b8637e698d
Exists in
master
sistema terminales
Showing
4 changed files
with
40 additions
and
5 deletions
Show diff stats
index.html
| ... | ... | @@ -65,6 +65,7 @@ |
| 65 | 65 | <script src="./node_modules/foca-sqlite/dist/foca-sqlite.min.js"></script> |
| 66 | 66 | <script src="./src/js/app.js"></script> |
| 67 | 67 | <script src="./src/js/controller.js"></script> |
| 68 | + <script src="./src/js/service.js"></script> | |
| 68 | 69 | <script src="./src/etc/develop.js"></script> |
| 69 | 70 | </head> |
| 70 | 71 | <body> |
src/etc/develop.ejemplo.js
src/js/controller.js
| ... | ... | @@ -3,7 +3,25 @@ angular.module('appWrapperDemo') |
| 3 | 3 | '$scope', |
| 4 | 4 | '$rootScope', |
| 5 | 5 | '$timeout', |
| 6 | - function($scope, $rootScope, $timeout) { | |
| 6 | + 'focaSqliteService', | |
| 7 | + 'API_ENDPOINT', | |
| 8 | + 'focaModalService', | |
| 9 | + function($scope, $rootScope, $timeout, focaSqliteService, API_ENDPOINT, focaModalService) { | |
| 10 | + document.addEventListener('deviceready', function() { | |
| 11 | + focaSqliteService.openDataBase(); | |
| 12 | + }); | |
| 13 | + | |
| 14 | + if(!API_ENDPOINT.URL) { | |
| 15 | + API_ENDPOINT.getUrl().then(success, error); | |
| 16 | + } | |
| 17 | + | |
| 18 | + function success(res) { | |
| 19 | + API_ENDPOINT.setUrl(res.data); | |
| 20 | + } | |
| 21 | + function error() { | |
| 22 | + focaModalService.alert('La terminal no esta configurada correctamente'); | |
| 23 | + } | |
| 24 | + | |
| 7 | 25 | $scope.usarTeclado = false; |
| 8 | 26 | $rootScope.$broadcast('usarTeclado', false); |
| 9 | 27 | $scope.mostrarTeclado = false; |
src/js/service.js
| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | +angular.module('appWrapperDemo') | |
| 2 | +.factory('API_ENDPOINT', [ | |
| 3 | + '$http', | |
| 4 | + '$localStorage', | |
| 5 | + 'ENDPOINT_BASE', | |
| 6 | + function($http, $localStorage, ENDPOINT_BASE) { | |
| 7 | + var direccion = ENDPOINT_BASE; | |
| 8 | + return { | |
| 9 | + URL: $localStorage.urlEndPoint, | |
| 10 | + setUrl: function(url) { | |
| 11 | + this.URL = url; | |
| 12 | + $localStorage.urlEndPoint = url; | |
| 13 | + }, | |
| 14 | + getUrl: function() { | |
| 15 | + return $http.get(direccion + '/terminal/consultar'); | |
| 16 | + } | |
| 17 | + }; | |
| 18 | +}]); |