diff --git a/src/js/controller.js b/src/js/controller.js index 6e149f7..87e3305 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -1,119 +1,9 @@ angular.module('focaBotoneraPrincipal') .controller('focaBotoneraPrincipalController', [ - '$scope', '$location', - function($scope, $location) { - // TODO: Tomar estos datos desde el servicio - $scope.botones = [ - { - texto: 'Abrir Turno', - clase: 'botonera-principal-abrir-turno', - accion: '/turno-apertura' - }, - { - texto: 'Cerrar Turno', - clase: 'botonera-principal-cerrar-turno', - accion: '/turno-cierre' - }, - { - texto: 'Nota Pedido', - clase: 'botonera-principal-nota-pedido', - accion: '/venta-nota-pedido/crear' - }, - { - texto: 'Seguimiento GPS', - clase: 'botonera-principal-seguimiento', - accion: '/admin-seguimiento' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - }, - { - texto: '', - clase: 'botonera-principal-vacio', - accion: '/' - } - ]; - + '$scope', '$location', 'botones', + function($scope, $location, botones) { $scope.paginas = []; - $scope.paginas.push($scope.botones.slice(0, 15)); - $scope.paginas.push($scope.botones.slice(15, 30)); + $scope.paginas.push(botones.data); $scope.irA = function(accion) { $location.path(accion); diff --git a/src/js/route.js b/src/js/route.js index 51fe99c..a7784ae 100644 --- a/src/js/route.js +++ b/src/js/route.js @@ -2,6 +2,11 @@ angular.module('focaBotoneraPrincipal') .config(['$routeProvider', function($routeProvider) { $routeProvider.when('/', { controller: 'focaBotoneraPrincipalController', - templateUrl: 'src/views/foca-botonera-principal.html' + templateUrl: 'src/views/foca-botonera-principal.html', + resolve: { + botones: ['focaBotoneraPrincipalService', function(focaBotoneraPrincipalService) { + return focaBotoneraPrincipalService.obtenerBotones(); + }] + } }); }]); diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..a1839d5 --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,11 @@ +angular.module('focaBotoneraPrincipal') + .service('focaBotoneraPrincipalService', [ + '$http', 'API_ENDPOINT', + function($http, API_ENDPOINT) { + return { + obtenerBotones: function() { + return $http.get(API_ENDPOINT.URL + '/boton'); + } + }; + } + ]);