diff --git a/index.html b/index.html index 8cbba29..05458a4 100644 --- a/index.html +++ b/index.html @@ -65,6 +65,7 @@ + diff --git a/src/etc/develop.ejemplo.js b/src/etc/develop.ejemplo.js index edabf57..fe06682 100644 --- a/src/etc/develop.ejemplo.js +++ b/src/etc/develop.ejemplo.js @@ -1,5 +1,3 @@ angular.module('appWrapperDemo') - .constant('API_ENDPOINT', { - 'URL': '//127.0.0.1:9000' - }) - .constant("APP", ''); // Posibles valores '', 'distribuidor', 'transportista' +.constant('APP', '') +.constant('ENDPOINT_BASE', 'http://10.231.45.127:3000'); diff --git a/src/js/controller.js b/src/js/controller.js index 0c72727..0d2d2f4 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -3,7 +3,25 @@ angular.module('appWrapperDemo') '$scope', '$rootScope', '$timeout', - function($scope, $rootScope, $timeout) { + 'focaSqliteService', + 'API_ENDPOINT', + 'focaModalService', + function($scope, $rootScope, $timeout, focaSqliteService, API_ENDPOINT, focaModalService) { + document.addEventListener('deviceready', function() { + focaSqliteService.openDataBase(); + }); + + if(!API_ENDPOINT.URL) { + API_ENDPOINT.getUrl().then(success, error); + } + + function success(res) { + API_ENDPOINT.setUrl(res.data); + } + function error() { + focaModalService.alert('La terminal no esta configurada correctamente'); + } + $scope.usarTeclado = false; $rootScope.$broadcast('usarTeclado', false); $scope.mostrarTeclado = false; diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..92606c0 --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,18 @@ +angular.module('appWrapperDemo') +.factory('API_ENDPOINT', [ + '$http', + '$localStorage', + 'ENDPOINT_BASE', + function($http, $localStorage, ENDPOINT_BASE) { + var direccion = ENDPOINT_BASE; + return { + URL: $localStorage.urlEndPoint, + setUrl: function(url) { + this.URL = url; + $localStorage.urlEndPoint = url; + }, + getUrl: function() { + return $http.get(direccion + '/terminal/consultar'); + } + }; +}]);